Dx11 traps?

Source: Internet
Author: User

In the past two days, the shader with delayed rendering is moved back to dx11.
I encountered the following disgusting things (of course, there are more disgusting things in DX9, but all disgusting things should be mentioned below ).
---------------------------------------------
1. dx11 is more strict with the linkage between shader. Of course, this helps your shader to be correct, but debugging is very annoying.
2. Be careful with the for loop. The first time I encountered a compilation error (double loop ).
The second problem is even worse.
To calculate the cascaded index of Cascaded.
I did this.

# Define emax_casacade 4
Float4x4 csmshadowmap [emax_casacade];
Float csmsplitvaluemin [emax_casacade];
Float csmsplitvaluemax [emax_casacade];
Float calcshadowmap (float zview, float3 vposition, float4 _ shadowmapsize, float fldotn)
{
Int idx = 0;
For (INT I = 0; I <emax_casacade; I ++)
{
If (csmsplitvaluemin [I] <= zview & csmsplitvaluemax [I]> = zview)
{
Idx = I;
Break;
}
}
// Calculate the code.
}

C ++ Passes parameters in this way.
Float csmsplitvaluemin [emax_casacade];
Float csmsplitvaluemax [emax_casacade];
Pshadertable-> setparam (L "csmsplitvaluemin", csmsplitvaluemin, emax_casacade );
.....
The value passed in is incorrect. It seems that the first number has passed. I used GPa to check it. It seems correct. But it is not correct in shader.

Later I changed the writing method.
Float4 csmsplitvaluemin;
Float4 csmsplitvaluemax;
Float calcshadowmap (float zview, float3 vposition, float4 _ shadowmapsize, float fldotn)
{
Int idx = 0;
Zview = ABS (zview );
Float fsplitvaluemin = csmsplitvaluemin. X;
Float fsplitvaluemax = csmsplitvaluemax. X;
If (csmsplitvaluemin. x <= zview & csmsplitvaluemax. x> = zview)
{
Idx = 0;
}
Else if (csmsplitvaluemin. Y <= zview & csmsplitvaluemax. Y> = zview)
{
Idx = 1;
Fsplitvaluemin = csmsplitvaluemin. Y;
Fsplitvaluemax = csmsplitvaluemax. Y;
}
Else if (csmsplitvaluemin. z <= zview & csmsplitvaluemax. z> = zview)
{
Idx = 2;
Fsplitvaluemin = csmsplitvaluemin. Z;
Fsplitvaluemax = csmsplitvaluemax. Z;
}
Else if (csmsplitvaluemin. W <= zview & csmsplitvaluemax. W> = zview)
{
Idx = 3;
Fsplitvaluemin = csmsplitvaluemin. W;
Fsplitvaluemax = csmsplitvaluemax. W;
}
}

In this way ..

Find out why. Sleepy. Have you slept? Or change it?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.