Wednesday, March 18, 2009

Craters

Another quick update. I have been working on adding craters to the procedural moon. I implemented a Voronoi diagram shader in HLSL and then I tweak it with quite a few different parameters to generate conical pits that are distorted slightly with fBm noise.









I tried for quite a while to get rims around the edges of the craters, but I couldn't get it to work. I tried using a colormap to alter the Voronoi results, but I was having issues with the it. I will continue to tinker around with it because I think having rims would add quite a bit.

Interesting fact: If I add even more fBm noise to the crater distortions, it forms pretty cool canyons:

2 comments:

Joel said...

Hello, I'm a software engineer from Spain specialized in computer graphics development and I'm learning HLSL. I try to write a HLSL pixel shader for procedural textures and I started with fBm, but I haven't success. can u help me?

I started with 2D noise texture created in photoshop, I sample it in HLSL and then apply the fBm:

////////////////////////////
//fBm Pixel Shader
////////////////////////////
float sum = 0.0;
float amp = 1.0;

float octaves = 2.0f;
float lacunarity = 2.0f;
float gain = 1.0f;

float x = IN.UV.x;
float y = 0.f;
float z = IN.UV.z;

for (int i=0;i(octaves;i+=1)
(
sum += amp * tex3D(NoiseSamp,
IN.WoodPos).x;
amp *= gain;
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
)

float3 res = float3(sum, sum, sum);
return float4(res, 1.0f);


Is this correct? Where is the mistake?
Thanks in Advance.

Joel.

Patrick said...

Well, the biggest problem you have is that you are not using your scaled texture coordinates (x, y, and z variables).

Your for loop should look more like this:

for (int i=0;i(octaves;i+=1)
(
sum += amp * tex3D(NoiseSamp,
float3(x, y, z)).x;
amp *= gain;
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
)