Hi All,
I have a scene mainly consisting of cubes and as such I expect to only have 6 unique normals ( using flat shading ). I wanted to create meshes where triangles can share vertices AND only uses 6 predefined normals. Sharing vertices using the index buffer is easy, but I cannot figure out there is a way to define normal indexes using different indexes than those used by the vertex buffer… The javadoc seems very sparse on this topic…
I imagined that instead of:
[java]
this.setBuffer( Type.Index, 1, BufferUtils.createIntBuffer( int []{ … } ) );
[/java]
I could define the buffer as:
[java]
this.setBuffer( Type.Index, 3, BufferUtils.createIntBuffer( int []{ … } ) );
[/java]
And then specify indexes for Vertice, Normal and Texture coordinates… Is something like this possible?
Cheers,
NiHal
No, and if you could I think it would be slow.
For your use-case, it’s easier to hack the .vert shader to use one of several constant normals based on a vertex attribute (maybe a third texture element (x,y,z) instead of just (x,y)) Or reuse one of the other vertex buffer types for the normal direction.
As far as I know, there is no way to decouple the vertex attributes from the vertexes like you propose.
1 Like
Thanks Pspeed,
I thought that might be the case. I will try to make a custom shader for the purpose then, I thought it might end like this sooner or later, tbh.
Thank you for the feedback, valuable as always - thumbs up!