Clipping using SV_CLIPDISTANCE - 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: Clipping using SV_CLIPDISTANCE (/showthread.php?tid=4203)
Clipping using SV_CLIPDISTANCE - TrialUser - 07-03-2020
I am a very beginner with DXEngine (currently working with the trial version). In the past I have developed a WPF 3D application with big models (BIM models), and I face severe performance problems, especially when clipping the model (so far I implemented only clipping on a Z level in world space).
Now I have implemented my first shaders using DXEngine, and the performance is quite impressive. But I have a special issue with clipping (setting SV_CLIPDISTANCE in the vertex shader).
My simple trial model is a cube of 8000 spheres (20x20x20), each modeled as a WPF ModelVisual3D.
This is my model rendered in DXEngine using no effect (I assume a "default standard effect" is used):
When I render it with my own shaders (which only change the colour), it looks like this:
This looks also fine and works very fast.
But when I clip the model (done also in my shader), it looks like this:
Clipping is basically correctly done. But the upper part (which should be clipped, i.e. invisible) seems to be rendered with the default standard effect.
For this sample I set the color of the WPFMaterial to completely opaque:
new DiffuseMaterial(new SolidColorBrush(Colors.Blue))
new DiffuseMaterial(new SolidColorBrush(Color.FromScRgb(1.0f, 0, 0, 1)))
But when I set the alpha value to a little bit lower than 1.0:
new DiffuseMaterial(new SolidColorBrush(Color.FromScRgb(0.99f, 0, 0, 1)))
clipping behaves now as expected:
What is the reason for this behaviour?
RE: Clipping using SV_CLIPDISTANCE - abenedik - 07-04-2020
If you have written a custom shader for DXEngine, then you are surely not a beginner anymore.
It is hard to say why the other objects are rendered with a standard effect.
How do you apply your custom effect?
You can also use the DXEngineSnoop to diagnose the problem - the tool is installed to the Tools folder in the DXEngine folder. To use it start your application so that the 3D scene is shown, then start DXEngineSnoop and connect to your application. A diagnostics window should open - from there you can open a menu and dump SceneNodes and RenderingQueues - this would give you some insight on which effect is used. You can also click on "DXEngine settings" to disable some optimizations. Read more here: https://www.ab4d.com/DirectX/3D/Diagnostics.aspx
You said that if you set alpha to less then 1, then everything is rendered correctly - in this case the objects are put into the TransparentRenderingQueue - this does not use some optimizations (command list caching, multi-threading). So maybe the problem is caused by some optimizations - you can disable them in code with:
RE: Clipping using SV_CLIPDISTANCE - TrialUser - 08-12-2020
MainDXViewportView.DXScene.MaxBackgroundThreadsCount = 0;
clipping worked as expected, also with alpha = 1.
Many thanks, abenedik, for your help.
In my environment, there is no IsCachingCommandLists property in DXScene. I use DXEngine version 3.3.7279.