vertex program light works but i can't understand

i am working on vertex program

i created a program which atleast work but i can’t understand it
as i make by hard work to just see the light but no concepts in my mind

here is the image

and here is the code i made

sorry for unused bindings

ATTRIB vn = vertex.normal;
ATTRIB vc = vertex.color;
ATTRIB vp = vertex.position;

PARAM mat[4] = {state.matrix.mvp};
PARAM lD = state.light[0].diffuse;
PARAM ld = state.light[0].position;
PARAM ma = state.material.ambient;
PARAM md = state.material.diffuse;
PARAM ms = state.material.shininess;
PARAM mS = state.material.specular;
OUTPUT ov = result.position;

TEMP s,sum;
ADD sum,ma,md;
ADD sum,sum,ms;
ADD sum,sum,ma;
ADD sum,sum,mS;
DP3 s.x,sum,vn;
DP3 s.y,sum,vn;
DP3 s.z,sum,vn;
DP3 s.w,sum,vn;
LIT s,s;
DP4 ov.x,vp,mat[0];
DP4 ov.y,vp,mat[1];
DP4 ov.z,vp,mat[2];
DP4 ov.w,vp,mat[3];
MUL result.color,s,vc;

i understands few thing like

vertex.color related to glColor3f();
but NO CONCEPTS how this light goes
and even don’t independently can say that it is light or not
as it can be controlled by glColor3f();

and also i want to use fog,texturemapping related things with

and here is some more pic so u know that i don’t know how light works
as there some problem with normals

don’t know why white spot comes but removed after CULL_FACE

and yes making depth buffer on code give undesired result like broke teapot,Cube,Sphere
thanks in advance
sorry for Grammar

no one even watched it.

i think instead of hoping answer you need to work hard on the codes of the programs

If you don’t understand shaders, why in the world are you programming in shader assembly? I suggest you use GLSL or Cg instead.

Also, if you have specific questions, please state those. Saying, “I wrote some code but I have no idea what it’s doing.” doesn’t really inspire most folks to help.

Also, state what you are trying to accomplish, and what behaviorally is wrong with what you’re seeing.

Hint:- please use the assembly code in the simple program with teapot rendering with a setting which just need a pass of Enable(DEPTH_TEST) to apply depth buffer as mentioned in Question

ok thanks for reply

the problem is that the color of light is not in my control

as in last line of assembly code

MUL result.color,s,vc;

vc -> vertex.color
s is result of the 4 component dot products of sum and vn

where sum is summation of material’s diffuse,ambient,
shininess and specular properties…bla

the cases are

Color3f function never affect the color when light is there(as i had seen in General programming)

but i need to change materials property by Color3f function
which is not fair

how i can set material’s properties without calling color3f function


as 8th line of the assembly code

PARAM ld = state.light[0].position;

i try to use ld in code

in place of vn(before last 2 lines where

DP4 ov..

is there)

how can i change light’s position in my code

when i use DEPTH Buffer for teapot the rendered primitive are bad enough to make anyone anger to close.

the pic to hint

how i can i use depth buffer so the primitives are not rendered as in break parts and instead of that hides the back primitives and show the front one

how can i do the above things in the right and well way

please help
thanks in advance
and thanks for reply

hey at-least some one please help me
i had tried to compile cg’s code and it give error
regarding Lit
and also

when i read extensions of OpenGL registry
then there is line which i see in most of place

in Addition to OpenGL 1.3 Specification…

are OpenGL specs mandatory

At last I found that
the c code goes in General fashion

if I am wrong please reply to this

it will interfered by state.material.ambient??
as i had tested in my codes

light also goes in same fashion

my Question is

:confused: How can I add light’s direction in my code

and one more
When I run any High Quality 3D application the fan in the back of laptop is becomes hot so

thanks to all who take the time to read this.

It’s may be obvious to you, but I think you’re not getting many responses because much of what you’re saying is being lost in the translation (poor English) and doesn’t make sense.

But yes, the material ambient value materializes in the shader as state.material.ambient IIRC, with ARB_vertex_program (and Cg, which can [or at least could] honor ARB_vertex_program semantics).

my Question is :confused: How can I add light’s direction in my code


See ARB_vertex_program for details.

and one more: When I run any High Quality 3D application the fan in the back of laptop is becomes hot so

That’s not an OpenGL question. That’s up to your laptop manufacturer.

Your battery could always explode, but I guess that’s just one risk folks take when they use a laptop :wink: