Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 8487052

Browse files
committed
Squashed commit of the following:
commit 76ebf99 Author: z3y <[email protected]> Date: Mon Sep 18 19:29:21 2023 +0200 removed bakery alpha meta pass commit d120dc3 Author: z3y <[email protected]> Date: Thu Sep 7 15:26:46 2023 +0200 layered shader fixed bump scale wrong property name commit 9fc3d49 Author: z3y <[email protected]> Date: Mon Sep 4 14:34:41 2023 +0200 Delete Shaders.meta commit b5b1f71 Author: z3y <[email protected]> Date: Mon Sep 4 14:29:49 2023 +0200 fixed shadowmask, subtractive, directional shadow fade issues commit 0e3dbda Author: z3y <[email protected]> Date: Sun Sep 3 20:00:41 2023 +0200 shadowmask bug fix at a distance commit 1989b19 Author: z3y <[email protected]> Date: Sun Sep 3 19:41:25 2023 +0200 prevent some macro redefinition warnings commit a5db54d Author: z3y <[email protected]> Date: Thu Aug 31 18:57:45 2023 +0200 Update CHANGELOG.md commit 421b775 Author: z3y <[email protected]> Date: Sat Aug 26 19:12:47 2023 +0200 custom attribute drawer commit 4b8c5a1 Author: z3y <[email protected]> Date: Sat Jul 22 00:37:31 2023 +0200 Update LitImporter.cs commit d614982 Author: z3y <[email protected]> Date: Sat Jul 22 00:31:01 2023 +0200 refactor importer code
1 parent 15ae487 commit 8487052

16 files changed

+71
-65
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
## [3.2.9] - 2023-09-18
10+
- Removed bakery meta pass because of performance issues
11+
12+
## [3.2.8] - 2023-08-31
13+
## Added
14+
- Support for using custom drawers in the inspector
15+
- Refactored Importer Code
16+
917
## [3.2.7] - 2023-07-20
1018
## Added
1119
- New automatic PBR material setup with texture packing
@@ -26,7 +34,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2634
- Adjustable height blending (Mask Map Blue channel)
2735
- Doesn't work with more than 4 layers currently
2836
- Possible bugs since I avoid using Unity terrain
29-
3037
- Ported over `SurfaceDescriptionInputs` and `VertexDescriptionInputs` functions from Shader Graph for getting shader data when creating new shaders in [Structs](/ShaderLibrary/Structs.hlsl)
3138

3239
## [3.2.6] - 2023-07-03

