0
\$\begingroup\$

I'm trying to create grass quads and have therefore disabled backface culling when rendering these quads. With each vertex normal set upwards ( 0.f, 1.f, 0.f ), all front faces are lit correctly, but backfaces are black. If I change the the Y normal to -1.f the backfaces light up and the front faces go black.

D3D11_RASTERIZER_DESC desc {};

desc.AntialiasedLineEnable  = false;
desc.CullMode               = D3D11_CULL_NONE;
desc.DepthBias              = 0;
desc.DepthBiasClamp         = 0.f;
desc.DepthClipEnable        = true;
desc.FillMode               = D3D11_FILL_SOLID;
desc.FrontCounterClockwise  = false;
desc.MultisampleEnable      = false;
desc.ScissorEnable          = false;
desc.SlopeScaledDepthBias   = 0.f;

I'm not so sure there's a problem here. Any ideas?

\$\endgroup\$
  • \$\begingroup\$ Are you only applying duffuse lighting? Ambient would need to be applied also \$\endgroup\$ – ErnieDingo Feb 22 '18 at 8:55
  • \$\begingroup\$ to add also, no, there is no problem here. I am assuming your lighting model is responding correctly due to the normal just being flipped. Could you post your pixel shader to assist in elaborating what your code is doing. \$\endgroup\$ – ErnieDingo Feb 22 '18 at 21:55
1
\$\begingroup\$

Back faces are facing in the opposite direction to front faces, so yes, their normals should also point in the opposite direction.

You can use the SV_IsFrontFace semantic to detect if you're currently drawing a backfacing primitive.

Alternatively, duplicate the data for front and back faces.

\$\endgroup\$
  • \$\begingroup\$ Do you mean I can check in the shader for backface and append the normal there? And are you suggesting the other option that i cull the backface and render an extra quad as the backface? \$\endgroup\$ – T. Elliott Feb 22 '18 at 10:49
0
\$\begingroup\$

Okay I've solved this - I should have provided more information; I'm using normal mapping and it turned out that since I hadn't provided tangent or bitangent vectors for the grass quads, that was causing the problem. Thanks for your assistance.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.