Jump to content
  • Advertisement
Sign in to follow this  
DwarvesH

DX11 I guess I manged to mess up GPU perlin?

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

This single octave of simplex noise doesn't look right, does it?

 

[attachment=28452:noise.png]

 

It is a port of:

https://digitalerr0r.wordpress.com/2011/05/15/xna-shader-programming-tutorial-25-perlin-noise-using-the-gpu/

 

Which implements:

http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter26.html

 

A port of a port and something was lost in translation, when switching from XNA and DX9 to C++ DX11.

 

Probably my code that generates the two textures on the CPU that are sent to the shader have some issues. Probably with the NormalizedByte4 type:

https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.packedvector.normalizedbyte4.aspx

 

This type must be matched to something, so I'm guessing DXGI_FORMAT_R8G8B8A8_SNORM? This type should give a range of [-1..1] in floats.

 

 

 

 

Share this post


Link to post
Share on other sites
Advertisement

Sorry, it is indeed that I misunderstood how to populate data for DXGI_FORMAT_R8G8B8A8_SNORM.

 

Multiple octave noise is looking as expected now:

 

[attachment=28454:noise4.png]

 

On the plus side, I know now how to do a weird procedural square snaky texture!

Share this post


Link to post
Share on other sites

Here is one thing I do not understand...

 

I generate a texture map with values [0..1], where 0 is ocean floor maximum and 1 is mountain maximum, 0.5 being sea level, using GPU simplex noise.

 

In my vertex shader, I sample that texture:

input.Position.y = permTexture2d.SampleLevel(permSampler2d, float4(input.texCoord, 0, 0), 0).x * 30;
float4 worldPosition = mul(float4(input.Position, 1), World);
output.Position = mul(worldPosition, ViewProj);

In the pixel shader I used to take the world position and use its y coordinate to done coloring, like:

float inz = ((input.wPos.y / 30) - 0.5) * 2;

Since at the moment I am using just low resolution meshes for terrain, I did not like the interpolation artifacts. Plus using the y coordinate causes very flat color gradients. So I decided to sample the same map as in the vertex shader, getting the actual height at that point:

float inz = (permTexture2d.SampleLevel(permSampler2d, float4(input.texCoord, 0, 0), 0).x - 0.5) * 2;

And this is what I get when I render all values inz <= 0 as black and the rest with some colors:

 

[attachment=28513:1002_06.png]

 

I really can't figure out why I get that pattern. It does not look like interpolation errors. It is not a big issue, I can work around it, but I am very curious what causes this. The shape depends on the size of the input maps, so it is related to sampling somehow...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!