06-24-2016, 10:39 AM
The problem with lines is caused by the EmissiveMaterial that is by default used to render 3D lines.
The EmissiveMaterial is "emitting" the color regardless of the lights in the scene. This is done by adding the color to the scene.
But when the same line is rendered over the same pixels multiple times (the line intersects with itself), the color is also added multiple times.
Because colors are actually byte numbers, the colors can change when the same color is added multiple times.
For example if you add dark blue (0,0,80) two times you get a lighter blue (0,0,160). If the color is added 4 times then you get full blue (0,0,255).
This works well for red, green, blue and white color because those colors are not changed when they are added to the final pixel multiple times. But other colors have problems when they intersect with itself.
It is not possible to change how EmissiveMaterials are rendered with WPF 3D.
But Ab3d.PowerToys allows to use standard DiffuseMaterial instead of EmissiveMaterial. This can be changed with setting Ab3d.Utilities.LinesUpdater.Instance.IsEmissiveMaterialUsed to false.
This prevents the problems with colors when lines intersects with itself, but using DiffuseMaterial will be affected by light positions and will be shaded based on the angle of the line surface and direction of lights.
A real solution to this problem is to use Ab3d.DXEngine to render 3D lines. There the line shader code always preserves the line color and is not adding color when the line intersects with itself.
The EmissiveMaterial is "emitting" the color regardless of the lights in the scene. This is done by adding the color to the scene.
But when the same line is rendered over the same pixels multiple times (the line intersects with itself), the color is also added multiple times.
Because colors are actually byte numbers, the colors can change when the same color is added multiple times.
For example if you add dark blue (0,0,80) two times you get a lighter blue (0,0,160). If the color is added 4 times then you get full blue (0,0,255).
This works well for red, green, blue and white color because those colors are not changed when they are added to the final pixel multiple times. But other colors have problems when they intersect with itself.
It is not possible to change how EmissiveMaterials are rendered with WPF 3D.
But Ab3d.PowerToys allows to use standard DiffuseMaterial instead of EmissiveMaterial. This can be changed with setting Ab3d.Utilities.LinesUpdater.Instance.IsEmissiveMaterialUsed to false.
This prevents the problems with colors when lines intersects with itself, but using DiffuseMaterial will be affected by light positions and will be shaded based on the angle of the line surface and direction of lights.
A real solution to this problem is to use Ab3d.DXEngine to render 3D lines. There the line shader code always preserves the line color and is not adding color when the line intersects with itself.
Andrej Benedik

