summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-07-03 18:28:55 -0700
committeryum <yum.food.vr@gmail.com>2026-07-03 18:28:55 -0700
commit0a8d744c2ad1182d1de6d1896a4c67d4eb536504 (patch)
tree3f68de6956bc790c3b4b4d4c02c3edb27f45038a
parent6aea3d8274e140e739dfd1da1133ed19656ff6ec (diff)
buncha shitttt
-rw-r--r--2ner.cginc10
-rw-r--r--2ner.shader2
-rw-r--r--LUTS/dfg-c.exrbin48866 -> 0 bytes
-rw-r--r--LUTS/dfg-c.exr.meta116
-rw-r--r--filamented.cginc6
-rw-r--r--globals.cginc3
-rw-r--r--pema99.cginc7
-rw-r--r--yum_brdf.cginc42
-rw-r--r--yum_lighting.cginc1
9 files changed, 35 insertions, 152 deletions
diff --git a/2ner.cginc b/2ner.cginc
index 87d9d29..79e44eb 100644
--- a/2ner.cginc
+++ b/2ner.cginc
@@ -303,6 +303,11 @@ float4 frag(v2f i, uint facing : SV_IsFrontFace
i.normal = normalize(i.normal);
i.tangent.xyz = normalize(i.tangent.xyz);
+#if defined(_SHATTER_WAVE) || defined(_SCREEN_SPACE_NORMALS)
+ calcNormalInScreenSpace(i.normal, i.objPos);
+ i.normal = UnityObjectToWorldNormal(i.normal);
+#endif
+
f2f f = (f2f) 0;
f.worldPos = mul(unity_ObjectToWorld, i.objPos);
f.binormal = cross(i.normal, i.tangent.xyz) * i.tangent.w;
@@ -368,11 +373,6 @@ float4 frag(v2f i, uint facing : SV_IsFrontFace
}
#endif
-#if defined(_SHATTER_WAVE) || defined(_SCREEN_SPACE_NORMALS)
- calcNormalInScreenSpace(i.normal, i.objPos);
- i.normal = UnityObjectToWorldNormal(i.normal);
-#endif
-
#if defined(_SHATTER_WAVE) || defined(_VERTEX_DOMAIN_WARPING) || defined(_TESSELLATION_HEIGHTMAP)
{
[branch]
diff --git a/2ner.shader b/2ner.shader
index 0ea5b2c..e2f4a83 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -2445,7 +2445,7 @@ Shader "yum_food/2ner"
//endex
[HideInInspector] m_FilamentStuff("Filament stuff", Float) = 0
- [NonModifiableTextureData]_DFG("DFG", 2D) = "white" {}
+ [NonModifiableTextureData]_DFG_LUT("DFG", 2D) = "white" {}
[ThryWideEnum(Water, 0.35, Skin, 0.42, Eyes, 0.39, Hair, 0.54, Teeth, 0.6, Fabric, 0.55, Stone, 0.55, Plastic, 0.50, Glass, 0.56, Gemstone, 0.9, Diamond, 1.0)]_reflectance("Reflectance", Float) = 0.55
_ExposureOcclusion("Exposure Occlusion", Float) = 1
[Helpbox]_reflectance_help("Values are documented in the filament whitepaper here https://google.github.io/filament/Filament.html#toc4.8.3.2", Float) = 1
diff --git a/LUTS/dfg-c.exr b/LUTS/dfg-c.exr
deleted file mode 100644
index ce3a47b..0000000
--- a/LUTS/dfg-c.exr
+++ /dev/null
Binary files differ
diff --git a/LUTS/dfg-c.exr.meta b/LUTS/dfg-c.exr.meta
deleted file mode 100644
index e1d68a6..0000000
--- a/LUTS/dfg-c.exr.meta
+++ /dev/null
@@ -1,116 +0,0 @@
-fileFormatVersion: 2
-guid: f8cd36daa53c6e74fb541de133e7f086
-TextureImporter:
- internalIDToNameTable: []
- externalObjects: {}
- serializedVersion: 11
- mipmaps:
- mipMapMode: 0
- enableMipMap: 0
- sRGBTexture: 0
- linearTexture: 0
- fadeOut: 0
- borderMipMap: 0
- mipMapsPreserveCoverage: 0
- alphaTestReferenceValue: 0.5
- mipMapFadeDistanceStart: 1
- mipMapFadeDistanceEnd: 3
- bumpmap:
- convertToNormalMap: 0
- externalNormalMap: 0
- heightScale: 0.25
- normalMapFilter: 0
- isReadable: 0
- streamingMipmaps: 0
- streamingMipmapsPriority: 0
- grayScaleToAlpha: 0
- generateCubemap: 6
- cubemapConvolution: 0
- seamlessCubemap: 0
- textureFormat: 1
- maxTextureSize: 2048
- textureSettings:
- serializedVersion: 2
- filterMode: 2
- aniso: 1
- mipBias: 0
- wrapU: 1
- wrapV: 1
- wrapW: 1
- nPOTScale: 1
- lightmap: 0
- compressionQuality: 50
- spriteMode: 0
- spriteExtrude: 1
- spriteMeshType: 1
- alignment: 0
- spritePivot: {x: 0.5, y: 0.5}
- spritePixelsToUnits: 100
- spriteBorder: {x: 0, y: 0, z: 0, w: 0}
- spriteGenerateFallbackPhysicsShape: 1
- alphaUsage: 1
- alphaIsTransparency: 0
- spriteTessellationDetail: -1
- textureType: 0
- textureShape: 1
- singleChannelComponent: 0
- maxTextureSizeSet: 0
- compressionQualitySet: 0
- textureFormatSet: 0
- applyGammaDecoding: 1
- platformSettings:
- - serializedVersion: 3
- buildTarget: DefaultTexturePlatform
- maxTextureSize: 2048
- resizeAlgorithm: 0
- textureFormat: -1
- textureCompression: 0
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- androidETC2FallbackOverride: 0
- forceMaximumCompressionQuality_BC6H_BC7: 0
- - serializedVersion: 3
- buildTarget: Standalone
- maxTextureSize: 2048
- resizeAlgorithm: 0
- textureFormat: -1
- textureCompression: 0
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- androidETC2FallbackOverride: 0
- forceMaximumCompressionQuality_BC6H_BC7: 0
- - serializedVersion: 3
- buildTarget: Android
- maxTextureSize: 2048
- resizeAlgorithm: 0
- textureFormat: -1
- textureCompression: 0
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- androidETC2FallbackOverride: 0
- forceMaximumCompressionQuality_BC6H_BC7: 0
- spriteSheet:
- serializedVersion: 2
- sprites: []
- outline: []
- physicsShape: []
- bones: []
- spriteID:
- internalID: 0
- vertices: []
- indices:
- edges: []
- weights: []
- secondaryTextures: []
- spritePackingTag:
- pSDRemoveMatte: 0
- pSDShowRemoveMatteOption: 0
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/filamented.cginc b/filamented.cginc
index ecf697f..c2eb5b9 100644
--- a/filamented.cginc
+++ b/filamented.cginc
@@ -254,8 +254,6 @@ SAMPLER(sampler_RNM0);
#define MIN_PERCEPTUAL_ROUGHNESS 0.045
-UNITY_DECLARE_TEX2D_FLOAT(_DFG);
-
// Filamented defines for spherical harmonics
#define SPHERICAL_HARMONICS_DEFAULT 0
#define SPHERICAL_HARMONICS_GEOMETRICS 1
@@ -859,10 +857,6 @@ float IrradianceToExposureOcclusion(float3 irradiance)
return saturate(length(irradiance + FLT_EPS) * getExposureOcclusionBias());
}
-float3 PrefilteredDFG_LUT(float lod, float NoV) {
- return UNITY_SAMPLE_TEX2D(_DFG, float2(NoV, lod));
-}
-
float3 specularDFG(const float3 dfg, const float3 f0) {
return lerp(dfg.xxx, dfg.yyy, f0);
}
diff --git a/globals.cginc b/globals.cginc
index e6e7423..90699a9 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -3,6 +3,8 @@
#include "features.cginc"
+texture2D _DFG_LUT;
+
#if defined(USING_BAKERY_VERTEXLM)
float bakeryLightmapMode;
#endif
@@ -23,6 +25,7 @@ float4 _CameraDepthTexture_TexelSize;
SamplerState point_repeat_s;
SamplerState linear_repeat_s;
+SamplerState bilinear_clamp_s;
SamplerState bilinear_repeat_s;
SamplerState linear_clamp_s;
SamplerState trilinear_repeat_s;
diff --git a/pema99.cginc b/pema99.cginc
index 0651761..9e1626b 100644
--- a/pema99.cginc
+++ b/pema99.cginc
@@ -32,4 +32,11 @@ bool isInMirror()
return unity_CameraProjection[2][0] != 0.f || unity_CameraProjection[2][1] != 0.f;
}
+bool textureExists(texture2D tex)
+{
+ int width, height;
+ tex.GetDimensions(width, height);
+ return width > 16;
+}
+
#endif // __PEMA_99_INC
diff --git a/yum_brdf.cginc b/yum_brdf.cginc
index c7424d0..7a4639f 100644
--- a/yum_brdf.cginc
+++ b/yum_brdf.cginc
@@ -7,6 +7,7 @@
#include "filamented.cginc"
#include "math.cginc"
+#include "pema99.cginc"
#include "yum_pbr.cginc"
#include "yum_lighting.cginc"
@@ -76,10 +77,6 @@ float computeDielectricF0(float reflectance) {
return 0.16 * reflectance * reflectance;
}
-float3 computeDiffuseColor(float3 baseColor, float metallic) {
- return baseColor * (1.0 - metallic);
-}
-
float computeSpecularAO(float NoV, float visibility, float roughness) {
// Lagarde and de Rousiers 2014, "Moving Frostbite to PBR"
return saturate(pow(NoV + visibility, exp2(-16.0 * roughness - 1.0)) - 1.0 + visibility);
@@ -144,6 +141,17 @@ float4 YumBRDF(v2f i, f2f f, const YumLighting light, YumPbr pbr) {
}
#endif
+ const float dielectric_f0 = computeDielectricF0(_reflectance);
+ const float3 f0 = lerp(dielectric_f0, pbr.albedo, pbr.metallic);
+ float2 dfg_uv = float2(NoV, pbr.roughness_perceptual);
+ float3 dfg;
+ [branch]
+ if (textureExists(_DFG_LUT)) {
+ dfg = _DFG_LUT.SampleLevel(bilinear_clamp_s, dfg_uv, 0).rgb;
+ } else {
+ dfg = float3(1, 1, 1);
+ }
+
float3 direct_standard;
{
float remainder = 1.0f;
@@ -163,18 +171,10 @@ float4 YumBRDF(v2f i, f2f f, const YumLighting light, YumPbr pbr) {
remainder -= Fcc;
remainder = max(0, remainder);
#endif
-
- const float dielectric_f0 = computeDielectricF0(_reflectance);
- const float3 f0 = lerp(dielectric_f0, pbr.albedo, pbr.metallic);
- const float3 dfg = PrefilteredDFG_LUT(pbr.roughness_perceptual, NoV);
const float3 E = specularDFG(dfg, f0);
const float3 energy_compensation = energyCompensation(dfg, f0);
- // Compute proper diffuse color with metallic blending
- float3 diffuseColor = computeDiffuseColor(pbr.albedo, pbr.metallic);
-
- // Fd_Burley already includes 1/PI, so multiply by PI to match Unity intensities
- float3 Fd = diffuseColor * Fd_Burley(pbr.roughness, NoV, NoL_wrapped_d, LoH) * PI;
+ float3 Fd = pbr.albedo.xyz * (1.0f - pbr.metallic) * Fd_Burley(pbr.roughness, NoV, NoL_wrapped_d, LoH) * PI;
Fd *= light.attenuation * pbr.ao * remainder;
// Multiply by PI to match Unity intensities (same as Filament's implementation)
@@ -187,6 +187,7 @@ float4 YumBRDF(v2f i, f2f f, const YumLighting light, YumPbr pbr) {
#endif
direct_standard = color * light.direct;
}
+ direct_standard = 0;
#if defined(_MATERIAL_TYPE_CLOTH)
float3 indirect_cloth;
@@ -256,8 +257,6 @@ float4 YumBRDF(v2f i, f2f f, const YumLighting light, YumPbr pbr) {
#if defined(_BRIGHTNESS_CONTROL)
cc_env_refl *= _Brightness_Multiplier;
#endif
-
- // Clearcoat Fresnel for view angle
float Fcc = F_Schlick(cc_f0, NoV_cc).x * cc_mask * _Clearcoat_Strength;
float3 indirect_specular_cc = Fcc * cc_env_refl;
@@ -266,19 +265,14 @@ float4 YumBRDF(v2f i, f2f f, const YumLighting light, YumPbr pbr) {
remainder = saturate(remainder - Fcc);
#endif
- const float dielectric_f0 = computeDielectricF0(_reflectance);
- const float3 f0 = lerp(dielectric_f0, pbr.albedo, pbr.metallic);
- const float3 dfg = PrefilteredDFG_LUT(pbr.roughness_perceptual, NoV);
- const float3 E = specularDFG(dfg, f0);
-
+ const float3 f0_spec = lerp(dielectric_f0, pbr.albedo.xyz, pbr.metallic);
+ const float3 ibl_specular_reflectance = lerp(dfg.xxx, dfg.yyy, f0_spec);
float diffuseAO = pbr.ao;
- float3 diffuseColor = computeDiffuseColor(pbr.albedo, pbr.metallic);
- float3 Fr = E * light.specular * remainder;
+ float3 Fr = ibl_specular_reflectance * light.specular * remainder;
remainder = saturate(remainder - Fr);
- float3 Fd = diffuseColor * light.diffuse * pbr.ao * remainder;
-
+ float3 Fd = pbr.albedo.xyz * (1.0f - pbr.metallic) * light.diffuse * pbr.ao * remainder;
indirect_standard += Fr + Fd;
}
diff --git a/yum_lighting.cginc b/yum_lighting.cginc
index a1bef47..a7e1a5e 100644
--- a/yum_lighting.cginc
+++ b/yum_lighting.cginc
@@ -325,6 +325,7 @@ float4 getIndirectDiffuse(v2f i,
#if defined(FORWARD_BASE_PASS)
diffuse.xyz += max(0, yumSH9(float4(normal, 0), f.worldPos, light));
#endif
+
return diffuse;
}