expose outline/rim values

This commit is contained in:
lightling 2022-04-19 23:43:43 -04:00
parent d61aa79428
commit 22d0253364
Signed by: lightling
GPG key ID: 016F11E0AA296B67
4 changed files with 66 additions and 6 deletions

View file

@ -206,6 +206,7 @@ void Game::LoadTextures()
materials[9]->LoadTexture(L"Assets/Textures/WithNormals/cushion.png", TEXTYPE_ALBEDO, device.Get(), context.Get());
materials[9]->LoadTexture(L"Assets/Textures/WithNormals/cushion_normals.png", TEXTYPE_NORMAL, device.Get(), context.Get());
materials[9]->LoadTexture(L"Assets/Textures/WithNormals/cushion_specular.png", TEXTYPE_SPECULAR, device.Get(), context.Get());
materials[9]->SetOutlineThickness(0);
materials[10]->PushSampler("BasicSampler", sampler);
materials[10]->LoadTexture(L"Assets/Textures/HQGame/structure-endgame-deepfloor_emissive.png", TEXTYPE_EMISSIVE, device.Get(), context.Get());

View file

@ -23,6 +23,9 @@ Material::Material(
hasSpecularMap = false;
hasNormalMap = false;
hasReflectionMap = false;
outlineThickness = 1;
rimCutoff = 0.075f;
rimTint = DirectX::XMFLOAT3(0.5f, 0.5f, 0.5f);
}
Material::~Material()
@ -70,11 +73,31 @@ float Material::GetNormalIntensity()
return normalIntensity;
}
float Material::GetRimCutoff()
{
return rimCutoff;
}
float Material::GetOutlineThickness()
{
return outlineThickness;
}
DirectX::XMFLOAT3 Material::GetEmitAmount()
{
return emitAmount;
}
DirectX::XMFLOAT3 Material::GetOutlineTint()
{
return outlineTint;
}
DirectX::XMFLOAT3 Material::GetRimTint()
{
return rimTint;
}
std::shared_ptr<SimpleVertexShader> Material::GetVertexShader()
{
return vertexShader;
@ -131,11 +154,31 @@ void Material::SetNormalIntensity(float _intensity)
normalIntensity = _intensity;
}
void Material::SetRimCutoff(float _cutoff)
{
rimCutoff = _cutoff;
}
void Material::SetOutlineThickness(float _thickness)
{
outlineThickness = _thickness;
}
void Material::SetEmitAmount(DirectX::XMFLOAT3 _emit)
{
emitAmount = _emit;
}
void Material::SetOutlineTint(DirectX::XMFLOAT3 _tint)
{
outlineTint = _tint;
}
void Material::SetRimTint(DirectX::XMFLOAT3 _tint)
{
rimTint = _tint;
}
void Material::SetVertexShader(std::shared_ptr<SimpleVertexShader> _vertexShader)
{
vertexShader = _vertexShader;
@ -188,6 +231,10 @@ void Material::ActivateStandard(Transform* _transform, std::shared_ptr<Camera> _
pixelShader->SetFloat3("ambient", _ambient);
pixelShader->SetFloat3("emitAmount", GetEmitAmount());
pixelShader->SetFloat3("tint", GetTint());
pixelShader->SetFloat3("rimTint", GetRimTint());
pixelShader->SetFloat3("outlineTint", GetOutlineTint());
pixelShader->SetFloat("outlineThickness", GetOutlineThickness());
pixelShader->SetFloat("rimCutoff", GetRimCutoff());
pixelShader->SetFloat("lightCount", (int)_lights.size());
pixelShader->SetInt("hasAlbedoMap", (int)hasAlbedoMap);
pixelShader->SetInt("hasEmissiveMap", (int)hasEmissiveMap);

View file

@ -42,7 +42,11 @@ public:
float GetAlpha();
float GetCutoff();
float GetNormalIntensity();
float GetRimCutoff();
float GetOutlineThickness();
DirectX::XMFLOAT3 GetEmitAmount();
DirectX::XMFLOAT3 GetOutlineTint();
DirectX::XMFLOAT3 GetRimTint();
std::shared_ptr<SimpleVertexShader> GetVertexShader();
std::shared_ptr<SimplePixelShader> GetPixelShader();
@ -53,7 +57,11 @@ public:
void SetAlpha(float _alpha);
void SetCutoff(float _cutoff);
void SetNormalIntensity(float _intensity);
void SetRimCutoff(float _cutoff);
void SetOutlineThickness(float _thickness);
void SetEmitAmount(DirectX::XMFLOAT3 _emit);
void SetOutlineTint(DirectX::XMFLOAT3 _tint);
void SetRimTint(DirectX::XMFLOAT3 _tint);
void SetVertexShader(std::shared_ptr<SimpleVertexShader> _vertexShader);
void SetPixelShader(std::shared_ptr<SimplePixelShader> _pixelShader);
@ -84,7 +92,11 @@ private:
float alpha;
float cutoff;
float normalIntensity;
float outlineThickness;
float rimCutoff;
DirectX::XMFLOAT3 emitAmount;
DirectX::XMFLOAT3 outlineTint;
DirectX::XMFLOAT3 rimTint;
DirectX::XMFLOAT2 uvScale;
DirectX::XMFLOAT2 uvOffset;
std::shared_ptr<SimpleVertexShader> vertexShader;

View file

@ -26,8 +26,8 @@ cbuffer ExternalData : register(b0)
float roughness;
float normalIntensity;
float3 outline;
float outlineIntensity;
float3 outlineTint;
float outlineThickness;
float3 rimTint;
float rimCutoff;
@ -120,17 +120,17 @@ float4 main(VertexToPixel input) : SV_TARGET
if (hasEmissiveMap > 0) emit = Emissive.Sample(BasicSampler, input.uv).rgb;
float vDotN = (1 - dot(view, input.normal));
float rimValue = GetRampSpecular(vDotN * pow(light, 0.075f));
float outlineValue = GetRampSpecular(vDotN * 2);
float rimValue = GetRampSpecular(vDotN * pow(light, rimCutoff));
float outlineValue = GetRampSpecular(vDotN * outlineThickness);
if (rimValue > 0)
{
return float4(light + (emit * emitAmount) + float3(1,1,1), alphaValue);
return float4(light + (emit * emitAmount) + rimTint, alphaValue);
}
if (outlineValue > 0)
{
return float4(outlineValue * float3(0,0,0), alphaValue);
return float4(outlineValue * outlineTint, alphaValue);
}
float3 final = float3(light + (emit * emitAmount));