Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualgigaworm

Posted 11 April 2013 - 12:53 PM

Hi, I've been really struggling to find information on how to generate a terrain using noise on the HLSL. Currently I have a terrain generated on the gpu using a couple of octaves of simplex noise but it runs a little slow. To speed it up I am trying to use a texture for the permutation table, but I cant find much information on it. First of all, I'm not sure how to fill the texture with values from 0-255, so I'm currently doing this on the cpu side and passing it in as a shader resource:

 

int index = 0;
int data[256];
for( int i = 0; i < 256; i++ )
{
    data[i] = ( p[index] );
    index++;
}
 

Would this work the same way as an array filled from 0-255? Or am I doing it completely wrong?

 

Then in the simplex noise function in the effect file, I dont understand how to use it as the permutation table. Normally I just use:


uint ii = i & 255;
uint jj = j & 255;
uint gi0 = perm[ii+perm[jj]] % 12; 
uint gi1 = perm[ii+i1+perm[jj+j1]] % 12; 
uint gi2 = perm[ii+1+perm[jj+1]] % 12;  
 

 

Where perm was the array, to get the hashed gradients, but with the texture I nee to use:

 

PermTex.SampleLevel( SampleType, ??, 0 )

Any help would be amazing.


#2gigaworm

Posted 11 April 2013 - 12:53 PM

Hi, I've been really struggling to find information on how to generate a terrain using noise on the HLSL. Currently I have a terrain generated on the gpu using a couple of octaves of simplex noise but it runs a little slow. To speed it up I am trying to use a texture for the permutation table, but I cant find much information on it. First of all, I'm not sure how to fill the texture with values from 0-255, so I'm currently doing this on the cpu side and passing it in as a shader resource:

 

int index = 0;
int data[256];
for( int i = 0; i < 256; i++ )
{
    data[i] = ( p[index] );
    index++;
}
 

Would this work the same way as an array filled from 0-255? Or am I doing it completely wrong?

 

Then in the simplex noise function in the effect file, I dont understand how to use it as the permutation table. Normally I just use:


 

uint ii = i & 255;
uint jj = j & 255;uint gi0 = perm[ii+perm[jj]] % 12; 
uint gi1 = perm[ii+i1+perm[jj+j1]] % 12; 
uint gi2 = perm[ii+1+perm[jj+1]] % 12;  
 

 

Where perm was the array, to get the hashed gradients, but with the texture I nee to use:

 

PermTex.SampleLevel( SampleType, ??, 0 )

Any help would be amazing.


#1gigaworm

Posted 11 April 2013 - 12:51 PM

Hi, I've been really struggling to find information on how to generate a terrain using noise on the HLSL. Currently I have a terrain generated on the gpu using a couple of octaves of simplex noise but it runs a little slow. To speed it up I am trying to use a texture for the permutation table, but I cant find much information on it. First of all, I'm not sure how to fill the texture with values from 0-255, so I'm currently doing this on the cpu side and passing it in as a shader resource:

 

int index = 0;
int data[256];
for( int i = 0; i < 256; i++ )
{
    data[i] = ( p[index] );
    index++;
}
 

Would this work the same way as an array filled from 0-255? Or am I doing it completely wrong?

 

Then in the simplex noise function in the effect file, I dont understand how to use it as the permutation table. Normally I just use:

 


uint ii = i & 255;
uint jj = j & 255;

uint gi0 = perm[ii+perm[jj]] % 12; uint gi1 = perm[ii+i1+perm[jj+j1]] % 12; uint gi2 = perm[ii+1+perm[jj+1]] % 12;  

Where perm was the array, to get the hashed gradients, but with the texture I nee to use:

 

PermTex.SampleLevel( SampleType, ??, 0 )

Any help would be amazing.


PARTNERS