Two girlies hanging out having a picnic in the park while the tyranny of choice hand circles the food choices. All objects modeled, uv unwrapped, and textured by me in Maya and Blender. All objects having shaders attached and specific lighting qualities based on the material they represent (shiny nails on the hand, matte hotdog bun, etc).
we can see the use of the skybox and a height-mapped terrain
Good example of utilizing different materials on a per mesh basis - we can see the glazed icing on the donut has a shine to it (specular attribute), while the cakey donut itself has no such shine.
Video of all the moving parts of the fun scene!
The technical scene showcases five different shaders - (in order of left to right when looking at the scene): 1. color shader, which is not affected by light, 2. texture shader, which is not affected by light, 3. color multi light shader, which is affected by multiple light sources, 4. texture color light shader, which is affected by only one light source, and 5. texture color multi light shader, which is affected by multiple light sources.
In the background we have a flat plane to give a backdrop to our models and lighting effects, then in the distance we have our height-mapped terrain.
Video exploring the technical scene to see the different lighting effects on the models.
// TexColMultiLight is ColorLightTexture + multiple light abilities
Texture2D mainTexture : register(t0);
// Material properties
struct Material
{
float4 Ambient;
float4 Diffuse;
float4 Specular; // Hack: w holds the specular power
};
{
float4x4 View;
float4x4 Projection;
};
{
DirectionalLight DirLight;
PointLight PntLight[8];
SpotLight SpLight[8];
float4 EyePosWorld;
};
{
float4x4 World;
float4x4 WorldInv;
Material Mater;
};
cbuffer bufFog : register(b3)
{
float fogStart;
float fogRange;
float4 fogColor;
bool fogShowing;
}
// Vertex Shader
//--------------------------------------------------------------------------------------
VS_OUTPUT VS( float4 Pos : POSITION, float2 Tex : TEXCOORD, float4 Norm : NORMAL )
{
VS_OUTPUT output;
output.PosMS = Pos; // We pass along the raw model space position
output.Norm = Norm; // and the face normal
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
// need to include Tex in the params, and set the output Texture
output.Tex = Tex;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( VS_OUTPUT input ) : SV_Target
{
// Compute light values in model-space
float4 msEyePos = mul(EyePosWorld, WorldInv);
float4 msDirToEye = normalize(msEyePos - input.PosMS);
float4 diffuse = float4(0, 0, 0, 0);
float4 spec = float4(0, 0, 0, 0);
diffuse += D;
spec += S;
int index = 0;
while (index < 8)
{
ComputePointLight(Mater, PntLight[index], input.PosMS, normalize(input.Norm), msDirToEye, A, D, S);
diffuse += D;
spec += S;
}
index = 0;
while (index < 8)
{
ComputeSpotLight(Mater, SpLight[index], input.PosMS, normalize(input.Norm), msDirToEye, A, D, S);
diffuse += D;
spec += S;
}
float4 litColor = (ambient + diffuse + spec);
// Fog Demo
if (fogShowing)
{
// These three values should be passed-in using cbuffers
//float FogStart = 5; // anything closer than this value will have no fog
float FogStart = fogStart;
//float FogRange = 25; // fog contribution increases linearly until full fog at dist = FogStart + Range
float FogRange = fogRange;
//float4 FogColor = float4(.2,.2,.2, 1); // grey
//float4 FogColor = float4(0.098039225f, 0.098039225f, 0.439215720f, 1); // MidnightBlue
float4 FogColor = fogColor;
float distToEye = length(msEyePos - input.PosMS);
float FogPercent = saturate((distToEye - FogStart) / FogRange);
// C_dst = litColor
// C_src = FogColor
// C = C_dst * (1 - FogPercent) + C_src * FogPercent
//litColor = litColor * (1 - FogPercent) + FogColor * FogPercent;
litColor = lerp(litColor, FogColor, FogPercent);
}
/****************************************************/
return mainTexture.Sample(aSampler, input.Tex) * litColor;
}