Editor/Graph.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Editor/Importer/LitImporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace z3y.Shaders
1414
{
15-
[ScriptedImporter(4, Ext, 0)]
15+
[ScriptedImporter(5, Ext, 0)]
1616
public class LitImporter : ScriptedImporter
1717
{
1818
public const string Ext = "litshader";
@@ -492,8 +492,8 @@ private string GetShaderLabCode(AssetImportContext ctx)
492492
sb.AppendLine("Pass"); // Meta
493493
sb.AppendLine("{");
494494
{
495-
sb.AppendLine("Name \"META_BAKERY\"");
496-
//sb.AppendLine("Name \"META_BAKERY\"");
495+
// sb.AppendLine("Name \"META_BAKERY\"");
496+
sb.AppendLine("Name \"META\"");
497497

498498
sb.AppendLine("Tags { \"LightMode\" = \"Meta\"}");
499499
sb.AppendLine("Cull Off");

Editor/Importer/LitImporterDefaultProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public static class LitImporterConstants
1010
[Enum(Off, 0, On, 1)] _ZWrite(""ZWrite"", Float) = 1
1111
[Enum(Off, 0, On, 1)] _AlphaToMask(""AlphaToMask"", Float) = 0
1212
[Enum(UnityEngine.Rendering.CullMode)] _Cull(""Cull"", Float) = 2
13-
[HideInInspector] BAKERY_META_ALPHA_ENABLE(""Enable Bakery alpha meta pass"", Float) = 1
1413
";
1514

1615
public const string DefaultPropertiesIncludeAfter = @"
1716
[ToggleUI] _BakeryAlphaDither(""Bakery Alpha Dither"", Float) = 0
1817
[ToggleOff(_GLOSSYREFLECTIONS_OFF)] _GlossyReflections(""Reflections"", Float) = 1
1918
[ToggleOff(_SPECULARHIGHLIGHTS_OFF)] _SpecularHighlights(""Specular Highlights"", Float) = 1
2019
[HideInInspector] [NonModifiableTextureData] [NoScaleOffset] _DFG(""DFG"", 2D) = ""white"" {}
20+
[HideInInspector] [NonModifiableTextureData] [NoScaleOffset] BlueNoise(""BlueNoise"", 2D) = ""white"" {}
2121
";
2222

2323
public const string AreaLitProperties = @"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ https://github.com/z3y/shaders.git
3434
|Emission GI Multiplier| Adjusts emission intensity used for baking lightmaps in the Meta pass |
3535
|Transparency Modes | Cutout, Fade, Premultiply, Additive, Multiply|
3636
|Non-Important lights per pixel| Cheaper real-time lights done in one pass. Does not work with lightmapped object |
37-
|Bakery Alpha Meta| Surface inputs used in the shader are properly passed to the meta pass for baking instead of just reading the main texture and main color|
3837
|Bakery Alpha Dither|Semi-Transparent baked shadows. Available only in Bakery L1 mode|
3938
|Baked Area Light Specular Approximation| Reduced smoothness in areas where there is less directionality for more accurate lightmapped specular|
4039
|Centroid Lightmap UVs|Fix for lightmap bleeding with very tight packing|

ShaderLibrary/ForwardLighting.hlsl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@ namespace CustomLighting
188188
#if defined(LIGHTMAP_ON)
189189
float2 lightmapUV = unpacked.lightmapUV.xy;
190190

191-
#if defined(HANDLE_SHADOWS_BLENDING_IN_GI)
192-
half bakedAtten = UnitySampleBakedOcclusion(lightmapUV.xy, unpacked.positionWS);
193-
float zDist = dot(_WorldSpaceCameraPos - unpacked.positionWS, UNITY_MATRIX_V[2].xyz);
194-
float fadeDist = UnityComputeShadowFadeDistance(unpacked.positionWS, zDist);
195-
half atten = UnityMixRealtimeAndBakedShadows(light.attenuation, bakedAtten, UnityComputeShadowFade(fadeDist));
196-
#endif
197-
198-
199191
#if defined(BICUBIC_LIGHTMAP)
200192
float4 lightmapTexelSize = BicubicSampling::GetTexelSize(unity_Lightmap);
201193
half4 bakedColorTex = BicubicSampling::SampleBicubic(unity_Lightmap, custom_bilinear_clamp_sampler, lightmapUV, lightmapTexelSize);
@@ -231,8 +223,8 @@ namespace CustomLighting
231223
#endif
232224

233225
#if defined(LIGHTMAP_SHADOW_MIXING) && !defined(SHADOWS_SHADOWMASK) && defined(SHADOWS_SCREEN)
226+
lightMap = SubtractMainLightWithRealtimeAttenuationFromLightmap(lightMap, light.attenuation, float4(0,0,0,0), sd.normalWS);
234227
light = (CustomLightData)0;
235-
lightMap = SubtractMainLightWithRealtimeAttenuationFromLightmap(lightMap, atten, float4(0,0,0,0), sd.normalWS);
236228
#endif
237229

238230
indirectDiffuse = lightMap;

ShaderLibrary/FragmentMeta.hlsl

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,32 @@ half3 UnityLightmappingAlbedo (half3 diffuse, half3 specular, half smoothness)
8080
// o.Albedo = UnityLightmappingAlbedo(diffuseColor, specColor, surfaceDescription.Smoothness);
8181
o.Albedo = surfaceDescription.Albedo;
8282
#endif
83-
o.SpecularColor = specColor;
84-
o.Emission = surfaceDescription.Emission;
83+
84+
o.SpecularColor = specColor;
85+
o.Emission = surfaceDescription.Emission;
8586

8687
#ifndef EDITOR_VISUALIZATION
8788

88-
#if defined(_ALPHATEST_ON)
89-
clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
90-
#endif
91-
92-
#if !defined(_ALPHAFADE_ON) && !defined(_ALPHATEST_ON) && !defined(_ALPHAPREMULTIPLY_ON) && !defined(_ALPHAMODULATE_ON)
93-
surfaceDescription.Alpha = 1.0f;
94-
#endif
89+
#if defined(_ALPHATEST_ON)
90+
clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
91+
#endif
9592

96-
// bakery alpha
97-
if (unity_MetaFragmentControl.w != 0)
98-
{
99-
#ifdef _ALPHAPREMULTIPLY_ON
100-
if (_BakeryAlphaDither > 0.5)
101-
{
102-
half dither = Unity_Dither(surfaceDescription.Alpha, unpacked.positionCS.xy);
103-
return dither < 0.0 ? 0 : 1;
104-
}
93+
#if !defined(_ALPHAFADE_ON) && !defined(_ALPHATEST_ON) && !defined(_ALPHAPREMULTIPLY_ON) && !defined(_ALPHAMODULATE_ON)
94+
surfaceDescription.Alpha = 1.0f;
10595
#endif
106-
return surfaceDescription.Alpha;
107-
}
96+
97+
// bakery alpha
98+
// if (unity_MetaFragmentControl.w != 0)
99+
// {
100+
// #ifdef _ALPHAPREMULTIPLY_ON
101+
// if (_BakeryAlphaDither > 0.5)
102+
// {
103+
// half dither = Unity_Dither(surfaceDescription.Alpha, unpacked.positionCS.xy);
104+
// return dither < 0.0 ? 0 : 1;
105+
// }
106+
// #endif
107+
// return surfaceDescription.Alpha;
108+
// }
108109
#endif
109110

110111
return UnityMetaFragment(o);

ShaderLibrary/ShaderPass.hlsl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ bool IsInMirror()
160160
#include "Packages/com.z3y.shaders/ShaderLibrary/CoreRP/CommonMaterial.hlsl"
161161
#endif
162162

163-
164163
#ifdef PIPELINE_BUILTIN
165164

166165
#ifdef FORCE_SPECCUBE_BOX_PROJECTION
@@ -171,6 +170,15 @@ bool IsInMirror()
171170

172171
#undef GLOBAL_CBUFFER_START // dont need reg
173172
#define GLOBAL_CBUFFER_START(name) CBUFFER_START(name)
173+
174+
#undef SAMPLE_DEPTH_TEXTURE
175+
#undef SAMPLE_DEPTH_TEXTURE_LOD
176+
#undef UNITY_MATRIX_P
177+
#undef UNITY_MATRIX_MVP
178+
#undef UNITY_MATRIX_MV
179+
#undef UNITY_MATRIX_T_MV
180+
#undef UNITY_MATRIX_IT_MV
181+
174182
#include "UnityShaderVariables.cginc"
175183
half4 _LightColor0;
176184
half4 _SpecColor;

ShaderLibrary/Shaders.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

ShaderLibrary/Structs.hlsl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ CustomLightData GetCustomMainLightData(Varyings unpacked)
1717
#endif
1818
UNITY_LIGHT_ATTENUATION(lightAttenuation, legacyVaryings, unpacked.positionWS.xyz);
1919

20-
#if defined(UNITY_PASS_FORWARDBASE) && !defined(SHADOWS_SCREEN)
20+
#if defined(HANDLE_SHADOWS_BLENDING_IN_GI) && defined(SHADOWS_SCREEN) && defined(LIGHTMAP_ON)
21+
half bakedAtten = UnitySampleBakedOcclusion(unpacked.lightmapUV, unpacked.positionWS);
22+
float zDist = dot(_WorldSpaceCameraPos - unpacked.positionWS, UNITY_MATRIX_V[2].xyz);
23+
float fadeDist = UnityComputeShadowFadeDistance(unpacked.positionWS, zDist);
24+
lightAttenuation = UnityMixRealtimeAndBakedShadows(lightAttenuation, bakedAtten, UnityComputeShadowFade(fadeDist));
25+
#endif
26+
27+
#if defined(UNITY_PASS_FORWARDBASE) && !defined(SHADOWS_SCREEN) && !defined(SHADOWS_SHADOWMASK)
2128
lightAttenuation = 1.0;
2229
#endif
2330
data.attenuation = lightAttenuation;

0 commit comments

Comments
 (0)