Game Development Community

Marble Shader?

by Dylan Sale · in Torque Game Engine Advanced · 06/15/2004 (7:11 am) · 5 replies

Does anyone know a good perlin noise marble shader? I tried to make my own but alas, it doesnt look right. I tried to see how they did it in RenderMonkey but I have no idea how to convert such a thing over to Torque. This is really just an exercise for me to do some shader programming as I hadnt touched it before.

Here is what I have at the moment:
www.llamageek.com/perlin3.jpg
Not exactly marbly :/

Also, how would I use 3D textures (for say, noise lookup) with TSE? I tried to point the material to the ATI NoiseVolume.dds and changed the tex* functions in the shader to 3D ones (and the sampler) but it just made it grey :|

#1
06/15/2004 (8:22 am)
The .fx files from shader apps dont look all that different from TSE .hlsl files used. It doesnt look hard to convert them.
#2
06/15/2004 (12:46 pm)
I assume you looked at Ken Perlin's home page. I'm not quite sure if your noise shader is correct, there is a noise shader as an NVidia demo.

When doing marble with noise, however, it is usually the case that noise is summed, to quite a few octaves, to achieve this. If I remember correctly (I did a presentation on noise last quarter) the function is:

|noise(p)| + |noise(2p)/2| + |noise(3p)/3| ... etc

This is, currently, impossible to do in real time. You can pre-compute the texture using a shader and write it to a texture, however you will not be able to do those cool marble Perlin noise textures in real time.
#3
06/15/2004 (6:20 pm)
I just used a noise texture that I made with the noise filter in Gimp, then did a lookup of that texture as you said (with increasing frequency and decreasing amplitude) for 3 iterations. I then did cos(x+noise) where x was the texCoord.x to get the 'banding'. Not exactly sure if its correct either, but without the cosine, it looks similar to other noise I've seen.

Turns out my code is pretty similar to the ATI code, except they used a 3D texture, could that be the reason? They also used the power function for some reason.

Well, thanks for your input, maybe I'll try something a little more simple ;)
#4
06/16/2004 (6:35 am)
Oops, you are right, I left out the cos( x + sum_noise ).

Hrmm. I don't think that the 3d vs the 2d texture would cause the problem. I am not an expert on this at all though. It looks like it actually may be alright if it was somehow 'scaled up' if that makes sense. The only reason I am suspisious of something being wrong is because I just see black and white, I don't see the whispy grey parts. If you want, I can send you the code for the procedural noise texture I did for a raytracing project this last school year. I don't know what to tell you though, I'm not sure what is wrong.
#5
06/16/2004 (11:41 am)
We will be supporting compressed textures and hopefully .dds as well fairly soon.