Jump to content
  • Advertisement
Sign in to follow this  
Narf the Mouse

Perlin noise, Shader Model 3.0 and Bitwise

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

Given that Shader Model 3.0 can't do bitwise operations (which are, IMU, essential to a pseudo-random number generator and thus to perlin noise), is it still possible (possibly through some kind of hack) to do perlin (or, more properly, pseudo-random) noise generation in shader model 3.0?

For example, would the following:

int i1 = 65535;
int i2 = 2147418112;
int i1a = i1 * pow(2, 16);
int i2a = i2 * pow(0.5, 16);
int i3a = i1a + i2a;

Be a bit-shifting substitute for:

int i1 = 65535;
int i2 = 2147418112;
int i1a = i1 << 16;
int i2a = i2 >> 16;
int i3a = i1a | i2a;

Granted, not too useful by itself, but it might be a proof of concept...A test in NVidia FX Composer says it works. Cool. I may have my answer right there. :)

The basic idea is to generate terrain vertex heights from said noise values. The CPU can do that, but it's slow, or, more properly, it's an embarrassingly-parallel problem.

This is the site I use for my definition of "perlin" or "pseudo-random" noise: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You could use a precomputed texture to store different bit operations in each channel (rgb would hold &, ^, |,). Then when you want to compute 34 & 628 you would lookup float2( 34/width, 628/height) in the texture and read the red channel. I've done this in the past and it works pretty well. It may not work for you though due to the texture size needed, but I thought I'd mention it. Be sure to use point sampling.

Share this post


Link to post
Share on other sites

You could use a precomputed texture to store different bit operations in each channel (rgb would hold &, ^, |,). Then when you want to compute 34 & 628 you would lookup float2( 34/width, 628/height) in the texture and read the red channel. I've done this in the past and it works pretty well. It may not work for you though due to the texture size needed, but I thought I'd mention it. Be sure to use point sampling.

Thanks, but yeah, the texture memory requirements are prohibitive - An IntxInt's worth, unless someone has a way to compact that.

Share this post


Link to post
Share on other sites

This is the site I use for my definition of "perlin" or "pseudo-random" noise: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Just so you aren't confused later. That tutorial is about value noise. Perlin noise is a type of gradient noise which that article doesn't discuss. Common misunderstanding.

Share this post


Link to post
Share on other sites

[quote name='Narf the Mouse' timestamp='1316672891' post='4864556']
This is the site I use for my definition of "perlin" or "pseudo-random" noise: http://freespace.vir...ls/m_perlin.htm

Just so you aren't confused later. That tutorial is about value noise. Perlin noise is a type of gradient noise which that article doesn't discuss. Common misunderstanding.
[/quote]
Hmm, thought I made it clear I knew it's not Perlin noise in the first post. Guess not.

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!