更新
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Includes/Common/Input.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 tangentOS : TANGENT;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD1;
|
||||
float3 normalWS : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
Varyings DepthNormalsVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
||||
output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS);
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 DepthNormalsFragment(Varyings input) : SV_TARGET
|
||||
{
|
||||
#if _ALPHATEST_ON
|
||||
{
|
||||
half alpha = tex2D(_BaseMap, input.uv).a * _BaseColor.a;
|
||||
clip(alpha - _Cutoff);
|
||||
}
|
||||
#endif
|
||||
|
||||
half3 normalVS = TransformWorldToViewDir(input.normalWS, true);
|
||||
half2 packedNormal = PackNormalOctRectEncode(normalVS);
|
||||
return float4(packedNormal, 0.0, 0.0);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 568b0935a96762947be6e90b1e7f2bae
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Passes/DepthNormalsPass.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "Includes/Common/Input.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 positionCS : SV_POSITION;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
Varyings DepthOnlyVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 DepthOnlyFragment(Varyings input) : SV_TARGET
|
||||
{
|
||||
#if _ALPHATEST_ON
|
||||
{
|
||||
half alpha = tex2D(_BaseMap, input.uv).a * _BaseColor.a;
|
||||
clip(alpha - _Cutoff);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fad61a0d8e3772c47971b05a2c3ea5bb
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Passes/DepthOnlyPass.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ParallaxMapping.hlsl"
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
#include "Includes/Common/Input.hlsl"
|
||||
#include "Includes/Utils/MathUtils.hlsl"
|
||||
#include "Includes/Utils/ColorSpaceUtils.hlsl"
|
||||
|
||||
#if defined(LIGHTMAP_ON)
|
||||
#define DECLARE_LIGHTMAP_OR_SH(lmName, shName, index) float2 lmName : TEXCOORD##index
|
||||
#define OUTPUT_LIGHTMAP_UV(lightmapUV, lightmapScaleOffset, OUT) OUT.xy = lightmapUV.xy * lightmapScaleOffset.xy + lightmapScaleOffset.zw;
|
||||
#define OUTPUT_SH(normalWS, OUT)
|
||||
#else
|
||||
#define DECLARE_LIGHTMAP_OR_SH(lmName, shName, index) half3 shName : TEXCOORD##index
|
||||
#define OUTPUT_LIGHTMAP_UV(lightmapUV, lightmapScaleOffset, OUT)
|
||||
#define OUTPUT_SH(normalWS, OUT) OUT.xyz = SampleSHVertex(normalWS)
|
||||
#endif
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
full3 positionOS : POSITION;
|
||||
half3 normalOS : NORMAL;
|
||||
half4 tangentOS : TANGENT;
|
||||
half4 color : COLOR;
|
||||
full2 uv : TEXCOORD0; // The base map and detail map use the same UVs
|
||||
full2 lightmapUV : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
full4 positionCS : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
full4 uv : TEXCOORD0; // xy: baseUV, zw: detailUV
|
||||
full3 positionOS : TEXCOORD2;
|
||||
full3 positionWS : TEXCOORD3;
|
||||
full3 positionVS : TEXCOORD4;
|
||||
full3 normalWS : TEXCOORD5;
|
||||
half4 tangentWS : TEXCOORD6;
|
||||
half3 bitangentWS : TEXCOORD7;
|
||||
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 8);
|
||||
half fogFactor : TEXCOORD9; // x: fogFactor, yzw: vertex light
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
Varyings mVaryings;
|
||||
|
||||
#include "Includes/Features/Surface/Data/TBN.hlsl"
|
||||
#include "Includes/Features/Surface/Data/ViewData.hlsl"
|
||||
#include "Includes/Features/Surface/Data/UV.hlsl"
|
||||
#include "Includes/Features/Surface/Maps/BaseMap.hlsl"
|
||||
#include "Includes/Features/Surface/Maps/HeightMap.hlsl"
|
||||
#include "Includes/Features/Surface/Maps/NormalMap.hlsl"
|
||||
#include "Includes/Features/Surface/Maps/MaskMap.hlsl"
|
||||
#include "Includes/Features/Surface/Maps/DetailMap.hlsl"
|
||||
#include "Includes/Features/Lighting/Lighting.hlsl"
|
||||
#include "Includes/Features/Effects/Emission.hlsl"
|
||||
#include "Includes/Features/Effects/Rim.hlsl"
|
||||
#include "Includes/Features/Effects/MatCap.hlsl"
|
||||
#include "Includes/Features/Effects/Outline.hlsl"
|
||||
#include "Includes/Features/Misc/DebugColors.hlsl"
|
||||
|
||||
Varyings VertexForwardLit(Attributes input)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
// ApplyOutline(input);
|
||||
|
||||
Varyings output = (Varyings)0;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS);
|
||||
|
||||
output.color = input.color;
|
||||
|
||||
// xy: baseUV, zw: detailUV
|
||||
output.uv.xy = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
output.uv.zw = TRANSFORM_TEX(input.uv, _DetailAlbedoMap);
|
||||
|
||||
output.positionOS = input.positionOS;
|
||||
output.positionWS = TransformObjectToWorld(input.positionOS);
|
||||
output.positionVS = TransformWorldToView(output.positionWS);
|
||||
|
||||
output.normalWS = TransformObjectToWorldNormal(input.normalOS);
|
||||
output.tangentWS.xyz = TransformObjectToWorldDir(input.tangentOS.xyz);
|
||||
output.tangentWS.w = input.tangentOS.w * unity_WorldTransformParams.w; // tangentSign
|
||||
output.bitangentWS = cross(output.normalWS, output.tangentWS.xyz) * output.tangentWS.w;
|
||||
// output.bitangentWS = cross(output.normalWS, output.tangentWS);
|
||||
|
||||
OUTPUT_LIGHTMAP_UV(input.lightmapUV, unity_LightmapST, output.lightmapUV);
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
|
||||
output.fogFactor = ComputeFogFactor(output.positionCS.z);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 FragmentForwardLit(Varyings input, half facing : VFACE) : SV_Target
|
||||
{
|
||||
ApplyLODCrossFade(input.positionCS.xy);
|
||||
|
||||
mVaryings = input;
|
||||
// return half4(mVaryings.normalWS, 1);
|
||||
|
||||
// #if UNITY_VERSION < 600000
|
||||
mVaryings.normalWS *= facing;
|
||||
// #endif
|
||||
|
||||
SetupTBN();
|
||||
SetupViewData();
|
||||
SetupUV();
|
||||
SetupHeightMap(); // use view dirs, adjust uv
|
||||
SetupBaseMap(); // use uv
|
||||
|
||||
#if _ALPHATEST_ON
|
||||
{
|
||||
clip(mAlpha - _Cutoff);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _SURFACE_TYPE_OPAQUE
|
||||
{
|
||||
mAlpha = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
SetupMaskMap(); // use uv
|
||||
SetupNormalMap(); // use uv, tbn
|
||||
SetupDetailMap(); // adjust basemap & normalmap
|
||||
|
||||
half3 lightingColor = GetLightingColor();
|
||||
half3 effectColor = GetEmission() + GetRim();
|
||||
// return half4(effectColor, 1);
|
||||
|
||||
half3 lightingColorBlendMatCap = BlendMatCap(lightingColor);
|
||||
half4 finalColor = half4(lightingColorBlendMatCap + effectColor, mAlpha);
|
||||
|
||||
#if _OUTLINE_ON
|
||||
{
|
||||
finalColor = _OutlineColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
finalColor.rgb = MixFog(finalColor.rgb, mVaryings.fogFactor);
|
||||
|
||||
#if _DEBUG_COLORS_ON
|
||||
{
|
||||
finalColor = GetDebugColor(finalColor);
|
||||
}
|
||||
#endif
|
||||
|
||||
finalColor.rgb = TryLinearToGamma(finalColor.rgb);
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96ab640cff82edc4badf6a98f62f159e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Passes/ForwardPass.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
Varyings mVaryings;
|
||||
|
||||
#include "Includes/Common/Input.hlsl"
|
||||
#include "Includes/Utils/MathUtils.hlsl"
|
||||
#include "Includes/Utils/ColorSpaceUtils.hlsl"
|
||||
#include "Includes/Features/Surface/Data/UV.hlsl"
|
||||
#include "Includes/Features/Surface/Maps/BaseMap.hlsl"
|
||||
#include "Includes/Features/Surface/Maps/MaskMap.hlsl"
|
||||
#include "Includes/Features/Effects/Emission.hlsl"
|
||||
|
||||
Varyings VertexMeta(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = MetaVertexPosition(input.positionOS, input.uv1, input.uv2, unity_LightmapST, unity_DynamicLightmapST);
|
||||
output.uv.xy = TRANSFORM_TEX(input.uv0, _BaseMap);
|
||||
output.uv.zw = input.uv0.zw;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 FragmentMeta(Varyings input) : SV_Target
|
||||
{
|
||||
mVaryings = input;
|
||||
|
||||
SetupUV();
|
||||
SetupBaseMap();
|
||||
SetupMaskMap();
|
||||
|
||||
float2 uv = input.uv;
|
||||
MetaInput metaInput = (MetaInput)0;
|
||||
metaInput.Albedo = _BaseColor.rgb * tex2D(_BaseMap, uv).rgb;
|
||||
// metaInput.SpecularColor = SampleSpecularSmoothness(uv, 1.0h, _DirectSpecularColor, tex2D(_MaskTEXTURE2D_ARGS(_SpecGlossMap, sampler_SpecGlossMap)).xyz;
|
||||
metaInput.Emission = GetEmission();
|
||||
|
||||
return MetaFragment(metaInput);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4284bd79b4a9c7648ada529c1b447a84
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Passes/MetaPass.hlsl
|
||||
uploadId: 820558
|
||||
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
|
||||
|
||||
#include "Includes/Common/Input.hlsl"
|
||||
|
||||
// Cutout and transparent objects need an Alpha value; enable this define to get Alpha value
|
||||
#if defined(_ALPHATEST_ON) || defined(_SURFACE_TYPE_TRANSPARENT)
|
||||
#define ALPHA 1
|
||||
#endif
|
||||
|
||||
// Whether to use dither mask to sparsify transparent areas of ShadowMap; when generating screen space ShadowMap, invert to calculate transparent results
|
||||
// UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS is determined by TierSettings.semitransparentShadows
|
||||
#if defined(_SURFACE_TYPE_TRANSPARENT) && defined(UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS)
|
||||
#define USE_DITHER_MASK 1
|
||||
#endif
|
||||
|
||||
sampler3D _DitherMaskLOD;
|
||||
full3 _LightDirection;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
full4 positionOS : POSITION;
|
||||
half3 normalOS : NORMAL;
|
||||
half4 tangentOS : TANGENT;
|
||||
full2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
full4 positionCS : SV_POSITION;
|
||||
full2 uv : TEXCOORD0; // Transparent shadows need to sample main texture data, so UV is required
|
||||
};
|
||||
|
||||
full4 GetShadowPositionHClip(Attributes input)
|
||||
{
|
||||
full3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
|
||||
full3 normalWS = TransformObjectToWorldNormal(input.normalOS);
|
||||
|
||||
full4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
|
||||
|
||||
#if UNITY_REVERSED_Z
|
||||
{
|
||||
positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
|
||||
}
|
||||
#else
|
||||
{
|
||||
positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
return positionCS;
|
||||
}
|
||||
|
||||
void VertexShadowCaster(Attributes input, out Varyings output)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
output.positionCS = GetShadowPositionHClip(input);
|
||||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
}
|
||||
|
||||
half4 FragmentShadowCaster(Varyings input) : SV_Target
|
||||
{
|
||||
ApplyLODCrossFade(input.positionCS.xy);
|
||||
|
||||
#if defined(ALPHA)
|
||||
{
|
||||
half alpha = tex2D(_BaseMap, input.uv).a * _BaseColor.a;
|
||||
|
||||
// Cutout is simple; discard pixels outside threshold
|
||||
#if defined(_ALPHATEST_ON)
|
||||
clip (alpha - _Cutoff);
|
||||
#endif
|
||||
|
||||
// Fade or Transparent
|
||||
#if defined(_SURFACE_TYPE_TRANSPARENT)
|
||||
{
|
||||
#if defined(USE_DITHER_MASK)
|
||||
{
|
||||
// Apply dither sparsification
|
||||
// Use dither mask for alpha blended shadows, based on pixel position xy and alpha level.
|
||||
// Our dither texture is 4x4x16.
|
||||
half3 vpos = input.positionCS.xyz / input.positionCS.w;
|
||||
half alphaRef = tex3D(_DitherMaskLOD, half3(vpos.xy * 0.25, alpha * 0.9375)).a;
|
||||
clip(alphaRef - 0.01);
|
||||
}
|
||||
#else
|
||||
{
|
||||
// Without dithering, it's similar to Cutout
|
||||
clip(alpha - _Cutoff);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b66f6ca53af70934080da6d65fb09678
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 328765
|
||||
packageName: LitPlus - URP Enhanced Lit Shader
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Passes/ShadowCasterPass.hlsl
|
||||
uploadId: 820558
|
||||
Reference in New Issue
Block a user