This wiki is archived from 2021-09-05

Talk:Shaders

From Planetary Annihilation: TITANS and Classic PA Wiki
Jump to navigation Jump to search

range_ring_instanced.fs

This is responsible for rendering range rings like patrol circle, mex area commands and that kind of thing.

What I have worked out so far: When a range is being rendered, a huge low poly sphere is used as a scaffold. (I call it a scaffold because it is really just used to generate fragments for the fragment shader that is not too wasteful.

The iconosphere is centred on the origin of the unit/range and is sized to encompass the range of the unit. The iconosphere is rendered into fragments but then depth buffer is actually that of the scene's geometry.

For each fragment, we compute the world-space coordinates, given the 'depth' of the fragment, and screen coordinates. Once the world space coordinate is computed, we can compute the distance of this fragment from the centre of the sphere.