Original Post
I have a big problem and my knowledge of hlsl is too less to solve this by my own.
Following Situation
We make a visualisation of sun system.
Planets are rendered with depth buffer, the sun as a quad with effects like beams and so on, with alphablending - so without depth buffer.
We do it like this:
1. Render planets behind sun.
2. Render sun as a round thing on quad
3. Render planets in front of sun.
4. Render effects in front of all planets IF SUN CENTER IS VISIBLE AND NOT BEHIND A PLANET.
And at the last point i have the problem. Here i have a screenshot:
www.goodnewsfans.de/problem.jpg
At the top you see the sun with both steps - the sun and the effects.
The second screenshot is just the effects. But i want to see these effects only if the center of the sun is not behind the planet.
The good thing is that the effects are just 1 vertex, and we make the quad to render the beams and also the lens flares in the geometry shader, so i have the sunCenterPosition for all pixels in pixelshaders.
My idea is to write in step 3. when i render the planets in front of sun, a 1 into the stencilbuffer if there is a planet. The rest is 0. In step4, i will multiply it with the color of effect. Can i use another point in stencilbuffer and writing on framebuffer? In the stencilbuffer the centralpoint of sun is important for an pixel of the lensflare...
How can i do this?
Any idea?
Following Situation
We make a visualisation of sun system.
Planets are rendered with depth buffer, the sun as a quad with effects like beams and so on, with alphablending - so without depth buffer.
We do it like this:
1. Render planets behind sun.
2. Render sun as a round thing on quad
3. Render planets in front of sun.
4. Render effects in front of all planets IF SUN CENTER IS VISIBLE AND NOT BEHIND A PLANET.
And at the last point i have the problem. Here i have a screenshot:
www.goodnewsfans.de/problem.jpg
At the top you see the sun with both steps - the sun and the effects.
The second screenshot is just the effects. But i want to see these effects only if the center of the sun is not behind the planet.
The good thing is that the effects are just 1 vertex, and we make the quad to render the beams and also the lens flares in the geometry shader, so i have the sunCenterPosition for all pixels in pixelshaders.
My idea is to write in step 3. when i render the planets in front of sun, a 1 into the stencilbuffer if there is a planet. The rest is 0. In step4, i will multiply it with the color of effect. Can i use another point in stencilbuffer and writing on framebuffer? In the stencilbuffer the centralpoint of sun is important for an pixel of the lensflare...
How can i do this?
Any idea?