# 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.

## 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 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.

##### 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 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 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.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013755
×