Yup that's what I found I had to do . I created a fragment shader and did the
basic lighting. I assume I could do that in the vertex shader as well.
Thanks for confirming.
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69809#69809
Does your vertex shader code perform any lighting calculations?
I remember that in my instancing vertex shader code I had to explicitly
perform required lighting calculations for ambient, diffuse, specular
components (the usual Blinn-Phong lighting equations) and set the vertex
colors
Hi guys,
Can you help me out with this one more time:)
As I said, I am now able to draw my geometry ( a simple square) using hardware
instancing. It works perfectly with excellent performance for millions of
squares- except for one thing.
Now I want to light the squares. I have turned on
Thanks for the help
I got it working by adding this to the StateSet
osg::VertexAttribDivisor *divisor = new osg::VertexAttribDivisor(1, 1);
ss->setAttribute(divisor);
And changing my loop to add one offset per primitive to my vertexArray
And thanks again!! I would never have
You can use osg::VertexAttribDivisor (set to 1) to tell the shader to use
one attribute index per instance.
Glenn Waldron
On Thu, Dec 22, 2016 at 12:35 PM, Andrew Cunningham wrote:
> On thinking about this issue, I see the problem. I really only have 4
> vertices, so the
you might want to look into glVertexAttribDivisor
https://www.opengl.org/sdk/docs/man4/html/glVertexAttribDivisor.xhtml
That would let you make a vbo with 100 offsets in it and then each
instanced draw call would get a different offset.
you can even send down a 4x3 transform matrix by using more
On thinking about this issue, I see the problem. I really only have 4 vertices,
so the value d in my vertex shader just is always pulled from locations 0-3 in
my array. What I really need to do is access an array of offsets in my shader
indexed by glInstanceID
--
Read this
OSG 3.4.0
I am trying to use "instancing" (starting from the example osgdrawinstanced) to
draw simple square geometry at multiple locations.
I am getting all of my instances sitting on top of each other at (0,0,0). That
is they are not offset to their expected locations.
I know my shader is
8 matches
Mail list logo