Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 31 Jan 2010
Offline Last Active Jul 10 2014 05:24 PM

#4917648 How is it possible for the output register in a pixel shader to differ from P...

Posted by on 29 February 2012 - 02:00 AM


Solved!! The person who mentioned the floating point comparisons was on the right track. I needed to be round()-ing the floats, not just casting to int. There were apparently lots of 250.999999 in there (Showing up as 251.000 in PIX) and int was rounding them down to 250 which is a different set of textures in TexIndices... and so on for other areas of the terrain.

Thanks to MaulingMonkey on gamedev irc..

And thanks to all for your suggestions, I learned a lot along the way..

#4916923 Problem passing matrices to shader

Posted by on 27 February 2012 - 02:10 AM

I do something similar, in D3D11 - differences are:

-- using XMFLOAT4X4 for the matrix variable format
-- loading to XMMATRIX and transposing with XMMatrixTranspose before storing back to XMFLOAT4X4 and mapping to cbuffer
-- not using packoffset in the cbuffer declaration
-- register(cb0) instead of register(b0) for the cbuffer

I'll look closer at what you did later, but those are differences I've found and mine works fine..

Also, your PIX doesn't exactly show the problem, for me - are those cbuffer variables in the debugger not reasonable? they're definitely not zeroed out or something.. in what way are they wrong?

#4916903 [HLSL] How to use arrays of textures in hlsl?

Posted by on 27 February 2012 - 12:40 AM

With a Texture2DArray, you index into the texture array with the z coordinate when calling .Sample - you don't [] index.


Texture2DArray myTextures : register(t0);

then later..

float4 color = myTextures.Sample( sampler, float3( u, v, textureIndex ) );

A Texture2DArray is created differently though. You have to give it an array size in the texture desc, and when creating the SRV set the TEXTURE2DARRAY view dimension and Texture2DArray.* variables.