Jump to content
  • Advertisement
Sign in to follow this  

Procedural Planets and Interference with other Shaders

This topic is 2854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, it's been a while since I visited the forums, but lately I've been a bit bored so I pulled out one of my old game engines and started tinkering. So, for the last couple days I've been building a pretty nice procedural planet algorithm, details below. I'm actually very pleased with the results from the procedural planets, but for some reason the planet shader doesn't play nice with another shader I'm using, a custom shield shader for the ships.

But before I get into that, here's some pretty pictures of the procedural planets I'm generating:

Basically I'm using the technique described in GPU Gems with 8 octaves of noise, but with 3D wavelet noise instead of perlin noise and some fancy interpolation between bands (using a mixture of additive and multiplicative). Every aspect of the process is deterministically randomized from a seed integer, including lighting parameters, diffuse/specular colors, noise band granularity, noise band weights, noise band interpolation models, and the degree to which the normals are perturbed by the normal map. The random values are initially evenly distributed from 0-1 then passed through filters to favor values that produce more realistic planets (for instance we typically don't want planets that are neon colors).

Particularly cool is the effect given by combining additive and multiplicative interpolation by evaluating both with different weights and linearly interpolating the result. This really increases the diversity of the look of the surface. A code sample is below:

float4 nAdd = float4(0, 0, 0, 0);
float4 nMult = float4(1, 1, 1, 1);

for (int x = 0; x < BandCount; ++x) {
// NOTE: the noise lookup in this code example is 4D because it includes a 3D normal for normal mapping along with the 1D noise
float4 lookup = NoiseLookup(pos * BandScales[x]);
nAdd += lookup * AdditiveWeights[x];
nMult *= lookup * MultiplicativeWeights[x];

return nAdd * AdditiveBlend + nMult * (1 - AdditiveBlend);

However, like I said I'm a bit stumped by a wierd artifact I'm getting. The custom shield shader (shown below) causes a very bizarre effect on the planet, and I can't seem to figure out why. If I don't draw any shields, the wierdness goes away and we see pretty planets. Example:

At this point I suspect it must be something that's turned on during the shield shader (e.g. alpha blending settings) and not turned off before the planet shader, but I can't seem to put my finger on it. The reason I suspect that: If I remove the following line from the shield.fx shader the queer artifacts go away:
AlphaBlendEnable = true;

I try to turn alpha blending off afterwards both with the XNA command and by putting AlphaBlendEnable = false in the planet shader, but no matter what I do the glitch still occurs.

Any ideas?

Share this post

Link to post
Share on other sites
Well, I found a way around it...

Not sure if it's an XNA glitch or what, but if I turn on alpha blending in the shader as opposed to in XNA I get this glitch no matter what I try to do to turn off alpha blending afterward. However, if I set alpha blending outside the shader with XNA like so all is well.

Common.Game.GraphicsDevice.BlendState = BlendState.AlphaBlend;

Anyway, still feel free to comment or ask questions and/or give suggestions about procedural planets.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!