2283 lines
92 KiB
GLSL
2283 lines
92 KiB
GLSL
// Made with Amplify Shader Editor
|
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
|
Shader "Custom/ASE_MixerShaderHDRP"
|
|
{
|
|
/*CustomNodeUI:HDPBR*/
|
|
Properties
|
|
{
|
|
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
|
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
|
|
_Diffuse1("Diffuse1", 2D) = "white" {}
|
|
_SpecGloss1("SpecGloss1", 2D) = "white" {}
|
|
_Diffuse2("Diffuse2", 2D) = "white" {}
|
|
_SpecGloss2("SpecGloss2", 2D) = "white" {}
|
|
_NormalMap("NormalMap", 2D) = "bump" {}
|
|
_MixAmount("MixAmount", Range( 0 , 1)) = 0
|
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
|
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
LOD 0
|
|
|
|
|
|
Tags { "RenderPipeline"="HDRenderPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
|
|
|
|
Cull Back
|
|
Blend One Zero
|
|
ZTest LEqual
|
|
ZWrite On
|
|
ZClip [_ZClip]
|
|
|
|
HLSLINCLUDE
|
|
#pragma target 4.5
|
|
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options renderinglayer
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
|
|
struct GlobalSurfaceDescription
|
|
{
|
|
//Standard
|
|
float3 Albedo;
|
|
float3 Normal;
|
|
float3 Specular;
|
|
float Metallic;
|
|
float3 Emission;
|
|
float Smoothness;
|
|
float Occlusion;
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
float CoatMask;
|
|
//SSS
|
|
float DiffusionProfile;
|
|
float SubsurfaceMask;
|
|
//Transmission
|
|
float Thickness;
|
|
// Anisotropic
|
|
float3 TangentWS;
|
|
float Anisotropy;
|
|
//Iridescence
|
|
float IridescenceThickness;
|
|
float IridescenceMask;
|
|
// Transparency
|
|
float IndexOfRefraction;
|
|
float3 TransmittanceColor;
|
|
float TransmittanceAbsorptionDistance;
|
|
float TransmittanceMask;
|
|
};
|
|
|
|
struct AlphaSurfaceDescription
|
|
{
|
|
float Alpha;
|
|
float AlphaClipThreshold;
|
|
};
|
|
|
|
ENDHLSL
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "GBuffer"
|
|
Tags { "LightMode"="GBuffer" }
|
|
Stencil
|
|
{
|
|
Ref 2
|
|
WriteMask 51
|
|
Comp Always
|
|
Pass Replace
|
|
Fail Keep
|
|
ZFail Keep
|
|
}
|
|
|
|
|
|
HLSLPROGRAM
|
|
#define _MATERIAL_FEATURE_SPECULAR_COLOR 1
|
|
#define _NORMALMAP 1
|
|
#define ASE_SRP_VERSION 70108
|
|
|
|
//#define UNITY_MATERIAL_LIT
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_GBUFFER
|
|
#pragma multi_compile _ LIGHTMAP_ON
|
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
|
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
|
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
|
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
|
|
#pragma multi_compile _ LIGHT_LAYERS
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
#define ATTRIBUTES_NEED_TEXCOORD1
|
|
#define ATTRIBUTES_NEED_TEXCOORD2
|
|
#define VARYINGS_NEED_POSITION_WS
|
|
#define VARYINGS_NEED_TANGENT_TO_WORLD
|
|
#define VARYINGS_NEED_TEXCOORD1
|
|
#define VARYINGS_NEED_TEXCOORD2
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
float3 interp00 : TEXCOORD0;
|
|
float3 interp01 : TEXCOORD1;
|
|
float4 interp02 : TEXCOORD2;
|
|
float4 interp03 : TEXCOORD3;
|
|
float4 interp04 : TEXCOORD4;
|
|
float4 ase_texcoord5 : TEXCOORD5;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
sampler2D _Diffuse1;
|
|
sampler2D _Diffuse2;
|
|
sampler2D _NormalMap;
|
|
sampler2D _SpecGloss1;
|
|
sampler2D _SpecGloss2;
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Diffuse1_ST;
|
|
float4 _Diffuse2_ST;
|
|
float _MixAmount;
|
|
float4 _NormalMap_ST;
|
|
float4 _SpecGloss1_ST;
|
|
float4 _SpecGloss2_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
|
|
void BuildSurfaceData ( FragInputs fragInputs, GlobalSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData )
|
|
{
|
|
ZERO_INITIALIZE ( SurfaceData, surfaceData );
|
|
|
|
float3 normalTS = float3( 0.0f, 0.0f, 1.0f );
|
|
normalTS = surfaceDescription.Normal;
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
GetNormalWS ( fragInputs, normalTS, surfaceData.normalWS ,doubleSidedConstants);
|
|
|
|
surfaceData.ambientOcclusion = 1.0f;
|
|
|
|
surfaceData.baseColor = surfaceDescription.Albedo;
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
|
|
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
surfaceData.specularColor = surfaceDescription.Specular;
|
|
#else
|
|
surfaceData.metallic = surfaceDescription.Metallic;
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceData.diffusionProfileHash = asuint(surfaceDescription.DiffusionProfile);
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
surfaceData.subsurfaceMask = surfaceDescription.SubsurfaceMask;
|
|
#else
|
|
surfaceData.subsurfaceMask = 1.0f;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
surfaceData.thickness = surfaceDescription.Thickness;
|
|
#endif
|
|
|
|
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.anisotropy = surfaceDescription.Anisotropy;
|
|
|
|
#else
|
|
surfaceData.anisotropy = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
surfaceData.coatMask = surfaceDescription.CoatMask;
|
|
#else
|
|
surfaceData.coatMask = 0.0f;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness;
|
|
surfaceData.iridescenceMask = surfaceDescription.IridescenceMask;
|
|
#else
|
|
surfaceData.iridescenceThickness = 0.0;
|
|
surfaceData.iridescenceMask = 1.0;
|
|
#endif
|
|
|
|
//ASE CUSTOM TAG
|
|
#ifdef _MATERIAL_FEATURE_TRANSPARENCY
|
|
surfaceData.ior = surfaceDescription.IndexOfRefraction;
|
|
surfaceData.transmittanceColor = surfaceDescription.TransmittanceColor;
|
|
surfaceData.atDistance = surfaceDescription.TransmittanceAbsorptionDistance;
|
|
surfaceData.transmittanceMask = surfaceDescription.TransmittanceMask;
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1000000.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
#if defined(_BENTNORMALMAP) && defined(_ENABLESPECULAROCCLUSION)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO( V, bentNormalWS, surfaceData );
|
|
#elif defined(_MASKMAP)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion( NdotV, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness( surfaceData.perceptualSmoothness ) );
|
|
#endif
|
|
#if HAVE_DECALS
|
|
if( _EnableDecals )
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData( posInput, surfaceDescription.Alpha );
|
|
ApplyDecalToSurfaceData( decalSurfaceData, surfaceData );
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData( GlobalSurfaceDescription surfaceDescription , FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData );
|
|
|
|
// Builtin Data
|
|
// For back lighting we use the oposite vertex normal
|
|
InitBuiltinData (posInput, surfaceDescription.Alpha, surfaceData.normalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
builtinData.distortion = float2(0.0, 0.0); // surfaceDescription.Distortion -- if distortion pass
|
|
builtinData.distortionBlur = 0.0; // surfaceDescription.DistortionBlur -- if distortion pass
|
|
builtinData.depthOffset = 0.0; // ApplyPerPixelDisplacement(input, V, layerTexCoord, blendMasks); #ifdef _DEPTHOFFSET_ON : ApplyDepthOffsetPositionInput(V, depthOffset, GetWorldToHClipMatrix(), posInput);
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID ( inputMesh );
|
|
UNITY_TRANSFER_INSTANCE_ID ( inputMesh, outputPackedVaryingsMeshToPS );
|
|
|
|
outputPackedVaryingsMeshToPS.ase_texcoord5.xy = inputMesh.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
outputPackedVaryingsMeshToPS.ase_texcoord5.zw = 0;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld ( inputMesh.positionOS.xyz );
|
|
float3 normalWS = TransformObjectToWorldNormal ( inputMesh.normalOS );
|
|
float4 tangentWS = float4( TransformObjectToWorldDir ( inputMesh.tangentOS.xyz ), inputMesh.tangentOS.w );
|
|
float4 positionCS = TransformWorldToHClip ( positionRWS );
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = positionCS;
|
|
outputPackedVaryingsMeshToPS.interp00.xyz = positionRWS;
|
|
outputPackedVaryingsMeshToPS.interp01.xyz = normalWS;
|
|
outputPackedVaryingsMeshToPS.interp02.xyzw = tangentWS;
|
|
outputPackedVaryingsMeshToPS.interp03 = inputMesh.uv1;
|
|
outputPackedVaryingsMeshToPS.interp04 = inputMesh.uv2;
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
void Frag ( PackedVaryingsMeshToPS packedInput,
|
|
OUTPUT_GBUFFER ( outGBuffer )
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE ( FragInputs, input );
|
|
input.tangentToWorld = k_identity3x3;
|
|
|
|
float3 positionRWS = packedInput.interp00.xyz;
|
|
float3 normalWS = packedInput.interp01.xyz;
|
|
float4 tangentWS = packedInput.interp02.xyzw;
|
|
|
|
input.positionSS = packedInput.positionCS;
|
|
input.positionRWS = positionRWS;
|
|
input.tangentToWorld = BuildTangentToWorld ( tangentWS, normalWS );
|
|
input.texCoord1 = packedInput.interp03;
|
|
input.texCoord2 = packedInput.interp04;
|
|
|
|
// input.positionSS is SV_Position
|
|
PositionInputs posInput = GetPositionInput ( input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS );
|
|
|
|
float3 normalizedWorldViewDir = GetWorldSpaceNormalizeViewDir ( input.positionRWS );
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
|
|
GlobalSurfaceDescription surfaceDescription = ( GlobalSurfaceDescription ) 0;
|
|
float2 uv_Diffuse1 = packedInput.ase_texcoord5.xy * _Diffuse1_ST.xy + _Diffuse1_ST.zw;
|
|
float4 tex2DNode1 = tex2D( _Diffuse1, uv_Diffuse1 );
|
|
float2 uv_Diffuse2 = packedInput.ase_texcoord5.xy * _Diffuse2_ST.xy + _Diffuse2_ST.zw;
|
|
float4 lerpResult7 = lerp( tex2DNode1 , tex2D( _Diffuse2, uv_Diffuse2 ) , _MixAmount);
|
|
|
|
float2 uv_NormalMap = packedInput.ase_texcoord5.xy * _NormalMap_ST.xy + _NormalMap_ST.zw;
|
|
|
|
float2 uv_SpecGloss1 = packedInput.ase_texcoord5.xy * _SpecGloss1_ST.xy + _SpecGloss1_ST.zw;
|
|
float2 uv_SpecGloss2 = packedInput.ase_texcoord5.xy * _SpecGloss2_ST.xy + _SpecGloss2_ST.zw;
|
|
float4 lerpResult8 = lerp( tex2D( _SpecGloss1, uv_SpecGloss1 ) , tex2D( _SpecGloss2, uv_SpecGloss2 ) , _MixAmount);
|
|
float4 break9 = lerpResult8;
|
|
float4 appendResult10 = (float4(break9.r , break9.g , break9.b , 0.0));
|
|
|
|
surfaceDescription.Albedo = lerpResult7.rgb;
|
|
surfaceDescription.Normal = UnpackNormalmapRGorAG( tex2D( _NormalMap, uv_NormalMap ), 1.0f );
|
|
surfaceDescription.Emission = 0;
|
|
surfaceDescription.Specular = appendResult10.xyz;
|
|
surfaceDescription.Metallic = 0;
|
|
surfaceDescription.Smoothness = break9.a;
|
|
surfaceDescription.Occlusion = 1;
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = 0;
|
|
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceDescription.CoatMask = 0;
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceDescription.DiffusionProfile = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceDescription.SubsurfaceMask = 1;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceDescription.Thickness = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceDescription.Anisotropy = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceDescription.IridescenceThickness = 0;
|
|
surfaceDescription.IridescenceMask = 1;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSPARENCY
|
|
surfaceDescription.IndexOfRefraction = 1;
|
|
surfaceDescription.TransmittanceColor = float3( 1, 1, 1 );
|
|
surfaceDescription.TransmittanceAbsorptionDistance = 1000000;
|
|
surfaceDescription.TransmittanceMask = 0;
|
|
#endif
|
|
GetSurfaceAndBuiltinData ( surfaceDescription, input, normalizedWorldViewDir, posInput, surfaceData, builtinData );
|
|
ENCODE_INTO_GBUFFER ( surfaceData, builtinData, posInput.positionSS, outGBuffer );
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "META"
|
|
Tags { "LightMode"="Meta" }
|
|
Cull Off
|
|
HLSLPROGRAM
|
|
#define _MATERIAL_FEATURE_SPECULAR_COLOR 1
|
|
#define _NORMALMAP 1
|
|
#define ASE_SRP_VERSION 70108
|
|
|
|
//#define UNITY_MATERIAL_LIT
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
#define ATTRIBUTES_NEED_TEXCOORD0
|
|
#define ATTRIBUTES_NEED_TEXCOORD1
|
|
#define ATTRIBUTES_NEED_TEXCOORD2
|
|
#define ATTRIBUTES_NEED_COLOR
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float2 uv0 : TEXCOORD0;
|
|
float2 uv1 : TEXCOORD1;
|
|
float2 uv2 : TEXCOORD2;
|
|
float4 color : COLOR;
|
|
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
};
|
|
|
|
sampler2D _Diffuse1;
|
|
sampler2D _Diffuse2;
|
|
sampler2D _NormalMap;
|
|
sampler2D _SpecGloss1;
|
|
sampler2D _SpecGloss2;
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Diffuse1_ST;
|
|
float4 _Diffuse2_ST;
|
|
float _MixAmount;
|
|
float4 _NormalMap_ST;
|
|
float4 _SpecGloss1_ST;
|
|
float4 _SpecGloss2_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
|
|
void BuildSurfaceData ( FragInputs fragInputs, GlobalSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData )
|
|
{
|
|
ZERO_INITIALIZE ( SurfaceData, surfaceData );
|
|
|
|
float3 normalTS = float3( 0.0f, 0.0f, 1.0f );
|
|
normalTS = surfaceDescription.Normal;
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
GetNormalWS ( fragInputs, normalTS, surfaceData.normalWS ,doubleSidedConstants);
|
|
|
|
surfaceData.ambientOcclusion = 1.0f;
|
|
|
|
surfaceData.baseColor = surfaceDescription.Albedo;
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
|
|
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
surfaceData.specularColor = surfaceDescription.Specular;
|
|
#else
|
|
surfaceData.metallic = surfaceDescription.Metallic;
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceData.diffusionProfileHash = asuint(surfaceDescription.DiffusionProfile);
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
surfaceData.subsurfaceMask = surfaceDescription.SubsurfaceMask;
|
|
|
|
#else
|
|
surfaceData.subsurfaceMask = 1.0f;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
surfaceData.thickness = surfaceDescription.Thickness;
|
|
#endif
|
|
|
|
surfaceData.tangentWS = normalize ( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
surfaceData.tangentWS = Orthonormalize ( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.anisotropy = surfaceDescription.Anisotropy;
|
|
|
|
#else
|
|
surfaceData.anisotropy = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
surfaceData.coatMask = surfaceDescription.CoatMask;
|
|
#else
|
|
surfaceData.coatMask = 0.0f;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness;
|
|
surfaceData.iridescenceMask = surfaceDescription.IridescenceMask;
|
|
#else
|
|
surfaceData.iridescenceThickness = 0.0;
|
|
surfaceData.iridescenceMask = 1.0;
|
|
#endif
|
|
|
|
//ASE CUSTOM TAG
|
|
#ifdef _MATERIAL_FEATURE_TRANSPARENCY
|
|
surfaceData.ior = surfaceDescription.IndexOfRefraction;
|
|
surfaceData.transmittanceColor = surfaceDescription.TransmittanceColor;
|
|
surfaceData.atDistance = surfaceDescription.TransmittanceAbsorptionDistance;
|
|
surfaceData.transmittanceMask = surfaceDescription.TransmittanceMask;
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1000000.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion (ClampNdotV (dot (surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness (surfaceData.perceptualSmoothness));
|
|
|
|
#if HAVE_DECALS
|
|
if (_EnableDecals)
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData (posInput, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData (decalSurfaceData, surfaceData);
|
|
}
|
|
#endif
|
|
|
|
#if defined(_BENTNORMALMAP) && defined(_ENABLESPECULAROCCLUSION)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO ( V, bentNormalWS, surfaceData );
|
|
#elif defined(_MASKMAP)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion ( NdotV, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness ( surfaceData.perceptualSmoothness ) );
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData( GlobalSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
BuildSurfaceData (fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
|
|
// Builtin Data
|
|
// For back lighting we use the oposite vertex normal
|
|
InitBuiltinData (posInput, surfaceDescription.Alpha, surfaceData.normalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
builtinData.distortion = float2(0.0, 0.0); // surfaceDescription.Distortion -- if distortion pass
|
|
builtinData.distortionBlur = 0.0; // surfaceDescription.DistortionBlur -- if distortion pass
|
|
builtinData.depthOffset = 0.0; // ApplyPerPixelDisplacement(input, V, layerTexCoord, blendMasks); #ifdef _DEPTHOFFSET_ON : ApplyDepthOffsetPositionInput(V, depthOffset, GetWorldToHClipMatrix(), posInput);
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
|
|
CBUFFER_START ( UnityMetaPass )
|
|
bool4 unity_MetaVertexControl;
|
|
bool4 unity_MetaFragmentControl;
|
|
CBUFFER_END
|
|
|
|
|
|
float unity_OneOverOutputBoost;
|
|
float unity_MaxOutputValue;
|
|
|
|
PackedVaryingsMeshToPS Vert ( AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID ( inputMesh );
|
|
UNITY_TRANSFER_INSTANCE_ID ( inputMesh, outputPackedVaryingsMeshToPS );
|
|
|
|
outputPackedVaryingsMeshToPS.ase_texcoord.xy = inputMesh.uv0;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
outputPackedVaryingsMeshToPS.ase_texcoord.zw = 0;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float2 uv;
|
|
|
|
if ( unity_MetaVertexControl.x )
|
|
{
|
|
uv = inputMesh.uv1 * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
}
|
|
else if ( unity_MetaVertexControl.y )
|
|
{
|
|
uv = inputMesh.uv2 * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
}
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = float4( uv * 2.0 - 1.0, inputMesh.positionOS.z > 0 ? 1.0e-4 : 0.0, 1.0 );
|
|
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
float4 Frag ( PackedVaryingsMeshToPS packedInput ) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE ( FragInputs, input );
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput ( input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS );
|
|
|
|
float3 V = 0;
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
|
|
GlobalSurfaceDescription surfaceDescription = ( GlobalSurfaceDescription ) 0;
|
|
float2 uv_Diffuse1 = packedInput.ase_texcoord.xy * _Diffuse1_ST.xy + _Diffuse1_ST.zw;
|
|
float4 tex2DNode1 = tex2D( _Diffuse1, uv_Diffuse1 );
|
|
float2 uv_Diffuse2 = packedInput.ase_texcoord.xy * _Diffuse2_ST.xy + _Diffuse2_ST.zw;
|
|
float4 lerpResult7 = lerp( tex2DNode1 , tex2D( _Diffuse2, uv_Diffuse2 ) , _MixAmount);
|
|
|
|
float2 uv_NormalMap = packedInput.ase_texcoord.xy * _NormalMap_ST.xy + _NormalMap_ST.zw;
|
|
|
|
float2 uv_SpecGloss1 = packedInput.ase_texcoord.xy * _SpecGloss1_ST.xy + _SpecGloss1_ST.zw;
|
|
float2 uv_SpecGloss2 = packedInput.ase_texcoord.xy * _SpecGloss2_ST.xy + _SpecGloss2_ST.zw;
|
|
float4 lerpResult8 = lerp( tex2D( _SpecGloss1, uv_SpecGloss1 ) , tex2D( _SpecGloss2, uv_SpecGloss2 ) , _MixAmount);
|
|
float4 break9 = lerpResult8;
|
|
float4 appendResult10 = (float4(break9.r , break9.g , break9.b , 0.0));
|
|
|
|
surfaceDescription.Albedo = lerpResult7.rgb;
|
|
surfaceDescription.Normal = UnpackNormalmapRGorAG( tex2D( _NormalMap, uv_NormalMap ), 1.0f );
|
|
surfaceDescription.Emission = 0;
|
|
surfaceDescription.Specular = appendResult10.xyz;
|
|
surfaceDescription.Metallic = 0;
|
|
surfaceDescription.Smoothness = break9.a;
|
|
surfaceDescription.Occlusion = 1;
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = 0;
|
|
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceDescription.CoatMask = 0;
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceDescription.DiffusionProfile = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceDescription.SubsurfaceMask = 1;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceDescription.Thickness = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceDescription.Anisotropy = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceDescription.IridescenceThickness = 0;
|
|
surfaceDescription.IridescenceMask = 1;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSPARENCY
|
|
surfaceDescription.IndexOfRefraction = 1;
|
|
surfaceDescription.TransmittanceColor = float3( 1, 1, 1 );
|
|
surfaceDescription.TransmittanceAbsorptionDistance = 1000000;
|
|
surfaceDescription.TransmittanceMask = 0;
|
|
#endif
|
|
|
|
GetSurfaceAndBuiltinData ( surfaceDescription, input, V, posInput, surfaceData, builtinData );
|
|
|
|
BSDFData bsdfData = ConvertSurfaceDataToBSDFData ( input.positionSS.xy, surfaceData );
|
|
|
|
LightTransportData lightTransportData = GetLightTransportData ( surfaceData, builtinData, bsdfData );
|
|
|
|
float4 res = float4( 0.0, 0.0, 0.0, 1.0 );
|
|
if ( unity_MetaFragmentControl.x )
|
|
{
|
|
res.rgb = clamp ( pow ( abs ( lightTransportData.diffuseColor ), saturate ( unity_OneOverOutputBoost ) ), 0, unity_MaxOutputValue );
|
|
}
|
|
|
|
if ( unity_MetaFragmentControl.y )
|
|
{
|
|
res.rgb = lightTransportData.emissiveColor;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "ShadowCaster"
|
|
Tags { "LightMode"="ShadowCaster" }
|
|
ColorMask 0
|
|
|
|
|
|
HLSLPROGRAM
|
|
#define _MATERIAL_FEATURE_SPECULAR_COLOR 1
|
|
#define _NORMALMAP 1
|
|
#define ASE_SRP_VERSION 70108
|
|
|
|
//#define UNITY_MATERIAL_LIT
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_SHADOWS
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Diffuse1_ST;
|
|
float4 _Diffuse2_ST;
|
|
float _MixAmount;
|
|
float4 _NormalMap_ST;
|
|
float4 _SpecGloss1_ST;
|
|
float4 _SpecGloss2_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, AlphaSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
surfaceData.ambientOcclusion = 1.0f;
|
|
surfaceData.subsurfaceMask = 1.0f;
|
|
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
GetNormalWS(fragInputs, normalTS, surfaceData.normalWS,doubleSidedConstants);
|
|
surfaceData.tangentWS = normalize(fragInputs.tangentToWorld[0].xyz);
|
|
surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
|
|
surfaceData.anisotropy = 0;
|
|
surfaceData.coatMask = 0.0f;
|
|
surfaceData.iridescenceThickness = 0.0;
|
|
surfaceData.iridescenceMask = 1.0;
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
|
surfaceData.atDistance = 1000000.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceData.specularOcclusion = 1.0;
|
|
#if defined(_BENTNORMALMAP) && defined(_ENABLESPECULAROCCLUSION)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData);
|
|
#elif defined(_MASKMAP)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(NdotV, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
#if HAVE_DECALS
|
|
if (_EnableDecals)
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData (posInput, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData (decalSurfaceData, surfaceData);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData( AlphaSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
// Builtin Data
|
|
// For back lighting we use the oposite vertex normal
|
|
InitBuiltinData (posInput, surfaceDescription.Alpha, surfaceData.normalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
builtinData.distortion = float2(0.0, 0.0); // surfaceDescription.Distortion -- if distortion pass
|
|
builtinData.distortionBlur = 0.0; // surfaceDescription.DistortionBlur -- if distortion pass
|
|
builtinData.depthOffset = 0.0; // ApplyPerPixelDisplacement(input, V, layerTexCoord, blendMasks); #ifdef _DEPTHOFFSET_ON : ApplyDepthOffsetPositionInput(V, depthOffset, GetWorldToHClipMatrix(), posInput);
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
PackedVaryingsMeshToPS Vert( AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID ( inputMesh );
|
|
UNITY_TRANSFER_INSTANCE_ID ( inputMesh, outputPackedVaryingsMeshToPS );
|
|
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld ( inputMesh.positionOS.xyz );
|
|
float4 positionCS = TransformWorldToHClip ( positionRWS );
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = positionCS;
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float1 depthColor : SV_Target1
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH) // When only WRITE_MSAA_DEPTH is define and not WRITE_NORMAL_BUFFER it mean we are Unlit and only need depth, but we still have normal buffer binded
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
, out float1 depthColor : SV_Target1
|
|
#else
|
|
, out float4 outColor : SV_Target0
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS; // input.positionCS is SV_Position
|
|
|
|
// input.positionSS is SV_Position
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
AlphaSurfaceDescription surfaceDescription = (AlphaSurfaceDescription)0;
|
|
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = 0;
|
|
|
|
GetSurfaceAndBuiltinData(surfaceDescription,input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), posInput.positionSS, outNormalBuffer);
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.positionCS.z;
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH)
|
|
outNormalBuffer = float4(0.0, 0.0, 0.0, 1.0);
|
|
depthColor = packedInput.vmesh.positionCS.z;
|
|
#elif defined(SCENESELECTIONPASS)
|
|
outColor = float4(_ObjectId, _PassValue, 1.0, 1.0);
|
|
#else
|
|
outColor = float4(0.0, 0.0, 0.0, 0.0);
|
|
#endif
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "SceneSelectionPass"
|
|
Tags { "LightMode"="SceneSelectionPass" }
|
|
|
|
ColorMask 0
|
|
|
|
HLSLPROGRAM
|
|
#define _MATERIAL_FEATURE_SPECULAR_COLOR 1
|
|
#define _NORMALMAP 1
|
|
#define ASE_SRP_VERSION 70108
|
|
|
|
//#define UNITY_MATERIAL_LIT
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#define SCENESELECTIONPASS
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
|
|
int _ObjectId;
|
|
int _PassValue;
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Diffuse1_ST;
|
|
float4 _Diffuse2_ST;
|
|
float _MixAmount;
|
|
float4 _NormalMap_ST;
|
|
float4 _SpecGloss1_ST;
|
|
float4 _SpecGloss2_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, AlphaSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
surfaceData.ambientOcclusion = 1.0f;
|
|
surfaceData.subsurfaceMask = 1.0f;
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
GetNormalWS(fragInputs, normalTS, surfaceData.normalWS,doubleSidedConstants);
|
|
surfaceData.tangentWS = normalize(fragInputs.tangentToWorld[0].xyz);
|
|
surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
|
|
surfaceData.anisotropy = 0;
|
|
surfaceData.coatMask = 0.0f;
|
|
surfaceData.iridescenceThickness = 0.0;
|
|
surfaceData.iridescenceMask = 1.0;
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
|
surfaceData.atDistance = 1000000.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceData.specularOcclusion = 1.0;
|
|
#if defined(_BENTNORMALMAP) && defined(_ENABLESPECULAROCCLUSION)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData);
|
|
#elif defined(_MASKMAP)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(NdotV, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
|
|
#if HAVE_DECALS
|
|
if (_EnableDecals)
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData (posInput, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData (decalSurfaceData, surfaceData);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(AlphaSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
InitBuiltinData (posInput, surfaceDescription.Alpha, surfaceData.normalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
builtinData.distortion = float2(0.0, 0.0);
|
|
builtinData.distortionBlur = 0.0;
|
|
builtinData.depthOffset = 0.0;
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
|
|
PackedVaryingsMeshToPS Vert(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float1 depthColor : SV_Target1
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH)
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
, out float1 depthColor : SV_Target1
|
|
#elif defined(SCENESELECTIONPASS)
|
|
, out float4 outColor : SV_Target0
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
|
|
// input.positionSS is SV_Position
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
|
|
float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
AlphaSurfaceDescription surfaceDescription = ( AlphaSurfaceDescription ) 0;
|
|
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = 0;
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), posInput.positionSS, outNormalBuffer);
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.positionCS.z;
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH)
|
|
outNormalBuffer = float4(0.0, 0.0, 0.0, 1.0);
|
|
depthColor = packedInput.vmesh.positionCS.z;
|
|
#elif defined(SCENESELECTIONPASS)
|
|
outColor = float4(_ObjectId, _PassValue, 1.0, 1.0);
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "DepthOnly"
|
|
Tags { "LightMode"="DepthOnly" }
|
|
Stencil
|
|
{
|
|
Ref 0
|
|
WriteMask 48
|
|
Comp Always
|
|
Pass Replace
|
|
Fail Keep
|
|
ZFail Keep
|
|
}
|
|
|
|
|
|
HLSLPROGRAM
|
|
#define _MATERIAL_FEATURE_SPECULAR_COLOR 1
|
|
#define _NORMALMAP 1
|
|
#define ASE_SRP_VERSION 70108
|
|
|
|
//#define UNITY_MATERIAL_LIT
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#pragma multi_compile _ WRITE_NORMAL_BUFFER
|
|
#pragma multi_compile _ WRITE_MSAA_DEPTH
|
|
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
#define ATTRIBUTES_NEED_TEXCOORD0
|
|
#define ATTRIBUTES_NEED_TEXCOORD1
|
|
#define ATTRIBUTES_NEED_TEXCOORD2
|
|
#define ATTRIBUTES_NEED_TEXCOORD3
|
|
#define ATTRIBUTES_NEED_COLOR
|
|
#define VARYINGS_NEED_POSITION_WS
|
|
#define VARYINGS_NEED_TANGENT_TO_WORLD
|
|
#define VARYINGS_NEED_TEXCOORD0
|
|
#define VARYINGS_NEED_TEXCOORD1
|
|
#define VARYINGS_NEED_TEXCOORD2
|
|
#define VARYINGS_NEED_TEXCOORD3
|
|
#define VARYINGS_NEED_COLOR
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Diffuse1_ST;
|
|
float4 _Diffuse2_ST;
|
|
float _MixAmount;
|
|
float4 _NormalMap_ST;
|
|
float4 _SpecGloss1_ST;
|
|
float4 _SpecGloss2_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, AlphaSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
surfaceData.ambientOcclusion = 1.0f;
|
|
surfaceData.subsurfaceMask = 1.0f;
|
|
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
GetNormalWS(fragInputs, normalTS, surfaceData.normalWS,doubleSidedConstants);
|
|
surfaceData.tangentWS = normalize(fragInputs.tangentToWorld[0].xyz); // The tangent is not normalize in tangentToWorld for mikkt. TODO: Check if it expected that we normalize with Morten. Tag: SURFACE_GRADIENT
|
|
surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
|
|
surfaceData.anisotropy = 0;
|
|
surfaceData.coatMask = 0.0f;
|
|
surfaceData.iridescenceThickness = 0.0;
|
|
surfaceData.iridescenceMask = 1.0;
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
|
surfaceData.atDistance = 1000000.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceData.specularOcclusion = 1.0;
|
|
#if defined(_BENTNORMALMAP) && defined(_ENABLESPECULAROCCLUSION)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData);
|
|
#elif defined(_MASKMAP)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(NdotV, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
#if HAVE_DECALS
|
|
if (_EnableDecals)
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData (posInput, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData (decalSurfaceData, surfaceData);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(AlphaSurfaceDescription surfaceDescription,FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
InitBuiltinData (posInput, surfaceDescription.Alpha, surfaceData.normalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
|
|
builtinData.distortion = float2(0.0, 0.0); // surfaceDescription.Distortion -- if distortion pass
|
|
builtinData.distortionBlur = 0.0; // surfaceDescription.DistortionBlur -- if distortion pass
|
|
builtinData.depthOffset = 0.0; // ApplyPerPixelDisplacement(input, V, layerTexCoord, blendMasks); #ifdef _DEPTHOFFSET_ON : ApplyDepthOffsetPositionInput(V, depthOffset, GetWorldToHClipMatrix(), posInput);
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
PackedVaryingsMeshToPS Vert(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float1 depthColor : SV_Target1
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH) // When only WRITE_MSAA_DEPTH is define and not WRITE_NORMAL_BUFFER it mean we are Unlit and only need depth, but we still have normal buffer binded
|
|
, out float4 outNormalBuffer : SV_Target0
|
|
, out float1 depthColor : SV_Target1
|
|
#else
|
|
, out float4 outColor : SV_Target0
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = float3(1.0, 1.0, 1.0);
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
AlphaSurfaceDescription surfaceDescription = ( AlphaSurfaceDescription ) 0;
|
|
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = 0;
|
|
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, V, posInput, surfaceData, builtinData);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), posInput.positionSS, outNormalBuffer);
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.positionCS.z;
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH)
|
|
outNormalBuffer = float4(0.0, 0.0, 0.0, 1.0);
|
|
depthColor = packedInput.positionCS.z;
|
|
#elif defined(SCENESELECTIONPASS)
|
|
outColor = float4(_ObjectId, _PassValue, 1.0, 1.0);
|
|
#else
|
|
outColor = float4(0.0, 0.0, 0.0, 0.0);
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "Motion Vectors"
|
|
Tags { "LightMode"="MotionVectors" }
|
|
|
|
Stencil
|
|
{
|
|
Ref 128
|
|
WriteMask 176
|
|
Comp Always
|
|
Pass Replace
|
|
Fail Keep
|
|
ZFail Keep
|
|
}
|
|
|
|
|
|
HLSLPROGRAM
|
|
#define _MATERIAL_FEATURE_SPECULAR_COLOR 1
|
|
#define _NORMALMAP 1
|
|
#define ASE_SRP_VERSION 70108
|
|
|
|
//#define UNITY_MATERIAL_LIT
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_MOTION_VECTORS
|
|
#pragma multi_compile _ WRITE_NORMAL_BUFFER
|
|
#pragma multi_compile _ WRITE_MSAA_DEPTH
|
|
|
|
#define VARYINGS_NEED_POSITION_WS
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VaryingsMeshToPS
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
float3 positionRWS;
|
|
};
|
|
|
|
struct AttributesPass
|
|
{
|
|
float3 previousPositionOS : TEXCOORD4;
|
|
};
|
|
|
|
struct VaryingsPassToPS
|
|
{
|
|
float4 positionCS;
|
|
float4 previousPositionCS;
|
|
};
|
|
|
|
#define VARYINGS_NEED_PASS
|
|
|
|
struct VaryingsToPS
|
|
{
|
|
VaryingsMeshToPS vmesh;
|
|
VaryingsPassToPS vpass;
|
|
};
|
|
|
|
struct PackedVaryingsToPS
|
|
{
|
|
float3 vmeshInterp00 : TEXCOORD0;
|
|
float4 vmeshPositionCS : SV_Position;
|
|
float3 vpassInterpolators0 : TEXCOORD1;
|
|
float3 vpassInterpolators1 : TEXCOORD2;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Diffuse1_ST;
|
|
float4 _Diffuse2_ST;
|
|
float _MixAmount;
|
|
float4 _NormalMap_ST;
|
|
float4 _SpecGloss1_ST;
|
|
float4 _SpecGloss2_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
|
|
FragInputs BuildFragInputs(VaryingsMeshToPS input)
|
|
{
|
|
FragInputs output;
|
|
ZERO_INITIALIZE(FragInputs, output);
|
|
output.tangentToWorld = k_identity3x3;
|
|
output.positionSS = input.positionCS;
|
|
output.positionRWS = input.positionRWS;
|
|
return output;
|
|
}
|
|
|
|
void BuildSurfaceData(FragInputs fragInputs, AlphaSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
|
|
{
|
|
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
surfaceData.ambientOcclusion = 1.0f;
|
|
surfaceData.subsurfaceMask = 1.0f;
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
#endif
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
#endif
|
|
|
|
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
GetNormalWS(fragInputs, normalTS, surfaceData.normalWS,doubleSidedConstants);
|
|
surfaceData.tangentWS = normalize(fragInputs.tangentToWorld[0].xyz); // The tangent is not normalize in tangentToWorld for mikkt. TODO: Check if it expected that we normalize with Morten. Tag: SURFACE_GRADIENT
|
|
surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
|
|
surfaceData.anisotropy = 0;
|
|
surfaceData.coatMask = 0.0f;
|
|
surfaceData.iridescenceThickness = 0.0;
|
|
surfaceData.iridescenceMask = 1.0;
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
|
surfaceData.atDistance = 1000000.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
surfaceData.specularOcclusion = 1.0;
|
|
#if defined(_BENTNORMALMAP) && defined(_ENABLESPECULAROCCLUSION)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData);
|
|
#elif defined(_MASKMAP)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(NdotV, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
|
#endif
|
|
#if HAVE_DECALS
|
|
if (_EnableDecals)
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData (posInput, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData (decalSurfaceData, surfaceData);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData(AlphaSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
InitBuiltinData (posInput, surfaceDescription.Alpha, surfaceData.normalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
builtinData.distortion = float2(0.0, 0.0);
|
|
builtinData.distortionBlur = 0.0;
|
|
builtinData.depthOffset = 0.0;
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
|
|
VaryingsMeshToPS UnpackVaryingsMeshToPS(PackedVaryingsToPS input)
|
|
{
|
|
VaryingsMeshToPS output;
|
|
output.positionCS = input.vmeshPositionCS;
|
|
output.positionRWS = input.vmeshInterp00.xyz;
|
|
return output;
|
|
}
|
|
|
|
VaryingsPassToPS UnpackVaryingsPassToPS(PackedVaryingsToPS input)
|
|
{
|
|
VaryingsPassToPS output;
|
|
output.positionCS = float4(input.vpassInterpolators0.xy, 0.0, input.vpassInterpolators0.z);
|
|
output.previousPositionCS = float4(input.vpassInterpolators1.xy, 0.0, input.vpassInterpolators1.z);
|
|
|
|
return output;
|
|
}
|
|
|
|
PackedVaryingsToPS PackVaryingsToPS(VaryingsToPS varyingsType)
|
|
{
|
|
PackedVaryingsToPS outputPackedVaryingsToPS;
|
|
|
|
outputPackedVaryingsToPS.vmeshPositionCS = varyingsType.vmesh.positionCS;
|
|
outputPackedVaryingsToPS.vmeshInterp00.xyz = varyingsType.vmesh.positionRWS;
|
|
outputPackedVaryingsToPS.vpassInterpolators0 = float3(varyingsType.vpass.positionCS.xyw);
|
|
outputPackedVaryingsToPS.vpassInterpolators1 = float3(varyingsType.vpass.previousPositionCS.xyw);
|
|
return outputPackedVaryingsToPS;
|
|
}
|
|
#if UNITY_VERSION < 201930
|
|
float3 TransformPreviousObjectToWorldNormal(float3 normalOS)
|
|
{
|
|
#ifdef UNITY_ASSUME_UNIFORM_SCALING
|
|
return normalize(mul((float3x3)unity_MatrixPreviousM, normalOS));
|
|
#else
|
|
return normalize(mul(normalOS, (float3x3)unity_MatrixPreviousMI));
|
|
#endif
|
|
}
|
|
|
|
float3 TransformPreviousObjectToWorld(float3 positionOS)
|
|
{
|
|
float4x4 previousModelMatrix = ApplyCameraTranslationToMatrix(unity_MatrixPreviousM);
|
|
return mul(previousModelMatrix, float4(positionOS, 1.0)).xyz;
|
|
}
|
|
#endif
|
|
void VelocityPositionZBias(VaryingsToPS input)
|
|
{
|
|
#if defined(UNITY_REVERSED_Z)
|
|
input.vmesh.positionCS.z -= unity_MotionVectorsParams.z * input.vmesh.positionCS.w;
|
|
#else
|
|
input.vmesh.positionCS.z += unity_MotionVectorsParams.z * input.vmesh.positionCS.w;
|
|
#endif
|
|
}
|
|
|
|
PackedVaryingsToPS Vert(AttributesMesh inputMesh,
|
|
AttributesPass inputPass
|
|
|
|
)
|
|
{
|
|
PackedVaryingsToPS outputPackedVaryingsToPS;
|
|
VaryingsToPS varyingsType;
|
|
VaryingsMeshToPS outputVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsToPS );
|
|
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
outputVaryingsMeshToPS.positionRWS = positionRWS;
|
|
outputVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
|
|
|
|
varyingsType.vmesh = outputVaryingsMeshToPS;
|
|
|
|
VelocityPositionZBias(varyingsType);
|
|
varyingsType.vpass.positionCS = mul(_NonJitteredViewProjMatrix, float4(varyingsType.vmesh.positionRWS, 1.0));
|
|
bool forceNoMotion = unity_MotionVectorsParams.y == 0.0;
|
|
if (forceNoMotion)
|
|
{
|
|
varyingsType.vpass.previousPositionCS = float4(0.0, 0.0, 0.0, 1.0);
|
|
}
|
|
else
|
|
{
|
|
bool hasDeformation = unity_MotionVectorsParams.x > 0.0; // Skin or morph target
|
|
|
|
float3 previousPositionRWS = TransformPreviousObjectToWorld(hasDeformation ? inputPass.previousPositionOS : inputMesh.positionOS);
|
|
|
|
float3 normalWS = float3(0.0, 0.0, 0.0);
|
|
|
|
varyingsType.vpass.previousPositionCS = mul(_PrevViewProjMatrix, float4(previousPositionRWS, 1.0));
|
|
}
|
|
|
|
outputPackedVaryingsToPS.vmeshPositionCS = varyingsType.vmesh.positionCS;
|
|
outputPackedVaryingsToPS.vmeshInterp00.xyz = varyingsType.vmesh.positionRWS;
|
|
|
|
outputPackedVaryingsToPS.vpassInterpolators0 = float3(varyingsType.vpass.positionCS.xyw);
|
|
outputPackedVaryingsToPS.vpassInterpolators1 = float3(varyingsType.vpass.previousPositionCS.xyw);
|
|
|
|
return outputPackedVaryingsToPS;
|
|
}
|
|
|
|
void Frag( PackedVaryingsToPS packedInput
|
|
, out float4 outMotionVector : SV_Target0
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
, out float4 outNormalBuffer : SV_Target1
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
, out float1 depthColor : SV_Target2
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH)
|
|
, out float4 outNormalBuffer : SV_Target1
|
|
, out float1 depthColor : SV_Target2
|
|
#endif
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(packedInput);
|
|
FragInputs input = BuildFragInputs(unpacked);
|
|
|
|
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
|
|
AlphaSurfaceDescription surfaceDescription = (AlphaSurfaceDescription)0;
|
|
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = 0;
|
|
|
|
GetSurfaceAndBuiltinData(surfaceDescription,input, V, posInput, surfaceData, builtinData);
|
|
|
|
VaryingsPassToPS inputPass = UnpackVaryingsPassToPS(packedInput);
|
|
#ifdef _DEPTHOFFSET_ON
|
|
inputPass.positionCS.w += builtinData.depthOffset;
|
|
inputPass.previousPositionCS.w += builtinData.depthOffset;
|
|
#endif
|
|
|
|
float2 motionVector = CalculateMotionVector (inputPass.positionCS, inputPass.previousPositionCS);
|
|
EncodeMotionVector (motionVector * 0.5, outMotionVector);
|
|
|
|
bool forceNoMotion = unity_MotionVectorsParams.y == 0.0;
|
|
if (forceNoMotion)
|
|
outMotionVector = float4(2.0, 0.0, 0.0, 0.0);
|
|
|
|
#ifdef WRITE_NORMAL_BUFFER
|
|
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), posInput.positionSS, outNormalBuffer);
|
|
|
|
#ifdef WRITE_MSAA_DEPTH
|
|
depthColor = packedInput.vmeshPositionCS.z;
|
|
#endif
|
|
#elif defined(WRITE_MSAA_DEPTH)
|
|
outNormalBuffer = float4(0.0, 0.0, 0.0, 1.0);
|
|
depthColor = packedInput.vmeshPositionCS.z;
|
|
#endif
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
|
|
Name "Forward"
|
|
Tags { "LightMode"="Forward" }
|
|
Stencil
|
|
{
|
|
Ref 2
|
|
WriteMask 51
|
|
Comp Always
|
|
Pass Replace
|
|
Fail Keep
|
|
ZFail Keep
|
|
}
|
|
|
|
|
|
HLSLPROGRAM
|
|
#define _MATERIAL_FEATURE_SPECULAR_COLOR 1
|
|
#define _NORMALMAP 1
|
|
#define ASE_SRP_VERSION 70108
|
|
|
|
//#define UNITY_MATERIAL_LIT
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_FORWARD
|
|
#pragma multi_compile _ LIGHTMAP_ON
|
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
|
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
|
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
|
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
|
|
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
|
|
#pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH
|
|
|
|
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
|
|
#define ATTRIBUTES_NEED_NORMAL
|
|
#define ATTRIBUTES_NEED_TANGENT
|
|
#define ATTRIBUTES_NEED_TEXCOORD1
|
|
#define ATTRIBUTES_NEED_TEXCOORD2
|
|
#define VARYINGS_NEED_POSITION_WS
|
|
#define VARYINGS_NEED_TANGENT_TO_WORLD
|
|
#define VARYINGS_NEED_TEXCOORD1
|
|
#define VARYINGS_NEED_TEXCOORD2
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
|
|
|
|
#define HAS_LIGHTLOOP
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl"
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv1 : TEXCOORD1;
|
|
float4 uv2 : TEXCOORD2;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsMeshToPS
|
|
{
|
|
float4 positionCS : SV_Position;
|
|
float3 interp00 : TEXCOORD0;
|
|
float3 interp01 : TEXCOORD1;
|
|
float4 interp02 : TEXCOORD2;
|
|
float4 interp03 : TEXCOORD3;
|
|
float4 interp04 : TEXCOORD4;
|
|
float4 ase_texcoord5 : TEXCOORD5;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
sampler2D _Diffuse1;
|
|
sampler2D _Diffuse2;
|
|
sampler2D _NormalMap;
|
|
sampler2D _SpecGloss1;
|
|
sampler2D _SpecGloss2;
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Diffuse1_ST;
|
|
float4 _Diffuse2_ST;
|
|
float _MixAmount;
|
|
float4 _NormalMap_ST;
|
|
float4 _SpecGloss1_ST;
|
|
float4 _SpecGloss2_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
|
|
|
|
void BuildSurfaceData ( FragInputs fragInputs, GlobalSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData )
|
|
{
|
|
ZERO_INITIALIZE ( SurfaceData, surfaceData );
|
|
|
|
float3 normalTS = float3( 0.0f, 0.0f, 1.0f );
|
|
normalTS = surfaceDescription.Normal;
|
|
float3 doubleSidedConstants = float3(1.0, 1.0, 1.0);
|
|
GetNormalWS ( fragInputs, normalTS, surfaceData.normalWS ,doubleSidedConstants);
|
|
|
|
surfaceData.ambientOcclusion = 1.0f;
|
|
|
|
surfaceData.baseColor = surfaceDescription.Albedo;
|
|
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
|
|
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
|
|
|
|
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
|
|
|
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
|
surfaceData.specularColor = surfaceDescription.Specular;
|
|
#else
|
|
surfaceData.metallic = surfaceDescription.Metallic;
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceData.diffusionProfileHash = asuint(surfaceDescription.DiffusionProfile);
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
|
surfaceData.subsurfaceMask = surfaceDescription.SubsurfaceMask;
|
|
#else
|
|
surfaceData.subsurfaceMask = 1.0f;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
|
surfaceData.thickness = surfaceDescription.Thickness;
|
|
#endif
|
|
|
|
surfaceData.tangentWS = normalize ( fragInputs.tangentToWorld[ 0 ].xyz );
|
|
surfaceData.tangentWS = Orthonormalize ( surfaceData.tangentWS, surfaceData.normalWS );
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
|
surfaceData.anisotropy = surfaceDescription.Anisotropy;
|
|
|
|
#else
|
|
surfaceData.anisotropy = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
|
surfaceData.coatMask = surfaceDescription.CoatMask;
|
|
#else
|
|
surfaceData.coatMask = 0.0f;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
|
surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness;
|
|
surfaceData.iridescenceMask = surfaceDescription.IridescenceMask;
|
|
#else
|
|
surfaceData.iridescenceThickness = 0.0;
|
|
surfaceData.iridescenceMask = 1.0;
|
|
#endif
|
|
|
|
//ASE CUSTOM TAG
|
|
#ifdef _MATERIAL_FEATURE_TRANSPARENCY
|
|
surfaceData.ior = surfaceDescription.IndexOfRefraction;
|
|
surfaceData.transmittanceColor = surfaceDescription.TransmittanceColor;
|
|
surfaceData.atDistance = surfaceDescription.TransmittanceAbsorptionDistance;
|
|
surfaceData.transmittanceMask = surfaceDescription.TransmittanceMask;
|
|
#else
|
|
surfaceData.ior = 1.0;
|
|
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
|
|
surfaceData.atDistance = 1000000.0;
|
|
surfaceData.transmittanceMask = 0.0;
|
|
#endif
|
|
|
|
surfaceData.specularOcclusion = 1.0;
|
|
|
|
#if defined(_BENTNORMALMAP) && defined(_ENABLESPECULAROCCLUSION)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO ( V, bentNormalWS, surfaceData );
|
|
#elif defined(_MASKMAP)
|
|
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion ( NdotV, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness ( surfaceData.perceptualSmoothness ) );
|
|
#endif
|
|
#if HAVE_DECALS
|
|
if (_EnableDecals)
|
|
{
|
|
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData (posInput, surfaceDescription.Alpha);
|
|
ApplyDecalToSurfaceData (decalSurfaceData, surfaceData);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void GetSurfaceAndBuiltinData( GlobalSurfaceDescription surfaceDescription , FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
{
|
|
#if _ALPHATEST_ON
|
|
DoAlphaTest ( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
|
|
#endif
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
|
|
InitBuiltinData (posInput, surfaceDescription.Alpha, surfaceData.normalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData);
|
|
|
|
builtinData.emissiveColor = surfaceDescription.Emission;
|
|
builtinData.distortion = float2(0.0, 0.0); // surfaceDescription.Distortion -- if distortion pass
|
|
builtinData.distortionBlur = 0.0; // surfaceDescription.DistortionBlur -- if distortion pass
|
|
|
|
builtinData.depthOffset = 0.0; // ApplyPerPixelDisplacement(input, V, layerTexCoord, blendMasks); #ifdef _DEPTHOFFSET_ON : ApplyDepthOffsetPositionInput(V, depthOffset, GetWorldToHClipMatrix(), posInput);
|
|
|
|
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
|
|
}
|
|
|
|
|
|
PackedVaryingsMeshToPS Vert(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
|
|
|
|
outputPackedVaryingsMeshToPS.ase_texcoord5.xy = inputMesh.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
outputPackedVaryingsMeshToPS.ase_texcoord5.zw = 0;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = inputMesh.positionOS.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3( 0, 0, 0 );
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue ;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
inputMesh.positionOS.xyz = vertexValue;
|
|
#else
|
|
inputMesh.positionOS.xyz += vertexValue;
|
|
#endif
|
|
|
|
inputMesh.normalOS = inputMesh.normalOS ;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
outputPackedVaryingsMeshToPS.positionCS = TransformWorldToHClip(positionRWS);
|
|
outputPackedVaryingsMeshToPS.interp00.xyz = positionRWS;
|
|
outputPackedVaryingsMeshToPS.interp01.xyz = normalWS;
|
|
outputPackedVaryingsMeshToPS.interp02.xyzw = tangentWS;
|
|
outputPackedVaryingsMeshToPS.interp03.xyzw = inputMesh.uv1;
|
|
outputPackedVaryingsMeshToPS.interp04.xyzw = inputMesh.uv2;
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
|
|
return outputPackedVaryingsMeshToPS;
|
|
}
|
|
|
|
void Frag( PackedVaryingsMeshToPS packedInput,
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
out float4 outColor : SV_Target0,
|
|
out float4 outDiffuseLighting : SV_Target1,
|
|
OUTPUT_SSSBUFFER (outSSSBuffer)
|
|
#else
|
|
out float4 outColor : SV_Target0
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
, out float4 outMotionVec : SV_Target1
|
|
#endif
|
|
#endif
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( packedInput );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( packedInput );
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
float3 positionRWS = packedInput.interp00.xyz;
|
|
float3 normalWS = packedInput.interp01.xyz;
|
|
float4 tangentWS = packedInput.interp02.xyzw;
|
|
|
|
input.positionRWS = positionRWS;
|
|
input.tangentToWorld = BuildTangentToWorld(tangentWS, normalWS);
|
|
input.texCoord1 = packedInput.interp03.xyzw;
|
|
input.texCoord2 = packedInput.interp04.xyzw;
|
|
|
|
// input.positionSS is SV_Position
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, uint2(input.positionSS.xy) / GetTileSize() );
|
|
|
|
float3 normalizedWorldViewDir = GetWorldSpaceNormalizeViewDir ( input.positionRWS );
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GlobalSurfaceDescription surfaceDescription = ( GlobalSurfaceDescription ) 0;
|
|
float2 uv_Diffuse1 = packedInput.ase_texcoord5.xy * _Diffuse1_ST.xy + _Diffuse1_ST.zw;
|
|
float4 tex2DNode1 = tex2D( _Diffuse1, uv_Diffuse1 );
|
|
float2 uv_Diffuse2 = packedInput.ase_texcoord5.xy * _Diffuse2_ST.xy + _Diffuse2_ST.zw;
|
|
float4 lerpResult7 = lerp( tex2DNode1 , tex2D( _Diffuse2, uv_Diffuse2 ) , _MixAmount);
|
|
|
|
float2 uv_NormalMap = packedInput.ase_texcoord5.xy * _NormalMap_ST.xy + _NormalMap_ST.zw;
|
|
|
|
float2 uv_SpecGloss1 = packedInput.ase_texcoord5.xy * _SpecGloss1_ST.xy + _SpecGloss1_ST.zw;
|
|
float2 uv_SpecGloss2 = packedInput.ase_texcoord5.xy * _SpecGloss2_ST.xy + _SpecGloss2_ST.zw;
|
|
float4 lerpResult8 = lerp( tex2D( _SpecGloss1, uv_SpecGloss1 ) , tex2D( _SpecGloss2, uv_SpecGloss2 ) , _MixAmount);
|
|
float4 break9 = lerpResult8;
|
|
float4 appendResult10 = (float4(break9.r , break9.g , break9.b , 0.0));
|
|
|
|
surfaceDescription.Albedo = lerpResult7.rgb;
|
|
surfaceDescription.Normal = UnpackNormalmapRGorAG( tex2D( _NormalMap, uv_NormalMap ), 1.0f );
|
|
surfaceDescription.Emission = 0;
|
|
surfaceDescription.Specular = appendResult10.xyz;
|
|
surfaceDescription.Metallic = 0;
|
|
surfaceDescription.Smoothness = break9.a;
|
|
surfaceDescription.Occlusion = 1;
|
|
surfaceDescription.Alpha = 1;
|
|
surfaceDescription.AlphaClipThreshold = 0;
|
|
|
|
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
|
surfaceDescription.CoatMask = 0;
|
|
#endif
|
|
|
|
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) || defined(_MATERIAL_FEATURE_TRANSMISSION)
|
|
surfaceDescription.DiffusionProfile = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
|
surfaceDescription.SubsurfaceMask = 1;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
|
surfaceDescription.Thickness = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
|
surfaceDescription.Anisotropy = 0;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
|
surfaceDescription.IridescenceThickness = 0;
|
|
surfaceDescription.IridescenceMask = 1;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_FEATURE_TRANSPARENCY
|
|
surfaceDescription.IndexOfRefraction = 1;
|
|
surfaceDescription.TransmittanceColor = float3( 1, 1, 1 );
|
|
surfaceDescription.TransmittanceAbsorptionDistance = 1000000;
|
|
surfaceDescription.TransmittanceMask = 0;
|
|
#endif
|
|
GetSurfaceAndBuiltinData(surfaceDescription, input, normalizedWorldViewDir, posInput, surfaceData, builtinData);
|
|
|
|
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData);
|
|
|
|
PreLightData preLightData = GetPreLightData(normalizedWorldViewDir, posInput, bsdfData);
|
|
|
|
outColor = float4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
{
|
|
#ifdef _SURFACE_TYPE_TRANSPARENT
|
|
uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_TRANSPARENT;
|
|
#else
|
|
uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_OPAQUE;
|
|
#endif
|
|
float3 diffuseLighting;
|
|
float3 specularLighting;
|
|
|
|
LightLoop(normalizedWorldViewDir, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting);
|
|
|
|
diffuseLighting *= GetCurrentExposureMultiplier();
|
|
specularLighting *= GetCurrentExposureMultiplier();
|
|
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
if (_EnableSubsurfaceScattering != 0 && ShouldOutputSplitLighting(bsdfData))
|
|
{
|
|
outColor = float4(specularLighting, 1.0);
|
|
outDiffuseLighting = float4(TagLightingForSSS(diffuseLighting), 1.0);
|
|
}
|
|
else
|
|
{
|
|
outColor = float4(diffuseLighting + specularLighting, 1.0);
|
|
outDiffuseLighting = 0;
|
|
}
|
|
ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer);
|
|
#else
|
|
outColor = ApplyBlendMode(diffuseLighting, specularLighting, builtinData.opacity);
|
|
outColor = EvaluateAtmosphericScattering(posInput, normalizedWorldViewDir, outColor);
|
|
#endif
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
//VaryingsPassToPS inputPass = UnpackVaryingsPassToPS (packedInput.vpass);
|
|
//bool forceNoMotion = any (unity_MotionVectorsParams.yw == 0.0);
|
|
//if (forceNoMotion)
|
|
//{
|
|
// outMotionVec = float4(2.0, 0.0, 0.0, 0.0);
|
|
//}
|
|
//else
|
|
//{
|
|
// float2 motionVec = CalculateMotionVector (inputPass.positionCS, inputPass.previousPositionCS);
|
|
// EncodeMotionVector (motionVec * 0.5, outMotionVec);
|
|
// outMotionVec.zw = 1.0;
|
|
//}
|
|
#endif
|
|
}
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
}
|
|
Fallback "Hidden/InternalErrorShader"
|
|
CustomEditor "ASEMaterialInspector"
|
|
|
|
}
|
|
/*ASEBEGIN
|
|
Version=17700
|
|
1920;0;1920;1029;1191.71;550.2914;1.408453;True;True
|
|
Node;AmplifyShaderEditor.RangedFloatNode;6;-736.7779,4.195162;Float;False;Property;_MixAmount;MixAmount;12;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SamplerNode;4;-418.6291,341.1088;Inherit;True;Property;_SpecGloss2;SpecGloss2;10;0;Create;True;0;0;False;0;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;2;-385.9171,-103.6721;Inherit;True;Property;_SpecGloss1;SpecGloss1;8;0;Create;True;0;0;False;0;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.LerpOp;8;76.76295,-1.253525;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.SamplerNode;1;-398.5434,-302.2025;Inherit;True;Property;_Diffuse1;Diffuse1;7;0;Create;True;0;0;False;0;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;3;-381.9138,131.6544;Inherit;True;Property;_Diffuse2;Diffuse2;9;0;Create;True;0;0;False;0;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.BreakToComponentsNode;9;260.247,-33.35107;Inherit;False;COLOR;1;0;COLOR;0,0,0,0;False;16;FLOAT;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT;5;FLOAT;6;FLOAT;7;FLOAT;8;FLOAT;9;FLOAT;10;FLOAT;11;FLOAT;12;FLOAT;13;FLOAT;14;FLOAT;15
|
|
Node;AmplifyShaderEditor.LerpOp;7;77.12698,-185.5135;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;11;113.8752,264.3283;Float;False;Property;_TranslucencyPower;TranslucencyPower;13;0;Create;True;0;0;False;0;0.5;0;0;1;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SamplerNode;5;252.9559,-211.9071;Inherit;True;Property;_NormalMap;NormalMap;11;0;Create;True;0;0;False;0;-1;None;None;True;0;False;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.DynamicAppendNode;10;558.1501,-49.81421;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;12;519.7376,161.581;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;22;838.6375,-130.3303;Float;False;False;-1;2;ASEMaterialInspector;0;1;New Amplify Shader;bb308bce79762c34e823049efce65141;True;META;0;1;META;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;False;False;True;1;False;-1;True;3;False;-1;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;0;False;False;False;True;2;False;-1;False;False;False;False;False;True;1;LightMode=Meta;False;0;Hidden/InternalErrorShader;0;0;Specular;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;23;838.6375,-130.3303;Float;False;False;-1;2;ASEMaterialInspector;0;1;New Amplify Shader;bb308bce79762c34e823049efce65141;True;ShadowCaster;0;2;ShadowCaster;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;False;False;True;1;False;-1;True;3;False;-1;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;0;False;False;False;False;True;False;False;False;False;0;False;-1;False;False;False;False;True;1;LightMode=ShadowCaster;False;0;Hidden/InternalErrorShader;0;0;Specular;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;24;838.6375,-130.3303;Float;False;False;-1;2;ASEMaterialInspector;0;1;New Amplify Shader;bb308bce79762c34e823049efce65141;True;SceneSelectionPass;0;3;SceneSelectionPass;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;False;False;True;1;False;-1;True;3;False;-1;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;0;False;False;False;False;True;False;False;False;False;0;False;-1;False;False;False;False;True;1;LightMode=SceneSelectionPass;False;0;Hidden/InternalErrorShader;0;0;Specular;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;25;838.6375,-130.3303;Float;False;False;-1;2;ASEMaterialInspector;0;1;New Amplify Shader;bb308bce79762c34e823049efce65141;True;DepthOnly;0;4;DepthOnly;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;False;False;True;1;False;-1;True;3;False;-1;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;0;False;False;False;False;False;True;True;0;False;-1;255;False;-1;48;False;-1;7;False;-1;3;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;True;1;LightMode=DepthOnly;False;0;Hidden/InternalErrorShader;0;0;Specular;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;26;838.6375,-130.3303;Float;False;False;-1;2;ASEMaterialInspector;0;1;New Amplify Shader;bb308bce79762c34e823049efce65141;True;Motion Vectors;0;5;Motion Vectors;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;False;False;True;1;False;-1;True;3;False;-1;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;0;False;False;False;False;False;True;True;128;False;-1;255;False;-1;176;False;-1;7;False;-1;3;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;True;1;LightMode=MotionVectors;False;0;Hidden/InternalErrorShader;0;0;Specular;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;27;838.6375,-130.3303;Float;False;False;-1;2;ASEMaterialInspector;0;1;New Amplify Shader;bb308bce79762c34e823049efce65141;True;Forward;0;6;Forward;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;False;False;True;1;False;-1;True;3;False;-1;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;0;False;False;False;False;False;True;True;2;False;-1;255;False;-1;51;False;-1;7;False;-1;3;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;True;1;LightMode=Forward;False;0;Hidden/InternalErrorShader;0;0;Specular;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;21;838.6375,-130.3303;Float;False;True;-1;2;ASEMaterialInspector;0;4;Custom/ASE_MixerShaderHDRP;bb308bce79762c34e823049efce65141;True;GBuffer;0;0;GBuffer;22;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;False;False;True;1;False;-1;True;3;False;-1;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;0;False;False;False;False;False;True;True;2;False;-1;255;False;-1;51;False;-1;7;False;-1;3;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;True;1;LightMode=GBuffer;False;0;Hidden/InternalErrorShader;0;0;Specular;1;Vertex Position,InvertActionOnDeselection;1;0;7;True;True;True;True;True;True;True;False;;0
|
|
WireConnection;8;0;2;0
|
|
WireConnection;8;1;4;0
|
|
WireConnection;8;2;6;0
|
|
WireConnection;9;0;8;0
|
|
WireConnection;7;0;1;0
|
|
WireConnection;7;1;3;0
|
|
WireConnection;7;2;6;0
|
|
WireConnection;10;0;9;0
|
|
WireConnection;10;1;9;1
|
|
WireConnection;10;2;9;2
|
|
WireConnection;12;0;1;0
|
|
WireConnection;12;1;11;0
|
|
WireConnection;21;0;7;0
|
|
WireConnection;21;1;5;0
|
|
WireConnection;21;3;10;0
|
|
WireConnection;21;5;9;3
|
|
ASEEND*/
|
|
//CHKSM=6A6366151BFE80FC094BBA898F93288E020BC252 |