How to keep size of material shape when camera zoom out?

I wrote a custom material with simple fragment shader code and it worked well. But when I zoomed out, the shape would be large too. I just want my shape to stay the same like Biilboard does.

I’ve read the source code about Billborad's shader, but there are a lot of calculation which was too complex to me who is new to GIS and cesium to understand. So I’m here for some help.

Please let me know if there is a solution, thanks very much.

@Gu-Miao

Thank you for sharing this question with the community! A little bit more context on the custom material that you created would be very helpful. In addition, can you please provide a sandcastle demo of what you have so far? I am looking forward to learning more.

-Sam

Thank you so much for the reply, which I’ve waiting for many days.

What I want to do is like this:
picture

I want the effects on polygon’s surface(the green part).

The material was made of a lot of small points and they will randomly fade in. I basically make it come true and there’s the sandcastle:

You could easily find that my sandcastle above has problems that the material shapes will move as the camera position moved and the material shape always face to me even change the pitch of camera especially when I increase the size of shapes.

So I tried to use materialInput.st instead of gl_FragCoord.xy, with this, the previous problems were gone, but when I zoom out the shape will be very large, because the shape’s size is fixed percentage of polygon’s size. But what I want is let the shape size to be fixed pixel so it could correctly show whether the camera zoom out or not.

Also, I won’t give it up. materialInput.st is a 0~1 coordinate so if I get a correct multiplier to scale, the problem will be resolved. I could get diff of longitude and latitude, or turn them to meters, but I don’t know how to transform the data to pixels and how to calculate when camera zoom out.

So, this is the situation. I am looking forward to your next reply.