ARB vertex shader newbie

Hi,

Thanks to You, I managed to write a simple ARB v1.0 vertex shader for my program, unfortunately I need something bit more complex then transforming vertex to clip space and changing the output color.

What other operations could I implement inside the vertex shader? I thought about calculating normal to the surfaces of my 3D object in realtime. There are some nice equations which I could put in the schader progam (since normalization is a bunch of multiplications and sqrt function), below is some code (a mix of what I found on the web and my own poor imagination…).


!!ARBvp1.0

ATTRIB iPos    = vertex.position;
ATTRIB iNorm   = vertex.normal;
ATTRIB iColor  = vertex.color.primary;

PARAM  mv[4]   = { state.matrix.modelview };
PARAM  proj[4] = { state.matrix.projection };
PARAM  params  = { 0.0, 0.5, 1.0, 2.0 };

TEMP   r0;
TEMP   r1;
TEMP   r2;
TEMP   r3;

OUTPUT oPos    = result.position;
OUTPUT oColor  = result.color;

DP4 r0.x, iPos, mv[0];
DP4 r0.y, iPos, mv[1];
DP4 r0.z, iPos, mv[2];
DP4 r0.w, iPos, mv[3];

DP3 r1.x, iNorm, mv[0];
DP3 r1.y, iNorm, mv[1];
DP3 r1.z, iNorm, mv[2];

ADD r2, -r0, params.xxxz;   # V vector
DP3 r2.w, r2, r2;           # normalizing...
RSQ r2.w, r2.w;             # normalizing...
MUL r2.xyz, r2, r2.w;       # r2 = normalized V

DP3 r3, r2, r1;
ADD r3, r3, r3;
MUL r1, r1, r3;

DP4 oPos.x, r0, proj[0];
DP4 oPos.y, r0, proj[1];
DP4 oPos.z, r0, proj[2];
DP4 oPos.w, r0, proj[3];

MOV oColor, iColor;

END

As you probably see it doesn’t work ;-), at least in my case, and by the way, could I replace a glNormal() function with binding and disabling this kind of vertex code?

I’m a Java-man, and I have to admit that OpenGL and this low level stuff defeated me… I’ll be really grateful for some help.

Best regards,
Sebastian Kapciak

Why not try the GLSL instead of the assembly; Much easier in IMHO.

Well, my developement enviroment is… a laptop with integrated Intel GMA950 graphic card. It supports only OpenGL 1.4 and as far as I know I need OpenGL 2.0 to use GLSL. My knowledge of ARB is less than basic and GLSL even worst than that.

The program I need, should show that complex shader programs can improve overall 3D performance (more FPS frame rate).

Thanks for the reply!
Sebastian

Ah…Get it.Same problem with me and a (desktop) ATI 9000. Even though the extensions for shading language exist ATI won’t implement them.
I have opted to wait till I upgrade before writing any shader stuff.Good luck with your project. Unfortunately I haven’t read any tutorials on the subject to recommend.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.