DX11 not drawing anything

Started by
12 comments, last by kauna 11 years, 12 months ago

Shader colors range from 0.0 to 1.0. If you normalize (255, 255, 255) it'll be about (0.58, 0.58, 0.58) and that's just gray.
You could simply do return float4(1, 1, 1, 1) to return white color.[/quote]

Right on. tongue.png
At least my clear color isn't gray.

Also commenting those out changes nothing.
Advertisement
It seems you send 3 floats for position to the shader:

polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;

However in the shader you try to accept 4 floats:

float4 Position : POSITION0;


Also I think you have to use SV_POSITION for vertex's output position, not POSITION0 like you do.

If I haven't made any mistake shader should look like this:

float4x4 World;
float4x4 View;
float4x4 Projection;
texture2D Texture;

SamplerState textureSampler {
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

struct VertexShaderInput {
float3 Position : POSITION0;
float2 TextureCoordinate : TEXCOORD0;
};

struct VertexShaderOutput {
float4 Position : SV_POSITION;
float2 TextureCoordinate : TEXCOORD0;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input) {
VertexShaderOutput output;

output.Position = mul(float4(input.Position, 1), World);
output.Position = mul(output.Position, View);
output.Position = mul(output.Position, Projection);
output.TextureCoordinate = input.TextureCoordinate;

return output;
};

float4 PixelShaderFunction(VertexShaderOutput input) : SV_TARGET {
return float4(1, 1, 1, 1)
};

technique11 Textured {
pass p0 {
SetVertexShader(CompileShader(vs_5_0, VertexShaderFunction()));
SetPixelShader(CompileShader(ps_5_0, PixelShaderFunction()));
}
};


P.S. I'm not sure if these things might cause your issue, I just try to find differences between your code and mine.
No difference :P

Thanks for looking

it seems you send 3 floats for position to the shader:
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
However in the shader you try to accept 4 floats:
float4 Position : POSITION0;


It is correct to send 3 floats and read 4 floats. The shader sets the w-component to 1 automatically.

Cheers!

This topic is closed to new replies.

Advertisement