testss
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#ifndef SG_DEPTH_ONLY_PASS_INCLUDED
|
||||
#define SG_DEPTH_ONLY_PASS_INCLUDED
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = (PackedVaryings)0;
|
||||
packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#endif
|
||||
|
||||
return float4(PackNormalOctRectEncode(TransformWorldToViewDir(unpacked.normalWS, true)), 0.0, 0.0);
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,29 @@
|
||||
#ifndef SG_DEPTH_ONLY_PASS_INCLUDED
|
||||
#define SG_DEPTH_ONLY_PASS_INCLUDED
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = (PackedVaryings)0;
|
||||
packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,32 @@
|
||||
#ifndef SG_LIT_META_INCLUDED
|
||||
#define SG_LIT_META_INCLUDED
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = (PackedVaryings)0;
|
||||
packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#endif
|
||||
|
||||
MetaInput metaInput = (MetaInput)0;
|
||||
metaInput.Albedo = surfaceDescription.BaseColor;
|
||||
metaInput.Emission = surfaceDescription.Emission;
|
||||
|
||||
return MetaFragment(metaInput);
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,30 @@
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = (PackedVaryings)0;
|
||||
packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
clip(alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#elif _SURFACE_TYPE_TRANSPARENT
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
#else
|
||||
half alpha = 1;
|
||||
#endif
|
||||
|
||||
half4 color = half4(surfaceDescription.BaseColor, alpha);
|
||||
return color;
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
void BuildInputData(Varyings input, SurfaceDescription surfaceDescription, out InputData inputData)
|
||||
{
|
||||
inputData.positionWS = input.positionWS;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
#if _NORMAL_DROPOFF_TS
|
||||
// IMPORTANT! If we ever support Flip on double sided materials ensure bitangent and tangent are NOT flipped.
|
||||
float crossSign = (input.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale();
|
||||
float3 bitangent = crossSign * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
inputData.normalWS = TransformTangentToWorld(surfaceDescription.NormalTS, half3x3(input.tangentWS.xyz, bitangent, input.normalWS.xyz));
|
||||
#elif _NORMAL_DROPOFF_OS
|
||||
inputData.normalWS = TransformObjectToWorldNormal(surfaceDescription.NormalOS);
|
||||
#elif _NORMAL_DROPOFF_WS
|
||||
inputData.normalWS = surfaceDescription.NormalWS;
|
||||
#endif
|
||||
#else
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
inputData.viewDirectionWS = SafeNormalize(input.viewDirectionWS);
|
||||
|
||||
#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 = input.fogFactorAndVertexLight.x;
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.sh, inputData.normalWS);
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV);
|
||||
}
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = (PackedVaryings)0;
|
||||
packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
clip(alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#elif _SURFACE_TYPE_TRANSPARENT
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
#else
|
||||
half alpha = 1;
|
||||
#endif
|
||||
|
||||
InputData inputData;
|
||||
BuildInputData(unpacked, surfaceDescription, inputData);
|
||||
|
||||
#ifdef _SPECULAR_SETUP
|
||||
float3 specular = surfaceDescription.Specular;
|
||||
float metallic = 1;
|
||||
#else
|
||||
float3 specular = 0;
|
||||
float metallic = surfaceDescription.Metallic;
|
||||
#endif
|
||||
|
||||
SurfaceData surface = (SurfaceData)0;
|
||||
surface.albedo = surfaceDescription.BaseColor;
|
||||
surface.metallic = saturate(metallic);
|
||||
surface.specular = specular;
|
||||
surface.smoothness = saturate(surfaceDescription.Smoothness),
|
||||
surface.occlusion = surfaceDescription.Occlusion,
|
||||
surface.emission = surfaceDescription.Emission,
|
||||
surface.alpha = saturate(alpha);
|
||||
surface.clearCoatMask = 0;
|
||||
surface.clearCoatSmoothness = 1;
|
||||
|
||||
#ifdef _CLEARCOAT
|
||||
surface.clearCoatMask = saturate(surfaceDescription.CoatMask);
|
||||
surface.clearCoatSmoothness = saturate(surfaceDescription.CoatSmoothness);
|
||||
#endif
|
||||
|
||||
half4 color = UniversalFragmentPBR(inputData, surface);
|
||||
|
||||
color.rgb = MixFog(color.rgb, inputData.fogCoord);
|
||||
return color;
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
void BuildInputData(Varyings input, SurfaceDescription surfaceDescription, out InputData inputData)
|
||||
{
|
||||
inputData.positionWS = input.positionWS;
|
||||
#ifdef _NORMALMAP
|
||||
|
||||
#if _NORMAL_DROPOFF_TS
|
||||
// IMPORTANT! If we ever support Flip on double sided materials ensure bitangent and tangent are NOT flipped.
|
||||
float crossSign = (input.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale();
|
||||
float3 bitangent = crossSign * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
inputData.normalWS = TransformTangentToWorld(surfaceDescription.NormalTS, half3x3(input.tangentWS.xyz, bitangent, input.normalWS.xyz));
|
||||
#elif _NORMAL_DROPOFF_OS
|
||||
inputData.normalWS = TransformObjectToWorldNormal(surfaceDescription.NormalOS);
|
||||
#elif _NORMAL_DROPOFF_WS
|
||||
inputData.normalWS = surfaceDescription.NormalWS;
|
||||
#endif
|
||||
#else
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
inputData.viewDirectionWS = SafeNormalize(input.viewDirectionWS);
|
||||
|
||||
#if defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
|
||||
#else
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
inputData.fogCoord = input.fogFactorAndVertexLight.x;
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.sh, inputData.normalWS);
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV);
|
||||
}
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = (PackedVaryings)0;
|
||||
packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
FragmentOutput frag(PackedVaryings packedInput)
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
clip(alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#elif _SURFACE_TYPE_TRANSPARENT
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
#else
|
||||
half alpha = 1;
|
||||
#endif
|
||||
|
||||
InputData inputData;
|
||||
BuildInputData(unpacked, surfaceDescription, inputData);
|
||||
|
||||
#ifdef _SPECULAR_SETUP
|
||||
float3 specular = surfaceDescription.Specular;
|
||||
float metallic = 1;
|
||||
#else
|
||||
float3 specular = 0;
|
||||
float metallic = surfaceDescription.Metallic;
|
||||
#endif
|
||||
|
||||
// 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(surfaceDescription.BaseColor, metallic, specular, surfaceDescription.Smoothness, 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, surfaceDescription.Occlusion, inputData.normalWS, inputData.viewDirectionWS);
|
||||
|
||||
return BRDFDataToGbuffer(brdfData, inputData, surfaceDescription.Smoothness, surfaceDescription.Emission + color);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
#ifndef UNIVERSAL_SHADERPASS_INCLUDED
|
||||
#define UNIVERSAL_SHADERPASS_INCLUDED
|
||||
|
||||
#define SHADERPASS_FORWARD (0)
|
||||
#define SHADERPASS_GBUFFER (1)
|
||||
#define SHADERPASS_DEPTHONLY (2)
|
||||
#define SHADERPASS_SHADOWCASTER (3)
|
||||
#define SHADERPASS_META (4)
|
||||
#define SHADERPASS_2D (5)
|
||||
#define SHADERPASS_UNLIT (6)
|
||||
#define SHADERPASS_SPRITELIT (7)
|
||||
#define SHADERPASS_SPRITENORMAL (8)
|
||||
#define SHADERPASS_SPRITEFORWARD (9)
|
||||
#define SHADERPASS_SPRITEUNLIT (10)
|
||||
#define SHADERPASS_DEPTHNORMALSONLY (11)
|
||||
#endif
|
@@ -0,0 +1,28 @@
|
||||
#ifndef SG_SHADOW_PASS_INCLUDED
|
||||
#define SG_SHADOW_PASS_INCLUDED
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = (PackedVaryings)0;
|
||||
packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,26 @@
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#ifdef UNIVERSAL_USELEGACYSPRITEBLOCKS
|
||||
half4 color = surfaceDescription.SpriteColor;
|
||||
#else
|
||||
half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha);
|
||||
#endif
|
||||
|
||||
color *= unpacked.color;
|
||||
return color;
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
#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
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/CombinedShapeLightShared.hlsl"
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#ifdef UNIVERSAL_USELEGACYSPRITEBLOCKS
|
||||
half4 color = surfaceDescription.SpriteColor;
|
||||
#else
|
||||
half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha);
|
||||
#endif
|
||||
|
||||
color *= unpacked.color;
|
||||
return CombinedShapeLightShared(color, surfaceDescription.SpriteMask, unpacked.screenPosition.xy / unpacked.screenPosition.w);
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
half crossSign = (unpacked.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale();
|
||||
half3 bitangent = crossSign * cross(unpacked.normalWS.xyz, unpacked.tangentWS.xyz);
|
||||
|
||||
#ifdef UNIVERSAL_USELEGACYSPRITEBLOCKS
|
||||
half4 color = surfaceDescription.SpriteColor;
|
||||
#else
|
||||
half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha);
|
||||
#endif
|
||||
|
||||
return NormalsRenderingShared(color, surfaceDescription.NormalTS, unpacked.tangentWS.xyz, bitangent, unpacked.normalWS);
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
half4 _RendererColor;
|
||||
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#ifdef UNIVERSAL_USELEGACYSPRITEBLOCKS
|
||||
half4 color = surfaceDescription.SpriteColor;
|
||||
#else
|
||||
half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha);
|
||||
#endif
|
||||
|
||||
color *= unpacked.color * _RendererColor;
|
||||
return color;
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
PackedVaryings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
output = BuildVaryings(input);
|
||||
PackedVaryings packedOutput = PackVaryings(output);
|
||||
return packedOutput;
|
||||
}
|
||||
|
||||
half4 frag(PackedVaryings packedInput) : SV_TARGET
|
||||
{
|
||||
Varyings unpacked = UnpackVaryings(packedInput);
|
||||
UNITY_SETUP_INSTANCE_ID(unpacked);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
|
||||
|
||||
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
|
||||
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
|
||||
|
||||
#if _AlphaClip
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
clip(alpha - surfaceDescription.AlphaClipThreshold);
|
||||
#elif _SURFACE_TYPE_TRANSPARENT
|
||||
half alpha = surfaceDescription.Alpha;
|
||||
#else
|
||||
half alpha = 1;
|
||||
#endif
|
||||
|
||||
#ifdef _ALPHAPREMULTIPLY_ON
|
||||
surfaceDescription.BaseColor *= surfaceDescription.Alpha;
|
||||
#endif
|
||||
|
||||
return half4(surfaceDescription.BaseColor, alpha);
|
||||
}
|
@@ -0,0 +1,127 @@
|
||||
#if (SHADERPASS == SHADERPASS_SHADOWCASTER)
|
||||
// Shadow Casting Light geometric parameters. These variables are used when applying the shadow Normal Bias and are set by UnityEngine.Rendering.Universal.ShadowUtils.SetupShadowCasterConstantBuffer in com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs
|
||||
// For Directional lights, _LightDirection is used when applying shadow Normal Bias.
|
||||
// For Spot lights and Point lights, _LightPosition is used to compute the actual light direction because it is different at each shadow caster geometry vertex.
|
||||
float3 _LightDirection;
|
||||
float3 _LightPosition;
|
||||
#endif
|
||||
|
||||
Varyings BuildVaryings(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
#if defined(FEATURES_GRAPH_VERTEX)
|
||||
// Evaluate Vertex Graph
|
||||
VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input);
|
||||
VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs);
|
||||
|
||||
// Assign modified vertex attributes
|
||||
input.positionOS = vertexDescription.Position;
|
||||
#if defined(VARYINGS_NEED_NORMAL_WS)
|
||||
input.normalOS = vertexDescription.Normal;
|
||||
#endif //FEATURES_GRAPH_NORMAL
|
||||
#if defined(VARYINGS_NEED_TANGENT_WS)
|
||||
input.tangentOS.xyz = vertexDescription.Tangent.xyz;
|
||||
#endif //FEATURES GRAPH TANGENT
|
||||
#endif //FEATURES_GRAPH_VERTEX
|
||||
|
||||
// TODO: Avoid path via VertexPositionInputs (Universal)
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
|
||||
// Returns the camera relative position (if enabled)
|
||||
float3 positionWS = TransformObjectToWorld(input.positionOS);
|
||||
|
||||
#ifdef ATTRIBUTES_NEED_NORMAL
|
||||
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
|
||||
#else
|
||||
// Required to compile ApplyVertexModification that doesn't use normal.
|
||||
float3 normalWS = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
|
||||
#ifdef ATTRIBUTES_NEED_TANGENT
|
||||
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
|
||||
#endif
|
||||
|
||||
// TODO: Change to inline ifdef
|
||||
// Do vertex modification in camera relative space (if enabled)
|
||||
#if defined(HAVE_VERTEX_MODIFICATION)
|
||||
ApplyVertexModification(input, normalWS, positionWS, _TimeParameters.xyz);
|
||||
#endif
|
||||
|
||||
#ifdef VARYINGS_NEED_POSITION_WS
|
||||
output.positionWS = positionWS;
|
||||
#endif
|
||||
|
||||
#ifdef VARYINGS_NEED_NORMAL_WS
|
||||
output.normalWS = normalWS; // normalized in TransformObjectToWorldNormal()
|
||||
#endif
|
||||
|
||||
#ifdef VARYINGS_NEED_TANGENT_WS
|
||||
output.tangentWS = tangentWS; // normalized in TransformObjectToWorldDir()
|
||||
#endif
|
||||
|
||||
#if (SHADERPASS == SHADERPASS_SHADOWCASTER)
|
||||
// Define shadow pass specific clip position for Universal
|
||||
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
float3 lightDirectionWS = normalize(_LightPosition - positionWS);
|
||||
#else
|
||||
float3 lightDirectionWS = _LightDirection;
|
||||
#endif
|
||||
output.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
|
||||
#if UNITY_REVERSED_Z
|
||||
output.positionCS.z = min(output.positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
||||
#else
|
||||
output.positionCS.z = max(output.positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
||||
#endif
|
||||
#elif (SHADERPASS == SHADERPASS_META)
|
||||
output.positionCS = MetaVertexPosition(float4(input.positionOS, 0), input.uv1, input.uv2, unity_LightmapST, unity_DynamicLightmapST);
|
||||
#else
|
||||
output.positionCS = TransformWorldToHClip(positionWS);
|
||||
#endif
|
||||
|
||||
#if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0)
|
||||
output.texCoord0 = input.uv0;
|
||||
#endif
|
||||
#if defined(VARYINGS_NEED_TEXCOORD1) || defined(VARYINGS_DS_NEED_TEXCOORD1)
|
||||
output.texCoord1 = input.uv1;
|
||||
#endif
|
||||
#if defined(VARYINGS_NEED_TEXCOORD2) || defined(VARYINGS_DS_NEED_TEXCOORD2)
|
||||
output.texCoord2 = input.uv2;
|
||||
#endif
|
||||
#if defined(VARYINGS_NEED_TEXCOORD3) || defined(VARYINGS_DS_NEED_TEXCOORD3)
|
||||
output.texCoord3 = input.uv3;
|
||||
#endif
|
||||
|
||||
#if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR)
|
||||
output.color = input.color;
|
||||
#endif
|
||||
|
||||
#ifdef VARYINGS_NEED_VIEWDIRECTION_WS
|
||||
output.viewDirectionWS = GetWorldSpaceViewDir(positionWS);
|
||||
#endif
|
||||
|
||||
#ifdef VARYINGS_NEED_SCREENPOSITION
|
||||
output.screenPosition = vertexInput.positionNDC;
|
||||
#endif
|
||||
|
||||
#if (SHADERPASS == SHADERPASS_FORWARD) || (SHADERPASS == SHADERPASS_GBUFFER)
|
||||
OUTPUT_LIGHTMAP_UV(input.uv1, unity_LightmapST, output.lightmapUV);
|
||||
OUTPUT_SH(normalWS, output.sh);
|
||||
#endif
|
||||
|
||||
#ifdef VARYINGS_NEED_FOG_AND_VERTEX_LIGHT
|
||||
half3 vertexLight = VertexLighting(positionWS, normalWS);
|
||||
half fogFactor = ComputeFogFactor(output.positionCS.z);
|
||||
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = GetShadowCoord(vertexInput);
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
Reference in New Issue
Block a user