Worked hard on completing the 'BlendDemo' today, but no real problems.
Three more custom shaders 'basic_land2.cpp', 'basic_water2.cpp' and 'basic_box2.cpp' were added.
These shaders incorporated two more Technique parameter options: '
gAlphaClip' and '
gFogEnabled'
This increases the number of Technique choices significantly... one can now compile the shaders with 1,2 or 3 directional lights, texture or no texture, alphaclipping or not, fog or no fog (see the 'CompileShaders()' function in the code)
Added a transparency parameter ('
water_AlphaFactor') to the 'basic_water2.cpp' shader to control the amount of water transparency required
Added a wire cage box with a 'WireFence.dds' alpha texture.
When '
gAlphaClip' is set then the intrinsic HLSL function '
clip(x)' is activated.This function can only be called in a pixel shader,
and it discards the current pixel from further processing if x < 0.1, where x is the current pixel's alpha value.
I noticed that the inside back face of the box cage was not showing. After perusing the EE documentation I found that the Material applied to a mesh controls, via the Material '.clip' method, whether the back faces of meshes are clipped or not. The default is 'true' (clipping applied). So I set it to 'false', and I could then see the backside of the wire cage through the front face.
The final addition to this demo is the activation of fogging in the pixel shader, depending whether '
gFogEnabled' is true or not.
This makes use of the HLSL '
lerp()' function which blends the fog color in with the water, land and box colors according to camera distance from the current pixel.
The following shader fog parameters can be set in the 'Main' code and passed down to the shaders.
Flt gFogStart;
Flt gFogRange;
Vec4 gFogColor;
Sky background set to same color as fog, so that fog blends in with the sky.
BlendDemo_executable