Jump to content
  • Advertisement
Sign in to follow this  
CDProp

OpenGL Implementing Simplex Noise with Shaders

This topic is 2982 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

I was wondering, how is this typically done? All of the implementations I can find have been in C or Java. Some parts of the algorithm, as-is, aren't supported by the shader profile that I'm using (I'm running on a GeForce 6800, using OpenGL 2.1). So, for instance, when it comes to using the bitwise & as a quick modulus, it tells me: error C5508: the operator "&" is not supported by this profile And I have a permutation table (array of ints), and another array of gradients, however I cannot index into them from the fragment shader. I am told: error C6013: Only arrays of texcoords may be indexed in this profile, and only with a loop index variable So I suppose I could replace the bitwise & with a normal modulus (%). When I try, I don't get any compiler errors, but I can't run my shader yet to test it because compilation fails on those array look-ups. I guess I could replace those array lookups with texture lookups? I'm pretty sure this would work, but is it the best way or is it a naive method? Also, bonus question: I see a lot of people confused about how to create tiling simplex noise. Shouldn't this be trivial? The pattern repeats itself every 256 units anyway, so just render something that is 257x257?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Geometrian
Bitwise operators aren't yet supported.


They in GL 3.0 or the GL_EXT_gpu_shader4 extension. But just using a texture is fine.

Share this post


Link to post
Share on other sites
Draw a noise texture. Most painting packages have a noise function. If you don't just want random noise, you could produce the textures yourself with a Perlin noise implementation eventually. There is ready-to-use code for that on the net.

Then in your shader read the texture. Probably you want the texture coordinates varying. You could use the model original texture coordinates and shift them with a timer-parameter and/or vertex/pixel position. If you don't need to randomize for each pixel, you can do the texture fetch also in the vertex shader already, if you have support for shader model 3.0.

Share this post


Link to post
Share on other sites
Just a quickie: SM3 is not a defacto way to assume VTF, so don't rely on that.

I've realised this to my horror recently whilst implementing grass. A lot of DX10 (or better) cards will do VTF properly under DX9 drivers, but not all, or only handle R32F or R16F (and not even both).

My Radeon 4800, which isn't brand new but is hardly a piece of crap either, will only do R32F for example. The DX9 cards we have at work won't do it at all, which kinda sucks, even though they support all other SM3 features.

You really need to check the texture compat stuff as I'm sure the situation under OGL can't be much/any better.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!