Jump to content
  • Advertisement
Sign in to follow this  

DX11 I guess I manged to mess up GPU perlin?

This topic is 1219 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?




It is a port of:



Which implements:



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:



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

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


Multiple octave noise is looking as expected now:




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:




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.

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!