mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-12-12 06:02:31 +00:00
56 lines
1.3 KiB
GLSL
56 lines
1.3 KiB
GLSL
|
#version 330
|
|||
|
|
|||
|
const float PI = 3.14159265359;
|
|||
|
|
|||
|
vec3 FresnelSchlick(float cosTheta, vec3 F0)
|
|||
|
{
|
|||
|
return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0);
|
|||
|
}
|
|||
|
|
|||
|
vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)
|
|||
|
{
|
|||
|
return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(1.0 - cosTheta, 5.0);
|
|||
|
}
|
|||
|
|
|||
|
float DistributionGGX(vec3 N, vec3 H, float roughness)
|
|||
|
{
|
|||
|
float a = roughness*roughness;
|
|||
|
float a2 = a*a;
|
|||
|
float NdotH = max(dot(N, H), 0.0);
|
|||
|
float NdotH2 = NdotH*NdotH;
|
|||
|
|
|||
|
float num = a2;
|
|||
|
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
|||
|
denom = PI * denom * denom;
|
|||
|
|
|||
|
return num / denom;
|
|||
|
}
|
|||
|
|
|||
|
float GeometrySchlickGGX(float NdotV, float roughness)
|
|||
|
{
|
|||
|
float r = (roughness + 1.0);
|
|||
|
float k = (r*r) / 8.0;
|
|||
|
|
|||
|
float num = NdotV;
|
|||
|
float denom = NdotV * (1.0 - k) + k;
|
|||
|
|
|||
|
return num / denom;
|
|||
|
}
|
|||
|
|
|||
|
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
|
|||
|
{
|
|||
|
float NdotV = max(dot(N, V), 0.0);
|
|||
|
float NdotL = max(dot(N, L), 0.0);
|
|||
|
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
|||
|
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
|||
|
|
|||
|
return ggx1 * ggx2;
|
|||
|
}
|
|||
|
|
|||
|
vec3 saturation(vec3 rgb, float adjustment)
|
|||
|
{
|
|||
|
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
|
|||
|
vec3 intensity = vec3(dot(rgb, W));
|
|||
|
return mix(intensity, rgb, adjustment);
|
|||
|
}
|