• Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About gigaworm

  • Rank
  1. Simplex Noise Texture Lookups?

    Yeah the array is for the gradient but it only has 12 values in it, so if you tried passing 13 for example, it wouldn't work and I pass the values that are obtained through the texture lookup into it.    I've been messing about with it some more and I've used some if statements to try and debug it a little and find out what values are getting returned from the texture. A few things I've noticed are that if I make a texture of 10 width using:   float data[10] = {10,10,10,10,10,10,10,10,10,10};   and set it up the same way as I posted before with R32 Floats then some interesting things happen. If I sample to the first point in the texture using 0.1 as the co-ord and change the 10 to other numbers to see what value I'm getting then using 1 returns ~5.5 instead of 1 and using 4 returns exactly 7 instead of 4. Any idea why this is?
  2. Simplex Noise Texture Lookups?

    Ah of course! its now changing the terrain which is good. I'm still trying to figure out what to pass in as co-ordinates though and for some reason when I use for example 0 which should point to 151, the array for the gradient doesn't get an out of bounds error which it should if the value is not between 0-11. I thought that maybe the value was just a fraction of that value or something so I tried adding 100 to gi0 after the look up so it would break out but it didnt, but it does if I set it to 100, whats going on?
  3. Simplex Noise Texture Lookups?

    I tried that before but I get no output using it as a texture, and it doesnt change the terrain either :(
  4. Simplex Noise Texture Lookups?

    Ok, heres my the code to set up the texture:   static int p[] = {151,160,137...131}; int index = 0; float data[512]; float data2[256]; for( int i = 0; i < 256; i++ ) {    data2[i] = ( p[index] ); index++; } for(int i=0;i<256;i++) { data[i] = data2[i]; } for(int i=0;i<256;i++) { data[i+256] = data2[i]; } ID3D11Texture1D* PermTexture = NULL; ID3D11ShaderResourceView* PermTextureSRV = NULL; D3D11_TEXTURE1D_DESC desc; desc.Width = 512; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format =  DXGI_FORMAT_R16_FLOAT; desc.Usage = D3D11_USAGE_IMMUTABLE; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = 0; desc.MiscFlags = 0; D3D11_SUBRESOURCE_DATA dataDesc; dataDesc.pSysMem = data; dataDesc.SysMemPitch = 512; device->CreateTexture1D( &desc, &dataDesc, &PermTexture ); D3D11_SHADER_RESOURCE_VIEW_DESC descSRV; ZeroMemory( &descSRV, sizeof( descSRV ) ); descSRV.Format = DXGI_FORMAT_R16_FLOAT; descSRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; descSRV.Texture1D.MipLevels = 1; descSRV.Texture1D.MostDetailedMip = 0; device->CreateShaderResourceView( PermTexture, &descSRV, &PermTextureSRV ); deviceContext->PSSetShaderResources(0, 1, &PermTextureSRV);  And then in the shader I have       Texture1D<float>   tex : register(t0);  SamplerState SampleType {     Filter = MIN_MAG_MIP_POINT;     AddressU = Wrap;     AddressV = Wrap; }; float test = tried lots of values here; float gi0 = tex.SampleLevel( SampleType, test, 0 ) ;      
  5. Simplex Noise Texture Lookups?

    Hey, thanks for all your help, I'm still struggling to get this working. I'm now using DXGI_FORMAT_R16_FLOAT and that shows up when using it as a texture for the terrain so I know it has been created correctly, but when I try SampleLevel or Load, no matter what a pass in as co-ordinates it still outputs the terrain as if gi0,2 and 3 where equal to zero. I've made the texture 512 wide, and put divided ii by 256.0 and still nothing. I also tried converting the texture to a 1D texture instead and still nothing. Any ideas?
  6. Simplex Noise Texture Lookups?

    So I need to wrap the texture when I create it to a 512 texture? Also, I used the texture I created as the texture for the terrain to make sure it was being passed in correctly and for some reason the only value that will output some form of texture is DXGI_FORMAT_R8_TYPELESS, otherwise I just get a black screen.    So for what to use as the texture parameter, something like this?       float ii = (i & 255)/256; float jj = (j & 255)/256; float gi0 = PermTex.SampleLevel( SampleType, ii+ (PermTex.SampleLevel( SampleType, jj, 0 )), 0 ) ;    
  7. 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.