PDA

View Full Version : vertex program light works but i can't understand



vivek vyas
10-10-2009, 06:05 AM
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

http://lh6.ggpht.com/_vCOTaIVJWLs/StCDnoibztI/AAAAAAAAADk/cKNqcWlIEiA/s800/stillworkingonit.jpg

and here is the code i made

sorry for unused bindings


!!ARBvp1.0\n\
ATTRIB vn = vertex.normal;\n\
ATTRIB vc = vertex.color;\n\
ATTRIB vp = vertex.position;\n\
\n\
PARAM mat[4] = {state.matrix.mvp};\n\
PARAM lD = state.light[0].diffuse;\n\
PARAM ld = state.light[0].position;\n\
PARAM ma = state.material.ambient;\n\
PARAM md = state.material.diffuse;\n\
PARAM ms = state.material.shininess;\n\
PARAM mS = state.material.specular;\n\
OUTPUT ov = result.position;\n\
\n\
TEMP s,sum;\n\
ADD sum,ma,md;\n\
ADD sum,sum,ms;\n\
ADD sum,sum,ma;\n\
ADD sum,sum,mS;\n\
DP3 s.x,sum,vn;\n\
DP3 s.y,sum,vn;\n\
DP3 s.z,sum,vn;\n\
DP3 s.w,sum,vn;\n\
LIT s,s;\n\
\
DP4 ov.x,vp,mat[0];\n\
DP4 ov.y,vp,mat[1];\n\
DP4 ov.z,vp,mat[2];\n\
DP4 ov.w,vp,mat[3];\n\
MUL result.color,s,vc;\n\
END


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
ARB_vertex_program



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
http://lh3.ggpht.com/_vCOTaIVJWLs/StCDnVel70I/AAAAAAAAADc/oz0hfq1pmDA/s800/accidentallight.jpg

http://lh4.ggpht.com/_vCOTaIVJWLs/StCDndYixAI/AAAAAAAAADg/vq41DyDBeQg/s800/here%20its%20right.jpg


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

vivek vyas
10-10-2009, 08:30 AM
no one even watched it.

vivek vyas
10-10-2009, 08:33 AM
i think instead of hoping answer you need to work hard on the codes of the programs
work HARD HARD HARD and HARD.

Dark Photon
10-10-2009, 10:53 AM
i created a program which atleast work but i can't understand it.


!!ARBvp1.0
...

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.

vivek vyas
10-10-2009, 01:07 PM
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;\n\
where
vc -> vertex.color
and
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
Q

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

Q


as 8th line of the assembly code

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

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
Q

when i use DEPTH Buffer for teapot the rendered primitive are bad enough to http://lh4.ggpht.com/_vCOTaIVJWLs/StDudVKOcPI/AAAAAAAAAEA/fbC7XVX4ah4/s800/WTF.jpg make anyone anger to close.

the pic to hint


so
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

vivek vyas
10-10-2009, 08:53 PM
hey at-least some one please help me
i had tried to compile cg's simple.cg 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

vivek vyas
10-11-2009, 08:05 AM
At last I found that
the c code goes in General fashion
eg

if I am wrong please reply to this

glMaterialfv(GL_FRONT,GL_AMBIENT,amb);
it will interfered by state.material.ambient??
as i had tested in my codes
so

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
:confused: IS THERE ANY RISK OF DAMAGES


thanks to all who take the time to read this.

Dark Photon
10-13-2009, 06:05 PM
glMaterialfv(GL_FRONT,GL_AMBIENT,amb);
it will interfered by state.material.ambient??
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
station.light[0].position

See ARB_vertex_program (http://www.opengl.org/registry/specs/ARB/vertex_program.txt) for details.


and one more: When I run any High Quality 3D application the fan in the back of laptop is becomes hot so
:confused: IS THERE ANY RISK OF DAMAGES
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 ;)