initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e674d0c2643d94245b5da6cc11dfe0ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b1e0c8a42c5ad194389231f7780e158d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
#ifndef COMBINED_SHAPE_LIGHT_PASS
|
||||
#define COMBINED_SHAPE_LIGHT_PASS
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
|
||||
|
||||
half _HDREmulationScale;
|
||||
half _UseSceneLighting;
|
||||
half4 _RendererColor;
|
||||
|
||||
half4 CombinedShapeLightShared(in SurfaceData2D surfaceData, in InputData2D inputData)
|
||||
{
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
half4 debugColor = 0;
|
||||
|
||||
if (CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
|
||||
{
|
||||
return debugColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
half alpha = surfaceData.alpha;
|
||||
half4 color = half4(surfaceData.albedo, alpha);
|
||||
const half4 mask = surfaceData.mask;
|
||||
const half2 lightingUV = inputData.lightingUV;
|
||||
|
||||
if (alpha == 0.0)
|
||||
discard;
|
||||
|
||||
color = color * _RendererColor; // This is needed for sprite shape
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_0
|
||||
half4 shapeLight0 = SAMPLE_TEXTURE2D(_ShapeLightTexture0, sampler_ShapeLightTexture0, lightingUV);
|
||||
|
||||
if (any(_ShapeLightMaskFilter0))
|
||||
{
|
||||
half4 processedMask = (1 - _ShapeLightInvertedFilter0) * mask + _ShapeLightInvertedFilter0 * (1 - mask);
|
||||
shapeLight0 *= dot(processedMask, _ShapeLightMaskFilter0);
|
||||
}
|
||||
|
||||
half4 shapeLight0Modulate = shapeLight0 * _ShapeLightBlendFactors0.x;
|
||||
half4 shapeLight0Additive = shapeLight0 * _ShapeLightBlendFactors0.y;
|
||||
#else
|
||||
half4 shapeLight0Modulate = 0;
|
||||
half4 shapeLight0Additive = 0;
|
||||
#endif
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_1
|
||||
half4 shapeLight1 = SAMPLE_TEXTURE2D(_ShapeLightTexture1, sampler_ShapeLightTexture1, lightingUV);
|
||||
|
||||
if (any(_ShapeLightMaskFilter1))
|
||||
{
|
||||
half4 processedMask = (1 - _ShapeLightInvertedFilter1) * mask + _ShapeLightInvertedFilter1 * (1 - mask);
|
||||
shapeLight1 *= dot(processedMask, _ShapeLightMaskFilter1);
|
||||
}
|
||||
|
||||
half4 shapeLight1Modulate = shapeLight1 * _ShapeLightBlendFactors1.x;
|
||||
half4 shapeLight1Additive = shapeLight1 * _ShapeLightBlendFactors1.y;
|
||||
#else
|
||||
half4 shapeLight1Modulate = 0;
|
||||
half4 shapeLight1Additive = 0;
|
||||
#endif
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_2
|
||||
half4 shapeLight2 = SAMPLE_TEXTURE2D(_ShapeLightTexture2, sampler_ShapeLightTexture2, lightingUV);
|
||||
|
||||
if (any(_ShapeLightMaskFilter2))
|
||||
{
|
||||
half4 processedMask = (1 - _ShapeLightInvertedFilter2) * mask + _ShapeLightInvertedFilter2 * (1 - mask);
|
||||
shapeLight2 *= dot(processedMask, _ShapeLightMaskFilter2);
|
||||
}
|
||||
|
||||
half4 shapeLight2Modulate = shapeLight2 * _ShapeLightBlendFactors2.x;
|
||||
half4 shapeLight2Additive = shapeLight2 * _ShapeLightBlendFactors2.y;
|
||||
#else
|
||||
half4 shapeLight2Modulate = 0;
|
||||
half4 shapeLight2Additive = 0;
|
||||
#endif
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_3
|
||||
half4 shapeLight3 = SAMPLE_TEXTURE2D(_ShapeLightTexture3, sampler_ShapeLightTexture3, lightingUV);
|
||||
|
||||
if (any(_ShapeLightMaskFilter3))
|
||||
{
|
||||
half4 processedMask = (1 - _ShapeLightInvertedFilter3) * mask + _ShapeLightInvertedFilter3 * (1 - mask);
|
||||
shapeLight3 *= dot(processedMask, _ShapeLightMaskFilter3);
|
||||
}
|
||||
|
||||
half4 shapeLight3Modulate = shapeLight3 * _ShapeLightBlendFactors3.x;
|
||||
half4 shapeLight3Additive = shapeLight3 * _ShapeLightBlendFactors3.y;
|
||||
#else
|
||||
half4 shapeLight3Modulate = 0;
|
||||
half4 shapeLight3Additive = 0;
|
||||
#endif
|
||||
|
||||
half4 finalOutput;
|
||||
#if !USE_SHAPE_LIGHT_TYPE_0 && !USE_SHAPE_LIGHT_TYPE_1 && !USE_SHAPE_LIGHT_TYPE_2 && ! USE_SHAPE_LIGHT_TYPE_3
|
||||
finalOutput = color;
|
||||
#else
|
||||
half4 finalModulate = shapeLight0Modulate + shapeLight1Modulate + shapeLight2Modulate + shapeLight3Modulate;
|
||||
half4 finalAdditve = shapeLight0Additive + shapeLight1Additive + shapeLight2Additive + shapeLight3Additive;
|
||||
finalOutput = _HDREmulationScale * (color * finalModulate + finalAdditve);
|
||||
#endif
|
||||
|
||||
finalOutput.a = alpha;
|
||||
finalOutput = lerp(color, finalOutput, _UseSceneLighting);
|
||||
|
||||
return max(0, finalOutput);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e7ee44e4db2311b428e6f789318838f8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
#ifndef INPUT_DATA_2D_INCLUDED
|
||||
#define INPUT_DATA_2D_INCLUDED
|
||||
|
||||
struct InputData2D
|
||||
{
|
||||
float2 uv;
|
||||
half2 lightingUV;
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
float3 positionWS;
|
||||
float4 texelSize;
|
||||
float4 mipInfo;
|
||||
uint mipCount;
|
||||
#endif
|
||||
};
|
||||
|
||||
void InitializeInputData(float2 uv, half2 lightingUV, out InputData2D inputData)
|
||||
{
|
||||
inputData = (InputData2D)0;
|
||||
|
||||
inputData.uv = uv;
|
||||
inputData.lightingUV = lightingUV;
|
||||
}
|
||||
|
||||
void InitializeInputData(float2 uv, out InputData2D inputData)
|
||||
{
|
||||
InitializeInputData(uv, 0, inputData);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 15c09e9f82634f5881e6676d62f25bcb
|
||||
timeCreated: 1614177501
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
#if USE_NORMAL_MAP
|
||||
#if LIGHT_QUALITY_FAST
|
||||
#define NORMALS_LIGHTING_COORDS(TEXCOORDA, TEXCOORDB) \
|
||||
half4 lightDirection : TEXCOORDA;\
|
||||
half2 screenUV : TEXCOORDB;
|
||||
|
||||
#define TRANSFER_NORMALS_LIGHTING(output, worldSpacePos)\
|
||||
output.screenUV = ComputeNormalizedDeviceCoordinates(output.positionCS.xyz / output.positionCS.w);\
|
||||
half3 planeNormal = -GetViewForwardDir();\
|
||||
half3 projLightPos = _LightPosition.xyz - (dot(_LightPosition.xyz - worldSpacePos.xyz, planeNormal) - _LightZDistance) * planeNormal;\
|
||||
output.lightDirection.xyz = normalize(projLightPos - worldSpacePos.xyz);\
|
||||
output.lightDirection.w = 0;
|
||||
|
||||
#define APPLY_NORMALS_LIGHTING(input, lightColor)\
|
||||
half4 normal = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, input.screenUV);\
|
||||
half3 normalUnpacked = UnpackNormalRGBNoScale(normal);\
|
||||
lightColor = lightColor * saturate(dot(input.lightDirection.xyz, normalUnpacked));
|
||||
#else
|
||||
#define NORMALS_LIGHTING_COORDS(TEXCOORDA, TEXCOORDB) \
|
||||
half4 positionWS : TEXCOORDA;\
|
||||
half2 screenUV : TEXCOORDB;
|
||||
|
||||
#define TRANSFER_NORMALS_LIGHTING(output, worldSpacePos) \
|
||||
output.screenUV = ComputeNormalizedDeviceCoordinates(output.positionCS.xyz / output.positionCS.w); \
|
||||
output.positionWS = worldSpacePos;
|
||||
|
||||
#define APPLY_NORMALS_LIGHTING(input, lightColor)\
|
||||
half4 normal = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, input.screenUV);\
|
||||
half3 normalUnpacked = UnpackNormalRGBNoScale(normal);\
|
||||
half3 planeNormal = -GetViewForwardDir();\
|
||||
half3 projLightPos = _LightPosition.xyz - (dot(_LightPosition.xyz - input.positionWS.xyz, planeNormal) - _LightZDistance) * planeNormal;\
|
||||
half3 dirToLight = normalize(projLightPos - input.positionWS.xyz);\
|
||||
lightColor = lightColor * saturate(dot(dirToLight, normalUnpacked));
|
||||
#endif
|
||||
|
||||
#define NORMALS_LIGHTING_VARIABLES \
|
||||
TEXTURE2D(_NormalMap); \
|
||||
SAMPLER(sampler_NormalMap); \
|
||||
half4 _LightPosition;\
|
||||
half _LightZDistance;
|
||||
#else
|
||||
#define NORMALS_LIGHTING_COORDS(TEXCOORDA, TEXCOORDB)
|
||||
#define NORMALS_LIGHTING_VARIABLES
|
||||
#define TRANSFER_NORMALS_LIGHTING(output, worldSpacePos)
|
||||
#define APPLY_NORMALS_LIGHTING(input, lightColor)
|
||||
#endif
|
||||
|
||||
#define SHADOW_COORDS(TEXCOORDA)\
|
||||
float2 shadowUV : TEXCOORDA;
|
||||
|
||||
#define SHADOW_VARIABLES\
|
||||
float _ShadowIntensity;\
|
||||
float _ShadowVolumeIntensity;\
|
||||
half4 _ShadowColorMask = 1;\
|
||||
TEXTURE2D(_ShadowTex);\
|
||||
SAMPLER(sampler_ShadowTex);
|
||||
|
||||
//#define APPLY_SHADOWS(input, color, intensity)\
|
||||
// if(intensity < 1)\
|
||||
// {\
|
||||
// half4 shadow = saturate(SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.shadowUV)); \
|
||||
// half shadowIntensity = 1 - (shadow.r * saturate(2 * (shadow.g - 0.5f * shadow.b))); \
|
||||
// color.rgb = (color.rgb * shadowIntensity) + (color.rgb * intensity*(1 - shadowIntensity));\
|
||||
// }
|
||||
|
||||
//half shadowIntensity = 1-dot(_ShadowColorMask, shadow); \
|
||||
//color.rgb = (color.rgb * shadowIntensity) + (color.rgb * intensity*(1 - shadowIntensity));\
|
||||
|
||||
// Need to look at shadow caster to remove issue with shadows
|
||||
#define APPLY_SHADOWS(input, color, intensity)\
|
||||
if(intensity < 1)\
|
||||
{\
|
||||
half4 shadow = saturate(SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.shadowUV)); \
|
||||
half shadowIntensity = 1-dot(_ShadowColorMask, shadow.rgba) ; \
|
||||
color.rgb = (color.rgb * shadowIntensity) + (color.rgb * intensity*(1 - shadowIntensity));\
|
||||
}
|
||||
|
||||
#define TRANSFER_SHADOWS(output)\
|
||||
output.shadowUV = ComputeNormalizedDeviceCoordinates(output.positionCS.xyz / output.positionCS.w);
|
||||
|
||||
#define SHAPE_LIGHT(index)\
|
||||
TEXTURE2D(_ShapeLightTexture##index);\
|
||||
SAMPLER(sampler_ShapeLightTexture##index);\
|
||||
half2 _ShapeLightBlendFactors##index;\
|
||||
half4 _ShapeLightMaskFilter##index;\
|
||||
half4 _ShapeLightInvertedFilter##index;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 931e5ffca47cea54783e99bf989216b5
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#if !defined(NORMALS_RENDERING_PASS)
|
||||
#define NORMALS_RENDERING_PASS
|
||||
|
||||
half4 NormalsRenderingShared(half4 color, half3 normalTS, half3 tangent, half3 bitangent, half3 normal)
|
||||
{
|
||||
half4 normalColor;
|
||||
half3 normalWS = TransformTangentToWorld(normalTS, half3x3(tangent.xyz, bitangent.xyz, normal.xyz));
|
||||
|
||||
normalColor.rgb = 0.5 * ((normalWS)+1);
|
||||
normalColor.a = color.a; // used for blending
|
||||
|
||||
return normalColor;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b9c3f97797bd9374cb2607614554fe54
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#if !defined(SHADOW_PROJECT_VERTEX)
|
||||
#define SHADOW_PROJECT_VERTEX
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 vertex : POSITION;
|
||||
float4 tangent: TANGENT;
|
||||
float4 extrusion : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
uniform float3 _LightPos;
|
||||
uniform float4x4 _ShadowModelMatrix; // This is a custom model matrix without scaling
|
||||
uniform float4x4 _ShadowModelInvMatrix;
|
||||
uniform float3 _ShadowModelScale; // This is the scale
|
||||
uniform float _ShadowRadius;
|
||||
|
||||
Varyings ProjectShadow(Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
|
||||
float3 vertexWS = TransformObjectToWorld(v.vertex); // This should be in world space
|
||||
float3 lightDir = _LightPos - vertexWS;
|
||||
lightDir.z = 0;
|
||||
|
||||
// Start of code to see if this point should be extruded
|
||||
float3 lightDirection = normalize(lightDir);
|
||||
|
||||
|
||||
float adjShadowRadius = 1.4143 * _ShadowRadius; // Needed as our shadow fits like a circumscribed box around our light radius
|
||||
float3 endpoint = vertexWS + (adjShadowRadius * -lightDirection);
|
||||
|
||||
float3 worldTangent = TransformObjectToWorldDir(v.tangent.xyz);
|
||||
float sharedShadowTest = saturate(ceil(dot(lightDirection, worldTangent)));
|
||||
|
||||
// Start of code to calculate offset
|
||||
float3 vertexWS0 = TransformObjectToWorld(float3(v.extrusion.xy, 0));
|
||||
float3 vertexWS1 = TransformObjectToWorld(float3(v.extrusion.zw, 0));
|
||||
float3 shadowDir0 = vertexWS0 - _LightPos;
|
||||
shadowDir0.z = 0;
|
||||
shadowDir0 = normalize(shadowDir0);
|
||||
|
||||
float3 shadowDir1 = vertexWS1 - _LightPos;
|
||||
shadowDir1.z = 0;
|
||||
shadowDir1 = normalize(shadowDir1);
|
||||
|
||||
float3 shadowDir = normalize(shadowDir0 + shadowDir1);
|
||||
|
||||
|
||||
float3 sharedShadowOffset = sharedShadowTest * adjShadowRadius * shadowDir;
|
||||
|
||||
float3 position;
|
||||
position = vertexWS + sharedShadowOffset;
|
||||
|
||||
o.vertex = TransformWorldToHClip(position);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 97832dc646b4fb4498bf5aa61e366c13
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
#if !defined(SPRITE_MASK_SHARED)
|
||||
#define SPRITE_MASK_SHARED
|
||||
|
||||
|
||||
// alpha below which a mask should discard a pixel, thereby preventing the stencil buffer from being marked with the Mask's presence
|
||||
half _Cutoff;
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
Varyings MaskRenderingVertex(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = input.texcoord;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 MaskRenderingFragment(Varyings input) : SV_Target
|
||||
{
|
||||
half4 c = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
|
||||
// for masks: discard pixel if alpha falls below MaskingCutoff
|
||||
clip(c.a - _Cutoff);
|
||||
|
||||
return half4(1, 1, 1, 0.2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9ac51d204bc24b118ec6bc5ab6c29c6
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
#ifndef SURFACE_DATA_2D_INCLUDED
|
||||
#define SURFACE_DATA_2D_INCLUDED
|
||||
|
||||
struct SurfaceData2D
|
||||
{
|
||||
half3 albedo;
|
||||
half alpha;
|
||||
half4 mask;
|
||||
half3 normalTS;
|
||||
};
|
||||
|
||||
void InitializeSurfaceData(half3 albedo, half alpha, half4 mask, half3 normalTS, out SurfaceData2D surfaceData)
|
||||
{
|
||||
surfaceData = (SurfaceData2D)0;
|
||||
|
||||
surfaceData.albedo = albedo;
|
||||
surfaceData.alpha = alpha;
|
||||
surfaceData.mask = mask;
|
||||
surfaceData.normalTS = normalTS;
|
||||
}
|
||||
|
||||
void InitializeSurfaceData(half3 albedo, half alpha, half4 mask, out SurfaceData2D surfaceData)
|
||||
{
|
||||
const half3 normalTS = half3(0, 0, 1);
|
||||
|
||||
InitializeSurfaceData(albedo, alpha, mask, normalTS, surfaceData);
|
||||
}
|
||||
|
||||
void InitializeSurfaceData(half3 albedo, half alpha, out SurfaceData2D surfaceData)
|
||||
{
|
||||
InitializeSurfaceData(albedo, alpha, 1, surfaceData);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2861459260b14a2481f8f8e7f6637d8f
|
||||
timeCreated: 1614008064
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
Shader "Hidden/Light2d-Point-Volumetric"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend One One
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_local USE_POINT_LIGHT_COOKIES __
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half2 lookupUV : TEXCOORD2; // This is used for light relative direction
|
||||
|
||||
SHADOW_COORDS(TEXCOORD5)
|
||||
};
|
||||
|
||||
#if USE_POINT_LIGHT_COOKIES
|
||||
TEXTURE2D(_PointLightCookieTex);
|
||||
SAMPLER(sampler_PointLightCookieTex);
|
||||
#endif
|
||||
|
||||
TEXTURE2D(_FalloffLookup);
|
||||
SAMPLER(sampler_FalloffLookup);
|
||||
half _FalloffIntensity;
|
||||
|
||||
TEXTURE2D(_LightLookup);
|
||||
SAMPLER(sampler_LightLookup);
|
||||
half4 _LightLookup_TexelSize;
|
||||
|
||||
half4 _LightColor;
|
||||
half _VolumeOpacity;
|
||||
float4 _LightPosition;
|
||||
float4x4 _LightInvMatrix;
|
||||
float4x4 _LightNoRotInvMatrix;
|
||||
half _LightZDistance;
|
||||
half _OuterAngle; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
|
||||
half _InnerAngleMult; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
|
||||
half _InnerRadiusMult; // 1-0 where 1 is the value at the center and 0 is the value at the outer radius
|
||||
half _InverseHDREmulationScale;
|
||||
half _IsFullSpotlight;
|
||||
|
||||
SHADOW_VARIABLES
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS);
|
||||
output.uv = input.texcoord;
|
||||
|
||||
float4 worldSpacePos;
|
||||
worldSpacePos.xyz = TransformObjectToWorld(input.positionOS);
|
||||
worldSpacePos.w = 1;
|
||||
|
||||
float4 lightSpacePos = mul(_LightInvMatrix, worldSpacePos);
|
||||
float4 lightSpaceNoRotPos = mul(_LightNoRotInvMatrix, worldSpacePos);
|
||||
float halfTexelOffset = 0.5 * _LightLookup_TexelSize.x;
|
||||
output.lookupUV = 0.5 * (lightSpacePos.xy + 1) + halfTexelOffset;
|
||||
|
||||
TRANSFER_SHADOWS(output)
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
half4 lookupValue = SAMPLE_TEXTURE2D(_LightLookup, sampler_LightLookup, input.lookupUV); // r = distance, g = angle, b = x direction, a = y direction
|
||||
|
||||
// Inner Radius
|
||||
half attenuation = saturate(_InnerRadiusMult * lookupValue.r); // This is the code to take care of our inner radius
|
||||
|
||||
// Spotlight
|
||||
half spotAttenuation = saturate((_OuterAngle - lookupValue.g + _IsFullSpotlight) * _InnerAngleMult);
|
||||
attenuation = attenuation * spotAttenuation;
|
||||
|
||||
half2 mappedUV;
|
||||
mappedUV.x = attenuation;
|
||||
mappedUV.y = _FalloffIntensity;
|
||||
attenuation = SAMPLE_TEXTURE2D(_FalloffLookup, sampler_FalloffLookup, mappedUV).r;
|
||||
|
||||
#if USE_POINT_LIGHT_COOKIES
|
||||
half4 cookieColor = SAMPLE_TEXTURE2D(_PointLightCookieTex, sampler_PointLightCookieTex, input.lookupUV);
|
||||
half4 lightColor = cookieColor * _LightColor * attenuation;
|
||||
#else
|
||||
half4 lightColor = _LightColor * attenuation;
|
||||
#endif
|
||||
|
||||
APPLY_SHADOWS(input, lightColor, _ShadowVolumeIntensity);
|
||||
|
||||
return _VolumeOpacity * lightColor * _InverseHDREmulationScale;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c7d04ca57e5449d49ad9cee1c604bc26
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
Shader "Hidden/Light2D-Point"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlend][_DstBlend]
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_local USE_POINT_LIGHT_COOKIES __
|
||||
#pragma multi_compile_local LIGHT_QUALITY_FAST __
|
||||
#pragma multi_compile_local USE_NORMAL_MAP __
|
||||
#pragma multi_compile_local USE_ADDITIVE_BLENDING __
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half2 lookupUV : TEXCOORD2; // This is used for light relative direction
|
||||
|
||||
NORMALS_LIGHTING_COORDS(TEXCOORD4, TEXCOORD5)
|
||||
SHADOW_COORDS(TEXCOORD6)
|
||||
};
|
||||
|
||||
#if USE_POINT_LIGHT_COOKIES
|
||||
TEXTURE2D(_PointLightCookieTex);
|
||||
SAMPLER(sampler_PointLightCookieTex);
|
||||
#endif
|
||||
|
||||
TEXTURE2D(_FalloffLookup);
|
||||
SAMPLER(sampler_FalloffLookup);
|
||||
half _FalloffIntensity;
|
||||
|
||||
TEXTURE2D(_LightLookup);
|
||||
SAMPLER(sampler_LightLookup);
|
||||
half4 _LightLookup_TexelSize;
|
||||
|
||||
NORMALS_LIGHTING_VARIABLES
|
||||
SHADOW_VARIABLES
|
||||
|
||||
half4 _LightColor;
|
||||
float4x4 _LightInvMatrix;
|
||||
float4x4 _LightNoRotInvMatrix;
|
||||
half _OuterAngle; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
|
||||
half _InnerAngleMult; // 1-0 where 1 is the value at 0 degrees and 1 is the value at 180 degrees
|
||||
half _InnerRadiusMult; // 1-0 where 1 is the value at the center and 0 is the value at the outer radius
|
||||
half _InverseHDREmulationScale;
|
||||
half _IsFullSpotlight;
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS);
|
||||
output.uv = input.texcoord;
|
||||
|
||||
float4 worldSpacePos;
|
||||
worldSpacePos.xyz = TransformObjectToWorld(input.positionOS);
|
||||
worldSpacePos.w = 1;
|
||||
|
||||
float4 lightSpacePos = mul(_LightInvMatrix, worldSpacePos);
|
||||
float4 lightSpaceNoRotPos = mul(_LightNoRotInvMatrix, worldSpacePos);
|
||||
float halfTexelOffset = 0.5 * _LightLookup_TexelSize.x;
|
||||
output.lookupUV = 0.5 * (lightSpacePos.xy + 1) + halfTexelOffset;
|
||||
|
||||
TRANSFER_NORMALS_LIGHTING(output, worldSpacePos)
|
||||
TRANSFER_SHADOWS(output)
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
half4 lookupValue = SAMPLE_TEXTURE2D(_LightLookup, sampler_LightLookup, input.lookupUV); // r = distance, g = angle, b = x direction, a = y direction
|
||||
|
||||
// Inner Radius
|
||||
half attenuation = saturate(_InnerRadiusMult * lookupValue.r); // This is the code to take care of our inner radius
|
||||
|
||||
// Spotlight
|
||||
half spotAttenuation = saturate((_OuterAngle - lookupValue.g + _IsFullSpotlight) * _InnerAngleMult);
|
||||
attenuation = attenuation * spotAttenuation;
|
||||
|
||||
half2 mappedUV;
|
||||
mappedUV.x = attenuation;
|
||||
mappedUV.y = _FalloffIntensity;
|
||||
attenuation = SAMPLE_TEXTURE2D(_FalloffLookup, sampler_FalloffLookup, mappedUV).r;
|
||||
|
||||
#if USE_POINT_LIGHT_COOKIES
|
||||
half4 cookieColor = SAMPLE_TEXTURE2D(_PointLightCookieTex, sampler_PointLightCookieTex, input.lookupUV);
|
||||
half4 lightColor = cookieColor * _LightColor;
|
||||
#else
|
||||
half4 lightColor = _LightColor;
|
||||
#endif
|
||||
|
||||
#if USE_ADDITIVE_BLENDING
|
||||
lightColor *= attenuation;
|
||||
#else
|
||||
lightColor.a = attenuation;
|
||||
#endif
|
||||
|
||||
APPLY_NORMALS_LIGHTING(input, lightColor);
|
||||
APPLY_SHADOWS(input, lightColor, _ShadowIntensity);
|
||||
|
||||
return lightColor * _InverseHDREmulationScale;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e35a31e1679aeff489e202f5cc4853d5
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
Shader "Hidden/Light2D-Shape-Volumetric"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha One
|
||||
ZWrite Off
|
||||
ZTest Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_local SPRITE_LIGHT __
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
half2 uv : TEXCOORD0;
|
||||
|
||||
SHADOW_COORDS(TEXCOORD1)
|
||||
};
|
||||
|
||||
half4 _LightColor;
|
||||
half _FalloffDistance;
|
||||
half _VolumeOpacity;
|
||||
half _InverseHDREmulationScale;
|
||||
|
||||
#ifdef SPRITE_LIGHT
|
||||
TEXTURE2D(_CookieTex); // This can either be a sprite texture uv or a falloff texture
|
||||
SAMPLER(sampler_CookieTex);
|
||||
#else
|
||||
uniform half _FalloffIntensity;
|
||||
TEXTURE2D(_FalloffLookup);
|
||||
SAMPLER(sampler_FalloffLookup);
|
||||
#endif
|
||||
|
||||
SHADOW_VARIABLES
|
||||
|
||||
Varyings vert(Attributes attributes)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
|
||||
float3 positionOS = attributes.positionOS;
|
||||
|
||||
positionOS.x = positionOS.x + _FalloffDistance * attributes.color.r;
|
||||
positionOS.y = positionOS.y + _FalloffDistance * attributes.color.g;
|
||||
|
||||
o.positionCS = TransformObjectToHClip(positionOS);
|
||||
o.color = _LightColor * _InverseHDREmulationScale;
|
||||
o.color.a = _LightColor.a * _VolumeOpacity;
|
||||
|
||||
#ifdef SPRITE_LIGHT
|
||||
o.uv = attributes.uv;
|
||||
#else
|
||||
o.uv = float2(attributes.color.a, _FalloffIntensity);
|
||||
#endif
|
||||
TRANSFER_SHADOWS(o)
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(Varyings i) : SV_Target
|
||||
{
|
||||
half4 color = i.color;
|
||||
|
||||
#if SPRITE_LIGHT
|
||||
color *= SAMPLE_TEXTURE2D(_CookieTex, sampler_CookieTex, i.uv);
|
||||
#else
|
||||
color.a = i.color.a * SAMPLE_TEXTURE2D(_FalloffLookup, sampler_FalloffLookup, i.uv).r;
|
||||
#endif
|
||||
|
||||
APPLY_SHADOWS(i, color, _ShadowVolumeIntensity);
|
||||
|
||||
return color;
|
||||
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7e60080c8cd24a2468cb08b4bfee5606
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
Shader "Hidden/Light2D-Shape"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_local SPRITE_LIGHT __
|
||||
#pragma multi_compile_local USE_NORMAL_MAP __
|
||||
#pragma multi_compile_local USE_ADDITIVE_BLENDING __
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
half2 uv : TEXCOORD0;
|
||||
|
||||
SHADOW_COORDS(TEXCOORD1)
|
||||
NORMALS_LIGHTING_COORDS(TEXCOORD2, TEXCOORD3)
|
||||
};
|
||||
|
||||
half _InverseHDREmulationScale;
|
||||
half4 _LightColor;
|
||||
half _FalloffDistance;
|
||||
|
||||
#ifdef SPRITE_LIGHT
|
||||
TEXTURE2D(_CookieTex); // This can either be a sprite texture uv or a falloff texture
|
||||
SAMPLER(sampler_CookieTex);
|
||||
#else
|
||||
half _FalloffIntensity;
|
||||
TEXTURE2D(_FalloffLookup);
|
||||
SAMPLER(sampler_FalloffLookup);
|
||||
#endif
|
||||
NORMALS_LIGHTING_VARIABLES
|
||||
SHADOW_VARIABLES
|
||||
|
||||
Varyings vert(Attributes attributes)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
|
||||
float3 positionOS = attributes.positionOS;
|
||||
|
||||
positionOS.x = positionOS.x + _FalloffDistance * attributes.color.r;
|
||||
positionOS.y = positionOS.y + _FalloffDistance * attributes.color.g;
|
||||
|
||||
o.positionCS = TransformObjectToHClip(positionOS);
|
||||
o.color = _LightColor * _InverseHDREmulationScale;
|
||||
o.color.a = attributes.color.a;
|
||||
|
||||
#ifdef SPRITE_LIGHT
|
||||
o.uv = attributes.uv;
|
||||
#else
|
||||
o.uv = float2(o.color.a, _FalloffIntensity);
|
||||
#endif
|
||||
|
||||
float4 worldSpacePos;
|
||||
worldSpacePos.xyz = TransformObjectToWorld(positionOS);
|
||||
worldSpacePos.w = 1;
|
||||
TRANSFER_NORMALS_LIGHTING(o, worldSpacePos)
|
||||
TRANSFER_SHADOWS(o)
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(Varyings i) : SV_Target
|
||||
{
|
||||
half4 color = i.color;
|
||||
#if SPRITE_LIGHT
|
||||
half4 cookie = SAMPLE_TEXTURE2D(_CookieTex, sampler_CookieTex, i.uv);
|
||||
#if USE_ADDITIVE_BLENDING
|
||||
|
||||
color *= cookie * cookie.a;
|
||||
#else
|
||||
color *= cookie;
|
||||
#endif
|
||||
#else
|
||||
#if USE_ADDITIVE_BLENDING
|
||||
color *= SAMPLE_TEXTURE2D(_FalloffLookup, sampler_FalloffLookup, i.uv).r;
|
||||
#else
|
||||
color.a = SAMPLE_TEXTURE2D(_FalloffLookup, sampler_FalloffLookup, i.uv).r;
|
||||
#endif
|
||||
#endif
|
||||
APPLY_NORMALS_LIGHTING(i, color);
|
||||
APPLY_SHADOWS(i, color, _ShadowIntensity);
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d79e1c784eaf80c4585c0be7391f757a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
Shader "Hidden/ShadowProjected2D"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _ShadowColorMask("__ShadowColorMask", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" }
|
||||
|
||||
Cull Off
|
||||
BlendOp Add
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
// This pass draws the projected shadow and sets the composite shadow bit.
|
||||
Pass
|
||||
{
|
||||
// Bit 0: Composite Shadow Bit, Bit 1: Global Shadow Bit
|
||||
Stencil
|
||||
{
|
||||
Ref 5
|
||||
ReadMask 4
|
||||
WriteMask 1
|
||||
Comp NotEqual
|
||||
Pass Replace
|
||||
Fail Keep
|
||||
}
|
||||
|
||||
ColorMask [_ShadowColorMask]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/ShadowProjectVertex.hlsl"
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
return ProjectShadow(v);
|
||||
}
|
||||
|
||||
half4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
return half4(1,1,1,1);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
// Sets the global shadow bit, and clears the composite shadow bit
|
||||
Pass
|
||||
{
|
||||
// Bit 0: Composite Shadow Bit, Bit 1: Global Shadow Bit
|
||||
Stencil
|
||||
{
|
||||
Ref 3
|
||||
WriteMask 2
|
||||
ReadMask 1
|
||||
Comp Equal
|
||||
Pass Replace
|
||||
Fail Keep
|
||||
}
|
||||
|
||||
// We only want to change the stencil value in this pass
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/ShadowProjectVertex.hlsl"
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
return ProjectShadow(v);
|
||||
}
|
||||
|
||||
half4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
return half4(1,1,1,1);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce09d4a80b88c5a4eb9768fab4f1ee00
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
Shader "Hidden/Shadow2DShadowSprite"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _ShadowColorMask("__ShadowColorMask", Int) = 1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" }
|
||||
|
||||
Cull Off
|
||||
BlendOp Add
|
||||
Blend One One, One One
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
//Bit 0: Composite Shadow Bit, Bit 1: Global Shadow Bit
|
||||
Stencil
|
||||
{
|
||||
Ref 0
|
||||
Comp Equal
|
||||
Pass Keep
|
||||
Fail Keep
|
||||
}
|
||||
|
||||
ColorMask [_ShadowColorMask]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(Varyings i) : SV_Target
|
||||
{
|
||||
half4 main = tex2D(_MainTex, i.uv);
|
||||
half color = main.a;
|
||||
return half4(color, color, color, color);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 44fc62292b65ab04eabcf310e799ccf6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
Shader "Hidden/Shadow2DUnshadowGeometry"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" }
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
//Bit 0: Composite Shadow Bit, Bit 1: Global Shadow Bit, Bit2: Caster Mask Bit
|
||||
Stencil
|
||||
{
|
||||
Ref 4
|
||||
ReadMask 4
|
||||
WriteMask 4
|
||||
Comp NotEqual
|
||||
Pass Replace
|
||||
Fail Keep
|
||||
}
|
||||
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(Varyings i) : SV_Target
|
||||
{
|
||||
return half4(0,0,0,0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
//Bit 0: Composite Shadow Bit, Bit 1: Global Shadow Bit, Bit2: Caster Mask Bit
|
||||
Stencil
|
||||
{
|
||||
Ref 4
|
||||
ReadMask 4
|
||||
WriteMask 4
|
||||
Comp Equal
|
||||
Pass Zero
|
||||
Fail Keep
|
||||
}
|
||||
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
|
||||
Varyings vert(Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(Varyings i) : SV_Target
|
||||
{
|
||||
return half4(0,0,0,0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 77774d9009bb81447b048c907d4c6273
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
Shader "Hidden/Shadow2DUnshadowSprite"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _ShadowColorMask("__ShadowColorMask", Int) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" }
|
||||
|
||||
Cull Off
|
||||
BlendOp Add
|
||||
Blend OneMinusSrcColor SrcColor, OneMinusSrcAlpha SrcAlpha
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
//Bit 0: Composite Shadow Bit, Bit 1: Global Shadow Bit
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp Equal
|
||||
Pass Keep
|
||||
Fail Keep
|
||||
}
|
||||
|
||||
ColorMask [_ShadowColorMask]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(Varyings i) : SV_Target
|
||||
{
|
||||
half4 main = tex2D(_MainTex, i.uv);
|
||||
half color = 1-main.a;
|
||||
return half4(color, color, color, color);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de02b375720b5c445afe83cd483bedf3
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,256 @@
|
|||
Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Diffuse", 2D) = "white" {}
|
||||
_MaskTex("Mask", 2D) = "white" {}
|
||||
_NormalMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
// Legacy properties. They're here so that materials using this shader can gracefully fallback to the legacy sprite shader.
|
||||
[HideInInspector] _Color("Tint", Color) = (1,1,1,1)
|
||||
[HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
|
||||
[HideInInspector] _Flip("Flip", Vector) = (1,1,1,1)
|
||||
[HideInInspector] _AlphaTex("External Alpha", 2D) = "white" {}
|
||||
[HideInInspector] _EnableExternalAlpha("Enable External Alpha", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode" = "Universal2D" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
#pragma vertex CombinedShapeLightVertex
|
||||
#pragma fragment CombinedShapeLightFragment
|
||||
|
||||
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_0 __
|
||||
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_1 __
|
||||
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_2 __
|
||||
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_3 __
|
||||
#pragma multi_compile _ DEBUG_DISPLAY
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
half2 lightingUV : TEXCOORD1;
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
float3 positionWS : TEXCOORD2;
|
||||
#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_MaskTex);
|
||||
SAMPLER(sampler_MaskTex);
|
||||
half4 _MainTex_ST;
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_0
|
||||
SHAPE_LIGHT(0)
|
||||
#endif
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_1
|
||||
SHAPE_LIGHT(1)
|
||||
#endif
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_2
|
||||
SHAPE_LIGHT(2)
|
||||
#endif
|
||||
|
||||
#if USE_SHAPE_LIGHT_TYPE_3
|
||||
SHAPE_LIGHT(3)
|
||||
#endif
|
||||
|
||||
Varyings CombinedShapeLightVertex(Attributes v)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = TransformObjectToHClip(v.positionOS);
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
o.positionWS = TransformObjectToWorld(v.positionOS);
|
||||
#endif
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.lightingUV = half2(ComputeScreenPos(o.positionCS / o.positionCS.w).xy);
|
||||
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/CombinedShapeLightShared.hlsl"
|
||||
|
||||
half4 CombinedShapeLightFragment(Varyings i) : SV_Target
|
||||
{
|
||||
const half4 main = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
const half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv);
|
||||
SurfaceData2D surfaceData;
|
||||
InputData2D inputData;
|
||||
|
||||
InitializeSurfaceData(main.rgb, main.a, mask, surfaceData);
|
||||
InitializeInputData(i.uv, i.lightingUV, inputData);
|
||||
|
||||
return CombinedShapeLightShared(surfaceData, inputData);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode" = "NormalsRendering"}
|
||||
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
#pragma vertex NormalsRenderingVertex
|
||||
#pragma fragment NormalsRenderingFragment
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 tangent : TANGENT;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
half3 normalWS : TEXCOORD1;
|
||||
half3 tangentWS : TEXCOORD2;
|
||||
half3 bitangentWS : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_NormalMap);
|
||||
SAMPLER(sampler_NormalMap);
|
||||
half4 _NormalMap_ST; // Is this the right way to do this?
|
||||
|
||||
Varyings NormalsRenderingVertex(Attributes attributes)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(attributes);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = TransformObjectToHClip(attributes.positionOS);
|
||||
o.uv = TRANSFORM_TEX(attributes.uv, _NormalMap);
|
||||
o.color = attributes.color;
|
||||
o.normalWS = -GetViewForwardDir();
|
||||
o.tangentWS = TransformObjectToWorldDir(attributes.tangent.xyz);
|
||||
o.bitangentWS = cross(o.normalWS, o.tangentWS) * attributes.tangent.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/NormalsRenderingShared.hlsl"
|
||||
|
||||
half4 NormalsRenderingFragment(Varyings i) : SV_Target
|
||||
{
|
||||
const half4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
const half3 normalTS = UnpackNormal(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, i.uv));
|
||||
|
||||
return NormalsRenderingShared(mainTex, normalTS, i.tangentWS.xyz, i.bitangentWS.xyz, i.normalWS.xyz);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent"}
|
||||
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
#pragma vertex UnlitVertex
|
||||
#pragma fragment UnlitFragment
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
float3 positionWS : TEXCOORD2;
|
||||
#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
float4 _MainTex_ST;
|
||||
|
||||
Varyings UnlitVertex(Attributes attributes)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(attributes);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = TransformObjectToHClip(attributes.positionOS);
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
o.positionWS = TransformObjectToWorld(v.positionOS);
|
||||
#endif
|
||||
o.uv = TRANSFORM_TEX(attributes.uv, _MainTex);
|
||||
o.color = attributes.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 UnlitFragment(Varyings i) : SV_Target
|
||||
{
|
||||
float4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
SurfaceData2D surfaceData;
|
||||
InputData2D inputData;
|
||||
half4 debugColor = 0;
|
||||
|
||||
InitializeSurfaceData(mainTex.rgb, mainTex.a, surfaceData);
|
||||
InitializeInputData(i.uv, inputData);
|
||||
SETUP_DEBUG_DATA_2D(inputData, i.positionWS);
|
||||
|
||||
if(CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
|
||||
{
|
||||
return debugColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
return mainTex;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Sprites/Default"
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e260cfa7296ee7642b167f1eb5be5023
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
Shader "Universal Render Pipeline/2D/Sprite-Mask"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
[HideInInspector] _Cutoff ("Mask alpha cutoff", Range(0.0, 1.0)) = 0.0
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
ENDHLSL
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
Blend Off
|
||||
ColorMask 0
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
HLSLPROGRAM
|
||||
#pragma vertex MaskRenderingVertex
|
||||
#pragma fragment MaskRenderingFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SpriteMaskShared.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Tags{ "LightMode" = "NormalsRendering" }
|
||||
HLSLPROGRAM
|
||||
#pragma vertex MaskRenderingVertex
|
||||
#pragma fragment MaskRenderingFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SpriteMaskShared.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Tags{ "LightMode" = "UniversalForward" }
|
||||
HLSLPROGRAM
|
||||
#pragma vertex MaskRenderingVertex
|
||||
#pragma fragment MaskRenderingFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SpriteMaskShared.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e39bd598ce13f44ba8af997d3e42cd18
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_Color ("Tint", Color) = (1,1,1,1)
|
||||
|
||||
// Legacy properties. They're here so that materials using this shader can gracefully fallback to the legacy sprite shader.
|
||||
[HideInInspector] PixelSnap ("Pixel snap", Float) = 0
|
||||
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
|
||||
[HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
|
||||
[HideInInspector] _AlphaTex ("External Alpha", 2D) = "white" {}
|
||||
[HideInInspector] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode" = "Universal2D" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
|
||||
#endif
|
||||
|
||||
#pragma vertex UnlitVertex
|
||||
#pragma fragment UnlitFragment
|
||||
|
||||
#pragma multi_compile _ DEBUG_DISPLAY
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
float3 positionWS : TEXCOORD2;
|
||||
#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
half4 _MainTex_ST;
|
||||
|
||||
Varyings UnlitVertex(Attributes v)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = TransformObjectToHClip(v.positionOS);
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
o.positionWS = TransformObjectToWorld(v.positionOS);
|
||||
#endif
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 UnlitFragment(Varyings i) : SV_Target
|
||||
{
|
||||
float4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
SurfaceData2D surfaceData;
|
||||
InputData2D inputData;
|
||||
half4 debugColor = 0;
|
||||
|
||||
InitializeSurfaceData(mainTex.rgb, mainTex.a, surfaceData);
|
||||
InitializeInputData(i.uv, inputData);
|
||||
SETUP_DEBUG_DATA_2D(inputData, i.positionWS);
|
||||
|
||||
if(CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
|
||||
{
|
||||
return debugColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
return mainTex;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent"}
|
||||
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
|
||||
#endif
|
||||
|
||||
#pragma vertex UnlitVertex
|
||||
#pragma fragment UnlitFragment
|
||||
|
||||
#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
float3 positionWS : TEXCOORD2;
|
||||
#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
float4 _MainTex_ST;
|
||||
|
||||
Varyings UnlitVertex(Attributes attributes)
|
||||
{
|
||||
Varyings o = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(attributes);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = TransformObjectToHClip(attributes.positionOS);
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
o.positionWS = TransformObjectToWorld(attributes.positionOS);
|
||||
#endif
|
||||
o.uv = TRANSFORM_TEX(attributes.uv, _MainTex);
|
||||
o.color = attributes.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 UnlitFragment(Varyings i) : SV_Target
|
||||
{
|
||||
float4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
SurfaceData2D surfaceData;
|
||||
InputData2D inputData;
|
||||
half4 debugColor = 0;
|
||||
|
||||
InitializeSurfaceData(mainTex.rgb, mainTex.a, surfaceData);
|
||||
InitializeInputData(i.uv, inputData);
|
||||
SETUP_DEBUG_DATA_2D(inputData, i.positionWS);
|
||||
|
||||
if(CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
|
||||
{
|
||||
return debugColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
return mainTex;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Sprites/Default"
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 13c02b14c4d048fa9653293d54f6e0e1
|
||||
timeCreated: 1614780416
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ffac7c69f2faf9345b5b32ae0580e2e9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0e9d5a909a1f7e84882a534d0d11e49f
|
||||
ScriptedImporter:
|
||||
fileIDToRecycleName:
|
||||
4800000: MainAsset
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 80aa867ac363ac043847b06ad71604cd
|
||||
ScriptedImporter:
|
||||
fileIDToRecycleName:
|
||||
4800000: MainAsset
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5c81372d981403744adbdda4433c9c11
|
||||
ScriptedImporter:
|
||||
fileIDToRecycleName:
|
||||
4800000: MainAsset
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
|
|
@ -0,0 +1,382 @@
|
|||
Shader "Universal Render Pipeline/Baked Lit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainTexture] _BaseMap("Texture", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
|
||||
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
// BlendMode
|
||||
_Surface("__surface", Float) = 0.0
|
||||
_Blend("__mode", Float) = 0.0
|
||||
_Cull("__cull", Float) = 2.0
|
||||
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
|
||||
// Editmode props
|
||||
_QueueOffset("Queue offset", Float) = 0.0
|
||||
|
||||
[HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" "ShaderModel"="4.5"}
|
||||
LOD 100
|
||||
|
||||
Blend [_SrcBlend][_DstBlend]
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "BakedLit"
|
||||
Tags{ "LightMode" = "UniversalForwardOnly" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile _ DEBUG_DISPLAY
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_O
|
||||
|
||||
#pragma vertex BakedLitForwardPassVertex
|
||||
#pragma fragment BakedLitForwardPassFragment
|
||||
|
||||
// Lighting include is needed because of GI
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitForwardPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture with the forward renderer or the depthNormal prepass with the deferred renderer.
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormalsOnly"
|
||||
Tags{"LightMode" = "DepthNormalsOnly"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitDepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// Same as DepthNormals pass, but used for deferred renderer and forwardOnly materials.
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormalsOnly"
|
||||
Tags{"LightMode" = "DepthNormalsOnly"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant
|
||||
|
||||
//--------------------------------------
|
||||
// Defines
|
||||
#define BUMP_SCALE_NOT_SUPPORTED 1
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaUnlit
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitMetaPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" "ShaderModel"="2.0"}
|
||||
LOD 100
|
||||
|
||||
Blend [_SrcBlend][_DstBlend]
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "BakedLit"
|
||||
Tags{ "LightMode" = "UniversalForwardOnly" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile _ DEBUG_DISPLAY
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma vertex BakedLitForwardPassVertex
|
||||
#pragma fragment BakedLitForwardPassFragment
|
||||
|
||||
// Lighting include is needed because of GI
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitForwardPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags{"LightMode" = "DepthNormals"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitDepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaUnlit
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitMetaPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
FallBack "Universal Render Pipeline/Unlit"
|
||||
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.BakedLitShader"
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ca6dca7396eb48e5849247ffd444914
|
||||
timeCreated: 1496762173
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
#ifndef UNIVERSAL_BAKEDLIT_DEPTH_NORMALS_PASS_INCLUDED
|
||||
#define UNIVERSAL_BAKEDLIT_DEPTH_NORMALS_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/EncodeNormalsTexture.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
half3 normalOS : NORMAL;
|
||||
half4 tangentOS : TANGENT;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
half3 normalWS : TEXCOORD1;
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
half4 tangentWS : TEXCOORD3;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings DepthNormalsVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
output.vertex = vertexInput.positionCS;
|
||||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap).xy;
|
||||
|
||||
// normalWS and tangentWS already normalize.
|
||||
// this is required to avoid skewing the direction during interpolation
|
||||
// also required for per-vertex SH evaluation
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
|
||||
output.normalWS = half3(normalInput.normalWS);
|
||||
#if defined(_NORMALMAP)
|
||||
real sign = input.tangentOS.w * GetOddNegativeScale();
|
||||
output.tangentWS = half4(normalInput.tangentWS.xyz, sign);
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 DepthNormalsFragment(Varyings input) : SV_TARGET
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
half4 texColor = (half4) SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv);
|
||||
half alpha = texColor.a * _BaseColor.a;
|
||||
AlphaDiscard(alpha, _Cutoff);
|
||||
|
||||
#if defined(_GBUFFER_NORMALS_OCT)
|
||||
float3 normalWS = normalize(input.normalWS);
|
||||
float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms
|
||||
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
|
||||
half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1]
|
||||
return half4(packedNormalWS, 0.0);
|
||||
#else
|
||||
#if defined(_NORMALMAP)
|
||||
half3 normalTS = SampleNormal(input.uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap)).xyz;
|
||||
half sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
half3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
half3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent, input.normalWS));
|
||||
#else
|
||||
half3 normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
return half4(EncodeWSNormalForNormalsTex(NormalizeNormalPerPixel(normalWS)), 0.0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9604e389528d04ae39fe05a7b4212172
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 staticLightmapUV : TEXCOORD1;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 uv0AndFogCoord : TEXCOORD0; // xy: uv0, z: fogCoord
|
||||
DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 1);
|
||||
half3 normalWS : TEXCOORD2;
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
half4 tangentWS : TEXCOORD3;
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
float3 positionWS : TEXCOORD4;
|
||||
float3 viewDirWS : TEXCOORD5;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData)
|
||||
{
|
||||
inputData = (InputData)0;
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
inputData.positionWS = input.positionWS;
|
||||
inputData.viewDirectionWS = input.viewDirWS;
|
||||
#else
|
||||
inputData.positionWS = float3(0, 0, 0);
|
||||
inputData.viewDirectionWS = half3(0, 0, 1);
|
||||
#endif
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
|
||||
inputData.tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz);
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, inputData.tangentToWorld);
|
||||
#else
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
inputData.fogCoord = input.uv0AndFogCoord.z;
|
||||
inputData.vertexLighting = half3(0, 0, 0);
|
||||
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = half4(1, 1, 1, 1);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#if defined(LIGHTMAP_ON)
|
||||
inputData.staticLightmapUV = input.staticLightmapUV;
|
||||
#else
|
||||
inputData.vertexSH = input.vertexSH;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
Varyings BakedLitForwardPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
output.uv0AndFogCoord.xy = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
#if defined(_FOG_FRAGMENT)
|
||||
output.uv0AndFogCoord.z = vertexInput.positionVS.z;
|
||||
#else
|
||||
output.uv0AndFogCoord.z = ComputeFogFactor(vertexInput.positionCS.z);
|
||||
#endif
|
||||
|
||||
// normalWS and tangentWS already normalize.
|
||||
// this is required to avoid skewing the direction during interpolation
|
||||
// also required for per-vertex SH evaluation
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
|
||||
output.normalWS = normalInput.normalWS;
|
||||
#if defined(_NORMALMAP)
|
||||
real sign = input.tangentOS.w * GetOddNegativeScale();
|
||||
output.tangentWS = half4(normalInput.tangentWS.xyz, sign);
|
||||
#endif
|
||||
OUTPUT_LIGHTMAP_UV(input.staticLightmapUV, unity_LightmapST, output.staticLightmapUV);
|
||||
OUTPUT_SH(output.normalWS, output.vertexSH);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
output.positionWS = vertexInput.positionWS;
|
||||
output.viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS);
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 BakedLitForwardPassFragment(Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
half2 uv = input.uv0AndFogCoord.xy;
|
||||
#if defined(_NORMALMAP)
|
||||
half3 normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap)).xyz;
|
||||
#else
|
||||
half3 normalTS = half3(0, 0, 1);
|
||||
#endif
|
||||
InputData inputData;
|
||||
InitializeInputData(input, normalTS, inputData);
|
||||
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv0AndFogCoord.xy, _BaseMap);
|
||||
|
||||
half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv);
|
||||
half3 color = texColor.rgb * _BaseColor.rgb;
|
||||
half alpha = texColor.a * _BaseColor.a;
|
||||
|
||||
AlphaDiscard(alpha, _Cutoff);
|
||||
|
||||
#ifdef _DBUFFER
|
||||
ApplyDecalToBaseColorAndNormal(input.positionCS, color, inputData.normalWS);
|
||||
#endif
|
||||
|
||||
half4 finalColor = UniversalFragmentBakedLit(inputData, color, alpha, normalTS);
|
||||
|
||||
finalColor.a = OutputAlpha(finalColor.a, _Surface);
|
||||
return finalColor;
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 70003ec87ea6481a920369a377c1b623
|
||||
timeCreated: 1600853530
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef UNIVERSAL_BAKEDLIT_INPUT_INCLUDED
|
||||
#define UNIVERSAL_BAKEDLIT_INPUT_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
half4 _BaseColor;
|
||||
half _Cutoff;
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
half _Surface;
|
||||
CBUFFER_END
|
||||
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Glossiness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Metallic)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Surface)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
|
||||
#define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata_BaseColor)
|
||||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Cutoff)
|
||||
#define _Glossiness UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Glossiness)
|
||||
#define _Metallic UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Metallic)
|
||||
#define _Surface UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Surface)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef UNIVERSAL_BAKEDLIT_INPUT_INCLUDED
|
||||
#define UNIVERSAL_BAKEDLIT_INPUT_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
half4 _BaseColor;
|
||||
half _Cutoff;
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
half _Surface;
|
||||
CBUFFER_END
|
||||
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Glossiness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Metallic)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Surface)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
|
||||
#define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata__BaseColor)
|
||||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Cutoff)
|
||||
#define _Glossiness UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Glossiness)
|
||||
#define _Metallic UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Metallic)
|
||||
#define _Surface UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Surface)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b7c76ada0fa8c3d47b637abd2a2b2bdd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 463a8185744c2459f8e621f4e4eb74d3
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef UNIVERSAL_BAKEDLIT_META_PASS_INCLUDED
|
||||
#define UNIVERSAL_BAKEDLIT_META_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitMetaPass.hlsl"
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f31bf343921b848fa8e5cde15f1dbaab
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
Shader "Hidden/kMotion/CameraMotionVectors"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
Cull Off
|
||||
ZWrite On
|
||||
ZTest Always
|
||||
|
||||
HLSLPROGRAM
|
||||
// Required to compile gles 2.0 with standard srp library
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
// -------------------------------------
|
||||
// Includes
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
|
||||
#if defined(USING_STEREO_MATRICES)
|
||||
float4x4 _PrevViewProjMStereo[2];
|
||||
#define _PrevViewProjM _PrevViewProjMStereo[unity_StereoEyeIndex]
|
||||
#else
|
||||
#define _PrevViewProjM _PrevViewProjMatrix
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Structs
|
||||
struct Attributes
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
};
|
||||
|
||||
// -------------------------------------
|
||||
// Vertex
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.position = GetFullScreenTriangleVertexPosition(input.vertexID);
|
||||
return output;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Fragment
|
||||
half4 frag(Varyings input, out float outDepth : SV_Depth) : SV_Target
|
||||
{
|
||||
// Calculate PositionInputs
|
||||
half depth = LoadSceneDepth(input.position.xy).x;
|
||||
outDepth = depth;
|
||||
half2 screenSize = _ScreenSize.zw;
|
||||
PositionInputs positionInputs = GetPositionInput(input.position.xy, screenSize, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
||||
|
||||
// Calculate positions
|
||||
float4 previousPositionVP = mul(_PrevViewProjM, float4(positionInputs.positionWS, 1.0));
|
||||
float4 positionVP = mul(UNITY_MATRIX_VP, float4(positionInputs.positionWS, 1.0));
|
||||
|
||||
previousPositionVP.xy *= rcp(previousPositionVP.w);
|
||||
positionVP.xy *= rcp(positionVP.w);
|
||||
|
||||
// Calculate velocity
|
||||
float2 velocity = (positionVP.xy - previousPositionVP.xy);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
velocity.y = -velocity.y;
|
||||
#endif
|
||||
|
||||
// Convert velocity from Clip space (-1..1) to NDC 0..1 space
|
||||
// Note it doesn't mean we don't have negative value, we store negative or positive offset in NDC space.
|
||||
// Note: ((positionVP * 0.5 + 0.5) - (previousPositionVP * 0.5 + 0.5)) = (velocity * 0.5)
|
||||
return half4(velocity.xy * 0.5, 0, 0);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c56b7e0d4c7cb484e959caeeedae9bbf
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,540 @@
|
|||
// Complex Lit is superset of Lit, but provides
|
||||
// advanced material properties and is always forward rendered.
|
||||
// It also has higher hardware and shader model requirements.
|
||||
Shader "Universal Render Pipeline/Complex Lit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// Specular vs Metallic workflow
|
||||
// _WorkflowMode("WorkflowMode", Float) = 1.0
|
||||
|
||||
[MainTexture] _BaseMap("Albedo", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1,1,1,1)
|
||||
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
// _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
|
||||
|
||||
_Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
|
||||
// _SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
|
||||
// _SpecGlossMap("Specular", 2D) = "white" {}
|
||||
|
||||
// [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||
// [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
_Parallax("Scale", Range(0.005, 0.08)) = 0.005
|
||||
_ParallaxMap("Height Map", 2D) = "black" {}
|
||||
|
||||
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
|
||||
_OcclusionMap("Occlusion", 2D) = "white" {}
|
||||
|
||||
[HDR] _EmissionColor("Color", Color) = (0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
|
||||
_DetailMask("Detail Mask", 2D) = "white" {}
|
||||
_DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0
|
||||
_DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {}
|
||||
_DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0
|
||||
[Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[ToggleUI] _ClearCoat("Clear Coat", Float) = 0.0
|
||||
_ClearCoatMap("Clear Coat Map", 2D) = "white" {}
|
||||
_ClearCoatMask("Clear Coat Mask", Range(0.0, 1.0)) = 0.0
|
||||
_ClearCoatSmoothness("Clear Coat Smoothness", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
// Blending state
|
||||
_Surface("__surface", Float) = 0.0
|
||||
_Blend("__mode", Float) = 0.0
|
||||
_Cull("__cull", Float) = 2.0
|
||||
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
|
||||
[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
|
||||
// Editmode props
|
||||
_QueueOffset("Queue offset", Float) = 0.0
|
||||
|
||||
[HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
// Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
|
||||
// this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
|
||||
// material work with both Universal Render Pipeline and Builtin Unity Pipeline
|
||||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "ComplexLit" "IgnoreProjector" = "True" "ShaderModel"="4.5"}
|
||||
LOD 300
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Forward only pass.
|
||||
// Acts also as an opaque forward fallback for deferred rendering.
|
||||
Pass
|
||||
{
|
||||
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// no LightMode tag are also rendered by Universal Render Pipeline
|
||||
Name "ForwardLit"
|
||||
Tags{"LightMode" = "UniversalForwardOnly"}
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
#pragma shader_feature_local_fragment _ _CLEARCOAT _CLEARCOATMAP
|
||||
// #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
//#pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#pragma multi_compile _ _CLUSTERED_RENDERING
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
|
||||
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture with the forward renderer or the depthNormal prepass with the deferred renderer.
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormalsOnly"
|
||||
Tags{"LightMode" = "DepthNormalsOnly"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaLit
|
||||
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
|
||||
#pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
// Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
|
||||
// this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
|
||||
// material work with both Universal Render Pipeline and Builtin Unity Pipeline
|
||||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="2.0"}
|
||||
LOD 300
|
||||
|
||||
Pass
|
||||
{
|
||||
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// no LightMode tag are also rendered by Universal Render Pipeline
|
||||
Name "ForwardLit"
|
||||
Tags{"LightMode" = "UniversalForwardOnly"}
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
#pragma shader_feature_local_fragment _ _CLEARCOAT _CLEARCOATMAP
|
||||
// #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#pragma multi_compile _ _CLUSTERED_RENDERING
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags{"LightMode" = "DepthNormals"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaLit
|
||||
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
|
||||
#pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
FallBack "Hidden/Universal Render Pipeline/Lit"
|
||||
FallBack "Hidden/Universal Render Pipeline/FallbackError"
|
||||
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader"
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ee7e4c9a5f6364b688a332c67fc32cca
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 83e12e3399064822abd3e69798ce3053
|
||||
timeCreated: 1602509589
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
Shader "Hidden/Universal Render Pipeline/Debug/DebugReplacement"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Vertex Attributes"
|
||||
Tags {"LightMode" = "UniversalForward"}
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#define DEBUG_DISPLAY
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
float4 texcoord3 : TEXCOORD3;
|
||||
float4 color : COLOR;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
float4 texcoord3 : TEXCOORD3;
|
||||
float4 color : COLOR;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
};
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.texcoord0 = input.texcoord0;
|
||||
output.texcoord1 = input.texcoord1;
|
||||
output.texcoord2 = input.texcoord2;
|
||||
output.texcoord3 = input.texcoord3;
|
||||
output.color = input.color;
|
||||
output.normal = input.normal;
|
||||
output.tangent = input.tangent;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_TARGET
|
||||
{
|
||||
switch (_DebugVertexAttributeMode)
|
||||
{
|
||||
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD0:
|
||||
return input.texcoord0;
|
||||
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD1:
|
||||
return input.texcoord1;
|
||||
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD2:
|
||||
return input.texcoord2;
|
||||
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD3:
|
||||
return input.texcoord3;
|
||||
case DEBUGVERTEXATTRIBUTEMODE_COLOR:
|
||||
return input.color;
|
||||
case DEBUGVERTEXATTRIBUTEMODE_TANGENT:
|
||||
return input.tangent;
|
||||
case DEBUGVERTEXATTRIBUTEMODE_NORMAL:
|
||||
return input.normal;
|
||||
default:
|
||||
return half4(0, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf852408f2e174538bcd9b7fda1c5ae7
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9b4e681081e2b4c469111bb649e2f7ee
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
#ifndef UNIVERSAL_DEPTH_NORMALS_PASS_INCLUDED
|
||||
#define UNIVERSAL_DEPTH_NORMALS_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/EncodeNormalsTexture.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
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings DepthNormalsVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
half4 DepthNormalsFragment(Varyings input) : SV_TARGET
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff);
|
||||
|
||||
#if defined(_GBUFFER_NORMALS_OCT)
|
||||
float3 normalWS = normalize(input.normalWS);
|
||||
float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms.
|
||||
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
|
||||
half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1]
|
||||
return half4(packedNormalWS, 0.0);
|
||||
#else
|
||||
float3 normalWS = NormalizeNormalPerPixel(input.normalWS);
|
||||
return half4(EncodeWSNormalForNormalsTex(normalWS), 0.0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b76d45ea333b2a049bc45c5328ef3e7c
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef UNIVERSAL_DEPTH_ONLY_PASS_INCLUDED
|
||||
#define UNIVERSAL_DEPTH_ONLY_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.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
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings DepthOnlyVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 DepthOnlyFragment(Varyings input) : SV_TARGET
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0acd4fdbcf0cf654a9cdf3e9ccc2edce
|
||||
timeCreated: 1488965025
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,633 @@
|
|||
Shader "Universal Render Pipeline/Lit (PBR Workflow)"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// Specular vs Metallic workflow
|
||||
//_WorkflowMode("WorkflowMode", Float) = 1.0 //Nope
|
||||
|
||||
[MainTexture] _BaseMap("Albedo", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1,1,1,1)
|
||||
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 1.0 //defaulting to 1 instead of 0.5 because applying a texture will keep the default value as a scaler
|
||||
// _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0 //Unneeded variant
|
||||
|
||||
_Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
//We dont need Specular workflow. DELETED
|
||||
// _SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
|
||||
// _SpecGlossMap("Specular", 2D) = "white" {}
|
||||
//Forcing this stuff off as it adds to the variant count and should rarely be disabled in a PBR world.
|
||||
//[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||
// [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
// _Parallax("Scale", Range(0.005, 0.08)) = 0.005 //too heavy for quest
|
||||
// _ParallaxMap("Height Map", 2D) = "black" {}
|
||||
|
||||
//_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 //Meh. Not really needed. Just fix your texture
|
||||
//_OcclusionMap("Occlusion", 2D) = "white" {} //Packed together with metallic to match HDRP
|
||||
|
||||
[HDR] _EmissionColor("Color", Color) = (0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
|
||||
//_DetailMask("Detail Mask", 2D) = "white" {} //Using the Blue ch in metallic map instead
|
||||
_DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0
|
||||
_DetailMap("Detail Albedo x2", 2D) = "linearGrey" {} //Renamed
|
||||
_DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0
|
||||
_DetailSmoothnessMapScale("_DetailSmoothnessMapScale", Range(0.0, 2.0)) = 1
|
||||
//[Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {}
|
||||
//converting to HDRP detailmaps instead https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@10.2/manual/Mask-Map-and-Detail-Map.html
|
||||
|
||||
// SRP batching compatibility for Clear Coat (Not used in Lit)
|
||||
[HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0
|
||||
[HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0
|
||||
|
||||
// Blending state
|
||||
_Surface("__surface", Float) = 0.0
|
||||
_Blend("__blend", Float) = 0.0
|
||||
_Cull("__cull", Float) = 2.0
|
||||
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
|
||||
[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
|
||||
// Editmode props
|
||||
_QueueOffset("Queue offset", Float) = 0.0
|
||||
_OffsetUnits("OffsetUnits", Int) = 0.0
|
||||
_OffsetFactor("OffsetFactor", Int) = 0.0
|
||||
|
||||
// ObsoleteProperties
|
||||
[HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
|
||||
[HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0
|
||||
[HideInInspector] _Glossiness("Smoothness", Float) = 0.0
|
||||
[HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0
|
||||
|
||||
[HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
// Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
|
||||
// this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
|
||||
// material work with both Universal Render Pipeline and Builtin Unity Pipeline
|
||||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="4.5"}
|
||||
LOD 300
|
||||
|
||||
|
||||
HLSLINCLUDE
|
||||
#if !defined(SHADER_API_MOBILE)
|
||||
#pragma use_dxc vulkan
|
||||
#endif
|
||||
ENDHLSL
|
||||
// ------------------------------------------------------------------
|
||||
// Forward pass. Shades all light in a single pass. GI + emission + Fog
|
||||
Pass
|
||||
{
|
||||
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// no LightMode tag are also rendered by Universal Render Pipeline
|
||||
Name "ForwardLit"
|
||||
Tags{"LightMode" = "UniversalForward"}
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
Offset[_OffsetFactor] ,[_OffsetUnits]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP // Just force this on
|
||||
//#pragma shader_feature_local _PARALLAXMAP
|
||||
// #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
#pragma multi_compile_local_fragment _ _DETAIL_MULX2
|
||||
//_DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature_local_fragment _EMISSION // Force this on, gotta get rid of keywords
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
// #pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
// #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
//_MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#pragma multi_compile_fragment _ _VOLUMETRICS_ENABLED
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
|
||||
#pragma multi_compile_fog
|
||||
#pragma skip_variants FOG_LINEAR
|
||||
//#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DefaultLitVariants.hlsl"
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
|
||||
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// Pass
|
||||
// {
|
||||
// // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// // no LightMode tag are also rendered by Universal Render Pipeline
|
||||
// Name "GBuffer"
|
||||
// Tags{"LightMode" = "UniversalGBuffer"}
|
||||
//
|
||||
// ZWrite[_ZWrite]
|
||||
// ZTest LEqual
|
||||
// Cull[_Cull]
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma exclude_renderers gles gles3 glcore
|
||||
// #pragma target 4.5
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Material Keywords
|
||||
// #pragma shader_feature_local _NORMALMAP
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
// #pragma shader_feature_local_fragment _EMISSION
|
||||
// #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// // #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
// //#pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
// //#pragma shader_feature_local _PARALLAXMAP
|
||||
// #pragma shader_feature_local _ _DETAIL_MULX2
|
||||
// //_DETAIL_SCALED
|
||||
//
|
||||
// // #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// // #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
// // #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
// // #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Universal Pipeline keywords
|
||||
// #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
// //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
// //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
// #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
|
||||
// #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
|
||||
// #pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
// // #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
// // #pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
// #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Unity defined keywords
|
||||
// #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
// #pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
// #pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
// #pragma multi_compile _ LIGHTMAP_ON
|
||||
// #pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
// #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||
//
|
||||
// //--------------------------------------
|
||||
// // GPU Instancing
|
||||
// #pragma multi_compile_instancing
|
||||
// #pragma instancing_options renderinglayer
|
||||
// #pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
//
|
||||
// #pragma vertex LitGBufferPassVertex
|
||||
// #pragma fragment LitGBufferPassFragment
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl"
|
||||
// ENDHLSL
|
||||
// }
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags{"LightMode" = "DepthNormals"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
//#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2
|
||||
//_DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaLit
|
||||
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2
|
||||
//_DETAIL_SCALED
|
||||
|
||||
//#pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// Pass
|
||||
// {
|
||||
// Name "Universal2D"
|
||||
// Tags{ "LightMode" = "Universal2D" }
|
||||
//
|
||||
// Blend[_SrcBlend][_DstBlend]
|
||||
// ZWrite[_ZWrite]
|
||||
// Cull[_Cull]
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma exclude_renderers gles gles3 glcore
|
||||
// #pragma target 4.5
|
||||
//
|
||||
// #pragma vertex vert
|
||||
// #pragma fragment frag
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
// ENDHLSL
|
||||
// }
|
||||
|
||||
Pass{
|
||||
Name "BakedRaytrace"
|
||||
Tags{ "LightMode" = "BakedRaytrace" }
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.0
|
||||
#pragma raytracing BakedRaytrace
|
||||
#pragma shader_feature_local _EMISSION
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Volumetrics/LitTracingPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
// SubShader
|
||||
// {
|
||||
// // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
|
||||
// // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
|
||||
// // material work with both Universal Render Pipeline and Builtin Unity Pipeline
|
||||
// Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="2.0"}
|
||||
// LOD 300
|
||||
//
|
||||
// // ------------------------------------------------------------------
|
||||
// // Forward pass. Shades all light in a single pass. GI + emission + Fog
|
||||
// Pass
|
||||
// {
|
||||
// // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// // no LightMode tag are also rendered by Universal Render Pipeline
|
||||
// Name "ForwardLit"
|
||||
// Tags{"LightMode" = "UniversalForward"}
|
||||
//
|
||||
// Blend[_SrcBlend][_DstBlend]
|
||||
// ZWrite[_ZWrite]
|
||||
// Cull[_Cull]
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma only_renderers gles gles3 glcore d3d11
|
||||
// #pragma target 2.0
|
||||
//
|
||||
// //--------------------------------------
|
||||
// // GPU Instancing
|
||||
// #pragma multi_compile_instancing
|
||||
// #pragma instancing_options renderinglayer
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Material Keywords
|
||||
// #pragma shader_feature_local _NORMALMAP
|
||||
// //#pragma shader_feature_local _PARALLAXMAP
|
||||
// // #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
// #pragma shader_feature_local _ _DETAIL_MULX2
|
||||
// //_DETAIL_SCALED
|
||||
// #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
// #pragma shader_feature_local_fragment _EMISSION
|
||||
// #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// // #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
// //#pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
// // #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// // #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
// // #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Universal Pipeline keywords
|
||||
// #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE //_MAIN_LIGHT_SHADOWS_SCREEN
|
||||
// #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
// #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
// #pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
// #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
// //#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
// #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
|
||||
// #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
|
||||
// //#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
// #pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
// #pragma multi_compile _ _CLUSTERED_RENDERING
|
||||
// #pragma multi_compile _ _VOLUMETRICS_ENABLED
|
||||
//
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Unity defined keywords
|
||||
// #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
// #pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
// #pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
// #pragma multi_compile _ LIGHTMAP_ON
|
||||
// #pragma multi_compile_fog
|
||||
// #pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
//
|
||||
// #pragma vertex LitPassVertex
|
||||
// #pragma fragment LitPassFragment
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
|
||||
// ENDHLSL
|
||||
// }
|
||||
//
|
||||
// Pass
|
||||
// {
|
||||
// Name "ShadowCaster"
|
||||
// Tags{"LightMode" = "ShadowCaster"}
|
||||
//
|
||||
// ZWrite On
|
||||
// ZTest LEqual
|
||||
// ColorMask 0
|
||||
// Cull[_Cull]
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma only_renderers gles gles3 glcore d3d11
|
||||
// #pragma target 2.0
|
||||
//
|
||||
// //--------------------------------------
|
||||
// // GPU Instancing
|
||||
// #pragma multi_compile_instancing
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Material Keywords
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// // #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Universal Pipeline keywords
|
||||
//
|
||||
// // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
|
||||
// #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
//
|
||||
// #pragma vertex ShadowPassVertex
|
||||
// #pragma fragment ShadowPassFragment
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
// ENDHLSL
|
||||
// }
|
||||
//
|
||||
// Pass
|
||||
// {
|
||||
// Name "DepthOnly"
|
||||
// Tags{"LightMode" = "DepthOnly"}
|
||||
//
|
||||
// ZWrite On
|
||||
// ColorMask 0
|
||||
// Cull[_Cull]
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma only_renderers gles gles3 glcore d3d11
|
||||
// #pragma target 2.0
|
||||
//
|
||||
// //--------------------------------------
|
||||
// // GPU Instancing
|
||||
// #pragma multi_compile_instancing
|
||||
//
|
||||
// #pragma vertex DepthOnlyVertex
|
||||
// #pragma fragment DepthOnlyFragment
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Material Keywords
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// // #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
// ENDHLSL
|
||||
// }
|
||||
//
|
||||
// // This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
// Pass
|
||||
// {
|
||||
// Name "DepthNormals"
|
||||
// Tags{"LightMode" = "DepthNormals"}
|
||||
//
|
||||
// ZWrite On
|
||||
// Cull[_Cull]
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma only_renderers gles gles3 glcore d3d11
|
||||
// #pragma target 2.0
|
||||
//
|
||||
// #pragma vertex DepthNormalsVertex
|
||||
// #pragma fragment DepthNormalsFragment
|
||||
//
|
||||
// // -------------------------------------
|
||||
// // Material Keywords
|
||||
// #pragma shader_feature_local _NORMALMAP
|
||||
// //#pragma shader_feature_local _PARALLAXMAP
|
||||
// #pragma shader_feature_local _ _DETAIL_MULX2
|
||||
// //_DETAIL_SCALED
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// // #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
//
|
||||
// //--------------------------------------
|
||||
// // GPU Instancing
|
||||
// #pragma multi_compile_instancing
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
|
||||
// ENDHLSL
|
||||
// }
|
||||
//
|
||||
// // This pass it not used during regular rendering, only for lightmap baking.
|
||||
// Pass
|
||||
// {
|
||||
// Name "Meta"
|
||||
// Tags{"LightMode" = "Meta"}
|
||||
//
|
||||
// Cull Off
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma only_renderers gles gles3 glcore d3d11
|
||||
// #pragma target 2.0
|
||||
//
|
||||
// #pragma vertex UniversalVertexMeta
|
||||
// #pragma fragment UniversalFragmentMetaLit
|
||||
//
|
||||
// #pragma shader_feature EDITOR_VISUALIZATION
|
||||
// // #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
// #pragma shader_feature_local_fragment _EMISSION
|
||||
// #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// // #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
// #pragma shader_feature_local _ _DETAIL_MULX2
|
||||
// //_DETAIL_SCALED
|
||||
//
|
||||
// // #pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
|
||||
//
|
||||
// ENDHLSL
|
||||
// }
|
||||
// Pass
|
||||
// {
|
||||
// Name "Universal2D"
|
||||
// Tags{ "LightMode" = "Universal2D" }
|
||||
//
|
||||
// Blend[_SrcBlend][_DstBlend]
|
||||
// ZWrite[_ZWrite]
|
||||
// Cull[_Cull]
|
||||
//
|
||||
// HLSLPROGRAM
|
||||
// #pragma only_renderers gles gles3 glcore d3d11
|
||||
// #pragma target 2.0
|
||||
//
|
||||
// #pragma vertex vert
|
||||
// #pragma fragment frag
|
||||
// #pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
//
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
// #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
// ENDHLSL
|
||||
// }
|
||||
// }
|
||||
|
||||
//FallBack "Hidden/Universal Render Pipeline/FallbackError"
|
||||
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader"
|
||||
}
|
||||
|
|
@ -0,0 +1,630 @@
|
|||
Shader "Universal Render Pipeline/Lit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// Specular vs Metallic workflow
|
||||
_WorkflowMode("WorkflowMode", Float) = 1.0
|
||||
|
||||
[MainTexture] _BaseMap("Albedo", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1,1,1,1)
|
||||
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
// _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
|
||||
|
||||
_Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
|
||||
// _SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
|
||||
// _SpecGlossMap("Specular", 2D) = "white" {}
|
||||
|
||||
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||
[ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
_Parallax("Scale", Range(0.005, 0.08)) = 0.005
|
||||
_ParallaxMap("Height Map", 2D) = "black" {}
|
||||
|
||||
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
|
||||
_OcclusionMap("Occlusion", 2D) = "white" {}
|
||||
|
||||
[HDR] _EmissionColor("Color", Color) = (0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
|
||||
_DetailMask("Detail Mask", 2D) = "white" {}
|
||||
_DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0
|
||||
_DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {}
|
||||
_DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0
|
||||
[Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
// SRP batching compatibility for Clear Coat (Not used in Lit)
|
||||
[HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0
|
||||
[HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0
|
||||
|
||||
// Blending state
|
||||
_Surface("__surface", Float) = 0.0
|
||||
_Blend("__blend", Float) = 0.0
|
||||
_Cull("__cull", Float) = 2.0
|
||||
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
|
||||
// [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
|
||||
// Editmode props
|
||||
_QueueOffset("Queue offset", Float) = 0.0
|
||||
|
||||
// ObsoleteProperties
|
||||
[HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
|
||||
[HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0
|
||||
[HideInInspector] _Glossiness("Smoothness", Float) = 0.0
|
||||
[HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0
|
||||
|
||||
[HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
// Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
|
||||
// this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
|
||||
// material work with both Universal Render Pipeline and Builtin Unity Pipeline
|
||||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="4.5"}
|
||||
LOD 300
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Forward pass. Shades all light in a single pass. GI + emission + Fog
|
||||
Pass
|
||||
{
|
||||
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// no LightMode tag are also rendered by Universal Render Pipeline
|
||||
Name "ForwardLit"
|
||||
Tags{"LightMode" = "UniversalForward"}
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
// #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
// #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#pragma multi_compile _ _CLUSTERED_RENDERING
|
||||
#pragma multi_compile_fragment _ _VOLUMETRICS_ENABLED
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
// #pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
|
||||
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// no LightMode tag are also rendered by Universal Render Pipeline
|
||||
Name "GBuffer"
|
||||
Tags{"LightMode" = "UniversalGBuffer"}
|
||||
|
||||
ZWrite[_ZWrite]
|
||||
ZTest LEqual
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
//#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
|
||||
// #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
// #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#pragma vertex LitGBufferPassVertex
|
||||
#pragma fragment LitGBufferPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags{"LightMode" = "DepthNormals"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaLit
|
||||
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
|
||||
//#pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles gles3 glcore
|
||||
#pragma target 4.5
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
|
||||
Pass{
|
||||
Name "BakedRaytrace"
|
||||
Tags{ "LightMode" = "BakedRaytrace" }
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma raytracing BakedRaytrace
|
||||
#pragma shader_feature_local _EMISSION
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Volumetrics/LitTracingPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
// Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
|
||||
// this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
|
||||
// material work with both Universal Render Pipeline and Builtin Unity Pipeline
|
||||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="2.0"}
|
||||
LOD 300
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Forward pass. Shades all light in a single pass. GI + emission + Fog
|
||||
Pass
|
||||
{
|
||||
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
|
||||
// no LightMode tag are also rendered by Universal Render Pipeline
|
||||
Name "ForwardLit"
|
||||
Tags{"LightMode" = "UniversalForward"}
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
// #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local_fragment _OCCLUSIONMAP
|
||||
// #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
// #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
|
||||
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#pragma multi_compile _ _CLUSTERED_RENDERING
|
||||
#pragma multi_compile _ _VOLUMETRICS_ENABLED
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
// #pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
|
||||
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags{"LightMode" = "DepthNormals"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _PARALLAXMAP
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaLit
|
||||
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
// #pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
|
||||
|
||||
// #pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers gles gles3 glcore d3d11
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Hidden/Universal Render Pipeline/FallbackError"
|
||||
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader"
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 69c474c6c70749e4c9457e1ef0874322
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 933532a4fcc9baf4fa0491de14d08ed7
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _BaseMap: {instanceID: 0}
|
||||
- _MetallicGlossMap: {fileID: 2800000, guid: 09d470003bf37cd40a33d8792ac06dd6, type: 3}
|
||||
- _BumpMap: {instanceID: 0}
|
||||
- _EmissionMap: {instanceID: 0}
|
||||
- _DetailMap: {instanceID: 0}
|
||||
- _MainTex: {instanceID: 0}
|
||||
- unity_Lightmaps: {instanceID: 0}
|
||||
- unity_LightmapsInd: {instanceID: 0}
|
||||
- unity_ShadowMasks: {instanceID: 0}
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
#ifndef UNIVERSAL_FORWARD_LIT_DEPTH_NORMALS_PASS_INCLUDED
|
||||
#define UNIVERSAL_FORWARD_LIT_DEPTH_NORMALS_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/EncodeNormalsTexture.hlsl"
|
||||
|
||||
#if defined(_DETAIL_MULX2) || defined(_DETAIL_SCALED)
|
||||
#define _DETAIL
|
||||
#endif
|
||||
|
||||
// GLES2 has limited amount of interpolators
|
||||
#if defined(_PARALLAXMAP) && !defined(SHADER_API_GLES)
|
||||
#define REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
#if (defined(_NORMALMAP) || (defined(_PARALLAXMAP) && !defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR))) || defined(_DETAIL)
|
||||
#define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
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;
|
||||
half3 normalWS : TEXCOORD2;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
half4 tangentWS : TEXCOORD4; // xyz: tangent, w: sign
|
||||
#endif
|
||||
|
||||
half3 viewDirWS : TEXCOORD5;
|
||||
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirTS : TEXCOORD8;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
Varyings DepthNormalsVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
|
||||
output.normalWS = half3(normalInput.normalWS);
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) || defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
float sign = input.tangentOS.w * float(GetOddNegativeScale());
|
||||
half4 tangentWS = half4(normalInput.tangentWS.xyz, sign);
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
output.tangentWS = tangentWS;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirTS = GetViewDirectionTangentSpace(tangentWS, output.normalWS, viewDirWS);
|
||||
output.viewDirTS = viewDirTS;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
half4 DepthNormalsFragment(Varyings input) : SV_TARGET
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff);
|
||||
|
||||
#if defined(_GBUFFER_NORMALS_OCT)
|
||||
float3 normalWS = normalize(input.normalWS);
|
||||
float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms
|
||||
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
|
||||
half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1]
|
||||
return half4(packedNormalWS, 0.0);
|
||||
#else
|
||||
float2 uv = input.uv;
|
||||
#if defined(_PARALLAXMAP)
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirTS = input.viewDirTS;
|
||||
#else
|
||||
half3 viewDirTS = GetViewDirectionTangentSpace(input.tangentWS, input.normalWS, input.viewDirWS);
|
||||
#endif
|
||||
ApplyPerPixelDisplacement(viewDirTS, uv);
|
||||
#endif
|
||||
|
||||
#if defined(_NORMALMAP) || defined(_DETAIL)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
float3 normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
|
||||
|
||||
#if defined(_DETAIL)
|
||||
half detailMask = 1;//SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).a; //Just disabling because we dont use deferred
|
||||
float2 detailUv = uv;// * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw;
|
||||
normalTS = ApplyDetailNormal(detailUv, normalTS, detailMask);
|
||||
#endif
|
||||
|
||||
float3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
float3 normalWS = input.normalWS;
|
||||
#endif
|
||||
normalWS = NormalizeNormalPerPixel(normalWS);
|
||||
//half3 normalVS = mul((half3x3)UNITY_MATRIX_V, normalWS);
|
||||
// half2 octNormalWS = PackNormalOctQuadEncode(normalWS);
|
||||
return half4(EncodeWSNormalForNormalsTex(normalWS), 0.0);
|
||||
//return half4(normalWS, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d6641dcdedd1f422aa58ffec746e5342
|
||||
timeCreated: 1488965025
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,317 @@
|
|||
#ifndef UNIVERSAL_FORWARD_LIT_PASS_INCLUDED
|
||||
#define UNIVERSAL_FORWARD_LIT_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
// GLES2 has limited amount of interpolators
|
||||
#if defined(_PARALLAXMAP) && !defined(SHADER_API_GLES)
|
||||
#define REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
#if (defined(_NORMALMAP) || (defined(_PARALLAXMAP) && !defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR))) || defined(_DETAIL)
|
||||
#define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
// keep this file in sync with LitGBufferPass.hlsl
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 staticLightmapUV : TEXCOORD1;
|
||||
float2 dynamicLightmapUV : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
float3 positionWS : TEXCOORD1;
|
||||
#endif
|
||||
|
||||
half3 normalWS : TEXCOORD2;
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
half4 tangentWS : TEXCOORD3; // xyz: tangent, w: sign
|
||||
#endif
|
||||
float3 viewDirWS : TEXCOORD4;
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half4 fogFactorAndVertexLight : TEXCOORD5; // x: fogFactor, yzw: vertex light
|
||||
#else
|
||||
half fogFactor : TEXCOORD5;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
float4 shadowCoord : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirTS : TEXCOORD7;
|
||||
#endif
|
||||
|
||||
DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 8);
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
float2 dynamicLightmapUV : TEXCOORD9; // Dynamic lightmap UVs
|
||||
#endif
|
||||
|
||||
float4 positionCS : SV_POSITION;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData)
|
||||
{
|
||||
inputData = (InputData)0;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
inputData.positionWS = input.positionWS;
|
||||
#endif
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS);
|
||||
#if defined(_NORMALMAP) || defined(_DETAIL)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
inputData.tangentToWorld = tangentToWorld;
|
||||
#endif
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, tangentToWorld);
|
||||
#else
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
inputData.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
inputData.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
|
||||
#else
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactor);
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
#else
|
||||
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
#endif
|
||||
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.dynamicLightmapUV = input.dynamicLightmapUV;
|
||||
#endif
|
||||
#if defined(LIGHTMAP_ON)
|
||||
inputData.staticLightmapUV = input.staticLightmapUV;
|
||||
#else
|
||||
inputData.vertexSH = input.vertexSH;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//Directional variation
|
||||
void InitializeInputDataDir(Varyings input, half3 normalTS, half3 smoothness, out InputData inputData, out float BakedSpecular)
|
||||
{
|
||||
inputData = (InputData)0;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
inputData.positionWS = input.positionWS;
|
||||
#endif
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS);
|
||||
#if defined(_NORMALMAP) || defined(_DETAIL)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
inputData.tangentToWorld = tangentToWorld;
|
||||
#endif
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, tangentToWorld);
|
||||
#else
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
inputData.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
inputData.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
|
||||
#else
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactor);
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
#if LIGHTMAP_ON
|
||||
float4 encodedGI = SAMPLE_GI_DIR(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS, smoothness, viewDirWS);
|
||||
inputData.bakedGI = encodedGI.rgb;
|
||||
BakedSpecular = encodedGI.w;
|
||||
#else
|
||||
// inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
#endif
|
||||
#else
|
||||
#if LIGHTMAP_ON
|
||||
float4 encodedGI = SAMPLE_GI_DIR(input.staticLightmapUV, input.vertexSH, inputData.normalWS, smoothness, viewDirWS);
|
||||
inputData.bakedGI = encodedGI.rgb;
|
||||
BakedSpecular = encodedGI.w;
|
||||
#else
|
||||
// inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.dynamicLightmapUV = input.dynamicLightmapUV;
|
||||
#endif
|
||||
#if defined(LIGHTMAP_ON)
|
||||
inputData.staticLightmapUV = input.staticLightmapUV;
|
||||
#else
|
||||
inputData.vertexSH = input.vertexSH;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Vertex and Fragment functions //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Used in Standard (Physically Based) shader
|
||||
Varyings LitPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
|
||||
// normalWS and tangentWS already normalize.
|
||||
// this is required to avoid skewing the direction during interpolation
|
||||
// also required for per-vertex lighting and SH evaluation
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
|
||||
|
||||
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
|
||||
|
||||
half fogFactor = 0;
|
||||
#if !defined(_FOG_FRAGMENT)
|
||||
fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
|
||||
#endif
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
|
||||
// already normalized from normal transform to WS.
|
||||
output.normalWS = normalInput.normalWS;
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) || defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
real sign = input.tangentOS.w * GetOddNegativeScale();
|
||||
half4 tangentWS = half4(normalInput.tangentWS.xyz, sign);
|
||||
#endif
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
output.tangentWS = tangentWS;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
|
||||
half3 viewDirTS = GetViewDirectionTangentSpace(tangentWS, output.normalWS, viewDirWS);
|
||||
output.viewDirTS = viewDirTS;
|
||||
#endif
|
||||
|
||||
OUTPUT_LIGHTMAP_UV(input.staticLightmapUV, unity_LightmapST, output.staticLightmapUV);
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
output.dynamicLightmapUV = input.dynamicLightmapUV.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
|
||||
#else
|
||||
output.fogFactor = fogFactor;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
output.positionWS = vertexInput.positionWS;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = GetShadowCoord(vertexInput);
|
||||
#endif
|
||||
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// Used in Standard (Physically Based) shader
|
||||
half4 LitPassFragment(Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS);
|
||||
|
||||
#if defined(_PARALLAXMAP)
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirTS = input.viewDirTS;
|
||||
#else
|
||||
half3 viewDirTS = GetViewDirectionTangentSpace(input.tangentWS, input.normalWS, viewDirWS);
|
||||
#endif
|
||||
ApplyPerPixelDisplacement(viewDirTS, input.uv);
|
||||
#endif
|
||||
|
||||
SurfaceData surfaceData;
|
||||
InitializeStandardLitSurfaceData(input.uv, surfaceData);
|
||||
|
||||
InputData inputData;
|
||||
|
||||
#ifdef LIGHTMAP_ON
|
||||
float BakedSpecular = 0;
|
||||
InitializeInputDataDir(input, surfaceData.normalTS, surfaceData.smoothness, inputData, BakedSpecular);
|
||||
#else
|
||||
InitializeInputData(input, surfaceData.normalTS, inputData);
|
||||
#endif
|
||||
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv, _BaseMap);
|
||||
|
||||
|
||||
#ifdef _DBUFFER
|
||||
ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData);
|
||||
#endif
|
||||
|
||||
half4 color = UniversalFragmentPBR(inputData, surfaceData);
|
||||
|
||||
#ifdef LIGHTMAP_ON
|
||||
float3 MetalSpec = lerp(kDieletricSpec.rgb, surfaceData.albedo, surfaceData.metallic);
|
||||
color.rgb += BakedSpecular * surfaceData.occlusion * MetalSpec * inputData.bakedGI.rgb;
|
||||
#endif
|
||||
|
||||
|
||||
color.rgb = MixFog(color.rgb, -viewDirWS, inputData.fogCoord);
|
||||
color = Volumetrics ( color, input.positionWS);
|
||||
color.a = OutputAlpha(color.a, _Surface);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 116bd973269b9f741b7177c8523b9e50
|
||||
timeCreated: 1488965025
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
#ifndef UNIVERSAL_LIT_GBUFFER_PASS_INCLUDED
|
||||
#define UNIVERSAL_LIT_GBUFFER_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityGBuffer.hlsl"
|
||||
|
||||
// TODO: Currently we support viewDirTS caclulated in vertex shader and in fragments shader.
|
||||
// As both solutions have their advantages and disadvantages (etc. shader target 2.0 has only 8 interpolators).
|
||||
// We need to find out if we can stick to one solution, which we needs testing.
|
||||
// So keeping this until I get manaul QA pass.
|
||||
#if defined(_PARALLAXMAP) && (SHADER_TARGET >= 30)
|
||||
#define REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
#if (defined(_NORMALMAP) || (defined(_PARALLAXMAP) && !defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR))) || defined(_DETAIL)
|
||||
#define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
// keep this file in sync with LitForwardPass.hlsl
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 staticLightmapUV : TEXCOORD1;
|
||||
float2 dynamicLightmapUV : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
float3 positionWS : TEXCOORD1;
|
||||
#endif
|
||||
|
||||
half3 normalWS : TEXCOORD2;
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
half4 tangentWS : TEXCOORD3; // xyz: tangent, w: sign
|
||||
#endif
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half3 vertexLighting : TEXCOORD4; // xyz: vertex lighting
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
float4 shadowCoord : TEXCOORD5;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirTS : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 7);
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
float2 dynamicLightmapUV : TEXCOORD8; // Dynamic lightmap UVs
|
||||
#endif
|
||||
|
||||
float4 positionCS : SV_POSITION;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData)
|
||||
{
|
||||
inputData = (InputData)0;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
inputData.positionWS = input.positionWS;
|
||||
#endif
|
||||
|
||||
inputData.positionCS = input.positionCS;
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS);
|
||||
#if defined(_NORMALMAP) || defined(_DETAIL)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
inputData.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
inputData.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
|
||||
#else
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
inputData.fogCoord = 0.0; // we don't apply fog in the guffer pass
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.vertexLighting = input.vertexLighting.xyz;
|
||||
#else
|
||||
inputData.vertexLighting = half3(0, 0, 0);
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
#else
|
||||
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
#endif
|
||||
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Vertex and Fragment functions //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Used in Standard (Physically Based) shader
|
||||
Varyings LitGBufferPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
|
||||
// normalWS and tangentWS already normalize.
|
||||
// this is required to avoid skewing the direction during interpolation
|
||||
// also required for per-vertex lighting and SH evaluation
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
|
||||
// already normalized from normal transform to WS.
|
||||
output.normalWS = normalInput.normalWS;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) || defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
real sign = input.tangentOS.w * GetOddNegativeScale();
|
||||
half4 tangentWS = half4(normalInput.tangentWS.xyz, sign);
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
output.tangentWS = tangentWS;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
|
||||
half3 viewDirTS = GetViewDirectionTangentSpace(tangentWS, output.normalWS, viewDirWS);
|
||||
output.viewDirTS = viewDirTS;
|
||||
#endif
|
||||
|
||||
OUTPUT_LIGHTMAP_UV(input.staticLightmapUV, unity_LightmapST, output.staticLightmapUV);
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
output.dynamicLightmapUV = input.dynamicLightmapUV.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
|
||||
output.vertexLighting = vertexLight;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
output.positionWS = vertexInput.positionWS;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = GetShadowCoord(vertexInput);
|
||||
#endif
|
||||
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// Used in Standard (Physically Based) shader
|
||||
FragmentOutput LitGBufferPassFragment(Varyings input)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
#if defined(_PARALLAXMAP)
|
||||
#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
|
||||
half3 viewDirTS = input.viewDirTS;
|
||||
#else
|
||||
half3 viewDirTS = GetViewDirectionTangentSpace(input.tangentWS, input.normalWS, input.viewDirWS);
|
||||
#endif
|
||||
ApplyPerPixelDisplacement(viewDirTS, input.uv);
|
||||
#endif
|
||||
|
||||
SurfaceData surfaceData;
|
||||
InitializeStandardLitSurfaceData(input.uv, surfaceData);
|
||||
|
||||
InputData inputData;
|
||||
InitializeInputData(input, surfaceData.normalTS, inputData);
|
||||
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv, _BaseMap);
|
||||
|
||||
#ifdef _DBUFFER
|
||||
ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData);
|
||||
#endif
|
||||
|
||||
// Stripped down version of UniversalFragmentPBR().
|
||||
|
||||
// in LitForwardPass GlobalIllumination (and temporarily LightingPhysicallyBased) are called inside UniversalFragmentPBR
|
||||
// in Deferred rendering we store the sum of these values (and of emission as well) in the GBuffer
|
||||
BRDFData brdfData;
|
||||
InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData);
|
||||
|
||||
Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, inputData.shadowMask);
|
||||
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, inputData.shadowMask);
|
||||
half3 color = GlobalIllumination(brdfData, inputData.bakedGI, surfaceData.occlusion, inputData.positionWS, inputData.normalWS, inputData.viewDirectionWS);
|
||||
|
||||
return BRDFDataToGbuffer(brdfData, inputData, surfaceData.smoothness, surfaceData.emission + color, surfaceData.occlusion);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92673cbb58cac8e4d8b5d044ce912dd8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,289 @@
|
|||
#ifndef UNIVERSAL_LIT_INPUT_INCLUDED
|
||||
#define UNIVERSAL_LIT_INPUT_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
//#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ParallaxMapping.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
|
||||
|
||||
#if defined(_DETAIL_MULX2) || defined(_DETAIL_SCALED)
|
||||
#define _DETAIL
|
||||
#endif
|
||||
|
||||
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _DetailMap_ST;
|
||||
half4 _BaseColor;
|
||||
half4 _SpecColor;
|
||||
half4 _EmissionColor;
|
||||
half _Cutoff;
|
||||
half _Smoothness;
|
||||
half _Metallic;
|
||||
half _BumpScale;
|
||||
//half _Parallax;
|
||||
//half _OcclusionStrength;
|
||||
half _ClearCoatMask;
|
||||
half _ClearCoatSmoothness;
|
||||
half _DetailAlbedoMapScale;
|
||||
half _DetailNormalMapScale;
|
||||
half _DetailSmoothnessMapScale;
|
||||
half _Surface;
|
||||
CBUFFER_END
|
||||
|
||||
// NOTE: Do not ifdef the properties for dots instancing, but ifdef the actual usage.
|
||||
// Otherwise you might break CPU-side as property constant-buffer offsets change per variant.
|
||||
// NOTE: Dots instancing is orthogonal to the constant buffer above.
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _SpecColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _EmissionColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Smoothness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Metallic)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _BumpScale)
|
||||
// UNITY_DOTS_INSTANCED_PROP(float , _Parallax)
|
||||
// UNITY_DOTS_INSTANCED_PROP(float , _OcclusionStrength)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _ClearCoatMask)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _ClearCoatSmoothness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _DetailAlbedoMapScale)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _DetailNormalMapScale)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _DetailSmoothnessMapScale)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Surface)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
|
||||
#define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata_BaseColor)
|
||||
#define _SpecColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata_SpecColor)
|
||||
#define _EmissionColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata_EmissionColor)
|
||||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Cutoff)
|
||||
#define _Smoothness UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Smoothness)
|
||||
#define _Metallic UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Metallic)
|
||||
#define _BumpScale UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_BumpScale)
|
||||
//#define _Parallax UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Parallax)
|
||||
//#define _OcclusionStrength UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_OcclusionStrength)
|
||||
#define _ClearCoatMask UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_ClearCoatMask)
|
||||
#define _ClearCoatSmoothness UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_ClearCoatSmoothness)
|
||||
#define _DetailAlbedoMapScale UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_DetailAlbedoMapScale)
|
||||
#define _DetailNormalMapScale UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_DetailNormalMapScale)
|
||||
#define _DetailNormalMapScale UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_DetailSmoothnessMapScale)
|
||||
#define _Surface UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata_Surface)
|
||||
#endif
|
||||
//Converting Detail maps to HDRP's packing because of URP's TEXTURE2D bloat exceeding 16 samplers when using volumetrics and preventing compiling. Seriously, it's 2022, ditch specular workflow and optimze the packing.
|
||||
//https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@10.2/manual/Mask-Map-and-Detail-Map.html
|
||||
|
||||
//TEXTURE2D(_ParallaxMap); SAMPLER(sampler_ParallaxMap);
|
||||
//TEXTURE2D(_OcclusionMap); SAMPLER(sampler_OcclusionMap);
|
||||
//TEXTURE2D(_DetailMask); SAMPLER(sampler_DetailMask);
|
||||
TEXTURE2D(_DetailMap); SAMPLER(sampler_DetailMap); //renamed
|
||||
//TEXTURE2D(_DetailNormalMap); SAMPLER(sampler_DetailNormalMap);
|
||||
TEXTURE2D(_MetallicGlossMap); SAMPLER(sampler_MetallicGlossMap);
|
||||
TEXTURE2D(_SpecGlossMap); SAMPLER(sampler_SpecGlossMap);
|
||||
TEXTURE2D(_ClearCoatMap); SAMPLER(sampler_ClearCoatMap);
|
||||
|
||||
#ifdef _SPECULAR_SETUP
|
||||
#define SAMPLE_METALLICSPECULAR(uv) SAMPLE_TEXTURE2D(_SpecGlossMap, sampler_SpecGlossMap, uv)
|
||||
#else
|
||||
#define SAMPLE_METALLICSPECULAR(uv) SAMPLE_TEXTURE2D(_MetallicGlossMap, sampler_MetallicGlossMap, uv)
|
||||
#endif
|
||||
|
||||
half4 SampleMetallicSpecGloss(float2 uv, half albedoAlpha)
|
||||
{
|
||||
half4 specGloss;
|
||||
|
||||
#ifdef _METALLICSPECGLOSSMAP
|
||||
specGloss = half4(SAMPLE_METALLICSPECULAR(uv));
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
specGloss.a = albedoAlpha * _Smoothness;
|
||||
#else
|
||||
specGloss.a *= _Smoothness;
|
||||
#endif
|
||||
#else // _METALLICSPECGLOSSMAP
|
||||
#if _SPECULAR_SETUP
|
||||
specGloss.rgb = _SpecColor.rgb;
|
||||
#else
|
||||
specGloss.r = _Metallic;
|
||||
specGloss.gb = 1;
|
||||
#endif
|
||||
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
specGloss.a = albedoAlpha * _Smoothness;
|
||||
#else
|
||||
specGloss.a = _Smoothness;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return specGloss;
|
||||
}
|
||||
|
||||
half SampleOcclusion(float2 uv)
|
||||
{
|
||||
//Using Packed AO instead
|
||||
// #ifdef _OCCLUSIONMAP
|
||||
// // TODO: Controls things like these by exposing SHADER_QUALITY levels (low, medium, high)
|
||||
// #if defined(SHADER_API_GLES)
|
||||
// return SAMPLE_TEXTURE2D(_OcclusionMap, sampler_OcclusionMap, uv).g;
|
||||
// #else
|
||||
// half occ = SAMPLE_TEXTURE2D(_OcclusionMap, sampler_OcclusionMap, uv).g;
|
||||
// return LerpWhiteTo(occ, _OcclusionStrength);
|
||||
// #endif
|
||||
// #else
|
||||
return half(1.0);
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
||||
// Returns clear coat parameters
|
||||
// .x/.r == mask
|
||||
// .y/.g == smoothness
|
||||
half2 SampleClearCoat(float2 uv)
|
||||
{
|
||||
#if defined(_CLEARCOAT) || defined(_CLEARCOATMAP)
|
||||
half2 clearCoatMaskSmoothness = half2(_ClearCoatMask, _ClearCoatSmoothness);
|
||||
|
||||
#if defined(_CLEARCOATMAP)
|
||||
clearCoatMaskSmoothness *= SAMPLE_TEXTURE2D(_ClearCoatMap, sampler_ClearCoatMap, uv).rg;
|
||||
#endif
|
||||
|
||||
return clearCoatMaskSmoothness;
|
||||
#else
|
||||
return half2(0.0, 1.0);
|
||||
#endif // _CLEARCOAT
|
||||
}
|
||||
|
||||
void ApplyPerPixelDisplacement(half3 viewDirTS, inout float2 uv)
|
||||
{
|
||||
// #if defined(_PARALLAXMAP)
|
||||
// uv += ParallaxMapping(TEXTURE2D_ARGS(_ParallaxMap, sampler_ParallaxMap), viewDirTS, _Parallax, uv);
|
||||
// #endif
|
||||
}
|
||||
|
||||
// Used for scaling detail albedo. Main features:
|
||||
// - Depending if detailAlbedo brightens or darkens, scale magnifies effect.
|
||||
// - No effect is applied if detailAlbedo is 0.5.
|
||||
half3 ScaleDetailAlbedo(half3 detailAlbedo, half scale)
|
||||
{
|
||||
// detailAlbedo = detailAlbedo * 2.0h - 1.0h;
|
||||
// detailAlbedo *= _DetailAlbedoMapScale;
|
||||
// detailAlbedo = detailAlbedo * 0.5h + 0.5h;
|
||||
// return detailAlbedo * 2.0f;
|
||||
|
||||
// A bit more optimized
|
||||
return half(2.0) * detailAlbedo * scale - scale + half(1.0);
|
||||
}
|
||||
|
||||
half3 ApplyDetailAlbedo(float2 detailUv, half3 albedo, half detailMask)
|
||||
{
|
||||
#if defined(_DETAIL)
|
||||
half3 detailAlbedo = 1;// SAMPLE_TEXTURE2D(_DetailAlbedoMap, sampler_DetailAlbedoMap, detailUv).rgb;
|
||||
|
||||
// In order to have same performance as builtin, we do scaling only if scale is not 1.0 (Scaled version has 6 additional instructions)
|
||||
#if defined(_DETAIL_SCALED)
|
||||
detailAlbedo = ScaleDetailAlbedo(detailAlbedo, _DetailAlbedoMapScale);
|
||||
#else
|
||||
detailAlbedo = half(2.0) * detailAlbedo;
|
||||
#endif
|
||||
|
||||
return albedo * LerpWhiteTo(detailAlbedo, detailMask);
|
||||
#else
|
||||
return albedo;
|
||||
#endif
|
||||
}
|
||||
|
||||
half3 ApplyDetailNormal(float2 detailUv, half3 normalTS, half detailMask)
|
||||
{
|
||||
//Not using
|
||||
//#if defined(_DETAIL)
|
||||
//#if BUMP_SCALE_NOT_SUPPORTED
|
||||
// half3 detailNormalTS = UnpackNormal(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv));
|
||||
// #else
|
||||
// half3 detailNormalTS = UnpackNormalScale(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv), _DetailNormalMapScale);
|
||||
// #endif
|
||||
|
||||
// // With UNITY_NO_DXT5nm unpacked vector is not normalized for BlendNormalRNM
|
||||
// // For visual consistancy we going to do in all cases
|
||||
// detailNormalTS = normalize(detailNormalTS);
|
||||
|
||||
// return lerp(normalTS, BlendNormalRNM(normalTS, detailNormalTS), detailMask); // todo: detailMask should lerp the angle of the quaternion rotation, not the normals
|
||||
////#else
|
||||
return normalTS;
|
||||
//#endif
|
||||
}
|
||||
|
||||
half3 UnpackDetailNormal(half2 details )
|
||||
{
|
||||
return (half3(details,1) * 2) - 1 ;
|
||||
}
|
||||
|
||||
//Combining all the detail calculations into one function and doing a single sample
|
||||
void ApplyDetails( half2 detailUv, inout SurfaceData surfaceData, half detailMask ){
|
||||
#if defined(_DETAIL)
|
||||
|
||||
half4 detailMap = SAMPLE_TEXTURE2D(_DetailMap, sampler_DetailMap, detailUv);
|
||||
|
||||
//Albedo
|
||||
half3 detailAlbedo = detailMap.rrr;
|
||||
// In order to have same performance as builtin, we do scaling only if scale is not 1.0 (Scaled version has 6 additional instructions)
|
||||
#if defined(_DETAIL_SCALED)
|
||||
detailAlbedo = ScaleDetailAlbedo(detailAlbedo, _DetailAlbedoMapScale);
|
||||
#else
|
||||
detailAlbedo = half(2.0) * detailAlbedo;
|
||||
#endif
|
||||
surfaceData.albedo = surfaceData.albedo * LerpWhiteTo(detailAlbedo, detailMask);
|
||||
//
|
||||
|
||||
//Normal
|
||||
half3 detailNormalTS = UnpackDetailNormal(detailMap.ag); //Assuming the packing of the detail normals
|
||||
detailNormalTS = normalize(detailNormalTS);
|
||||
//Likely better to scale the normal rather than multipling the lerp :P
|
||||
surfaceData.normalTS = lerp(surfaceData.normalTS, BlendNormalRNM(surfaceData.normalTS, detailNormalTS), detailMask * _DetailNormalMapScale); // todo: detailMask should lerp the angle of the quaternion rotation, not the normals
|
||||
//
|
||||
|
||||
//Smoothness
|
||||
half detailSmoothness = half(2.0) * detailMap.b;
|
||||
surfaceData.smoothness = surfaceData.smoothness * LerpWhiteTo( detailSmoothness, detailMask * _DetailSmoothnessMapScale);
|
||||
//
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void InitializeStandardLitSurfaceData(float2 uv, out SurfaceData outSurfaceData)
|
||||
{
|
||||
half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
|
||||
outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff);
|
||||
|
||||
half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a);
|
||||
outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb;
|
||||
|
||||
// #if _SPECULAR_SETUP
|
||||
// outSurfaceData.metallic = half(1.0);
|
||||
// outSurfaceData.specular = specGloss.rgb;
|
||||
// #else
|
||||
outSurfaceData.metallic = specGloss.r;
|
||||
outSurfaceData.specular = half3(0.0, 0.0, 0.0);
|
||||
//#endif
|
||||
|
||||
outSurfaceData.smoothness = specGloss.a;
|
||||
outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
|
||||
outSurfaceData.occlusion = specGloss.g;
|
||||
outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));
|
||||
|
||||
#if defined(_CLEARCOAT) || defined(_CLEARCOATMAP)
|
||||
half2 clearCoat = SampleClearCoat(uv);
|
||||
outSurfaceData.clearCoatMask = clearCoat.r;
|
||||
outSurfaceData.clearCoatSmoothness = clearCoat.g;
|
||||
#else
|
||||
outSurfaceData.clearCoatMask = half(0.0);
|
||||
outSurfaceData.clearCoatSmoothness = half(0.0);
|
||||
#endif
|
||||
|
||||
#if defined(_DETAIL)
|
||||
half detailMask = specGloss.b;
|
||||
float2 detailUv = uv * _DetailMap_ST.xy + _DetailMap_ST.zw;
|
||||
ApplyDetails( detailUv , outSurfaceData, detailMask);
|
||||
// outSurfaceData.albedo = ApplyDetailAlbedo(detailUv, outSurfaceData.albedo, detailMask);
|
||||
// outSurfaceData.normalTS = ApplyDetailNormal(detailUv, outSurfaceData.normalTS, detailMask);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_INPUT_SURFACE_PBR_INCLUDED
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
#ifndef UNIVERSAL_LIT_INPUT_INCLUDED
|
||||
#define UNIVERSAL_LIT_INPUT_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ParallaxMapping.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
|
||||
|
||||
#if defined(_DETAIL_MULX2) || defined(_DETAIL_SCALED)
|
||||
#define _DETAIL
|
||||
#endif
|
||||
|
||||
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _DetailAlbedoMap_ST;
|
||||
half4 _BaseColor;
|
||||
half4 _SpecColor;
|
||||
half4 _EmissionColor;
|
||||
half _Cutoff;
|
||||
half _Smoothness;
|
||||
half _Metallic;
|
||||
half _BumpScale;
|
||||
half _Parallax;
|
||||
half _OcclusionStrength;
|
||||
half _ClearCoatMask;
|
||||
half _ClearCoatSmoothness;
|
||||
half _DetailAlbedoMapScale;
|
||||
half _DetailNormalMapScale;
|
||||
half _Surface;
|
||||
CBUFFER_END
|
||||
|
||||
// NOTE: Do not ifdef the properties for dots instancing, but ifdef the actual usage.
|
||||
// Otherwise you might break CPU-side as property constant-buffer offsets change per variant.
|
||||
// NOTE: Dots instancing is orthogonal to the constant buffer above.
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _SpecColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _EmissionColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Smoothness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Metallic)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _BumpScale)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Parallax)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _OcclusionStrength)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _ClearCoatMask)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _ClearCoatSmoothness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _DetailAlbedoMapScale)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _DetailNormalMapScale)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Surface)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
|
||||
#define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata__BaseColor)
|
||||
#define _SpecColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata__SpecColor)
|
||||
#define _EmissionColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata__EmissionColor)
|
||||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Cutoff)
|
||||
#define _Smoothness UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Smoothness)
|
||||
#define _Metallic UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Metallic)
|
||||
#define _BumpScale UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__BumpScale)
|
||||
#define _Parallax UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Parallax)
|
||||
#define _OcclusionStrength UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__OcclusionStrength)
|
||||
#define _ClearCoatMask UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__ClearCoatMask)
|
||||
#define _ClearCoatSmoothness UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__ClearCoatSmoothness)
|
||||
#define _DetailAlbedoMapScale UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__DetailAlbedoMapScale)
|
||||
#define _DetailNormalMapScale UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__DetailNormalMapScale)
|
||||
#define _Surface UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Surface)
|
||||
#endif
|
||||
|
||||
TEXTURE2D(_ParallaxMap); SAMPLER(sampler_ParallaxMap);
|
||||
TEXTURE2D(_OcclusionMap); SAMPLER(sampler_OcclusionMap);
|
||||
TEXTURE2D(_DetailMask); SAMPLER(sampler_DetailMask);
|
||||
TEXTURE2D(_DetailAlbedoMap); SAMPLER(sampler_DetailAlbedoMap);
|
||||
TEXTURE2D(_DetailNormalMap); SAMPLER(sampler_DetailNormalMap);
|
||||
TEXTURE2D(_MetallicGlossMap); SAMPLER(sampler_MetallicGlossMap);
|
||||
TEXTURE2D(_SpecGlossMap); SAMPLER(sampler_SpecGlossMap);
|
||||
TEXTURE2D(_ClearCoatMap); SAMPLER(sampler_ClearCoatMap);
|
||||
|
||||
#ifdef _SPECULAR_SETUP
|
||||
#define SAMPLE_METALLICSPECULAR(uv) SAMPLE_TEXTURE2D(_SpecGlossMap, sampler_SpecGlossMap, uv)
|
||||
#else
|
||||
#define SAMPLE_METALLICSPECULAR(uv) SAMPLE_TEXTURE2D(_MetallicGlossMap, sampler_MetallicGlossMap, uv)
|
||||
#endif
|
||||
|
||||
half4 SampleMetallicSpecGloss(float2 uv, half albedoAlpha)
|
||||
{
|
||||
half4 specGloss;
|
||||
|
||||
#ifdef _METALLICSPECGLOSSMAP
|
||||
specGloss = half4(SAMPLE_METALLICSPECULAR(uv));
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
specGloss.a = albedoAlpha * _Smoothness;
|
||||
#else
|
||||
specGloss.a *= _Smoothness;
|
||||
#endif
|
||||
#else // _METALLICSPECGLOSSMAP
|
||||
#if _SPECULAR_SETUP
|
||||
specGloss.rgb = _SpecColor.rgb;
|
||||
#else
|
||||
specGloss.rgb = _Metallic.rrr;
|
||||
#endif
|
||||
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
specGloss.a = albedoAlpha * _Smoothness;
|
||||
#else
|
||||
specGloss.a = _Smoothness;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return specGloss;
|
||||
}
|
||||
|
||||
half SampleOcclusion(float2 uv)
|
||||
{
|
||||
#ifdef _OCCLUSIONMAP
|
||||
// TODO: Controls things like these by exposing SHADER_QUALITY levels (low, medium, high)
|
||||
#if defined(SHADER_API_GLES)
|
||||
return SAMPLE_TEXTURE2D(_OcclusionMap, sampler_OcclusionMap, uv).g;
|
||||
#else
|
||||
half occ = SAMPLE_TEXTURE2D(_OcclusionMap, sampler_OcclusionMap, uv).g;
|
||||
return LerpWhiteTo(occ, _OcclusionStrength);
|
||||
#endif
|
||||
#else
|
||||
return half(1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Returns clear coat parameters
|
||||
// .x/.r == mask
|
||||
// .y/.g == smoothness
|
||||
half2 SampleClearCoat(float2 uv)
|
||||
{
|
||||
#if defined(_CLEARCOAT) || defined(_CLEARCOATMAP)
|
||||
half2 clearCoatMaskSmoothness = half2(_ClearCoatMask, _ClearCoatSmoothness);
|
||||
|
||||
#if defined(_CLEARCOATMAP)
|
||||
clearCoatMaskSmoothness *= SAMPLE_TEXTURE2D(_ClearCoatMap, sampler_ClearCoatMap, uv).rg;
|
||||
#endif
|
||||
|
||||
return clearCoatMaskSmoothness;
|
||||
#else
|
||||
return half2(0.0, 1.0);
|
||||
#endif // _CLEARCOAT
|
||||
}
|
||||
|
||||
void ApplyPerPixelDisplacement(half3 viewDirTS, inout float2 uv)
|
||||
{
|
||||
#if defined(_PARALLAXMAP)
|
||||
uv += ParallaxMapping(TEXTURE2D_ARGS(_ParallaxMap, sampler_ParallaxMap), viewDirTS, _Parallax, uv);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Used for scaling detail albedo. Main features:
|
||||
// - Depending if detailAlbedo brightens or darkens, scale magnifies effect.
|
||||
// - No effect is applied if detailAlbedo is 0.5.
|
||||
half3 ScaleDetailAlbedo(half3 detailAlbedo, half scale)
|
||||
{
|
||||
// detailAlbedo = detailAlbedo * 2.0h - 1.0h;
|
||||
// detailAlbedo *= _DetailAlbedoMapScale;
|
||||
// detailAlbedo = detailAlbedo * 0.5h + 0.5h;
|
||||
// return detailAlbedo * 2.0f;
|
||||
|
||||
// A bit more optimized
|
||||
return half(2.0) * detailAlbedo * scale - scale + half(1.0);
|
||||
}
|
||||
|
||||
half3 ApplyDetailAlbedo(float2 detailUv, half3 albedo, half detailMask)
|
||||
{
|
||||
#if defined(_DETAIL)
|
||||
half3 detailAlbedo = SAMPLE_TEXTURE2D(_DetailAlbedoMap, sampler_DetailAlbedoMap, detailUv).rgb;
|
||||
|
||||
// In order to have same performance as builtin, we do scaling only if scale is not 1.0 (Scaled version has 6 additional instructions)
|
||||
#if defined(_DETAIL_SCALED)
|
||||
detailAlbedo = ScaleDetailAlbedo(detailAlbedo, _DetailAlbedoMapScale);
|
||||
#else
|
||||
detailAlbedo = half(2.0) * detailAlbedo;
|
||||
#endif
|
||||
|
||||
return albedo * LerpWhiteTo(detailAlbedo, detailMask);
|
||||
#else
|
||||
return albedo;
|
||||
#endif
|
||||
}
|
||||
|
||||
half3 ApplyDetailNormal(float2 detailUv, half3 normalTS, half detailMask)
|
||||
{
|
||||
#if defined(_DETAIL)
|
||||
#if BUMP_SCALE_NOT_SUPPORTED
|
||||
half3 detailNormalTS = UnpackNormal(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv));
|
||||
#else
|
||||
half3 detailNormalTS = UnpackNormalScale(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv), _DetailNormalMapScale);
|
||||
#endif
|
||||
|
||||
// With UNITY_NO_DXT5nm unpacked vector is not normalized for BlendNormalRNM
|
||||
// For visual consistancy we going to do in all cases
|
||||
detailNormalTS = normalize(detailNormalTS);
|
||||
|
||||
return lerp(normalTS, BlendNormalRNM(normalTS, detailNormalTS), detailMask); // todo: detailMask should lerp the angle of the quaternion rotation, not the normals
|
||||
#else
|
||||
return normalTS;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void InitializeStandardLitSurfaceData(float2 uv, out SurfaceData outSurfaceData)
|
||||
{
|
||||
half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
|
||||
outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff);
|
||||
|
||||
half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a);
|
||||
outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb;
|
||||
|
||||
#if _SPECULAR_SETUP
|
||||
outSurfaceData.metallic = half(1.0);
|
||||
outSurfaceData.specular = specGloss.rgb;
|
||||
#else
|
||||
outSurfaceData.metallic = specGloss.r;
|
||||
outSurfaceData.specular = half3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
|
||||
outSurfaceData.smoothness = specGloss.a;
|
||||
outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
|
||||
outSurfaceData.occlusion = SampleOcclusion(uv);
|
||||
outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));
|
||||
|
||||
#if defined(_CLEARCOAT) || defined(_CLEARCOATMAP)
|
||||
half2 clearCoat = SampleClearCoat(uv);
|
||||
outSurfaceData.clearCoatMask = clearCoat.r;
|
||||
outSurfaceData.clearCoatSmoothness = clearCoat.g;
|
||||
#else
|
||||
outSurfaceData.clearCoatMask = half(0.0);
|
||||
outSurfaceData.clearCoatSmoothness = half(0.0);
|
||||
#endif
|
||||
|
||||
#if defined(_DETAIL)
|
||||
half detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).a;
|
||||
float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw;
|
||||
outSurfaceData.albedo = ApplyDetailAlbedo(detailUv, outSurfaceData.albedo, detailMask);
|
||||
outSurfaceData.normalTS = ApplyDetailNormal(detailUv, outSurfaceData.normalTS, detailMask);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_INPUT_SURFACE_PBR_INCLUDED
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 356e89f7621524b44bc9bd1f57ec51c5
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c46f85bf266d7496d9b3659acfbdc711
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9ed50b25f2438544793a5793591f5563
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,310 @@
|
|||
// Force reimport: 2
|
||||
Shader "SLZ/LitMAS/LitMAS Standard"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainTexture] _BaseMap("Base Map", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("BaseColor", Color) = (1,1,1,1)
|
||||
[ToggleUI] _Normals("Normal Map enabled", Float) = 0
|
||||
[NoScaleOffset][Normal] _BumpMap ("Normal map", 2D) = "bump" {}
|
||||
[NoScaleOffset]_MetallicGlossMap("MAS", 2D) = "white" {}
|
||||
[Space(30)][Header(Emissions)][Space(10)][ToggleUI] _Emission("Emission Enable", Float) = 0
|
||||
[NoScaleOffset]_EmissionMap("Emission Map", 2D) = "white" {}
|
||||
[HDR]_EmissionColor("Emission Color", Color) = (1,1,1,1)
|
||||
_EmissionFalloff("Emission Falloff", Float) = 1
|
||||
_BakedMutiplier("Emission Baked Mutiplier", Float) = 1
|
||||
[Space(30)][Header(Details)][Space(10)][Toggle(_DETAILS_ON)] _Details("Details enabled", Float) = 0
|
||||
_DetailMap("Detail Map", 2D) = "gray" {}
|
||||
[Space(30)][Header(Screen Space Reflections)][Space(10)][Toggle(_NO_SSR)] _SSROff("Disable SSR", Float) = 0
|
||||
[Header(This should be 0 for skinned meshes)]
|
||||
_SSRTemporalMul("Temporal Accumulation Factor", Range(0, 2)) = 1.0
|
||||
//[Toggle(_SM6_QUAD)] _SM6_Quad("Quad-avg SSR", Float) = 0
|
||||
|
||||
[HideInInspector]_Surface ("Surface Type", float) = 0
|
||||
[HideInInspector]_BlendSrc ("Blend Source", float) = 1
|
||||
[HideInInspector]_BlendDst ("Blend Destination", float) = 0
|
||||
[HideInInspector][ToggleUI] _ZWrite ("ZWrite", float) = 1
|
||||
[HideInInspector]_Cull ("Cull Side", float) = 2
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags {"RenderPipeline" = "UniversalPipeline" "RenderType" = "Opaque" "Queue" = "Geometry" }
|
||||
|
||||
ZTest LEqual
|
||||
Offset 0 , 0
|
||||
ColorMask RGBA
|
||||
//LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_BlendSrc] [_BlendDst]
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
Name "Forward"
|
||||
Tags {"Lightmode"="UniversalForward"}
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 5.0
|
||||
|
||||
#define LITMAS_FEATURE_LIGHTMAPPING
|
||||
#define LITMAS_FEATURE_TS_NORMALS
|
||||
#define LITMAS_FEATURE_EMISSION
|
||||
#define LITMAS_FEATURE_SSR
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#if defined(SHADER_API_DESKTOP)
|
||||
//#pragma require WaveVote
|
||||
//#pragma require QuadShuffle
|
||||
//#pragma shader_feature _SM6_QUAD
|
||||
//#define _SM6_QUAD 1
|
||||
#endif
|
||||
|
||||
#include_with_pragmas "LitMASInclude/ShaderInjector/StandardForward.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "DepthOnly"
|
||||
Tags {"Lightmode"="DepthOnly"}
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/DepthOnly.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags {"Lightmode" = "DepthNormals"}
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
//ZTest Off
|
||||
//ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/ShaderInjector/StandardDepthNormals.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
|
||||
ZWrite [_ZWrite]
|
||||
ZTest LEqual
|
||||
|
||||
Cull [_Cull]
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/ShadowCaster.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags { "LightMode" = "Meta" }
|
||||
Blend [_BlendSrc] [_BlendDst]
|
||||
ZWrite [_ZWrite]
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers vulkan
|
||||
#define _NORMAL_DROPOFF_TS 1
|
||||
#define _EMISSION
|
||||
#define _NORMALMAP 1
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#define SHADERPASS SHADERPASS_META
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/ShaderInjector/StandardMeta.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "BakedRaytrace"
|
||||
Tags{ "LightMode" = "BakedRaytrace" }
|
||||
HLSLPROGRAM
|
||||
#pragma only_renderers vulkan
|
||||
#pragma multi_compile _ _EMISSION_ON
|
||||
#include "LitMASInclude/ShaderInjector/StandardBakedRT.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicate subshader for DX11, since using '#pragma require' automatically marks the whole subshader as invalid for dx11 even if its guarded by an API define
|
||||
SubShader
|
||||
{
|
||||
Tags {"RenderPipeline" = "UniversalPipeline" "RenderType" = "Opaque" "Queue" = "Geometry" }
|
||||
|
||||
ZTest LEqual
|
||||
Offset 0 , 0
|
||||
ColorMask RGBA
|
||||
//LOD 100
|
||||
|
||||
HLSLINCLUDE
|
||||
//
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_BlendSrc] [_BlendDst]
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
Name "Forward"
|
||||
Tags {"Lightmode"="UniversalForward"}
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 5.0
|
||||
|
||||
#define LITMAS_FEATURE_LIGHTMAPPING
|
||||
#define LITMAS_FEATURE_TS_NORMALS
|
||||
#define LITMAS_FEATURE_EMISSION
|
||||
#define LITMAS_FEATURE_SSR
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
|
||||
//#if defined(SHADER_API_DESKTOP)
|
||||
//#pragma require QuadShuffle
|
||||
//#define _SM6_QUAD 1
|
||||
//#endif
|
||||
|
||||
#include_with_pragmas "LitMASInclude/ShaderInjector/StandardForward.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "DepthOnly"
|
||||
Tags {"Lightmode"="DepthOnly"}
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/DepthOnly.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags {"Lightmode" = "DepthNormals"}
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
//ZTest Off
|
||||
//ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/ShaderInjector/StandardDepthNormals.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
|
||||
ZWrite [_ZWrite]
|
||||
ZTest LEqual
|
||||
|
||||
Cull [_Cull]
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers vulkan
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/ShadowCaster.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags { "LightMode" = "Meta" }
|
||||
Blend [_BlendSrc] [_BlendDst]
|
||||
ZWrite [_ZWrite]
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers vulkan
|
||||
#define _NORMAL_DROPOFF_TS 1
|
||||
#define _EMISSION
|
||||
#define _NORMALMAP 1
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#define SHADERPASS SHADERPASS_META
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PlatformCompiler.hlsl"
|
||||
#include "LitMASInclude/ShaderInjector/StandardMeta.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "BakedRaytrace"
|
||||
Tags{ "LightMode" = "BakedRaytrace" }
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers vulkan
|
||||
#pragma multi_compile _ _EMISSION_ON
|
||||
#include "LitMASInclude/ShaderInjector/StandardBakedRT.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
//CustomEditor "LitMASGUI"
|
||||
CustomEditor "UnityEditor.LitMASIMGUI"
|
||||
//Fallback "Hidden/InternalErrorShader"
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e2bc12b142787a84e95ff4f3ca0bac39
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _BaseMap: {instanceID: 0}
|
||||
- _BumpMap: {instanceID: 0}
|
||||
- _MetallicGlossMap: {fileID: 2800000, guid: 93d3930e8ab926f48a63ecc221b21768, type: 3}
|
||||
- _EmissionMap: {instanceID: 0}
|
||||
- _DetailMap: {fileID: 2800000, guid: 633cfe6a6d4ee694c98830c630980cad, type: 3}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f4055219dc81cfe4485948b7056d2c33
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
#define SHADERPASS SHADERPASS_RAYTRACE
|
||||
|
||||
#include "UnityRaytracingMeshUtils.cginc"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
|
||||
#pragma raytracing BakeHit
|
||||
|
||||
struct RayPayload
|
||||
{
|
||||
float4 color;
|
||||
float3 dir;
|
||||
};
|
||||
|
||||
struct AttributeData
|
||||
{
|
||||
float2 barycentrics;
|
||||
};
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
float2 texcoord;
|
||||
float3 normal;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//https://coty.tips/raytracing-in-unity/
|
||||
[shader("closesthit")]
|
||||
void MyClosestHit(inout RayPayload payload, AttributeData attributes : SV_IntersectionAttributes) {
|
||||
|
||||
payload.color = float4(0,0,0,1); //Intializing
|
||||
payload.dir = float3(1,0,0);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1a9296f383d90fd449eb6306ed1d32c2
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
#define SHADERPASS SHADERPASS_DEPTHNORMALS
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/EncodeNormalsTexture.hlsl"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half3 normal : NORMAL;
|
||||
// half4 tangent : TANGENT;
|
||||
//float3 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
//float2 uv : TEXCOORD0;
|
||||
half3 normalWS : NORMAL;
|
||||
//half3 tangentWS : TANGENT;
|
||||
//half3 bitangentWS : BITANGENT;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
//o.uv = mad(v.uv.xy, _BaseMap_ST.xy, _BaseMap_ST.zw);
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
|
||||
//VertexNormalInputs ntb = GetVertexNormalInputs(v.normal, v.tangent);
|
||||
o.normalWS = TransformObjectToWorldNormal(v.normal);
|
||||
//o.tangentWS = ntb.tangentWS;
|
||||
//o.bitangentWS = ntb.bitangentWS;
|
||||
return o;
|
||||
}
|
||||
|
||||
/* Just set object normals for now, reading normal map in depth-normals prepass is expensive*/
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half3 normals = NormalizeNormalPerPixel(i.normalWS);
|
||||
normals = EncodeWSNormalForNormalsTex(normals);
|
||||
return half4(normals, 0.0);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27f6899236e35954799bd662d6dc8f5a
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#define SHADERPASS SHADERPASS_DEPTHONLY
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ea9faeb952d79a24f9be0debf6bd551c
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,438 @@
|
|||
|
||||
#define SHADERPASS SHADERPASS_FORWARD
|
||||
#define _NORMAL_DROPOFF_TS 1
|
||||
#define _EMISSION
|
||||
#define _NORMALMAP 1
|
||||
|
||||
#if defined(SHADER_API_MOBILE)
|
||||
#define _ADDITIONAL_LIGHTS_VERTEX
|
||||
#else
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
|
||||
#pragma shader_feature_fragment _ADDITIONAL_LIGHTS
|
||||
#pragma shader_feature_fragment _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma shader_feature_fragment _SHADOWS_SOFT
|
||||
|
||||
#pragma shader_feature_fragment _REFLECTION_PROBE_BLENDING
|
||||
//#pragma shader_feature_fragment _REFLECTION_PROBE_BOX_PROJECTION
|
||||
// We don't need a keyword for this! the w component of the probe position already branches box vs non-box, & so little cost on pc it doesn't matter
|
||||
#define _REFLECTION_PROBE_BOX_PROJECTION
|
||||
|
||||
#if defined(LITMAS_FEATURE_SSR)
|
||||
#pragma shader_feature_local_fragment _ _SSR_ON
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_TP)
|
||||
#pragma multi_compile_local_fragment _ _EXPENSIVE_TP
|
||||
|
||||
#if defined(_EXPENSIVE_TP)
|
||||
#define SLZ_SAMPLE_TP_MAIN(tex, sampl, uv) SAMPLE_TEXTURE2D_GRAD(tex, sampl, uv, ddxMain, ddyMain)
|
||||
#define SLZ_SAMPLE_TP_DETAIL(tex, sampl, uv) SAMPLE_TEXTURE2D_GRAD(tex, sampl, uv, ddxDetail, ddyDetail)
|
||||
#else
|
||||
#define SLZ_SAMPLE_TP_MAIN(tex, sampl, uv) SAMPLE_TEXTURE2D(tex, sampl, uv)
|
||||
#define SLZ_SAMPLE_TP_DETAIL(tex, sampl, uv) SAMPLE_TEXTURE2D(tex, sampl, uv)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#pragma multi_compile_fragment _ _VOLUMETRICS_ENABLED
|
||||
#pragma multi_compile_fog
|
||||
#pragma skip_variants FOG_LINEAR FOG_EXP
|
||||
//#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
#pragma multi_compile_fragment _ _DETAILS_ON
|
||||
//#pragma multi_compile_fragment _ _EMISSION_ON
|
||||
|
||||
#if defined(LITMAS_FEATURE_LIGHTMAPPING)
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#endif
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SLZLighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SLZBlueNoise.hlsl"
|
||||
#if !defined(SHADER_API_MOBILE) && defined(LITMAS_FEATURE_SSR)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SLZLightingSSR.hlsl"
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_TP)
|
||||
#include "Include/Triplanar.hlsl"
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_IMPACTS)
|
||||
#include "LitMASInclude/PosespaceImpacts.hlsl"
|
||||
#endif
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 uv0 : TEXCOORD0;
|
||||
float4 uv1 : TEXCOORD1;
|
||||
float4 uv2 : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 uv0XY_bitZ_fog: TEXCOORD0;
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
float4 uv1 : TEXCOORD1;
|
||||
#endif
|
||||
half4 SHVertLights : TEXCOORD2;
|
||||
half4 normXYZ_tanX : TEXCOORD3;
|
||||
#if defined(LITMAS_FEATURE_TS_NORMALS)
|
||||
half4 tanYZ_bitXY : TEXCOORD4;
|
||||
#endif
|
||||
float3 wPos : TEXCOORD5;
|
||||
|
||||
#if defined(LITMAS_FEATURE_IMPACTS)
|
||||
float3 unskinnedObjPos : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
TEXTURE2D(_BumpMap);
|
||||
TEXTURE2D(_MetallicGlossMap);
|
||||
TEXTURE2D(_EmissionMap);
|
||||
|
||||
TEXTURE2D(_DetailMap);
|
||||
SAMPLER(sampler_DetailMap);
|
||||
|
||||
#if defined(LITMAS_FEATURE_WHITEBOARD)
|
||||
TEXTURE2D(_PenMap);
|
||||
#endif
|
||||
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _DetailMap_ST;
|
||||
half4 _BaseColor;
|
||||
half _Details;
|
||||
half _Normals;
|
||||
half _Emission;
|
||||
half4 _EmissionColor;
|
||||
half _EmissionFalloff;
|
||||
half _BakedMutiplier;
|
||||
|
||||
#if defined(LITMAS_FEATURE_TP)
|
||||
half _DetailsuseLocalUVs;
|
||||
half _RotateUVs;
|
||||
half _UVScaler;
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_SSR)
|
||||
half _SSRSmoothPow;
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_WHITEBOARD)
|
||||
float4 _PenMap_ST;
|
||||
half _PenMono;
|
||||
half4 _PenMonoColor;
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_IMPACTS)
|
||||
float4x4 EllipsoidPosArray[HitArrayCount];
|
||||
int _NumberOfHits;
|
||||
float4 _HitColor;
|
||||
#endif
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
half3 OverlayBlendDetail(half source, half3 destination)
|
||||
{
|
||||
half3 switch0 = round(destination); // if destination >= 0.5 then 1, else 0 assuming 0-1 input
|
||||
half3 blendGreater = mad(mad(2.0, destination, -2.0), 1.0 - source, 1.0); // (2.0 * destination - 2.0) * ( 1.0 - source) + 1.0
|
||||
half3 blendLesser = (2.0 * source) * destination;
|
||||
return mad(switch0, blendGreater, mad(-switch0, blendLesser, blendLesser)); // switch0 * blendGreater + (1 - switch0) * blendLesser
|
||||
//return half3(destination.r > 0.5 ? blendGreater.r : blendLesser.r,
|
||||
// destination.g > 0.5 ? blendGreater.g : blendLesser.g,
|
||||
// destination.b > 0.5 ? blendGreater.b : blendLesser.b
|
||||
// );
|
||||
}
|
||||
|
||||
|
||||
VertOut vert(VertIn v)
|
||||
{
|
||||
VertOut o = (VertOut)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.wPos = TransformObjectToWorld(v.vertex.xyz);
|
||||
o.vertex = TransformWorldToHClip(o.wPos);
|
||||
o.uv0XY_bitZ_fog.xy = v.uv0.xy;
|
||||
|
||||
#if defined(LIGHTMAP_ON) || defined(DIRLIGHTMAP_COMBINED)
|
||||
OUTPUT_LIGHTMAP_UV(v.uv1.xy, unity_LightmapST, o.uv1.xy);
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
OUTPUT_LIGHTMAP_UV(v.uv2.xy, unity_DynamicLightmapST, o.uv1.zw);
|
||||
#endif
|
||||
|
||||
// Calculate tangent to world basis vectors
|
||||
#if defined(LITMAS_FEATURE_TS_NORMALS)
|
||||
VertexNormalInputs ntb = GetVertexNormalInputs(v.normal, v.tangent);
|
||||
o.normXYZ_tanX = half4(ntb.normalWS, ntb.tangentWS.x);
|
||||
o.tanYZ_bitXY = half4(ntb.tangentWS.yz, ntb.bitangentWS.xy);
|
||||
o.uv0XY_bitZ_fog.z = ntb.bitangentWS.z;
|
||||
#else
|
||||
o.normXYZ_tanX = half4(TransformObjectToWorldNormal(v.normal, false), 0);
|
||||
o.uv0XY_bitZ_fog.z = v.tangent.w; //Avoid optimization that would remove the tangent from the vertex input (causes issues)
|
||||
#endif
|
||||
|
||||
// Exp2 fog
|
||||
half clipZ_0Far = UNITY_Z_0_FAR_FROM_CLIPSPACE(o.vertex.z);
|
||||
o.uv0XY_bitZ_fog.w = unity_FogParams.x * clipZ_0Far;
|
||||
|
||||
o.SHVertLights = 0;
|
||||
// Calculate vertex lights and L2 probe lighting on quest
|
||||
|
||||
o.SHVertLights.xyz = VertexLighting(o.wPos, o.normXYZ_tanX.xyz);
|
||||
#if !defined(LIGHTMAP_ON) && !defined(DYNAMICLIGHTMAP_ON) && defined(SHADER_API_MOBILE)
|
||||
o.SHVertLights.xyz += SampleSHVertex(o.normXYZ_tanX.xyz);
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_IMPACTS)
|
||||
o.unskinnedObjPos = v.uv2;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(VertOut i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*---Read Input Data---------------------------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#if defined(LITMAS_FEATURE_TP) /*-Triplanar------------------------------------------------------------------------------*/
|
||||
|
||||
float2 uvTP;
|
||||
half3x3 TStoWsTP;
|
||||
half2 scale = 1.0/_UVScaler;
|
||||
|
||||
#if defined(_EXPENSIVE_TP)
|
||||
tpDerivatives tpDD;
|
||||
GetDirectionalDerivatives(i.wPos, tpDD);
|
||||
half2 ddxTP, ddyTP;
|
||||
GetTPUVExpensive(uvTP, ddxTP, ddyTP, TStoWsTP, i.wPos, normalize(i.normXYZ_tanX.xyz), tpDD);
|
||||
ddxTP = _RotateUVs ? half2(-ddxTP.y, ddxTP.x) : ddxTP;
|
||||
ddyTP = _RotateUVs ? half2(-ddyTP.y, ddyTP.x) : ddyTP;
|
||||
half2 ddxMain = ddxTP * scale;
|
||||
half2 ddyMain = ddyTP * scale;
|
||||
#else
|
||||
GetTPUVCheap(uvTP, TStoWsTP, i.wPos, normalize(i.normXYZ_tanX.xyz));
|
||||
#endif
|
||||
|
||||
uvTP = _RotateUVs ? float2(-uvTP.y, uvTP.x) : uvTP;
|
||||
float2 uv_main = mad(uvTP, scale, _BaseMap_ST.zw);
|
||||
half4 albedo = SLZ_SAMPLE_TP_MAIN(_BaseMap, sampler_BaseMap, uv_main) * _BaseColor;
|
||||
half3 mas = SLZ_SAMPLE_TP_MAIN(_MetallicGlossMap, sampler_BaseMap, uv_main).rgb;
|
||||
|
||||
|
||||
#else /*-Non-Triplanar---------------------------------------------------------------------------------------------------*/
|
||||
|
||||
float2 uv_main = mad(float2(i.uv0XY_bitZ_fog.xy), _BaseMap_ST.xy, _BaseMap_ST.zw);
|
||||
float2 uv_detail = mad(float2(i.uv0XY_bitZ_fog.xy), _DetailMap_ST.xy, _DetailMap_ST.zw);
|
||||
half4 albedo = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv_main) * _BaseColor;
|
||||
half3 mas = SAMPLE_TEXTURE2D(_MetallicGlossMap, sampler_BaseMap, uv_main).rgb;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_WHITEBOARD) /*-Whiteboard---------------------------------------------------------------------*/
|
||||
|
||||
float2 uv_pen = mad(float2(i.uv0XY_bitZ_fog.xy), _PenMap_ST.xy, _PenMap_ST.zw);
|
||||
half4 penMap = SAMPLE_TEXTURE2D(_PenMap, sampler_BaseMap, uv_pen);
|
||||
penMap = _PenMono > 0.5 ? penMap.rrrr : penMap;
|
||||
penMap.rgb = _PenMono > 0.5 ? penMap.rgb * _PenMonoColor.rgb : penMap.rgb;
|
||||
albedo.rgb = penMap.rgb + albedo.rgb * (1.0h - penMap.a);
|
||||
|
||||
#endif
|
||||
|
||||
half metallic = mas.r;
|
||||
half ao = mas.g;
|
||||
half smoothness = mas.b;
|
||||
|
||||
#if defined(LITMAS_FEATURE_IMPACTS)
|
||||
half2 impactUV = GetClosestImpactUV(i.unskinnedObjPos, EllipsoidPosArray, HitArrayCount);
|
||||
half4 impactMASI = SampleHitTexture(impactUV);
|
||||
impactMASI.a = impactUV.x > 0.999 ? 0 : impactMASI.a;
|
||||
albedo = lerp(_HitColor, albedo, impactMASI.a);
|
||||
metallic = lerp(impactMASI.r, metallic, impactMASI.a);
|
||||
smoothness = lerp(impactMASI.b, smoothness, impactMASI.a);
|
||||
ao = min(ao, max(impactMASI.a, impactMASI.g));
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*---Sample Normal Map-------------------------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
half3 normalTS = half3(0, 0, 1);
|
||||
half geoSmooth = 1;
|
||||
half4 normalMap = half4(0, 0, 1, 0);
|
||||
|
||||
#if defined(LITMAS_FEATURE_TS_NORMALS) /*-Tangent Space Normals----------------------------------------------------------*/
|
||||
|
||||
normalMap = SAMPLE_TEXTURE2D(_BumpMap, sampler_BaseMap, uv_main);
|
||||
normalTS = UnpackNormal(normalMap);
|
||||
normalTS = _Normals ? normalTS : half3(0, 0, 1);
|
||||
geoSmooth = _Normals ? normalMap.b : 1.0;
|
||||
smoothness = saturate(smoothness + geoSmooth - 1.0);
|
||||
|
||||
#elif defined(LITMAS_FEATURE_TP) /*-Triplanar Psuedo tangent space normals-----------------------------------------------*/
|
||||
|
||||
normalMap = SLZ_SAMPLE_TP_MAIN(_BumpMap, sampler_BaseMap, uv_main);
|
||||
normalTS = UnpackNormal(normalMap);
|
||||
normalTS = _Normals ? normalTS : half3(0, 0, 1);
|
||||
normalTS = _RotateUVs ? half3(normalTS.y, -normalTS.x, normalTS.z) : normalTS;
|
||||
geoSmooth = _Normals ? normalMap.b : 1.0;
|
||||
smoothness = saturate(smoothness + geoSmooth - 1.0);
|
||||
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*---Read Detail Map---------------------------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#if defined(_DETAILS_ON)
|
||||
|
||||
#if defined(LITMAS_FEATURE_TP) /*-Triplanar--------------------------------------------------------------------------*/
|
||||
|
||||
float2 uv_detail = mad(uvTP, _DetailMap_ST.xx, _DetailMap_ST.zw);
|
||||
uv_detail = _DetailsuseLocalUVs ? mad(float2(i.uv0XY_bitZ_fog.xy), _DetailMap_ST.xy, _DetailMap_ST.zw) : uv_detail;
|
||||
#if defined(_EXPENSIVE_TP)
|
||||
half2 ddxDetail = ddx(uv_detail);
|
||||
half2 ddyDetail = ddy(uv_detail);
|
||||
ddxDetail = _DetailsuseLocalUVs ? ddxDetail : ddxTP * _DetailMap_ST.xx;
|
||||
ddyDetail = _DetailsuseLocalUVs ? ddyDetail : ddyTP * _DetailMap_ST.xx;
|
||||
#endif
|
||||
half4 detailMap = SLZ_SAMPLE_TP_DETAIL(_DetailMap, sampler_DetailMap, uv_detail);
|
||||
half3 detailTS = half3(2.0 * detailMap.ag - 1.0, 1.0);
|
||||
detailTS = _RotateUVs && !(_DetailsuseLocalUVs) ? half3(detailTS.y, -detailTS.x, detailTS.z) : detailTS;
|
||||
normalTS = BlendNormal(normalTS, detailTS);
|
||||
|
||||
#elif defined(LITMAS_FEATURE_TS_NORMALS) /*-Tangent Space Normals----------------------------------------------------*/
|
||||
|
||||
half4 detailMap = SAMPLE_TEXTURE2D(_DetailMap, sampler_DetailMap, uv_detail);
|
||||
half3 detailTS = half3(2.0 * detailMap.ag - 1.0, 1.0);
|
||||
normalTS = BlendNormal(normalTS, detailTS);
|
||||
|
||||
#else /*-Default-----------------------------------------------------------------------------------------------------*/
|
||||
|
||||
half4 detailMap = SAMPLE_TEXTURE2D(_DetailMap, sampler_DetailMap, uv_detail);
|
||||
|
||||
#endif
|
||||
|
||||
smoothness = saturate(2.0 * detailMap.b * smoothness);
|
||||
albedo.rgb = OverlayBlendDetail(detailMap.r, albedo.rgb);
|
||||
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*---Transform Normals To Worldspace-----------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#if defined(LITMAS_FEATURE_TS_NORMALS) /*-Tangent Space Normals----------------------------------------------------------*/
|
||||
half3 normalWS = i.normXYZ_tanX.xyz;
|
||||
half3x3 TStoWS = half3x3(
|
||||
i.normXYZ_tanX.w, i.tanYZ_bitXY.z, normalWS.x,
|
||||
i.tanYZ_bitXY.x, i.tanYZ_bitXY.w, normalWS.y,
|
||||
i.tanYZ_bitXY.y, i.uv0XY_bitZ_fog.z, normalWS.z
|
||||
);
|
||||
|
||||
normalWS = mul(TStoWS, normalTS);
|
||||
normalWS = normalize(normalWS);
|
||||
|
||||
#elif defined(LITMAS_FEATURE_TP) /*-Triplanar----------------------------------------------------------------------------*/
|
||||
|
||||
half3 normalWS = mul(TStoWsTP, normalTS);
|
||||
normalWS = normalize(normalWS);
|
||||
|
||||
#else /*-Default---------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
half3 normalWS = i.normXYZ_tanX.xyz;
|
||||
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*---Lighting Calculations---------------------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#if !defined(SHADER_API_MOBILE) && !defined(LITMAS_FEATURE_TP) // Specular antialiasing based on normal derivatives. Only on PC to avoid cost of derivatives on Quest
|
||||
smoothness = min(smoothness, SLZGeometricSpecularAA(normalWS));
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(LIGHTMAP_ON)
|
||||
SLZFragData fragData = SLZGetFragData(i.vertex, i.wPos, normalWS, i.uv1.xy, i.uv1.zw, i.SHVertLights.xyz);
|
||||
#else
|
||||
SLZFragData fragData = SLZGetFragData(i.vertex, i.wPos, normalWS, float2(0, 0), float2(0, 0), i.SHVertLights.xyz);
|
||||
#endif
|
||||
|
||||
half4 emission = half4(0,0,0,0);
|
||||
|
||||
#if defined(LITMAS_FEATURE_EMISSION) /*-Emission-------------------------------------------------------------------------*/
|
||||
|
||||
UNITY_BRANCH if (_Emission)
|
||||
{
|
||||
emission = SAMPLE_TEXTURE2D(_EmissionMap, sampler_BaseMap, uv_main) * _EmissionColor;
|
||||
emission.rgb *= lerp(albedo.rgb, half3(1, 1, 1), emission.a);
|
||||
emission.rgb *= pow(abs(fragData.NoV), _EmissionFalloff);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LITMAS_FEATURE_SSR) && defined(_SSR_ON) && !defined(SHADER_API_MOBILE) /*-SSR--------------------------------*/
|
||||
|
||||
smoothness = pow(smoothness, _SSRSmoothPow);
|
||||
|
||||
#endif
|
||||
|
||||
SLZSurfData surfData = SLZGetSurfDataMetallicGloss(albedo.rgb, saturate(metallic), saturate(smoothness), ao, emission.rgb);
|
||||
half4 color = half4(1, 1, 1, 1);
|
||||
|
||||
#if defined(LITMAS_FEATURE_SSR) && defined(_SSR_ON) && !defined(SHADER_API_MOBILE) /*-SSR--------------------------------*/
|
||||
|
||||
half4 noiseRGBA = GetScreenNoiseRGBA(fragData.screenUV);
|
||||
color.rgb = SLZPBRFragmentSSR(fragData, surfData, i.normXYZ_tanX.xyz, noiseRGBA);
|
||||
|
||||
#else /*-Default---------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
color.rgb = SLZPBRFragment(fragData, surfData);
|
||||
|
||||
#endif
|
||||
|
||||
color.rgb = MixFog(color.rgb, -fragData.viewDir, i.uv0XY_bitZ_fog.w);
|
||||
color = Volumetrics(color, fragData.position);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 54b2789cde005854c84407f978e9f09b
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
TEXTURE2D(_EmissionMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _DetailMap_ST;
|
||||
half4 _BaseColor;
|
||||
half _Details;
|
||||
half _Normals;
|
||||
half _Emission;
|
||||
half4 _EmissionColor;
|
||||
half _EmissionFalloff;
|
||||
half _BakedMutiplier;
|
||||
CBUFFER_END
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 uv0 : TEXCOORD0;
|
||||
|
||||
float4 uv1 : TEXCOORD1;
|
||||
float4 uv2 : TEXCOORD2;
|
||||
float4 uv3 : TEXCOORD3;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
float4 VizUV : TEXCOORD2;
|
||||
float4 LightCoord : TEXCOORD3;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityMetaVertexPosition(v.vertex.xyz, v.uv1.xy, v.uv2.xy);
|
||||
o.uv = TRANSFORM_TEX(v.uv0.xy, _BaseMap);
|
||||
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
float2 vizUV = 0;
|
||||
float4 lightCoord = 0;
|
||||
UnityEditorVizData(v.vertex.xyz, v.uv0.xy, v.uv1.xy, v.uv2.xy, vizUV, lightCoord);
|
||||
o.VizUV = float4(vizUV, 0, 0);
|
||||
o.LightCoord = lightCoord;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
MetaInput metaInput = (MetaInput)0;
|
||||
half4 albedo = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, i.uv) * _BaseColor;
|
||||
metaInput.Albedo = albedo.rgb;
|
||||
half4 emission = _EmissionColor * SAMPLE_TEXTURE2D(_EmissionMap, sampler_BaseMap, i.uv) * _BakedMutiplier * _Emission;
|
||||
emission.rgb *= lerp(albedo.rgb, half3(1, 1, 1), emission.a);
|
||||
metaInput.Emission = emission.rgb;
|
||||
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
metaInput.VizUV = i.VizUV.xy;
|
||||
metaInput.LightCoord = i.LightCoord;
|
||||
#endif
|
||||
|
||||
return MetaFragment(metaInput);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 304529cc25180bb46849d1aa482fd738
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4cd62495f14133740a379210d5183fb0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bd7d1f8f9838c1541abbb5c264b254f6, type: 3}
|
||||
m_Name: AudioLinkBakedRT
|
||||
m_EditorClassIdentifier:
|
||||
outputInclude: {fileID: 10900000, guid: 497a7e9f509af43459766d9be2d894a3, type: 3}
|
||||
baseInclude: {fileID: 10900000, guid: ce3db88ac7e6cc545a92a754b24343f2, type: 3}
|
||||
injectableIncludes:
|
||||
- {fileID: 10900000, guid: 86d5c622b75cede49857fef3a19dae5a, type: 3}
|
||||
- {fileID: 10900000, guid: e37116b777e0f8448a96eff25344707d, type: 3}
|
||||
- {fileID: 10900000, guid: e9c4013a5ab6b0b4f8f10326087f2fbb, type: 3}
|
||||
- {fileID: 10900000, guid: 12f5100b5c37a4e4b98bf050659ec151, type: 3}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue