DX11 Shader Reflection Problem

Started by
18 comments, last by RubenRS 5 years, 7 months ago

It also gives reason as to why you get an mask value of 15 as you have a float4 in your input struct. Have you tried changing it to float3 to see what happens?

Have you looked to debug using PIX or RenderDoc?
Awesome tools for these kinds of problems.

Advertisement

That clearly is the problem, if you make it a float4 in the shader it's obviously going to report a float4 in reflection as well.

Only your pixel input with the semantic SV_POSITION require you to have a float4. You can change your vertex input to a float3 without any problem.

You'll also have to change this :


vsOut.pos = mul(vertex.pos, mvp_);

To this :


vsOut.pos = mul(float4(vertex.pos, 1.0), mvp_);
2 minutes ago, 0xnullptr said:

It also gives reason as to why you get an mask value of 15 as you have a float4 in your input struct. Have you tried changing it to float3 to see what happens?

Have you looked to debug using PIX or RenderDoc?
Awesome tools for these kinds of problems.

The image disappear. And no I haven't, I use Nvidia Nsight for rendering things but I'll check that tools, thanks.

Capture.PNG.5349edf1243d420966d12c24a2bfb6fd.PNG

? if I do the change in the shader it works... @ChuckNovice Why?

Capture.PNG.1b739abfe8394b9730e393e121140ee7.PNG

 

2 minutes ago, RubenRS said:

The image disappear. And no I haven't, I use Nvidia Nsight for rendering things but I'll check that tools, thanks.

 

Have you modified your multiplication to this ?


vsOut.pos = mul(float4(vertex.pos, 1.0), mvp_);

If not you probably now have a implicit conversion warning during your shader compile and the W value is set to 0.0 instead of 1.0.

Just now, ChuckNovice said:

Have you modified your multiplication to this ?



vsOut.pos = mul(float4(vertex.pos, 1.0), mvp_);

If not you probably now have a implicit conversion warning during your shader compile and the W value is set to 0.0 instead of 1.0.

I did the change in my vertex buffer first from XMFLOAT3 to XMFLOAT4 and that didn't work but when i changed it in the shader it works.... It's not the same?

8 minutes ago, RubenRS said:

 

? if I do the change in the shader it works... @ChuckNovice Why?

 

Because you let the compiler do an implicit conversion for you from float3 to float4. The last component will be set to 0.0 during that conversion and you actually want 1.0 there.

I'd highly suggest compiling your shaders with the flag that treat warnings as error. I don't make those kind of mistake since I activated this.

 

1 minute ago, RubenRS said:

I did the change in my vertex buffer first from XMFLOAT3 to XMFLOAT4 and that didn't work but when i changed it in the shader it works.... It's not the same?

But when you changed your vertex buffer to XMFLOAT4 did you actually feed 1.0 to the 4th component? It's important for the matrix multiplication

4 minutes ago, ChuckNovice said:

Because you let the compiler do an implicit conversion for you from float3 to float4. The last component will be set to 0.0 during that conversion and you actually want 1.0 there.

I'd highly suggest compiling your shaders with the flag that treat warnings as error. I don't make those kind of mistake since I activated this.

Where I can activate that flag?

1 minute ago, RubenRS said:

Where I can activate that flag?

That will be the D3DCOMPILE_WARNINGS_ARE_ERRORS flag that you pass to the Flags1 parameter of the D3DCompileXXX function.

https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/d3dcompilefromfile

https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/d3dcompile

? nice..!, well, thanks for your help and time @ChuckNovice  and @0xnullptr

Have a nice day :D!!!

This topic is closed to new replies.

Advertisement