CG study #7

Chapter 10 teach about stencil buffer and using it to mark a mirror from drawing a reflection or to use it to draw planar shadows.

ex 3 asked to produce image on figure 10.1 left side where all of the reflected skull was rendered not only the mirror part. This can be achieved by changing render state used when drawing mirror. In the D3D11_DEPTH_STENCIL_DESC drawReflectionDesc the FrontFace StencilFunc need to be changed to  D3D11_COMPARISON_ALWAYS so all of the reflection will drawn.

ex. 4 asked to produce left of the figure 10.10 this could be achieved by hanging front face stencil function to D3D11_STENCIL_OP_KEEP so all the reflected triangles on shadow would be drawn on top of each other showing those parts as darker.

ex. 7 was exercise about drawing cylinder with a bolt texture animation with additive blending. The cylinder had to be drawn last in the scene so that blend works correctly.

Capturech10ex7

Here is definition of additive blending blend state description:

D3D11_BLEND_DESC additiveBlendDesc = { 0 };
additiveBlendDesc.AlphaToCoverageEnable = false;
additiveBlendDesc.IndependentBlendEnable = false;

additiveBlendDesc.RenderTarget[0].BlendEnable = true;
additiveBlendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
additiveBlendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
additiveBlendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
additiveBlendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
additiveBlendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
additiveBlendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
additiveBlendDesc.RenderTarget[0].RenderTargetWriteMask = 0x0F;

HR(device->CreateBlendState(&additiveBlendDesc, &additiveBS));

 ex.11 asked to modify the mirror demo so that the floor is also reflected into the mirror.

This was done same way as drawing the skull reflection before drawing the mirror with alpha blending.

Capturech10ex11

Leave a Reply

Your email address will not be published. Required fields are marked *