On 03/09/2012 02:08 PM, Ethan Fahy wrote:
So I decided to go again and try to use a generic vertex attribute to store my
index numbers. I noticed from another osg forum thread that there is currently
a problem using int values for vertex attributes but that floats are working
and can be converted to ints in the shader. With that in mind, I implemented
Christian's code snippet up to the part where I've already added a vec2 float
vertex attribute to the 6th position. I have a couple of questions though:
1. in osg there is no Vec1Array (which makes sense), but then if I only wanted
to store 1 float value for each vertex, what would I use? osg::array ?
Close, osg::FloatArray :-)
2. I need to access the vertex values from a frag shader instead of the vertex
shader as seen in Christian's code snippet. If I have a generic vertex shader
like this:
Code:
void main(void)
{
gl_FrontColor = gl_Color;
gl_Position = ftransform();
}
then can I access the vertex attribute in the frag shader like this?
Code:
in vec2 indices;
void main(void)
{
//get index from vertex attribute 6
vec2 index = indices;
}
Depends on what you're after, but I'm guessing not. The fragment values
will be interpolated between the vertices, so if you have a value of 6.0
on one vertex and 8.0 on another, the value for the fragment halfway
between those vertices will be 7.0. If you're drawing triangles, and
you want all of the fragments on a particular triangle to have the same
value, you can specify flat shading in the fragment shader:
flat in vec2 indices;
which might give you what you're looking for (without knowing how your
geometry is laid out and how you're using the indices, I can only guess).
--"J"
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org