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