Noise in a texture

Hi,
I am just going through the orange book and I am on the chapter about noise where it is trying to explain how to use a texture map to store a previously computed noise function.

I presume the C function it gives to generate a 3D noise texture is done inside OpenGL and not the OpenGL Shading Language. The only problem is that it seems to use the noise3 function which I cant seem to use.

So I was wondering how else I could compute the values for the noise texture without the noise function.

Thanks.

I guess it suppose you provide your own C function for 3d noise. Ie, Perlin noise, or simply random, or whatever.

It isn’t a problem to implement a own noise function. But the bilinear interpolation in a shader is to expensive for practical use. The best variant is to use a small 2d or 3d texture with random values, because the filtering will be done by the texture filter (including anisotropic filtering)

Here is one of my procedural a noise implementations: http://lumina.sourceforge.net/?id=21

It is also possible to render a material into a texture: Use the texcoords as position in the vertex shader:


 gl_Position = vec4 (texcoords.xy * 2.0 - 1.0, 0.0 1.0);

The only problem are black texels at texture seams, that can be avoid by rendering multiple times with a small viewport offset.

Thanks for both your suggestions.

Although after thinking about this more I think I might have posted in the wrong area since I am actually more interested in using a texture map to store a previously computed noise function. I have already been able to attain a readymade noise function written by someone else which I can use within the OpenGL Shading Language, although I might make a shorter, easier to understand noise function by following the tutorial you gave above.

Otherwise I also want the experience of working with noise from previously computed 1D, 2D, or 3D texture maps, which I presume gets made in OpenGL and then is accessed from within the OpenGL Shading Language. This way I hope I can learn a bit more in how to work with noise.

So I suppose what my real question is does anyone have any good techniques or ideas for creating a 1D, 2D, or 3D noise texture map within OpenGL so I can then provide it to the graphics hardware using glTexImage3D.

The idea behind the noise texture map in the orange book was that the …

function creates an RGBA texture with the first octave of noise stored in the red texture component, the second octave stored in the green texture component, the third octave stored in the blue component, and the fourth octave stored in the alpha component. Each octave has twice the frequency and half the amplitude as the previous one.

Would it be a good idea to keep all noise textures like this or is this just one way of doing it?

Since I am using JOGL would I be best just to go and find a Perlin Noise function in Java and attempt to place the values in it produces into the texture values.

Sorry for asking more questions but your help is greatly appreciated.

Thanks

Yes of course you can just put pre computed noise in a texture, just find some C++/Java code that computes 2D or 3D noise… though you will want tiled noise most likely. The texture based version of noise probably doesn’t look as good overall since it is going to repeat, but it is faster.

The texture based version of noise probably doesn’t look as good overall since it is going to repeat, but it is faster.

Well the orange book does suggest Perlin’s implementation and then make use of John Kessenich setNoiseFrequency function to produce noise values that wrap smoothly from one edge of the array to the other. Meaning I will be able to set the wrapping mode set to GL_REPEAT, and hopefully I wont see any discontinuities in the function when it wraps.

I have already been able to attain a readymade noise function written by someone else which I can use within the OpenGL Shading Language

I actually got the ready made GLSL noise implementation from Stefan Updated GLSL noise implementation
Although after studying the code a bit more I see that it still needs to create and load a texture for a combined index permutation and gradient lookup table for both Perlin and Simplex noise.

Since my knowledge of noise is still not great does anyone know if it is possible to create a Perlin or simplex noise function entirely within a shader like the implementation that oc2k1 gave?

Thanks again for your input and time.

To avoid repeating artifacts in noise textures, it’ recommend to mix different octaves from a single texture together. I’ll write a example.

Edit: Texture based noise is available now:
http://lumina.sourceforge.net/index.php?id=21
It’s equal to a 1Mx1M texture

Maybee I will add a faster algorithm that uses mipmap levels of a texture in the next days

Just to add to the previous question,
How would I go about increasing the frequency in the GLSL noise implementation made by Stefan?
Currently it gives a very smooth noise texture

But I would like it to look a bit more like the example given by oc2k1

Reason being is that I want to add a grainier feel to my wall texture and figure a noise function with a higher frequency would be of more use.

Also any ideas on how I can introduce colour noise instead of just greyscale.

Thanks again.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.