[osg-users] Set color in fragment shader

2014-07-29 Thread ying song
Hello everyone,

I downloaded a 3d model which is in 3ds file format. At first I distorted this 
model in the vertex shader. Then I want to set the color of the model as same 
as the original color, but I don't know how to do it. 
I tried: 'gl_FragColor = gl_Color;' in the fragment shader, but then the model 
showed is totally black. Would anyone help me on this?

Moreover, if the 3d model also used some textures, to coloring it, I think I 
have to get the color of each vertex and then pass it to gl_FragColor. Would 
someone tell me am I right? (I applied unlinear distortion to the model)

Thank you!

Cheers,
ying

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60503#60503





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Set color in fragment shader

2014-07-29 Thread Bram Vaessen
don't forget to pass the color in the vertex shader:

gl_FrontColor = gl_Color;

for texture you use texture coordinates:

usually gl_TexCoord[0] = gl_MultiTexCoord0; in the vertex shader
and then for example use texture2D( sampler2D, vec2 [,float bias] ) to sample a 
color from the texture at the right texture coordinates.

You also have to load and bind the texture ofcourse, but that is also explained 
in the OSG beginners guide

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60504#60504





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org