01-22-2020, 12:26 PM
All OptimizedPointMeshes can have the same effect but each of them should have its own material - for example PixelMaterial (as in OptimizedPointCloud.xaml.cs sample).
Then you only need to change the PixelColor value in the specific PixelMaterial and notify DXEngine about the changes and the whole point cloud will be rendered with a different color.
For example, if you add a Test button to OptimizedPointCloud.xaml then you can use the following code to change the color:
This is a usual approach for the effects in DXEngine.
But the effect in ShadedPointCloudSample is different - this effect does not support multiple materials and defines all the material's properties in the effect's properties. So if you use the source code from that sample, then you need to create new ShadedPointCloudEffect instance for each point cloud. This will then allow you to change the color of each effect. Having multiple effect instances does not have any performance of memory drawbacks.
Note that if you do not need to have individual points in the point could shaded by light angle (so in case when all your points can have the same color), then it is much easier to use standard OptimizedPointMeshes instead of ShadedPointCloudEffect. The later can be also used when you want full control of the point cloud rendering and want to change the hlsl code of the shaders (this effect if provided with full source).
Then you only need to change the PixelColor value in the specific PixelMaterial and notify DXEngine about the changes and the whole point cloud will be rendered with a different color.
For example, if you add a Test button to OptimizedPointCloud.xaml then you can use the following code to change the color:
Code:
private void TestButton_OnClick(object sender, RoutedEventArgs e)
{
_pixelMaterial.PixelColor = Colors.Aqua.ToColor4();
_customRenderableNode.NotifySceneNodeChange(SceneNode.SceneNodeDirtyFlags.MaterialChanged);
}This is a usual approach for the effects in DXEngine.
But the effect in ShadedPointCloudSample is different - this effect does not support multiple materials and defines all the material's properties in the effect's properties. So if you use the source code from that sample, then you need to create new ShadedPointCloudEffect instance for each point cloud. This will then allow you to change the color of each effect. Having multiple effect instances does not have any performance of memory drawbacks.
Note that if you do not need to have individual points in the point could shaded by light angle (so in case when all your points can have the same color), then it is much easier to use standard OptimizedPointMeshes instead of ShadedPointCloudEffect. The later can be also used when you want full control of the point cloud rendering and want to change the hlsl code of the shaders (this effect if provided with full source).
Andrej Benedik

