PDA

View Full Version : nv_point_sprite's vs. Cg Shaders



DerSchelm
12-08-2003, 06:28 AM
Hi there,
i've been experimenting with nv_point_sprite's and if i use "normal" mode with
-> glEnable (GL_POINT_SPRITE_NV)
-> //draw some points
-> glDisable (GL_POINT_SPRITE_NV)

everything works well. But i have to change the appearence of the sprites with my cg vertex shader and later with my fragment shader dubios things happen. The main problem here is that they have the same size, no matter what the distance of the viewer is.

Has anybody out there an idea, or experiences in programming with point sprites and shaders ??

Thank you

Schelm

M/\dm/\n
12-08-2003, 06:49 AM
: PSIZE ?????

DerSchelm
12-09-2003, 07:17 AM
Changing the Point Size takes no effect. They stay on the same size no matter what distance they have or what the point size is.

Any ideas ??

Is there probably a demo out there using Point Sprites together with Shaders ??

Common dudes http://www.opengl.org/discussion_boards/ubb/smile.gif

Schelm

ScottManDeath
12-09-2003, 08:43 AM
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);

should do it http://www.opengl.org/discussion_boards/ubb/wink.gif together with with for example following ARBvp (emulation of the ARB_point_parameters extension)




!!ARBvp1.0
#
# vertexprogram welches die {ARB|EXT}_point_parameter extensions nachbildet
#
#
#

# wir lassen die Festverdrahtete HW T&L pipeline die vertices transformieren.

# Vertex Attribute
ATTRIB pos = vertex.position;

# GL state
PARAM mv[4] = { state.matrix.modelview } ;
PARAM mvp[4] = { state.matrix.mvp};
PARAM pSize = state.point.size;
PARAM pAtt = state.point.attenuation;


# Konstanten
PARAM eye= { 0.0, 0.0, 0.0, 1.0};

# Hilfsvariablen
TEMP dist;
TEMP dist_sqr;
TEMP transformed;
TEMP finalsize;

#variablen initialisieren
MOV finalsize,{ 0,0,0,0 };

#vertex projezieren
DP4 result.position.x, mvp[0], pos;
DP4 result.position.y, mvp[1], pos;
DP4 result.position.z, mvp[2], pos;
DP4 result.position.w, mvp[3], pos;

# vertex in eye space
DP4 transformed.x, mv[0], pos;
DP4 transformed.y, mv[1], pos;
DP4 transformed.z, mv[2], pos;
DP4 transformed.w, mv[3], pos;

# abstand zu eye ( 0,0,0,1)
SUB dist_sqr, transformed, eye;
DP3 dist_sqr, dist_sqr, dist_sqr;
RSQ dist, dist_sqr.w; # dist enthält 1/d,
RCP dist, dist.w; # dist enthält d, dist.w enthält d

# attenuation berechnen
# pointsize = size * sqrt( 1/ ( a+ b*d + c*d^2))
# finalsize = b * d + a
# finalsize = d^2 * c + finalsize
# finalsize = 1 / sqrt (finalsize )
MAD finalsize, pAtt.y, dist, pAtt.x;
MAD finalsize, pAtt.z, dist_sqr, finalsize;
RSQ finalsize.w, finalsize.w;

# point size anpassen
MUL finalsize.w,pSize.x, finalsize.w;

# clampen und ausgeben

MAX finalsize.w, pSize.y,finalsize.w;
MIN result.pointsize,pSize.z,finalsize.w;


# farbe ausgeben
MOV result.color, vertex.color;


END

DerSchelm
12-09-2003, 10:48 AM
Thank you man,

Danke Dir

Schelm