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

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

Post by Skybuck Fl » Sat, 05 Sep 2009 11:38:50


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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 18:47:30

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.

 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 18:58:11

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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 18:59:46

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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 19:32:54

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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 19:46:20

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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 20:36:53

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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 20:54:32

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 de *** ... but does 3D Studio Max have
a shader de *** ??? Hmm.

Bye,
Skybuck.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 20:59:16

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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 21:06:56

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.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 21:16:51

I managed to delete the faces, and preserving the verteces by turning off
"delete isolated verteces".

However exporting to 3DS format now gives the other warning I feared:

"Object [Plane01] has too many vertices (more than 64K) to export.

I tried opening the partial file or so in FX Composer (the file with the
face) but composer didn't show anything... first time I actually test
importing... maybe I should first do a small test to see if that would work
and how it would look but ok.

So far it seems 3DS format is seriously limited to 16 bit which means
everything having a limit of 64K

So best I can do is SQRT(64000) which is: 252x252 = 63504

However normally it's something like 256*256 = 65536

However C loops will fail under that condition so I fear 3DS Max 9 will spin
for ever when trying to save or load it...

Would be interesting to see... so I will attempt creating exactly 65536 or
65535 vertices to see what happens ;) :)

Bye,
Skybuck.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 21:25:42

Ok,

I did some testing that was kinda interesting :)

A plane of 255 by 255 segments creates exactly 65536 verteces.

Exporting to 3DS fails.

I deleted one vertec.

Exporting to 3DS fails.

Apperently the programmers/file format designers were paranoid enough to
limit it to 64000 ;)

So now I create a plane of (252-1) by (252-1) segments and that should be
the maximum square that will fit into 64000 verteces... it would almost
create double the ammount of faces so those need to be deleted and then I
can finally export something into FX Composer 2.5...

Would be funny if FX Composer is stubern enough to delete the unused
verteces... I hope not... but I fear the worst ! ;) :)

Bye,
Skybuck =D
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 21:34:24

With the faces I don't see anything in FX Composer 2.5...

This kinda sux.

Well new calculation:

Maximum number of faces is 64000

Each square needs to faces so new figure is 32000

SQRT(3200) = (178-1) by (178-1)

This should create the maximum allowable plane with faces for 3DS...

Gonna try it now... if that fails then I am gonna try a fricking teapot
lol... to see if it's gonna work at all :)

Bye,
Skybuck.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 21:40:27

FX Composer 2.5 seems to totally lock up when trying to load just 64K faces
and 32K verteces ?!?!?

Ouch ! Sigh...

Well just to test out my theories I guess I will have to seriously constrain
myself and limit myself to

10x10 faces... I hope it can handle that ?!? Gjez ! =D

LOL.

Bye,
Skybuck =D LOL.
 
 
 

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

Post by Skybuck Fl » Sat, 05 Sep 2009 21:46:43

Ok finally... 9 by 9 faces it can handle that ! LOL.

Giving me exactly 10 by 10 grid of verteces...

Now I try to write a vertex shader only to see how it can affect verteces...

According to docs it can fully change vertex locations... so that will be
most interesting to witness ! ;)

Bye,
Skybuck.