I’m using Cesium for a VR/AR application, therefore I have a tabletop version. Everything is fine until I try rendering my pointclouds with the Attenuation property to have bigger ‘points’.
The problem im actually facing is that I’ve edited the default 3D Tiles shader to support cutoff if things go over my table edge.
This works fine for normal pointcloud rendering but due to the way how Attenuation works it breaks the logic as it’s “most likely” not using the default tiles shader.
I’m not asking for a fix ( I know a github issue exists for around 3 years now ) as it’s probably a tad bit more complicated and more work but I’m asking for some limited workarounds I could use?
Is there any way to adjust the way Attenuation works so I can have these properly clipped like the rest of my 3D tiles? Thanks a lot!
Is it possible to copy n create my own version of it and make my specific 3D Tiles use that instead? This would give me the total freedom to do whatever
Yeah I’m aware of that PR. Turning that into shader graph would be amazing.
You said it’s possible to create my own version of “CesiumPointCloudShading.hlsl”, could you give me a slight step by step how to make the 3D Tileset component use my own custom hlsl shader implementation? I fear it’s not as easy as its sound.
If im able to have my own hlsl shader being used in my 3DTile components when attenuation is enabled then this would practically solve all my problem I have.
So sorry, I misremembered how the point cloud material system works. Looking at GitHub, the point cloud rendering component does a Resources.Load to find the material named "CesiumPointCloudShadingMaterial". This material references the CesiumPointCloudShading.hlsl shader underneath.
So in order to use your own shader version, you’ll have to either:
Find the CesiumPointCloudShadingMaterial included with the package and rename it to something else. Then, replace it with your own material of the same name.
If the above won’t work, you may have to modify the source code for this file to change the material used.
Hi thanks for the answer, I actually managed to get it working on my own and I’ll explain it a bit for others more indepth.
In order to change the shader which is used when enabling Attenuation you have to do the following:
The package script CesiumPointCloudRenderer loads a Material in OnEnable() we have the ability to overwrite which Material it should load by for example typing
In order to load this custom material you have to create a Resources directory in your Assets directory with the proper name. Now when rendering with Attenuation it’ll load your custom material. NOTE: I tried placing a material with the same name as given in the original PointCloudRenderer file in hopes it prioritieses the entry in my Assets folder but sadly this was not the case. Renaming it to something unique did the trick for me.
In order to modify the existing PointCloudShader you can simply copy paste it in your Resources directory and assign it to your newly created material. Now ever change to that shader will be applied to your point cloud.
A quick example to see if it works is by modifing the fragment shader to return the color green.
Would be nice if it were a bit easier to replace the shader logic being used for Attenuation (I know draft PR’s exist for it) but that’s a workaround for now.