john-chapman / im3d

Immediate mode rendering and 3d gizmos.
MIT License
1.21k stars 63 forks source link

Update README.md with more integration info #58

Closed Sand3r- closed 2 years ago

Sand3r- commented 2 years ago

I've added some info about pipeline setup that I wish I knew before I started integrating im3d into my project.

john-chapman commented 2 years ago

Hi - actually none of these states are strictly required, as the user can draw the output geometry in any conceivable manner (with or without depth test, blending, etc.). It's for this reason that I'd prefer to keep the README agnostic to any renderer-specific details.

Nonetheless I think this tip does have a place somewhere, so I've added a comment to the example code.

Sand3r- commented 2 years ago

On the contrary.

Culling

With VK_CULL_MODE_BACK: BackCulling Arrow only visible when it's end vertex isn't on screen. Clearly not intended. With VK_CULL_MODE_NONE: image Everything working just fine.

Depth testing

With .depthTestEnable = VK_TRUE in VkPipelineDepthStencilStateCreateInfo: image Gizmo not being visible inside of the objects that enclose them. With .depthTestEnable = VK_FALSE, obviously: image

Blending

With .blendEnable = VK_FALSE in VkPipelineColorBlendAttachmentState: image Gizmos not appearing as intended + having some weird artifacts on its move-within-a-plane-quads. Also the ability to have semi-transparent objects is disabled.

With .blendEnable = VK_TRUE: image Working as intended.

john-chapman commented 2 years ago

I agree that these states are used in most common cases, but as noted above this is really just a detail of the user's rendering implementation, which is why I think it belongs in the example code.

Disabling backface culling isn't strictly required if the renderer doesn't do line expansion in the same way that the examples do, plus users may want to enable it for triangle primitives.

Depth testing might be used to draw a different effect for Im3d primitives which intersect the depth buffer (i.e. draw twice and reverse the depth test).

Blending is optional, it generally looks nicer enabled but again there are multiple ways to achieve this.

Sand3r- commented 2 years ago

Yeah okay, that makes sense. In that case adding the comments was prolly the way to go. Thank you for the explanation.