Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 11 Apr 2013
Offline Last Active Jun 11 2013 11:30 AM

Posts I've Made

In Topic: Simplex Noise Texture Lookups?

28 April 2013 - 03:19 PM

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?

In Topic: Simplex Noise Texture Lookups?

27 April 2013 - 02:56 PM

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?

In Topic: Simplex Noise Texture Lookups?

22 April 2013 - 07:44 PM

I tried that before but I get no output using it as a texture, and it doesnt change the terrain either :(

In Topic: Simplex Noise Texture Lookups?

21 April 2013 - 05:35 PM

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] );
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;
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;
dataDesc.pSysMem = data;
dataDesc.SysMemPitch = 512;
device->CreateTexture1D( &desc, &dataDesc, &PermTexture );

ZeroMemory( &descSRV, sizeof( descSRV ) );
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 ) ;



In Topic: Simplex Noise Texture Lookups?

20 April 2013 - 06:43 AM

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?