Motherboard Forums


Reply
Thread Tools Display Modes

Turn vertex points on/off, so fragment points turn on/off

 
 





















Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 03:38 AM


Hello,

I am newb to gpgpu programming so I wonder if the following is possible and
what technique for it could be used to achieve it
(I saw someone else mention GL_POINTS so I will go on that):

The idea is as follows:

There is an array of verteces for example 1000 verteces.
Each vertex translates to a "pixel" / fragment.
So there should be 1000 pixels as well.

The vertex shader will be called first and each vertex must decide if it's
to be on or off based on some condition.

Each vertex that is on should trigger a fragment/pixel shader.

Therefore only the pixel/fragment associated with the vertex should execute
the pixel/fragment shader to make it as efficient/fast as possible.

So that's idea and I have a couple of questions about that:

1. Is this possible somehow ?

2. What techniques exist ?

3. Which technique would be fastest ?

I would prefer to use OpenGL + CG on DirectX9 cards like NVIDIA GTX 7900.

DirectX solutions would be interesting too.

(I posted this question on gpgpu forum as well (except above two lines), so
I am shotgunning multiple resources for some possible answers )

Thanks for any help ! God bless you !

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 10:47 AM
Ok,

It seems easy enough, however there is one little peculiar thing; the last
horizontal line does not get any points ? Weird... anybody have an
explanation for that ?

Here is the code:

(By changing the Z value from 0 to -2 or 2 the points will disappear... but
not when setting it to -1 or 1... why is that ? that's kinda strange too )

procedure CreateVertexPoints( ParaWidth : integer; ParaHeight : integer );
var
vX : integer;
vY : integer;
// vZ : integer;
begin
glBegin(GL_POINTS);

for vY := 0 to ParaHeight-1 do
begin
for vX := 0 to ParaWidth-1 do
begin
glVertex3f( vX, vY, 0 );
end;
end;

glEnd;
end;

procedure TForm1.mOpenGLGLInit(Sender: TObject);
begin
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, mOpenGL.Width, mOpenGL.Height, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, mOpenGL.Width, mOpenGL.Height );
end;

procedure TForm1.mOpenGLGLPaint(Sender: TObject);
begin
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity;
CreateVertexPoints( mOpenGL.Width, mOpenGL.Height );
end;

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 10:58 AM
Ok,

I read a posting somewhere how pixels are supposed to fall into the middle
or so...

So far there seem to be two solutions:

1. glVertex3f( 0.5 + vX, 0.5 + vY, 0 );

2. gluOrtho2D(0.0-0.5, mOpenGL.Width-0.5, mOpenGL.Height-0.5, 0.0 - 0.5);

Last solution would probably be better for two reasons:

1. First of all it's only done once.

2. Second of all I don't need to fuss around in all glVertex calls and such
which would be nice !

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 10:59 AM
Though I am not sure how these two solutions would affect gpgpu
programming...

Could this disturb the values by -0.5 ?

Hmm...

Well for now I can let it in... this is also advantage of solution 2...

If it needs to be removed then only in one place does it need to be removed
!

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 11:32 AM
Whatever I do it seems the speed is always 60 FPS, the rate of my LCD
monitor... kinda strange...

I am not sure if this is a locked speed of TOpenGL, Delphi, Windows or
something else... like maybe swapping buffers always being that slow... I
don't know...

Hmm.

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 11:46 AM
I love the internet, I love google, days like these I love

Searched and again found the answer in 3 seconds lol.

It's because of the double buffering... apperently it waits for a vertical
retrace.

Turn that off and it runs at 29000 fps LOL. (Not drawing anything except
black background )

Now I measure performance of the "slow" immediate vertex drawing mode

Here goes:

Ok for 500x400 verteces it achieves 160.72 fps.

The screen blinks a lot and the last lines are missing... but at least this
gives a bit of an indication how slow it is (?)

I also tried adding glFinish before measurements but that don't matter much
in this case

Yeah going from 29000 fps to 160 fps is bad

Bye,
Skybuck LOL.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 12:36 PM
Ok,

The idea is now to create a 4096x4096 vertex array in 3D Studio Max 9 or
so...

So that this file can be loaded into FX Composer 2.5 so that I can directly
program the shader in FX Composer 2.5 and see how it works out !

Hihi.

3D Studio 4.0 for DOS used to have some kind of generation/duplication
functionality to quickly duplicate objects probably even verteces now I go
figure this out for 3D Studio Max 9

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 12:54 PM
Hmm kinda interesting I am running into all kinds of problems/limitations
with 3D Studio:

1. First of all the plane is limited to 1000 by 1000 segments.

2. Second of FX Composer 2.5 cannot import MAX files ?

3. Third of all exporting to 3DS is problematic: 3D Studio Max 9 shows
warnings: Object(Plane01) has too many faces(more than 64K) to export.

Seems like this is a 3DS 4.0 file format limitation ? Ouch !

Well I don't need the faces... I just need the verteces... maybe I can
delete the triangles/faces... that would leave 1000x1000 verteces or so...
one million verteces... maybe it will complain again...

Hmmm...

I also wondering which tool would be better for developing shaders:

1. 3D Studio Max ?

or

2. FX Composer 2.5 ?

I know FX Composer 2.5 has a shader debugger... but does 3D Studio Max have
a shader debugger ??? Hmm.

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 12:59 PM
I am trying to find an export format that both tools support...

I tried the wave front (obj) format... but it's some kind of ****ed up
format that generates like 200+++ MB...

I had to terminate 3D Studio Max... just in case...

I kinda new that would happen... maybe it's some kind of length text file
format... don't know, don't care

Well hmm shitty... me must find good efficient format

Bye,
Skybuck.





 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      09-04-2009, 01:06 PM
I tried the FBX plugin... or whatever... but this also take a pretty long
time... I don't wanna wait for it... life is too short

Had to terminate 3D Studio Max 9 again... it used something like 1 GB of ram
during export.

I shall try one more time by trying to delete the faces or so... maybe that
helps but I doubt it

Bye,
Skybuck.


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT. The time now is 07:21 AM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43