summaryrefslogtreecommitdiffstats
path: root/MochieStandardBRDF.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-09-24 13:57:26 -0700
committeryum <yum.food.vr@gmail.com>2024-09-24 13:57:26 -0700
commit2b9e36fde45c5f488539f390288e0a2731d11fcf (patch)
treeed12017282d6145830b512ec2cf1a6d2834e15c7 /MochieStandardBRDF.cginc
parent88a524d71bf46bca1c65c3f7ed5fcd3f6edd1d5e (diff)
World lighting fixes
* Add channel selection for roughness and metallic textures * This lets u combine roughness & metallic into one texture * Add Bakery-compatible emission slot * Add compile-time toggle for brightness clamping * Add toggle for world interpolators * Add emission type dropdown (baked/realtime/none) * Switch to bilinear filtering for base PBR maps to match standard shader behavior * Add bugfixes for Mochie BRDF in world lighting mode * Rename _NormalTex to _BumpMap for compatibility with standard shader * World lighting mode uses Unity baked GI logic instead of normal world lighting logic * Use uv2 instead of lmuv for lightmap UVs
Diffstat (limited to 'MochieStandardBRDF.cginc')
-rw-r--r--MochieStandardBRDF.cginc30
1 files changed, 30 insertions, 0 deletions
diff --git a/MochieStandardBRDF.cginc b/MochieStandardBRDF.cginc
index 795bbee..2dd5c94 100644
--- a/MochieStandardBRDF.cginc
+++ b/MochieStandardBRDF.cginc
@@ -52,6 +52,36 @@ float GSAARoughness(float3 normal, float roughness){
return max(roughness, pow(base, 0.333)*_GSAAStrength);
}
+float3 Desaturate(float3 col){
+ return dot(col, float3(0.3, 0.59, 0.11));
+}
+
+float3 GetContrast(float3 col, float contrast){
+ return lerp(float3(0.5,0.5,0.5), col, contrast);
+}
+
+float oetf_sRGB_scalar(float L) {
+ float V = 1.055 * (pow(L, 1.0 / 2.4)) - 0.055;
+ if (L <= 0.0031308)
+ V = L * 12.92;
+ return V;
+}
+
+float3 oetf_sRGB(float3 L) {
+ return float3(oetf_sRGB_scalar(L.r), oetf_sRGB_scalar(L.g), oetf_sRGB_scalar(L.b));
+}
+
+float eotf_sRGB_scalar(float V) {
+ float L = pow((V + 0.055) / 1.055, 2.4);
+ if (V <= oetf_sRGB_scalar(0.0031308))
+ L = V / 12.92;
+ return L;
+}
+
+float3 GetHDR(float3 rgb) {
+ return float3(eotf_sRGB_scalar(rgb.r), eotf_sRGB_scalar(rgb.g), eotf_sRGB_scalar(rgb.b));
+}
+
half4 BRDF1_Mochie_PBS (
half3 diffColor, half3 specColor, half oneMinusReflectivity, half smoothness,
half3 normal, half3 viewDir, half3 worldPos, half2 screenUVs, half4 screenPos,