Drawing a multicolored triangle #730
Unanswered
CarlSandstrom
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi Carl,
It's hard to pinpoint what might be going on without having the source
code, but my best guess would be that the state set up is using a per
instance rather than per vertex binding for the colour array. The
vsg::Builder class is built around one color per geometry instances so the
binding are set up for this.
It would be more complicated to do more of the state setup yourself but
will give you full control, so for now I'd recommend against using
vsg::Builder a usage case it wan't designed for. Longer term I plan to
expand vsg::Builder to better support freeform scene graph setup rather
than primitive shapes that it does right now.
To roll your own geometry you could take a low level take as show in the
vsgdraw example, or use a high level approach like used by vsg::Builder.
For the later the vsggraphicspipelineconfiguratior is the place to start,
in this example it uses a per instance colour, but
https://github.com/vsg-dev/vsgExamples/blob/master/examples/utils/vsggraphicspipelineconfigurator/vsggraphicspipelineconfigurator.cpp#L142
To testing things ghanging this to a color array setup to a vsg::vec4Array
with the same number of entries are there are vertices then change the line:
graphicsPipelineConfig->assignArray(vertexArrays, "vsg_Color",
VK_VERTEX_INPUT_RATE_INSTANCE, colors);
To:
graphicsPipelineConfig->assignArray(vertexArrays, "vsg_Color",
VK_VERTEX_INPUT_RATE_VERTEX, colors);
Then when the graphicsPipelineConfig->init() is invoked it'll create a
graphics pipeline that exacts per vertex colours.
I hope this helps,
Robert.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to re-create the classic example of a multicolored triangle in VulkanSceneGraph.
To do this, I use a StateGroup object produced by the vsg::Builder::createStateGroup() method as the root node. Furthermore, I create vertices, normals, texcoords, colors and indices as follows:
Then I use the vsg::VertexIndexDraw class and add it to the StateGroup.
The program draws the triangle as expected, but the color is of the triangle is red. I have also tried using the vsg::Commands class but the result is a black triangle, even if a add a light source.
What am I missing? Is it wrong to pass a vector of vectors as color?
Beta Was this translation helpful? Give feedback.
All reactions