Tryz

I have this line in my Vertex Shader:

float4 Colors = tex2Dlod(ElevationSampler, float4(0, 0, 0.0f, 1.0f));

I'm expecting to see R:33,G:33,B:33,A:0, but instead I get 4 floats that are incredibly small (ie -2.14177722E+38).

I've gone after the data in my Texture2D directly (in C#) to test:

Texture.GetData<Color>(0, new Rectangle(0, 0, 10, 1), xx, 0, 10);

Texture.GetData<float>(0, new Rectangle(0, 0, 10, 1), yy, 0, 10);

When getting a "Color", I get exactly what I want. However, if I get a "float", the call returns what I see in the Vertext Shader.

How can I get the Vertex Shader to give me the real RGB colors and not the exponential

I've got to be missing something simple.

Thanks.



Re: XNA Game Studio Express Vertex Shader, Vertex Textures, & tex2Dlod

Shawn Hargreaves - MSFT

What format is your texture How are you creating it

You can't GetData from the same texture into both Color and float formats: you have to read back the same format that the texture actually contains, otherwise you'll just get garbage.






Re: XNA Game Studio Express Vertex Shader, Vertex Textures, & tex2Dlod

Surixurient

Code Snippet
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TextureCoords: TEXCOORD1;
};

Texture xColorMap;
sampler ColorSampler = sampler_state{ texture = <xColorMap>;
MinFilter = POINT;

MagFilter = POINT;

AddressU = CLAMP;

AddressV = CLAMP;
};


VertexToPixel TexturedVCsVS( float4 inPos : POSITION, float2 inCM: TEXCOORD1, float2 inTexCoords: TEXCOORD0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Color = tex2Dlod(ColorSampler, inCM);
}
tex2Dlod will not even compile for me




Re: XNA Game Studio Express Vertex Shader, Vertex Textures, & tex2Dlod

Shawn Hargreaves - MSFT

What error do you get

I'm guessing your problem there is that tex2Dlod takes a float4 coordinate, not a float2 (that's the "lod" part of it).






Re: XNA Game Studio Express Vertex Shader, Vertex Textures, & tex2Dlod

Surixurient

that was it, thanks.

how do i see compile errors it just returns null without giving any error if it fails to compile.




Re: XNA Game Studio Express Vertex Shader, Vertex Textures, & tex2Dlod

Shawn Hargreaves - MSFT

If you use the content pipeline (by adding your .fx file to GSE) the errors will appear in the VS error window when you build.

If you are compiling them yourself in code, error information is included in the CompiledEffect structure.