improved cartoon shading

This commit is contained in:
Turanszki Janos
2020-11-04 20:34:56 +01:00
parent c90163429e
commit af7cb4f3d5
5 changed files with 20 additions and 11 deletions
+9
View File
@@ -76,6 +76,10 @@ struct Surface
BdotV = dot(B, V);
at = max(0, alphaRoughness * (1.0 + anisotropy));
ab = max(0, alphaRoughness * (1.0 - anisotropy));
#ifdef BRDF_CARTOON
F = smoothstep(0.05, 0.1, F);
#endif // BRDF_CARTOON
}
};
inline Surface CreateSurface(
@@ -152,6 +156,11 @@ inline SurfaceToLight CreateSurfaceToLight(in Surface surface, in float3 L)
surfaceToLight.TdotH = dot(surface.T, surfaceToLight.H);
surfaceToLight.BdotH = dot(surface.B, surfaceToLight.H);
#ifdef BRDF_CARTOON
surfaceToLight.NdotL = smoothstep(0.005, 0.05, surfaceToLight.NdotL);
surfaceToLight.NdotH = smoothstep(0.98, 0.99, surfaceToLight.NdotH);
#endif // BRDF_CARTOON
return surfaceToLight;
}
+8 -8
View File
@@ -5,6 +5,10 @@
#include "voxelConeTracingHF.hlsli"
#include "skyHF.hlsli"
#ifdef BRDF_CARTOON
#define DISABLE_SOFT_SHADOWMAP
#endif // BRDF_CARTOON
struct LightingContribution
{
float diffuse;
@@ -38,13 +42,6 @@ inline Lighting CreateLighting(
// Combine the direct and indirect lighting into final contribution
inline LightingPart CombineLighting(in Surface surface, in Lighting lighting)
{
#ifdef LIGHTING_CARTOON
lighting.direct.diffuse = smoothstep(0.005, 0.05, lighting.direct.diffuse);
lighting.direct.specular = max(lighting.direct.specular.r, max(lighting.direct.specular.g, lighting.direct.specular.b));
lighting.direct.specular = step(0.05, lighting.direct.specular);
lighting.indirect.specular = smoothstep(0.008, 0.098, lighting.indirect.specular);
#endif // LIGHTING_CARTOON
LightingPart result;
result.diffuse = lighting.direct.diffuse + lighting.indirect.diffuse * surface.occlusion;
result.specular = lighting.direct.specular + lighting.indirect.specular * surface.F * surface.occlusion;
@@ -110,11 +107,14 @@ inline float shadowTrace(in Surface surface, in float3 L, in float dist)
ray.TMin = 0.001;
ray.TMax = dist;
ray.Origin = surface.P + surface.N * 0.01;
ray.Direction = L;
#ifndef BRDF_CARTOON
float seed = g_xFrame_FrameCount * 0.001f;
float2 uv = surface.screenUV;
float3 sampling_offset = float3(rand(seed, uv), rand(seed, uv), rand(seed, uv)) * 2 - 1; // todo: should be specific to light surface
ray.Direction = normalize(L + sampling_offset * 0.025f);
ray.Direction = normalize(ray.Direction + sampling_offset * 0.025f);
#endif // BRDF_CARTOON
q.TraceRayInline(scene_acceleration_structure, 0, 0xFF, ray);
q.Proceed();
+1 -1
View File
@@ -1,6 +1,6 @@
#define COMPILE_OBJECTSHADER_PS
#define OUTPUT_GBUFFER
#define TILEDFORWARD
#define LIGHTING_CARTOON
#define BRDF_CARTOON
#include "objectHF.hlsli"
@@ -1,6 +1,6 @@
#define COMPILE_OBJECTSHADER_PS
#define TILEDFORWARD
#define TRANSPARENT
#define LIGHTING_CARTOON
#define BRDF_CARTOON
#include "objectHF.hlsli"
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates, breaking API changes
const int minor = 49;
// minor bug fixes, alterations, refactors, updates
const int revision = 9;
const int revision = 10;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);