summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--2ner.cginc10
-rw-r--r--2ner.shader45
-rw-r--r--LUTS/bpe_lut.pngbin0 -> 598482 bytes
-rw-r--r--LUTS/dfg-c.exrbin48866 -> 0 bytes
-rw-r--r--LUTS/dfg-c.exr.meta116
-rw-r--r--LUTS/dfg-ms.exrbin34428 -> 0 bytes
-rw-r--r--LUTS/dfg-ms.exr.meta127
-rw-r--r--LUTS/dfg-s.exrbin35458 -> 0 bytes
-rw-r--r--LUTS/dfg-s.exr.meta116
-rw-r--r--LUTS/dfg_lut.exrbin0 -> 1839260 bytes
-rw-r--r--Scripts/generate_dfg_lut.py190
-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
16 files changed, 243 insertions, 420 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..a718be0 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -198,9 +198,8 @@ Shader "yum_food/2ner"
[ThryToggle(_MATCAP0)]_Matcap0_Enabled("Enable", Float) = 0
_Matcap0("Matcap", 2D) = "white" {}
[Toggle(_)]_Matcap0_Invert("Invert", Float) = 0
- [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
- _Matcap0_Mode("Mode", Int) = 0
- [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ [DoNotLock] [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)] _Matcap0_Mode("Mode", Int) = 0
+ [DoNotLock] [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
_Matcap0_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
_Matcap0_Strength("Strength", Float) = 1
//ifex _Matcap0_Mask_Enabled==0
@@ -222,9 +221,8 @@ Shader "yum_food/2ner"
[ThryToggle(_MATCAP1)]_Matcap1_Enabled("Enable", Float) = 0
_Matcap1("Matcap", 2D) = "white" {}
[Toggle(_)]_Matcap1_Invert("Invert", Float) = 0
- [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
- _Matcap1_Mode("Mode", Int) = 0
- [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ [DoNotLock] [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)] _Matcap1_Mode("Mode", Int) = 0
+ [DoNotLock] [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
_Matcap1_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
_Matcap1_Strength("Strength", Float) = 1
//ifex _Matcap1_Mask_Enabled==0
@@ -246,9 +244,8 @@ Shader "yum_food/2ner"
[ThryToggle(_MATCAP2)]_Matcap2_Enabled("Enable", Float) = 0
_Matcap2("Matcap", 2D) = "white" {}
[Toggle(_)]_Matcap2_Invert("Invert", Float) = 0
- [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
- _Matcap2_Mode("Mode", Int) = 0
- [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ [DoNotLock] [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)] _Matcap2_Mode("Mode", Int) = 0
+ [DoNotLock] [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
_Matcap2_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
_Matcap2_Strength("Strength", Float) = 1
//ifex _Matcap2_Mask_Enabled==0
@@ -270,14 +267,13 @@ Shader "yum_food/2ner"
[HideInInspector] m_start_Rim_Lighting("Rim lighting", Float) = 0
//ifex _Rim_Lighting0_Enabled==0
[HideInInspector] m_start_Rim_Lighting0("Rim lighting 0", Float) = 0
- [ThryToggle(_RIM_LIGHTING0)]_Rim_Lighting0_Enabled("Enable", Float) = 0
+ [DoNotLock] [ThryToggle(_RIM_LIGHTING0)]_Rim_Lighting0_Enabled("Enable", Float) = 0
_Rim_Lighting0_Center("Center", Range(0, 0.5)) = 0.5
_Rim_Lighting0_Power("Power", Float) = 5
_Rim_Lighting0_Color("Color", Color) = (1, 1, 1, 1)
_Rim_Lighting0_Brightness("Brightness", Float) = 1
- [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
- _Rim_Lighting0_Mode("Mode", Int) = 0
- [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ [DoNotLock] [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)] _Rim_Lighting0_Mode("Mode", Int) = 0
+ [DoNotLock] [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
_Rim_Lighting0_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
//ifex _Rim_Lighting0_Mask_Enabled==0
[HideInInspector] m_start_Rim_Lighting0_Mask("Mask", Float) = 0
@@ -303,14 +299,13 @@ Shader "yum_food/2ner"
//ifex _Rim_Lighting1_Enabled==0
[HideInInspector] m_start_Rim_Lighting1("Rim lighting 1", Float) = 0
- [ThryToggle(_RIM_LIGHTING1)]_Rim_Lighting1_Enabled("Enable", Float) = 0
+ [DoNotLock] [ThryToggle(_RIM_LIGHTING1)]_Rim_Lighting1_Enabled("Enable", Float) = 0
_Rim_Lighting1_Center("Center", Range(0, 0.5)) = 0.5
_Rim_Lighting1_Power("Power", Float) = 5
_Rim_Lighting1_Color("Color", Color) = (1, 1, 1, 1)
_Rim_Lighting1_Brightness("Brightness", Float) = 1
- [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
- _Rim_Lighting1_Mode("Mode", Int) = 0
- [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ [DoNotLock] [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)] _Rim_Lighting1_Mode("Mode", Int) = 0
+ [DoNotLock] [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
_Rim_Lighting1_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
//ifex _Rim_Lighting1_Mask_Enabled==0
[HideInInspector] m_start_Rim_Lighting1_Mask("Mask", Float) = 0
@@ -336,14 +331,13 @@ Shader "yum_food/2ner"
//ifex _Rim_Lighting2_Enabled==0
[HideInInspector] m_start_Rim_Lighting2("Rim lighting 2", Float) = 0
- [ThryToggle(_RIM_LIGHTING2)]_Rim_Lighting2_Enabled("Enable", Float) = 0
+ [DoNotLock] [ThryToggle(_RIM_LIGHTING2)]_Rim_Lighting2_Enabled("Enable", Float) = 0
_Rim_Lighting2_Center("Center", Range(0, 0.5)) = 0.5
_Rim_Lighting2_Power("Power", Float) = 5
_Rim_Lighting2_Color("Color", Color) = (1, 1, 1, 1)
_Rim_Lighting2_Brightness("Brightness", Float) = 1
- [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
- _Rim_Lighting2_Mode("Mode", Int) = 0
- [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ [DoNotLock] [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)] _Rim_Lighting2_Mode("Mode", Int) = 0
+ [DoNotLock] [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
_Rim_Lighting2_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
//ifex _Rim_Lighting2_Mask_Enabled==0
[HideInInspector] m_start_Rim_Lighting2_Mask("Mask", Float) = 0
@@ -369,14 +363,13 @@ Shader "yum_food/2ner"
//ifex _Rim_Lighting3_Enabled==0
[HideInInspector] m_start_Rim_Lighting3("Rim lighting 3", Float) = 0
- [ThryToggle(_RIM_LIGHTING3)]_Rim_Lighting3_Enabled("Enable", Float) = 0
+ [DoNotLock] [ThryToggle(_RIM_LIGHTING3)]_Rim_Lighting3_Enabled("Enable", Float) = 0
_Rim_Lighting3_Center("Center", Range(0, 0.5)) = 0.5
_Rim_Lighting3_Power("Power", Float) = 5
_Rim_Lighting3_Color("Color", Color) = (1, 1, 1, 1)
_Rim_Lighting3_Brightness("Brightness", Float) = 1
- [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
- _Rim_Lighting3_Mode("Mode", Int) = 0
- [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ [DoNotLock] [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)] _Rim_Lighting3_Mode("Mode", Int) = 0
+ [DoNotLock] [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
_Rim_Lighting3_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
//ifex _Rim_Lighting3_Mask_Enabled==0
[HideInInspector] m_start_Rim_Lighting3_Mask("Mask", Float) = 0
@@ -2445,7 +2438,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/bpe_lut.png b/LUTS/bpe_lut.png
new file mode 100644
index 0000000..740b1e1
--- /dev/null
+++ b/LUTS/bpe_lut.png
Binary files differ
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/LUTS/dfg-ms.exr b/LUTS/dfg-ms.exr
deleted file mode 100644
index 31e8c9d..0000000
--- a/LUTS/dfg-ms.exr
+++ /dev/null
Binary files differ
diff --git a/LUTS/dfg-ms.exr.meta b/LUTS/dfg-ms.exr.meta
deleted file mode 100644
index 8fc4adb..0000000
--- a/LUTS/dfg-ms.exr.meta
+++ /dev/null
@@ -1,127 +0,0 @@
-fileFormatVersion: 2
-guid: 53122c95e82e994448dce5a9c8346223
-TextureImporter:
- internalIDToNameTable: []
- externalObjects: {}
- serializedVersion: 12
- 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
- flipGreenChannel: 0
- isReadable: 0
- streamingMipmaps: 0
- streamingMipmapsPriority: 0
- vTOnly: 0
- ignoreMipmapLimit: 0
- grayScaleToAlpha: 0
- generateCubemap: 6
- cubemapConvolution: 0
- seamlessCubemap: 0
- textureFormat: 1
- maxTextureSize: 2048
- textureSettings:
- serializedVersion: 2
- filterMode: 1
- 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: 0
- alphaIsTransparency: 0
- spriteTessellationDetail: -1
- textureType: 0
- textureShape: 1
- singleChannelComponent: 0
- flipbookRows: 1
- flipbookColumns: 1
- maxTextureSizeSet: 0
- compressionQualitySet: 0
- textureFormatSet: 0
- ignorePngGamma: 0
- applyGammaDecoding: 1
- swizzle: 50462976
- cookieLightType: 1
- platformSettings:
- - serializedVersion: 3
- buildTarget: DefaultTexturePlatform
- maxTextureSize: 128
- resizeAlgorithm: 1
- textureFormat: -1
- textureCompression: 0
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- ignorePlatformSupport: 0
- androidETC2FallbackOverride: 0
- forceMaximumCompressionQuality_BC6H_BC7: 0
- - serializedVersion: 3
- buildTarget: Standalone
- maxTextureSize: 128
- resizeAlgorithm: 1
- textureFormat: -1
- textureCompression: 0
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- ignorePlatformSupport: 0
- androidETC2FallbackOverride: 0
- forceMaximumCompressionQuality_BC6H_BC7: 0
- - serializedVersion: 3
- buildTarget: Android
- maxTextureSize: 128
- resizeAlgorithm: 1
- textureFormat: -1
- textureCompression: 0
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- ignorePlatformSupport: 0
- androidETC2FallbackOverride: 0
- forceMaximumCompressionQuality_BC6H_BC7: 0
- spriteSheet:
- serializedVersion: 2
- sprites: []
- outline: []
- physicsShape: []
- bones: []
- spriteID:
- internalID: 0
- vertices: []
- indices:
- edges: []
- weights: []
- secondaryTextures: []
- nameFileIdTable: {}
- mipmapLimitGroupName:
- pSDRemoveMatte: 0
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/LUTS/dfg-s.exr b/LUTS/dfg-s.exr
deleted file mode 100644
index 1048da9..0000000
--- a/LUTS/dfg-s.exr
+++ /dev/null
Binary files differ
diff --git a/LUTS/dfg-s.exr.meta b/LUTS/dfg-s.exr.meta
deleted file mode 100644
index 5360498..0000000
--- a/LUTS/dfg-s.exr.meta
+++ /dev/null
@@ -1,116 +0,0 @@
-fileFormatVersion: 2
-guid: 302270a7d573a6f4287fc9c50a70d26a
-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/LUTS/dfg_lut.exr b/LUTS/dfg_lut.exr
new file mode 100644
index 0000000..3086d07
--- /dev/null
+++ b/LUTS/dfg_lut.exr
Binary files differ
diff --git a/Scripts/generate_dfg_lut.py b/Scripts/generate_dfg_lut.py
new file mode 100644
index 0000000..83759d2
--- /dev/null
+++ b/Scripts/generate_dfg_lut.py
@@ -0,0 +1,190 @@
+#!/usr/bin/env python3
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "numpy",
+# "openexr",
+# ]
+# ///
+"""
+Generate a DFG LUT (Look-Up Table) for PBR split-sum approximation.
+
+This computes the pre-integrated BRDF for the GGX microfacet model,
+storing scale and bias factors for the Fresnel term.
+
+Output: DFG LUT as an EXR file with RG channels (scale, bias).
+"""
+
+import numpy as np
+
+try:
+ import OpenEXR
+ import Imath
+ HAS_OPENEXR = True
+except ImportError:
+ HAS_OPENEXR = False
+
+
+def generate_hammersley_sequence(n):
+ """Pre-compute Hammersley 2D sequence for n samples."""
+ i = np.arange(n, dtype=np.uint32)
+
+ # Reverse bits for radical inverse
+ v = i.copy()
+ v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1)
+ v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2)
+ v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4)
+ v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8)
+ v = (v >> 16) | (v << 16)
+
+ e1 = i.astype(np.float32) / n
+ e2 = v.astype(np.float64) / 0x100000000
+
+ return e1, e2.astype(np.float32)
+
+
+def generate_dfg_lut(width=64, height=32, num_samples=512):
+ """
+ Generate the full DFG LUT (vectorized).
+
+ Compatible with HLSL: float2 dfg_uv = float2(NoV, roughness);
+ X axis (U): NdotV (0 to 1)
+ Y axis (V): roughness (0 to 1)
+ """
+ # Pre-compute Hammersley sequence
+ e1, e2 = generate_hammersley_sequence(num_samples)
+ phi = 2.0 * np.pi * e1
+ cos_phi = np.cos(phi)
+ sin_phi = np.sin(phi)
+
+ # Create coordinate grids matching HLSL UV layout
+ x = np.arange(width, dtype=np.float32)
+ y = np.arange(height, dtype=np.float32)
+ ndotv_arr = (x + 0.5) / width # shape: (width,) - U axis
+ roughness = (y + 0.5) / height # shape: (height,) - V axis
+
+ # Pre-compute roughness terms
+ m = roughness * roughness
+ m2 = m * m # shape: (height,)
+
+ lut = np.zeros((height, width, 2), dtype=np.float32)
+
+ for yi, (rough, rough_m2) in enumerate(zip(roughness, m2)):
+ # GGX importance sampling - vectorized over samples and NdotV
+ # cos_theta shape: (width, num_samples)
+ denom = 1.0 + (rough_m2 - 1.0) * e2[np.newaxis, :]
+ cos_theta = np.sqrt((1.0 - e2[np.newaxis, :]) / denom)
+ sin_theta = np.sqrt(1.0 - cos_theta * cos_theta)
+
+ # Half vector in tangent space
+ hx = sin_theta * cos_phi[np.newaxis, :]
+ hy = sin_theta * sin_phi[np.newaxis, :]
+ hz = cos_theta
+
+ # View vector in tangent space (varies per column)
+ ndotv = ndotv_arr[:, np.newaxis] # shape: (width, 1)
+ vx = np.sqrt(1.0 - ndotv * ndotv)
+ vz = ndotv
+
+ # V dot H
+ vdh = vx * hx + vz * hz
+
+ # Light vector (reflect view around half)
+ lx = 2.0 * vdh * hx - vx
+ lz = 2.0 * vdh * hz - vz
+
+ ndotl = np.maximum(lz, 0.0)
+ ndoth = np.maximum(hz, 0.0)
+ vdoth = np.maximum(vdh, 0.0)
+
+ # Visibility function (Smith GGX correlated)
+ vis_v = ndotl * np.sqrt(ndotv * (ndotv - ndotv * rough_m2) + rough_m2)
+ vis_l = ndotv * np.sqrt(ndotl * (ndotl - ndotl * rough_m2) + rough_m2)
+ vis = 0.5 / (vis_v + vis_l + 1e-8)
+
+ # Compute contribution
+ ndotl_vis_pdf = ndotl * vis * (4.0 * vdoth / (ndoth + 1e-8))
+ fresnel = (1.0 - vdoth) ** 5
+
+ # Mask invalid samples
+ mask = ndotl > 0.0
+ scale_contrib = np.where(mask, ndotl_vis_pdf * (1.0 - fresnel), 0.0)
+ bias_contrib = np.where(mask, ndotl_vis_pdf * fresnel, 0.0)
+
+ # Sum over samples
+ scale = np.sum(scale_contrib, axis=1) / num_samples
+ bias = np.sum(bias_contrib, axis=1) / num_samples
+
+ # Filament-compatible layout:
+ # R = bias (F0-independent term)
+ # G = scale + bias (reflectance when F0 = 1)
+ # Used as: lerp(dfg.x, dfg.y, f0) = bias + f0 * scale
+ lut[yi, :, 0] = bias
+ lut[yi, :, 1] = scale + bias
+
+ print(f"\rGenerating DFG LUT: {(yi + 1) / height * 100:.1f}%", end="", flush=True)
+
+ print()
+ # Flip vertically so V=0 (top) is high roughness, V=1 (bottom) is low roughness
+ return np.flipud(lut)
+
+
+def save_exr(filename, lut):
+ """Save the DFG LUT as an EXR file."""
+ if not HAS_OPENEXR:
+ raise ImportError("OpenEXR module not available. Install with: pip install OpenEXR")
+
+ height, width = lut.shape[:2]
+
+ header = OpenEXR.Header(width, height)
+ header['channels'] = {
+ 'R': Imath.Channel(Imath.PixelType(Imath.PixelType.FLOAT)),
+ 'G': Imath.Channel(Imath.PixelType(Imath.PixelType.FLOAT)),
+ }
+
+ r_channel = lut[:, :, 0].astype(np.float32).tobytes()
+ g_channel = lut[:, :, 1].astype(np.float32).tobytes()
+
+ exr = OpenEXR.OutputFile(filename, header)
+ exr.writePixels({'R': r_channel, 'G': g_channel})
+ exr.close()
+
+
+def save_npy(filename, lut):
+ """Save the DFG LUT as a numpy file (fallback)."""
+ np.save(filename, lut)
+
+
+def main():
+ import argparse
+
+ parser = argparse.ArgumentParser(description="Generate DFG LUT for PBR rendering")
+ parser.add_argument("-o", "--output", default="dfg_lut.exr", help="Output filename (default: dfg_lut.exr)")
+ parser.add_argument("-W", "--width", type=int, default=64, help="LUT width (NdotV axis, default: 64)")
+ parser.add_argument("-H", "--height", type=int, default=32, help="LUT height (roughness axis, default: 32)")
+ parser.add_argument("-s", "--samples", type=int, default=512, help="Number of samples per texel (default: 512)")
+ args = parser.parse_args()
+
+ print(f"Generating {args.width}x{args.height} DFG LUT with {args.samples} samples per texel...")
+ lut = generate_dfg_lut(args.width, args.height, args.samples)
+
+ output = args.output
+ if output.endswith(".exr"):
+ if HAS_OPENEXR:
+ save_exr(output, lut)
+ print(f"Saved EXR: {output}")
+ else:
+ output = output.replace(".exr", ".npy")
+ print("Warning: OpenEXR not available. Install with: pip install OpenEXR")
+ save_npy(output, lut)
+ print(f"Saved NumPy array instead: {output}")
+ elif output.endswith(".npy"):
+ save_npy(output, lut)
+ print(f"Saved NumPy array: {output}")
+ else:
+ save_exr(output, lut)
+ print(f"Saved: {output}")
+
+
+if __name__ == "__main__":
+ main()
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;
}