Preet | 30 Jun 2012 09:02
Picon
Gravatar

Problems using shader attributes

Hiya.

I'm trying to pass attributes to my vertex shader, but have come
across several issues.These issues only occur when I use OSG -- if I
try to do the same thing with straight OpenGL calls, it works fine.
I've set "setUseModelViewAndProjectionUniforms(true)" and
"setUseVertexAttributeAliasing(false)". I add vertex attributes to my
geometry by calling "setVertexAttribArray". I don't explicitly specify
any other arrays (I don't call "setVertexArray" or anything like
that).

* Assigning a position attribute to '0' works as expected and my
geometry shows up. Moving that position attribute to another slot
doesn't work. I explicitly call "setCullingActive(false)" on my
geometry and set zNear zFar on my camera but when I try to render the
scene I get what I think are scene culling related issues:

cull_draw() 0x15cd420
_clampProjectionMatrix not applied, invalid depth range, znear =
3.40282e+38  zfar = -3.40282e+38
end cull_draw() 0x15cd420

* I also tried playing around with a normal attribute. I just take the
normal and pass it as a varying to the fragment shader where it
directly sets the fragment color to the value of the normal. I get a
sane result when I set the normal attribute to slot 1,2 or 6 or 7. If
I set the normal attribute slot to anything else I get random gray
shapes obscuring the viewport:

normal attribute set to slot 1: http://i.imgur.com/C5MQ7.png
(Continue reading)

Preet | 30 Jun 2012 09:06
Picon
Gravatar

Re: Problems using shader attributes

-> small edit: the correctly rendered scene with straight opengl:
http://i.imgur.com/gLLdM.png
Robert Osfield | 9 Jul 2012 13:01
Picon

Re: Problems using shader attributes

Hi Preet,

The OSG provides more than just support for passing data to OpenGL, it
does culling and this requires knowledge of the bounding volume of the
object.  I would recommend sticking with using the standard
osg::Geometry::setVertexArray(..) for passing in the vertex positions
of your data so that the OSG can compute the bounding volumes
automatically for you.

Robert.

On 30 June 2012 08:02, Preet <prismatic.project@...> wrote:
> Hiya.
>
> I'm trying to pass attributes to my vertex shader, but have come
> across several issues.These issues only occur when I use OSG -- if I
> try to do the same thing with straight OpenGL calls, it works fine.
> I've set "setUseModelViewAndProjectionUniforms(true)" and
> "setUseVertexAttributeAliasing(false)". I add vertex attributes to my
> geometry by calling "setVertexAttribArray". I don't explicitly specify
> any other arrays (I don't call "setVertexArray" or anything like
> that).
>
> * Assigning a position attribute to '0' works as expected and my
> geometry shows up. Moving that position attribute to another slot
> doesn't work. I explicitly call "setCullingActive(false)" on my
> geometry and set zNear zFar on my camera but when I try to render the
> scene I get what I think are scene culling related issues:
>
> cull_draw() 0x15cd420
(Continue reading)


Gmane