diff --git a/Assets/Textures/HQGame/structure-endgame-deepfloor_specular.png b/Assets/Textures/HQGame/structure-endgame-deepfloor_specular.png
new file mode 100644
index 0000000..cc34877
Binary files /dev/null and b/Assets/Textures/HQGame/structure-endgame-deepfloor_specular.png differ
diff --git a/Assets/Textures/HQGame/structure-endgame-floor_specular.png b/Assets/Textures/HQGame/structure-endgame-floor_specular.png
new file mode 100644
index 0000000..38c7fb8
Binary files /dev/null and b/Assets/Textures/HQGame/structure-endgame-floor_specular.png differ
diff --git a/DX11Starter.vcxproj b/DX11Starter.vcxproj
index 1e863e5..2de5d16 100644
--- a/DX11Starter.vcxproj
+++ b/DX11Starter.vcxproj
@@ -625,6 +625,36 @@
$(OutDir)/Assets/Textures/HQGame
+
+
+ false
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ $(OutDir)/Assets/Textures/HQGame
+ $(OutDir)/Assets/Textures/HQGame
+ $(OutDir)/Assets/Textures/HQGame
+ $(OutDir)/Assets/Textures/HQGame
+
+
+ false
+ true
+ false
+ true
+ false
+ true
+ false
+ true
+ $(OutDir)/Assets/Textures/HQGame
+ $(OutDir)/Assets/Textures/HQGame
+ $(OutDir)/Assets/Textures/HQGame
+ $(OutDir)/Assets/Textures/HQGame
+
+
diff --git a/DX11Starter.vcxproj.filters b/DX11Starter.vcxproj.filters
index 8a5eee2..a0e215d 100644
--- a/DX11Starter.vcxproj.filters
+++ b/DX11Starter.vcxproj.filters
@@ -198,6 +198,12 @@
Assets\Textures\HQGame
+
+ Assets\Textures\HQGame
+
+
+ Assets\Textures\HQGame
+
diff --git a/Game.cpp b/Game.cpp
index a991acf..38af35d 100644
--- a/Game.cpp
+++ b/Game.cpp
@@ -106,19 +106,25 @@ void Game::LoadTextures()
device->CreateSamplerState(&sampDesc, sampler.GetAddressOf());
Microsoft::WRL::ComPtr
+ deepFloorSpecular,
deepFloorAlbedo,
+ floorSpecular,
floorAlbedo;
// taking the preprocessor macro from the demo because I don't like typing
#define GetTex(pathToTexture, shaderResourceView) CreateWICTextureFromFile(device.Get(), context.Get(), GetFullPathTo_Wide(pathToTexture).c_str(), 0, shaderResourceView.GetAddressOf());
+ GetTex(L"Assets/Textures/HQGame/structure-endgame-deepfloor_specular.png", deepFloorSpecular);
GetTex(L"Assets/Textures/HQGame/structure-endgame-deepfloor_albedo.png", deepFloorAlbedo);
+ GetTex(L"Assets/Textures/HQGame/structure-endgame-floor_specular.png", floorSpecular);
GetTex(L"Assets/Textures/HQGame/structure-endgame-floor_albedo.png", floorAlbedo);
materials[0]->PushSampler("BasicSampler", sampler);
materials[0]->PushTexture("Albedo", deepFloorAlbedo);
+ materials[0]->PushTexture("Specular", deepFloorSpecular);
materials[1]->PushSampler("BasicSampler", sampler);
materials[1]->PushTexture("Albedo", floorAlbedo);
+ materials[1]->PushTexture("Specular", floorSpecular);
}
void Game::LoadLighting()
@@ -238,7 +244,7 @@ void Game::Update(float deltaTime, float totalTime)
for (int i = 0; i < entities.size(); ++i)
{
- entities[i]->GetTransform()->SetRotation(sin(totalTime / 360) * 360, 0, 0);
+ entities[i]->GetTransform()->SetRotation(sin(totalTime / 720) * 360, 0, 0);
entities[i]->GetMaterial()->SetRoughness(sin(totalTime) * 0.5f + 0.49f);
}
}
diff --git a/SimplePixelShader.hlsl b/SimplePixelShader.hlsl
index 01c58cc..f85ff27 100644
--- a/SimplePixelShader.hlsl
+++ b/SimplePixelShader.hlsl
@@ -15,6 +15,7 @@ cbuffer ExternalData : register(b0)
}
Texture2D Albedo : register(t0);
+Texture2D Specular : register(t1);
SamplerState BasicSampler : register(s0);
// Gets the specular value for any light
@@ -28,22 +29,22 @@ float calculateSpecular(float3 normal, float3 direction, float3 view, float roug
}
// Gets the RGB value of a pixel with a directional light
-float3 calculateDirectionalLight(Light light, float3 normal, float3 view, float roughness, float3 surfaceColor)
+float3 calculateDirectionalLight(Light light, float3 normal, float3 view, float roughness, float3 surfaceColor, float specularValue)
{
float3 lightDirection = normalize(light.Direction);
float diffuse = getDiffuse(normal, -lightDirection);
- float specular = calculateSpecular(normal, lightDirection, view, roughness);
+ float specular = calculateSpecular(normal, lightDirection, view, roughness) * specularValue;
return (diffuse * surfaceColor + specular) * light.Intensity * light.Color;
}
// Gets the RGB value of a pixel with a point light
-float3 calculatePointLight(Light light, float3 normal, float3 view, float3 worldPosition, float roughness, float3 surfaceColor)
+float3 calculatePointLight(Light light, float3 normal, float3 view, float3 worldPosition, float roughness, float3 surfaceColor, float specularValue)
{
float3 lightDirection = normalize(light.Position - worldPosition);
float attenuation = getAttenuation(light.Position, worldPosition, light.Range);
float diffuse = getDiffuse(normal, lightDirection);
- float specular = calculateSpecular(normal, lightDirection, view, roughness);
+ float specular = calculateSpecular(normal, lightDirection, view, roughness) * specularValue;
return (diffuse * surfaceColor + specular) * attenuation * light.Intensity * light.Color;
}
@@ -58,6 +59,7 @@ float4 main(VertexToPixel input) : SV_TARGET
float3 view = getView(cameraPosition, input.worldPosition);
float4 albedo = Albedo.Sample(BasicSampler, input.uv).rgba;
+ float specular = Specular.Sample(BasicSampler, input.uv).r;
float3 surface = albedo.rgb * tint;
float3 light = ambient * surface;
@@ -67,10 +69,10 @@ float4 main(VertexToPixel input) : SV_TARGET
switch (lights[i].Type)
{
case LIGHT_TYPE_DIRECTIONAL:
- light += calculateDirectionalLight(lights[i], input.normal, view, roughness, surface);
+ light += calculateDirectionalLight(lights[i], input.normal, view, roughness, surface, specular);
break;
case LIGHT_TYPE_POINT:
- light += calculatePointLight(lights[i], input.normal, view, input.worldPosition, roughness, surface);
+ light += calculatePointLight(lights[i], input.normal, view, input.worldPosition, roughness, surface, specular);
break;
}
}