experiment with color banding

pull/3/head
cosmonaut 2020-10-02 17:29:20 -07:00
parent d370d4e2e4
commit a914c586b2
4 changed files with 23 additions and 24 deletions

View File

@ -18,8 +18,6 @@ namespace Kav
EffectParameter directionalLightDirectionParam;
EffectParameter directionalLightColorParam;
EffectParameter softnessParam;
EffectParameter cascadeFarPlanesParam;
EffectParameter shadowMapSizeParam;
@ -43,8 +41,6 @@ namespace Kav
public Vector3 DirectionalLightDirection { get; set; }
public Vector3 DirectionalLightColor { get; set; }
public float Softness { get; set; }
public float[] CascadeFarPlanes { get; }
public float ShadowMapSize { get; set; }
@ -76,8 +72,6 @@ namespace Kav
directionalLightDirectionParam.SetValue(DirectionalLightDirection);
directionalLightColorParam.SetValue(DirectionalLightColor);
softnessParam.SetValue(Softness);
cascadeFarPlanesParam.SetValue(CascadeFarPlanes);
shadowMapSizeParam.SetValue(ShadowMapSize);
@ -104,8 +98,6 @@ namespace Kav
directionalLightDirectionParam = Parameters["DirectionalLightDirection"];
directionalLightColorParam = Parameters["DirectionalLightColor"];
softnessParam = Parameters["Softness"];
cascadeFarPlanesParam = Parameters["CascadeFarPlanes"];
shadowMapSizeParam = Parameters["ShadowMapSize"];

BIN
Effects/FXB/Deferred_ToonEffect.fxb (Stored with Git LFS)

Binary file not shown.

View File

@ -18,8 +18,6 @@ float3 EyePosition _ps(c0) _cb(c0);
float3 DirectionalLightDirection _ps(c1) _cb(c1);
float3 DirectionalLightColor _ps(c2) _cb(c2);
float Softness _ps(c3) _cb(c3);
float CascadeFarPlanes[NUM_SHADOW_CASCADES] _ps(c4) _cb(c4);
float ShadowMapSize _ps(c8) _cb(c8);
@ -138,6 +136,26 @@ float ComputeShadow(float3 positionWorldSpace, float3 N, float3 L)
}
}
float IntensityBanding(float NdotL)
{
if (NdotL > 0.5)
{
return 1.0;
}
else if (NdotL > 0.25)
{
return 0.5;
}
else if (NdotL > 0.0)
{
return 0.25;
}
else
{
return 0.0;
}
}
// FIXME: organize this
float4 main_ps(PixelInput input) : SV_TARGET0
{
@ -153,16 +171,7 @@ float4 main_ps(PixelInput input) : SV_TARGET0
float NdotL = dot(N, L);
float NdotH = max(dot(N, H), 0.0);
float lightIntensity;
if (Softness > 0.0)
{
lightIntensity = smoothstep(0, Softness, NdotL);
}
else
{
lightIntensity = (NdotL > 0.0) ? 1.0 : 0.0;
}
float lightIntensity = IntensityBanding(NdotL);
float3 light = lightIntensity * DirectionalLightColor;
float specularIntensity = pow(NdotH * lightIntensity, 32 * 32);

View File

@ -352,8 +352,6 @@ namespace Kav
Deferred_ToonEffect.DirectionalLightColor =
directionalLight.Color.ToVector3() * directionalLight.Intensity;
Deferred_ToonEffect.Softness = 0.01f;
Deferred_ToonEffect.ShadowMapOne = ShadowRenderTargets[0];
if (NumShadowCascades > 1)
{