![]() |
|
Turn off antialiasing in polyLineVisual3D - 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: Turn off antialiasing in polyLineVisual3D (/showthread.php?tid=4005) |
Turn off antialiasing in polyLineVisual3D - pnelsonAG - 04-14-2017 When I draw a straight, slightly diagonal line using polyLineVisual3D it draws it with antialiasing. I don't want it drawn with antialiasing - I'd prefer to just have sharp staircasing. How do I turn off the antialiasing? I've attached an enlarged screen capture that shows the antialiasing. The code that generates this looks like: Code: MainViewport.BeginInit();Thanks in advance! RE: Turn off antialiasing in polyLineVisual3D - abenedik - 04-26-2017 To support rendering thick lines (with LineThickness > 1), DXEngine uses geometry shader that takes the line positions and converted them into triangles (2 triangles for each line segment). After that the lines are rendered as any other 3D model. This means that the anti-aliasing settings that are used to render all other 3D objects are also applied to line rendering. Anti-aliasing amount in DXEngine is specified with your GraphicsProfile settings. If you are using HighQualityHardwareRendering (by default), then you have 8x anti-aliasing enabled. To disable anti-aliasing you can use the following code (need to be executed before the DXViewportView is loaded): Code: var graphicsProfile = GraphicsProfile.HighQualityHardwareRendering.Clone();The code clones the HighQualityHardwareRendering and resets the PreferedMultisampleCount to 0. Then the changed GraphicsProfile object is specified as the only possible GraphicsProfile. If you will check the default value of the DXViewportView.GraphicsProfiles, you will see that the GraphicsProfiles array contains the following items: GraphicsProfile.NormalQualityHardwareRendering, GraphicsProfile.NormalQualitySoftwareRendering, GraphicsProfile.Wpf3D This adds some fallback capabilities in case when hardware rendering is not supported on the system. I would recommend that if you change the GraphicsProfiles array, that you follow similar principe. This described how to change anti-aliasing for the whole scene. But it is also possible to disable anti-aliasing only for 3D lines. To do this you need to do the following: Code: MainDXViewportView.DXScene.UseGeometryShaderFor3DLines = false;The first line disable using geometry shader to render 3D lines. 3D lines are then rendered as simple DirectX lines. A drawback of this is that without using geometry shader you will not be able to change line thickness - all the 3D lines will be rendered with thickness = 1. The second line that set RenderAntialiased3DLines to false instructs DirectX that when rendering lines, the lines should not be anti-aliased (this works only when UseGeometryShaderFor3DLines is false). Disabling gemetry shader and anti-aliasing also improves performance of line rendering. If you would like to set those two properties before the first frame is rendered you can use the following code: Code: MainDXViewportView.DXSceneDeviceCreated += delegate(object sender, EventArgs args)RE: Turn off antialiasing in polyLineVisual3D - pnelsonAG - 04-27-2017 Thanks! |