Change cullmode - Printable Version
+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.DXEngine (https://forum.ab4d.com/forumdisplay.php?fid=11)
+--- Thread: Change cullmode (/showthread.php?tid=4184)
Change cullmode - mange - 04-04-2020
The Physically Based Rendering effect does not seem to cull backfacing triangles and I would like to enable that.
In the examples ContextStatesManager.SetRasterizerState() is used in custom effects to set the cull mode.
Is there a way to change the cull mode for an already existing effect?
RE: Change cullmode - abenedik - 04-06-2020
You are right - culling is disabled when rendering PBR effect. This is not correct.
I will try to fix that tomorrow and prepare a pre-release version for you.
It is also possible to fix that with the current version - you need to use OverrideRasterizerState on the RenderObjectsRenderingStep.
If you are rendering only PBR objects, then you can easily fix that with the following:
DXScene.DefaultRenderObjectsRenderingStep.OverrideRasterizerState = DXScene.DXScene.DXDevice.CommonStates.CullCounterClockwise; // Or use CullClockwise
If you are also rendering objects that require other types of culling, then you would need to create a new RenderObjectsRenderingStep - one with overridden culling and one without. Then you would need to either use FilterRenderingQueuesFunction or FilterObjectsFunction on the RenderObjectsRenderingStep to define which objects are rendered with each RenderObjectsRenderingStep. This is slightly more complicated but DXEngine is flexible enough so it is also possible to achieve that. If you will try to do that and will have any problems, please contact me for more details.