Building a Custom Graphics API
Utilizing DirectX 11, I wrote code to facilitate communication between the CPU and the GPU in order to render a scene containing models, textures, and lighting.
I am showcasing two scenes here - a fun scene, that I designed more with an artistic eye, and a technical scene, that is more to showcase my technical skills and breadth of work. 
All objects in the first (fun) scene were designed, created, UV unwrapped, and textured by me in Maya and Blender. All objects in the second scene were made by me, but just using C++ code. All code to create and initialize the models, shaders, lights, and rendering process was done by me.
Below are images of the fun scene, and also a video to show off the scene in motion since there are a few moving parts. Under the fun scene, there are a few images from the technical scene as well as a video to show moving parts. A sample of one of my hlsl shader files is included after that, along with a link to a youtube video of me going over my whole project. 

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. 

Sample of my HLSL shader code for my texture color multi light shader (which includes the option to add a fog effect to the scene)
// MARY
// TexColMultiLight is ColorLightTexture + multiple light abilities
#pragma pack_matrix( row_major )
// we need the texture and sampler
Texture2D mainTexture : register(t0);
SamplerState aSampler : register(s0);

// Material properties
struct Material
{
    float4 Ambient;
    float4 Diffuse;
    float4 Specular;  // Hack: w holds the specular power
};
<...>
//  Constant Buffers
cbuffer CamData : register(b0)
{
    float4x4 View;
    float4x4 Projection;
};
cbuffer LightParameters : register (b1)
{
    DirectionalLight DirLight;
    PointLight PntLight[8];
    SpotLight SpLight[8];
    float4 EyePosWorld;
};
cbuffer InstanceData : register(b2)
{
    float4x4 World;
    float4x4 WorldInv;
    Material Mater;
};
// Fog constant buffer
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( Pos, World );
    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;
    return output;
}

//--------------------------------------------------------------------------------------
// 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 ambient = float4(0, 0, 0, 0); 
    float4 diffuse = float4(0, 0, 0, 0);
    float4 spec = float4(0, 0, 0, 0);
    float4 A, D, S;
    ComputeDirectionalLight(Mater, DirLight, normalize(input.Norm), msDirToEye, A, D, S);
    ambient += A;
    diffuse += D;
    spec += S;
    // loop through the point lights array
    int index = 0;
    while (index < 8)
    {
        ComputePointLight(Mater, PntLight[index], input.PosMS, normalize(input.Norm), msDirToEye, A, D, S);
        ambient += A;
        diffuse += D;
        spec += S;
        index++;
    }
    // loop through spot light array
    index = 0;
    while (index < 8)
    {
        ComputeSpotLight(Mater, SpLight[index], input.PosMS, normalize(input.Norm), msDirToEye, A, D, S);
        ambient += A;
        diffuse += D;
        spec += S;
        index++;
    }

    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;
        // Compute fog density as function of distance to eye
        float distToEye = length(msEyePos - input.PosMS);
        float FogPercent = saturate((distToEye - FogStart) / FogRange);  
        // blend litColor with fog level
        // 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);
    }
    /****************************************************/
    // need to account for the texture color in the final color
    return mainTexture.Sample(aSampler, input.Tex) * litColor;
}

Watch a youtube video demo of the project with code explanation here: Mary Montgomery GAM470 Final Project - YouTube
Back to Top