1448 lines
62 KiB
GLSL
1448 lines
62 KiB
GLSL
// Made with Amplify Shader Editor
|
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
|
Shader "ASESampleShaders/Decals Scifi Panels/Scifi Panel Decal"
|
|
{
|
|
Properties
|
|
{
|
|
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
|
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
|
|
[ASEBegin][NoScaleOffset]_Decal_BaseColor("Decal_BaseColor", 2D) = "white" {}
|
|
[NoScaleOffset]_Decal_Emissive("Decal_Emissive", 2D) = "white" {}
|
|
[NoScaleOffset]_Decal_MaskMap("Decal_MaskMap", 2D) = "white" {}
|
|
[NoScaleOffset]_Decal_Normal("Decal_Normal", 2D) = "bump" {}
|
|
[HDR]_EmissionTintIntensity("Emission Tint - Intensity", Color) = (0,0,0,0)
|
|
_Tiling("Tiling", Vector) = (0,0,0,0)
|
|
[ASEEnd]_Offset("Offset", Vector) = (0,0,0,0)
|
|
|
|
[HideInInspector]_DrawOrder("Draw Order", Int) = 0
|
|
[HideInInspector][Enum(Depth Bias, 0, View Bias, 1)]_DecalMeshBiasType("Float", Float) = 0
|
|
[HideInInspector]_DecalMeshDepthBias("DecalMesh DepthBias", Float) = 0
|
|
[HideInInspector]_DecalMeshViewBias("DecalMesh ViewBias", Float) = 0
|
|
[HideInInspector]_DecalStencilWriteMask("Float", Int) = 0
|
|
[HideInInspector]_DecalStencilRef("Float", Int) = 0
|
|
[HideInInspector][ToggleUI]_AffectAlbedo("Boolean", Float) = 1
|
|
[HideInInspector][ToggleUI]_AffectNormal("Boolean", Float) = 1
|
|
[HideInInspector][ToggleUI]_AffectAO("Boolean", Float) = 1
|
|
[HideInInspector][ToggleUI]_AffectMetal("Boolean", Float) = 1
|
|
[HideInInspector][ToggleUI]_AffectSmoothness("Boolean", Float) = 1
|
|
[HideInInspector][ToggleUI]_AffectEmission("Boolean", Float) = 1
|
|
[HideInInspector]_DecalColorMask0("Float", Int) = 0
|
|
[HideInInspector]_DecalColorMask1("Float", Int) = 0
|
|
[HideInInspector]_DecalColorMask2("Float", Int) = 0
|
|
[HideInInspector]_DecalColorMask3("Float", Int) = 0
|
|
[HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
|
|
[HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
|
|
[HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
|
|
}
|
|
SubShader
|
|
{
|
|
LOD 0
|
|
|
|
|
|
Tags { "RenderPipeline"="HDRenderPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
|
|
|
|
HLSLINCLUDE
|
|
#pragma target 4.5
|
|
#pragma only_renderers d3d11 metal vulkan xboxone xboxseries playstation switch
|
|
|
|
struct SurfaceDescription
|
|
{
|
|
float3 BaseColor;
|
|
float Alpha;
|
|
float3 NormalTS;
|
|
float NormalAlpha;
|
|
float Metallic;
|
|
float Occlusion;
|
|
float Smoothness;
|
|
float MAOSAlpha;
|
|
float3 Emission;
|
|
};
|
|
ENDHLSL
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "DBufferProjector"
|
|
Tags { "LightMode"="DBufferProjector" }
|
|
|
|
Cull Front
|
|
Blend 0 SrcAlpha OneMinusSrcAlpha, Zero OneMinusSrcAlpha Blend 1 SrcAlpha OneMinusSrcAlpha, Zero OneMinusSrcAlpha Blend 2 SrcAlpha OneMinusSrcAlpha, Zero OneMinusSrcAlpha Blend 3 Zero OneMinusSrcColor
|
|
ZTest Greater
|
|
ZWrite Off
|
|
ColorMask [_DecalColorMask0] ColorMask [_DecalColorMask1] 1 ColorMask [_DecalColorMask2] 2 ColorMask [_DecalColorMask3] 3
|
|
Stencil
|
|
{
|
|
Ref [_DecalStencilRef]
|
|
WriteMask [_DecalStencilWriteMask]
|
|
Comp Always
|
|
Pass Replace
|
|
Fail Keep
|
|
ZFail Keep
|
|
}
|
|
|
|
|
|
HLSLPROGRAM
|
|
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_ALBEDO
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_NORMAL
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_MASKMAP
|
|
#define _MATERIAL_AFFECTS_EMISSION
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#define ASE_SRP_VERSION 100600
|
|
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#pragma multi_compile_instancing
|
|
|
|
#pragma multi_compile DECALS_3RT DECALS_4RT
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_DBUFFER_PROJECTOR
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalPrepassBuffer.hlsl"
|
|
|
|
#define ASE_NEEDS_FRAG_TEXTURE_COORDINATES0
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsToPS
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
float3 positionRWS : TEXCOORD0;
|
|
#endif
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _EmissionTintIntensity;
|
|
float2 _Offset;
|
|
float2 _Tiling;
|
|
float _DrawOrder;
|
|
float _DecalMeshBiasType;
|
|
float _DecalMeshDepthBias;
|
|
float _DecalMeshViewBias;
|
|
float _DecalStencilWriteMask;
|
|
float _DecalStencilRef;
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
float _AffectAlbedo;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
float _AffectNormal;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
float _AffectAO;
|
|
float _AffectMetal;
|
|
float _AffectSmoothness;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
float _AffectEmission;
|
|
#endif
|
|
float _DecalColorMask0;
|
|
float _DecalColorMask1;
|
|
float _DecalColorMask2;
|
|
float _DecalColorMask3;
|
|
CBUFFER_END
|
|
|
|
sampler2D _Decal_BaseColor;
|
|
sampler2D _Decal_Normal;
|
|
sampler2D _Decal_MaskMap;
|
|
sampler2D _Decal_Emissive;
|
|
|
|
|
|
|
|
void GetSurfaceData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, PositionInputs posInput, float angleFadeFactor, out DecalSurfaceData surfaceData)
|
|
{
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float fadeFactor = clamp(normalToWorld[0][3], 0.0f, 1.0f) * angleFadeFactor;
|
|
float2 scale = float2(normalToWorld[3][0], normalToWorld[3][1]);
|
|
float2 offset = float2(normalToWorld[3][2], normalToWorld[3][3]);
|
|
fragInputs.texCoord0.xy = fragInputs.texCoord0.xy * scale + offset;
|
|
fragInputs.texCoord1.xy = fragInputs.texCoord1.xy * scale + offset;
|
|
fragInputs.texCoord2.xy = fragInputs.texCoord2.xy * scale + offset;
|
|
fragInputs.texCoord3.xy = fragInputs.texCoord3.xy * scale + offset;
|
|
fragInputs.positionRWS = posInput.positionWS;
|
|
fragInputs.tangentToWorld[2].xyz = TransformObjectToWorldDir(float3(0, 1, 0));
|
|
fragInputs.tangentToWorld[1].xyz = TransformObjectToWorldDir(float3(0, 0, 1));
|
|
#else
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
float fadeFactor = 1.0;
|
|
#endif
|
|
|
|
ZERO_INITIALIZE(DecalSurfaceData, surfaceData);
|
|
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
surfaceData.baseColor.xyz = surfaceDescription.BaseColor;
|
|
surfaceData.baseColor.w = surfaceDescription.Alpha * fadeFactor;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR)
|
|
surfaceData.normalWS.xyz = mul((float3x3)normalToWorld, surfaceDescription.NormalTS);
|
|
#elif (SHADERPASS == SHADERPASS_DBUFFER_MESH) || (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
surfaceData.normalWS.xyz = normalize(TransformTangentToWorld(surfaceDescription.NormalTS, fragInputs.tangentToWorld));
|
|
#endif
|
|
|
|
surfaceData.normalWS.w = surfaceDescription.NormalAlpha * fadeFactor;
|
|
#else
|
|
#if (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
surfaceData.normalWS.xyz = normalize(TransformTangentToWorld(float3(0.0, 0.0, 0.1), fragInputs.tangentToWorld));
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
surfaceData.mask.z = surfaceDescription.Smoothness;
|
|
surfaceData.mask.w = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
|
|
#ifdef DECALS_4RT
|
|
surfaceData.mask.x = surfaceDescription.Metallic;
|
|
surfaceData.mask.y = surfaceDescription.Occlusion;
|
|
surfaceData.MAOSBlend.x = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
surfaceData.MAOSBlend.y = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
#endif
|
|
|
|
#endif
|
|
}
|
|
|
|
PackedVaryingsToPS Vert(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsToPS output;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, output);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output );
|
|
|
|
#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;
|
|
inputMesh.tangentOS = inputMesh.tangentOS;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
output.positionCS = TransformWorldToHClip(positionRWS);
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
output.positionRWS = positionRWS;
|
|
#endif
|
|
|
|
return output;
|
|
}
|
|
|
|
void Frag( PackedVaryingsToPS packedInput,
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
OUTPUT_DBUFFER(outDBuffer)
|
|
#else
|
|
out float4 outEmissive : SV_Target0
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
UNITY_SETUP_INSTANCE_ID(packedInput);
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
float3 positionRWS = packedInput.positionRWS;
|
|
input.positionRWS = positionRWS;
|
|
#endif
|
|
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
DecalSurfaceData surfaceData;
|
|
float clipValue = 1.0;
|
|
float angleFadeFactor = 1.0;
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
|
|
float depth = LoadCameraDepth(input.positionSS.xy);
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
|
|
|
DecalPrepassData material;
|
|
ZERO_INITIALIZE(DecalPrepassData, material);
|
|
if (_EnableDecalLayers)
|
|
{
|
|
uint decalLayerMask = uint(UNITY_ACCESS_INSTANCED_PROP(Decal, _DecalLayerMaskFromDecal).x);
|
|
|
|
DecodeFromDecalPrepass(posInput.positionSS, material);
|
|
|
|
if ((decalLayerMask & material.decalLayerMask) == 0)
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
|
|
float3 positionDS = TransformWorldToObject(posInput.positionWS);
|
|
positionDS = positionDS * float3(1.0, -1.0, 1.0) + float3(0.5, 0.5, 0.5);
|
|
if (!(all(positionDS.xyz > 0.0f) && all(1.0f - positionDS.xyz > 0.0f)))
|
|
{
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
#ifndef SHADER_API_METAL
|
|
clip(clipValue);
|
|
#else
|
|
if (clipValue > 0.0)
|
|
{
|
|
#endif
|
|
input.texCoord0.xy = positionDS.xz;
|
|
input.texCoord1.xy = positionDS.xz;
|
|
input.texCoord2.xy = positionDS.xz;
|
|
input.texCoord3.xy = positionDS.xz;
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
|
|
if (_EnableDecalLayers)
|
|
{
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float2 angleFade = float2(normalToWorld[1][3], normalToWorld[2][3]);
|
|
|
|
if (angleFade.x > 0.0f)
|
|
{
|
|
float dotAngle = 1.0 - dot(material.geomNormalWS, normalToWorld[2].xyz);
|
|
angleFadeFactor = 1.0 - saturate(dotAngle * angleFade.x + angleFade.y);
|
|
}
|
|
}
|
|
|
|
#else
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, uint2(0, 0));
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
#else
|
|
float3 V = float3(1.0, 1.0, 1.0);
|
|
#endif
|
|
#endif
|
|
|
|
float4 texCoord0 = input.texCoord0;
|
|
float4 texCoord1 = input.texCoord1;
|
|
float4 texCoord2 = input.texCoord2;
|
|
float4 texCoord3 = input.texCoord3;
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
float2 texCoord13 = texCoord0.xy * _Tiling + _Offset;
|
|
float4 tex2DNode6 = tex2D( _Decal_BaseColor, texCoord13 );
|
|
|
|
float4 tex2DNode8 = tex2D( _Decal_MaskMap, texCoord13 );
|
|
|
|
float clampResult29 = clamp( _TimeParameters.y , 0.2 , 1.0 );
|
|
|
|
surfaceDescription.BaseColor = tex2DNode6.rgb;
|
|
surfaceDescription.Alpha = tex2DNode6.a;
|
|
surfaceDescription.NormalTS = UnpackNormalScale( tex2D( _Decal_Normal, texCoord13 ), 1.0f );
|
|
surfaceDescription.NormalAlpha = tex2DNode6.a;
|
|
surfaceDescription.Metallic = tex2DNode8.r;
|
|
surfaceDescription.Occlusion = tex2DNode8.g;
|
|
surfaceDescription.Smoothness = tex2DNode8.a;
|
|
surfaceDescription.MAOSAlpha = tex2DNode6.a;
|
|
surfaceDescription.Emission = ( ( tex2D( _Decal_Emissive, texCoord13 ) * _EmissionTintIntensity ) * clampResult29 ).rgb;
|
|
|
|
GetSurfaceData(surfaceDescription, input, V, posInput, angleFadeFactor, surfaceData);
|
|
|
|
#if ((SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)) && defined(SHADER_API_METAL)
|
|
} // if (clipValue > 0.0)
|
|
|
|
clip(clipValue);
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
ENCODE_INTO_DBUFFER(surfaceData, outDBuffer);
|
|
#else
|
|
// Emissive need to be pre-exposed
|
|
outEmissive.rgb = surfaceData.emissive * GetCurrentExposureMultiplier();
|
|
outEmissive.a = 1.0;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "DecalProjectorForwardEmissive"
|
|
Tags { "LightMode"="DecalProjectorForwardEmissive" }
|
|
|
|
Cull Front
|
|
Blend 0 SrcAlpha One
|
|
ZTest Greater
|
|
ZWrite Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_ALBEDO
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_NORMAL
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_MASKMAP
|
|
#define _MATERIAL_AFFECTS_EMISSION
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#define ASE_SRP_VERSION 100600
|
|
|
|
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#pragma multi_compile_instancing
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
#define SHADERPASS SHADERPASS_FORWARD_EMISSIVE_PROJECTOR
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalPrepassBuffer.hlsl"
|
|
|
|
#define ASE_NEEDS_FRAG_TEXTURE_COORDINATES0
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsToPS
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
float3 positionRWS : TEXCOORD0;
|
|
#endif
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _EmissionTintIntensity;
|
|
float2 _Offset;
|
|
float2 _Tiling;
|
|
float _DrawOrder;
|
|
float _DecalMeshBiasType;
|
|
float _DecalMeshDepthBias;
|
|
float _DecalMeshViewBias;
|
|
float _DecalStencilWriteMask;
|
|
float _DecalStencilRef;
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
float _AffectAlbedo;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
float _AffectNormal;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
float _AffectAO;
|
|
float _AffectMetal;
|
|
float _AffectSmoothness;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
float _AffectEmission;
|
|
#endif
|
|
float _DecalColorMask0;
|
|
float _DecalColorMask1;
|
|
float _DecalColorMask2;
|
|
float _DecalColorMask3;
|
|
CBUFFER_END
|
|
|
|
sampler2D _Decal_BaseColor;
|
|
sampler2D _Decal_Normal;
|
|
sampler2D _Decal_MaskMap;
|
|
sampler2D _Decal_Emissive;
|
|
|
|
|
|
|
|
void GetSurfaceData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, PositionInputs posInput, float angleFadeFactor, out DecalSurfaceData surfaceData)
|
|
{
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float fadeFactor = clamp(normalToWorld[0][3], 0.0f, 1.0f) * angleFadeFactor;
|
|
float2 scale = float2(normalToWorld[3][0], normalToWorld[3][1]);
|
|
float2 offset = float2(normalToWorld[3][2], normalToWorld[3][3]);
|
|
fragInputs.texCoord0.xy = fragInputs.texCoord0.xy * scale + offset;
|
|
fragInputs.texCoord1.xy = fragInputs.texCoord1.xy * scale + offset;
|
|
fragInputs.texCoord2.xy = fragInputs.texCoord2.xy * scale + offset;
|
|
fragInputs.texCoord3.xy = fragInputs.texCoord3.xy * scale + offset;
|
|
fragInputs.positionRWS = posInput.positionWS;
|
|
fragInputs.tangentToWorld[2].xyz = TransformObjectToWorldDir(float3(0, 1, 0));
|
|
fragInputs.tangentToWorld[1].xyz = TransformObjectToWorldDir(float3(0, 0, 1));
|
|
#else
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
float fadeFactor = 1.0;
|
|
#endif
|
|
|
|
ZERO_INITIALIZE(DecalSurfaceData, surfaceData);
|
|
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
surfaceData.emissive.rgb = surfaceDescription.Emission.rgb * fadeFactor;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR)
|
|
#elif (SHADERPASS == SHADERPASS_DBUFFER_MESH) || (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
#endif
|
|
|
|
#else
|
|
#if (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
|
|
#ifdef DECALS_4RT
|
|
#endif
|
|
|
|
#endif
|
|
}
|
|
|
|
PackedVaryingsToPS Vert(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsToPS output;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, output);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output );
|
|
|
|
#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;
|
|
inputMesh.tangentOS = inputMesh.tangentOS;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
output.positionCS = TransformWorldToHClip(positionRWS);
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
output.positionRWS = positionRWS;
|
|
#endif
|
|
|
|
return output;
|
|
}
|
|
|
|
void Frag( PackedVaryingsToPS packedInput,
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
OUTPUT_DBUFFER(outDBuffer)
|
|
#else
|
|
out float4 outEmissive : SV_Target0
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
UNITY_SETUP_INSTANCE_ID(packedInput);
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
input.tangentToWorld = k_identity3x3;
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
float3 positionRWS = packedInput.positionRWS;
|
|
input.positionRWS = positionRWS;
|
|
#endif
|
|
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
DecalSurfaceData surfaceData;
|
|
float clipValue = 1.0;
|
|
float angleFadeFactor = 1.0;
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
|
|
float depth = LoadCameraDepth(input.positionSS.xy);
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
|
|
|
DecalPrepassData material;
|
|
ZERO_INITIALIZE(DecalPrepassData, material);
|
|
if (_EnableDecalLayers)
|
|
{
|
|
uint decalLayerMask = uint(UNITY_ACCESS_INSTANCED_PROP(Decal, _DecalLayerMaskFromDecal).x);
|
|
|
|
DecodeFromDecalPrepass(posInput.positionSS, material);
|
|
|
|
if ((decalLayerMask & material.decalLayerMask) == 0)
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
|
|
float3 positionDS = TransformWorldToObject(posInput.positionWS);
|
|
positionDS = positionDS * float3(1.0, -1.0, 1.0) + float3(0.5, 0.5, 0.5);
|
|
if (!(all(positionDS.xyz > 0.0f) && all(1.0f - positionDS.xyz > 0.0f)))
|
|
{
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
#ifndef SHADER_API_METAL
|
|
clip(clipValue);
|
|
#else
|
|
if (clipValue > 0.0)
|
|
{
|
|
#endif
|
|
input.texCoord0.xy = positionDS.xz;
|
|
input.texCoord1.xy = positionDS.xz;
|
|
input.texCoord2.xy = positionDS.xz;
|
|
input.texCoord3.xy = positionDS.xz;
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
|
|
if (_EnableDecalLayers)
|
|
{
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float2 angleFade = float2(normalToWorld[1][3], normalToWorld[2][3]);
|
|
|
|
if (angleFade.x > 0.0f)
|
|
{
|
|
float dotAngle = 1.0 - dot(material.geomNormalWS, normalToWorld[2].xyz);
|
|
angleFadeFactor = 1.0 - saturate(dotAngle * angleFade.x + angleFade.y);
|
|
}
|
|
}
|
|
|
|
#else
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, uint2(0, 0));
|
|
#if defined(ASE_NEEDS_FRAG_RELATIVE_WORLD_POS)
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
#else
|
|
float3 V = float3(1.0, 1.0, 1.0);
|
|
#endif
|
|
#endif
|
|
|
|
float4 texCoord0 = input.texCoord0;
|
|
float4 texCoord1 = input.texCoord1;
|
|
float4 texCoord2 = input.texCoord2;
|
|
float4 texCoord3 = input.texCoord3;
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
float2 texCoord13 = texCoord0.xy * _Tiling + _Offset;
|
|
float4 tex2DNode6 = tex2D( _Decal_BaseColor, texCoord13 );
|
|
|
|
float4 tex2DNode8 = tex2D( _Decal_MaskMap, texCoord13 );
|
|
|
|
float clampResult29 = clamp( _TimeParameters.y , 0.2 , 1.0 );
|
|
|
|
surfaceDescription.BaseColor = tex2DNode6.rgb;
|
|
surfaceDescription.Alpha = tex2DNode6.a;
|
|
surfaceDescription.NormalTS = UnpackNormalScale( tex2D( _Decal_Normal, texCoord13 ), 1.0f );
|
|
surfaceDescription.NormalAlpha = tex2DNode6.a;
|
|
surfaceDescription.Metallic = tex2DNode8.r;
|
|
surfaceDescription.Occlusion = tex2DNode8.g;
|
|
surfaceDescription.Smoothness = tex2DNode8.a;
|
|
surfaceDescription.MAOSAlpha = tex2DNode6.a;
|
|
surfaceDescription.Emission = ( ( tex2D( _Decal_Emissive, texCoord13 ) * _EmissionTintIntensity ) * clampResult29 ).rgb;
|
|
|
|
GetSurfaceData(surfaceDescription, input, V, posInput, angleFadeFactor, surfaceData);
|
|
|
|
#if ((SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)) && defined(SHADER_API_METAL)
|
|
}
|
|
|
|
clip(clipValue);
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
ENCODE_INTO_DBUFFER(surfaceData, outDBuffer);
|
|
#else
|
|
// Emissive need to be pre-exposed
|
|
outEmissive.rgb = surfaceData.emissive * GetCurrentExposureMultiplier();
|
|
outEmissive.a = 1.0;
|
|
#endif
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "DBufferMesh"
|
|
Tags { "LightMode"="DBufferMesh" }
|
|
|
|
Blend 0 SrcAlpha OneMinusSrcAlpha, Zero OneMinusSrcAlpha Blend 1 SrcAlpha OneMinusSrcAlpha, Zero OneMinusSrcAlpha Blend 2 SrcAlpha OneMinusSrcAlpha, Zero OneMinusSrcAlpha Blend 3 Zero OneMinusSrcColor
|
|
ZTest LEqual
|
|
ZWrite Off
|
|
ColorMask [_DecalColorMask0] ColorMask [_DecalColorMask1] 1 ColorMask [_DecalColorMask2] 2 ColorMask [_DecalColorMask3] 3
|
|
|
|
Stencil
|
|
{
|
|
Ref [_DecalStencilRef]
|
|
WriteMask [_DecalStencilWriteMask]
|
|
Comp Always
|
|
Pass Replace
|
|
Fail Keep
|
|
ZFail Keep
|
|
}
|
|
|
|
|
|
HLSLPROGRAM
|
|
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_ALBEDO
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_NORMAL
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_MASKMAP
|
|
#define _MATERIAL_AFFECTS_EMISSION
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#define ASE_SRP_VERSION 100600
|
|
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
#pragma multi_compile_instancing
|
|
|
|
#pragma multi_compile DECALS_3RT DECALS_4RT
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
|
|
#define SHADERPASS SHADERPASS_DBUFFER_MESH
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalPrepassBuffer.hlsl"
|
|
|
|
#if ASE_SRP_VERSION >= 100301
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/DecalMeshBiasTypeEnum.cs.hlsl"
|
|
#endif
|
|
#define ASE_NEEDS_FRAG_TEXTURE_COORDINATES0
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv0 : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsToPS
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float3 interp0 : TEXCOORD0;
|
|
float3 interp1 : TEXCOORD1;
|
|
float4 interp2 : TEXCOORD2;
|
|
float4 interp3 : TEXCOORD3;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _EmissionTintIntensity;
|
|
float2 _Offset;
|
|
float2 _Tiling;
|
|
float _DrawOrder;
|
|
float _DecalMeshBiasType;
|
|
float _DecalMeshDepthBias;
|
|
float _DecalMeshViewBias;
|
|
float _DecalStencilWriteMask;
|
|
float _DecalStencilRef;
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
float _AffectAlbedo;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
float _AffectNormal;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
float _AffectAO;
|
|
float _AffectMetal;
|
|
float _AffectSmoothness;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
float _AffectEmission;
|
|
#endif
|
|
float _DecalColorMask0;
|
|
float _DecalColorMask1;
|
|
float _DecalColorMask2;
|
|
float _DecalColorMask3;
|
|
CBUFFER_END
|
|
|
|
sampler2D _Decal_BaseColor;
|
|
sampler2D _Decal_Normal;
|
|
sampler2D _Decal_MaskMap;
|
|
sampler2D _Decal_Emissive;
|
|
|
|
|
|
|
|
void GetSurfaceData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, PositionInputs posInput, float angleFadeFactor, out DecalSurfaceData surfaceData)
|
|
{
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float fadeFactor = clamp(normalToWorld[0][3], 0.0f, 1.0f) * angleFadeFactor;
|
|
float2 scale = float2(normalToWorld[3][0], normalToWorld[3][1]);
|
|
float2 offset = float2(normalToWorld[3][2], normalToWorld[3][3]);
|
|
fragInputs.texCoord0.xy = fragInputs.texCoord0.xy * scale + offset;
|
|
fragInputs.texCoord1.xy = fragInputs.texCoord1.xy * scale + offset;
|
|
fragInputs.texCoord2.xy = fragInputs.texCoord2.xy * scale + offset;
|
|
fragInputs.texCoord3.xy = fragInputs.texCoord3.xy * scale + offset;
|
|
fragInputs.positionRWS = posInput.positionWS;
|
|
fragInputs.tangentToWorld[2].xyz = TransformObjectToWorldDir(float3(0, 1, 0));
|
|
fragInputs.tangentToWorld[1].xyz = TransformObjectToWorldDir(float3(0, 0, 1));
|
|
#else
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
float fadeFactor = 1.0;
|
|
#endif
|
|
|
|
ZERO_INITIALIZE(DecalSurfaceData, surfaceData);
|
|
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
surfaceData.baseColor.xyz = surfaceDescription.BaseColor;
|
|
surfaceData.baseColor.w = surfaceDescription.Alpha * fadeFactor;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR)
|
|
surfaceData.normalWS.xyz = mul((float3x3)normalToWorld, surfaceDescription.NormalTS);
|
|
#elif (SHADERPASS == SHADERPASS_DBUFFER_MESH) || (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
surfaceData.normalWS.xyz = normalize(TransformTangentToWorld(surfaceDescription.NormalTS, fragInputs.tangentToWorld));
|
|
#endif
|
|
|
|
surfaceData.normalWS.w = surfaceDescription.NormalAlpha * fadeFactor;
|
|
#else
|
|
#if (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
surfaceData.normalWS.xyz = normalize(TransformTangentToWorld(float3(0.0, 0.0, 0.1), fragInputs.tangentToWorld));
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
surfaceData.mask.z = surfaceDescription.Smoothness;
|
|
surfaceData.mask.w = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
|
|
#ifdef DECALS_4RT
|
|
surfaceData.mask.x = surfaceDescription.Metallic;
|
|
surfaceData.mask.y = surfaceDescription.Occlusion;
|
|
surfaceData.MAOSBlend.x = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
surfaceData.MAOSBlend.y = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
#endif
|
|
|
|
#endif
|
|
}
|
|
|
|
PackedVaryingsToPS Vert(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsToPS output;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, output);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
|
|
#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;
|
|
inputMesh.tangentOS = inputMesh.tangentOS;
|
|
|
|
float3 worldSpaceBias = 0.0f;
|
|
#if ASE_SRP_VERSION >= 100301
|
|
if (_DecalMeshBiasType == DECALMESHDEPTHBIASTYPE_VIEW_BIAS)
|
|
{
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 V = GetWorldSpaceNormalizeViewDir(positionRWS);
|
|
worldSpaceBias = V * (_DecalMeshViewBias);
|
|
}
|
|
#endif
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS) + worldSpaceBias;
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
output.interp0.xyz = positionRWS;
|
|
output.positionCS = TransformWorldToHClip(positionRWS);
|
|
output.interp1.xyz = normalWS;
|
|
output.interp2.xyzw = tangentWS;
|
|
output.interp3.xyzw = inputMesh.uv0;
|
|
|
|
#if ASE_SRP_VERSION >= 100301
|
|
if (_DecalMeshBiasType == DECALMESHDEPTHBIASTYPE_DEPTH_BIAS)
|
|
{
|
|
#if UNITY_REVERSED_Z
|
|
output.positionCS.z -= _DecalMeshDepthBias;
|
|
#else
|
|
output.positionCS.z += _DecalMeshDepthBias;
|
|
#endif
|
|
}
|
|
#else
|
|
#if UNITY_REVERSED_Z
|
|
output.positionCS.z -= _DecalMeshDepthBias;
|
|
#else
|
|
output.positionCS.z += _DecalMeshDepthBias;
|
|
#endif
|
|
#endif
|
|
|
|
return output;
|
|
}
|
|
|
|
void Frag( PackedVaryingsToPS packedInput,
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
OUTPUT_DBUFFER(outDBuffer)
|
|
#else
|
|
out float4 outEmissive : SV_Target0
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
UNITY_SETUP_INSTANCE_ID(packedInput);
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
input.positionRWS = packedInput.interp0.xyz;
|
|
float3 positionRWS = input.positionRWS;
|
|
|
|
input.tangentToWorld = BuildTangentToWorld(packedInput.interp2.xyzw, packedInput.interp1.xyz);
|
|
input.texCoord0 = packedInput.interp3.xyzw;
|
|
|
|
DecalSurfaceData surfaceData;
|
|
float clipValue = 1.0;
|
|
float angleFadeFactor = 1.0;
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
|
|
float depth = LoadCameraDepth(input.positionSS.xy);
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
|
|
|
DecalPrepassData material;
|
|
ZERO_INITIALIZE(DecalPrepassData, material);
|
|
if (_EnableDecalLayers)
|
|
{
|
|
uint decalLayerMask = uint(UNITY_ACCESS_INSTANCED_PROP(Decal, _DecalLayerMaskFromDecal).x);
|
|
|
|
DecodeFromDecalPrepass(posInput.positionSS, material);
|
|
|
|
if ((decalLayerMask & material.decalLayerMask) == 0)
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
float3 positionDS = TransformWorldToObject(posInput.positionWS);
|
|
positionDS = positionDS * float3(1.0, -1.0, 1.0) + float3(0.5, 0.5, 0.5);
|
|
if (!(all(positionDS.xyz > 0.0f) && all(1.0f - positionDS.xyz > 0.0f)))
|
|
{
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
#ifndef SHADER_API_METAL
|
|
clip(clipValue);
|
|
#else
|
|
if (clipValue > 0.0)
|
|
{
|
|
#endif
|
|
input.texCoord0.xy = positionDS.xz;
|
|
input.texCoord1.xy = positionDS.xz;
|
|
input.texCoord2.xy = positionDS.xz;
|
|
input.texCoord3.xy = positionDS.xz;
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
|
|
|
|
if (_EnableDecalLayers)
|
|
{
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float2 angleFade = float2(normalToWorld[1][3], normalToWorld[2][3]);
|
|
|
|
if (angleFade.x > 0.0f)
|
|
{
|
|
float dotAngle = 1.0 - dot(material.geomNormalWS, normalToWorld[2].xyz);
|
|
angleFadeFactor = 1.0 - saturate(dotAngle * angleFade.x + angleFade.y);
|
|
}
|
|
}
|
|
|
|
#else
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, uint2(0, 0));
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
#endif
|
|
|
|
float4 texCoord0 = input.texCoord0;
|
|
float4 texCoord1 = input.texCoord1;
|
|
float4 texCoord2 = input.texCoord2;
|
|
float4 texCoord3 = input.texCoord3;
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
float2 texCoord13 = texCoord0.xy * _Tiling + _Offset;
|
|
float4 tex2DNode6 = tex2D( _Decal_BaseColor, texCoord13 );
|
|
|
|
float4 tex2DNode8 = tex2D( _Decal_MaskMap, texCoord13 );
|
|
|
|
float clampResult29 = clamp( _TimeParameters.y , 0.2 , 1.0 );
|
|
|
|
surfaceDescription.BaseColor = tex2DNode6.rgb;
|
|
surfaceDescription.Alpha = tex2DNode6.a;
|
|
surfaceDescription.NormalTS = UnpackNormalScale( tex2D( _Decal_Normal, texCoord13 ), 1.0f );
|
|
surfaceDescription.NormalAlpha = tex2DNode6.a;
|
|
surfaceDescription.Metallic = tex2DNode8.r;
|
|
surfaceDescription.Occlusion = tex2DNode8.g;
|
|
surfaceDescription.Smoothness = tex2DNode8.a;
|
|
surfaceDescription.MAOSAlpha = tex2DNode6.a;
|
|
surfaceDescription.Emission = ( ( tex2D( _Decal_Emissive, texCoord13 ) * _EmissionTintIntensity ) * clampResult29 ).rgb;
|
|
|
|
GetSurfaceData(surfaceDescription, input, V, posInput, angleFadeFactor, surfaceData);
|
|
|
|
#if ((SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)) && defined(SHADER_API_METAL)
|
|
}
|
|
|
|
clip(clipValue);
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
ENCODE_INTO_DBUFFER(surfaceData, outDBuffer);
|
|
#else
|
|
outEmissive.rgb = surfaceData.emissive * GetCurrentExposureMultiplier();
|
|
outEmissive.a = 1.0;
|
|
#endif
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "DecalMeshForwardEmissive"
|
|
Tags { "LightMode"="DecalMeshForwardEmissive" }
|
|
|
|
// Render State
|
|
Blend 0 SrcAlpha One
|
|
ZTest LEqual
|
|
ZWrite Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_ALBEDO
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_NORMAL
|
|
#pragma shader_feature _ _MATERIAL_AFFECTS_MASKMAP
|
|
#define _MATERIAL_AFFECTS_EMISSION
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#define ASE_SRP_VERSION 100600
|
|
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
#pragma multi_compile_instancing
|
|
|
|
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
|
|
#define SHADERPASS SHADERPASS_FORWARD_EMISSIVE_MESH
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.hlsl"
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalPrepassBuffer.hlsl"
|
|
|
|
#define ASE_NEEDS_FRAG_TEXTURE_COORDINATES0
|
|
|
|
|
|
struct AttributesMesh
|
|
{
|
|
float3 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float4 tangentOS : TANGENT;
|
|
float4 uv0 : TEXCOORD0;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct PackedVaryingsToPS
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float3 interp0 : TEXCOORD0;
|
|
float3 interp1 : TEXCOORD1;
|
|
float4 interp2 : TEXCOORD2;
|
|
float4 interp3 : TEXCOORD3;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _EmissionTintIntensity;
|
|
float2 _Offset;
|
|
float2 _Tiling;
|
|
float _DrawOrder;
|
|
float _DecalMeshBiasType;
|
|
float _DecalMeshDepthBias;
|
|
float _DecalMeshViewBias;
|
|
float _DecalStencilWriteMask;
|
|
float _DecalStencilRef;
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
float _AffectAlbedo;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
float _AffectNormal;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
float _AffectAO;
|
|
float _AffectMetal;
|
|
float _AffectSmoothness;
|
|
#endif
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
float _AffectEmission;
|
|
#endif
|
|
float _DecalColorMask0;
|
|
float _DecalColorMask1;
|
|
float _DecalColorMask2;
|
|
float _DecalColorMask3;
|
|
CBUFFER_END
|
|
|
|
sampler2D _Decal_BaseColor;
|
|
sampler2D _Decal_Normal;
|
|
sampler2D _Decal_MaskMap;
|
|
sampler2D _Decal_Emissive;
|
|
|
|
|
|
|
|
void GetSurfaceData(SurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, PositionInputs posInput, float angleFadeFactor, out DecalSurfaceData surfaceData)
|
|
{
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float fadeFactor = clamp(normalToWorld[0][3], 0.0f, 1.0f) * angleFadeFactor;
|
|
float2 scale = float2(normalToWorld[3][0], normalToWorld[3][1]);
|
|
float2 offset = float2(normalToWorld[3][2], normalToWorld[3][3]);
|
|
fragInputs.texCoord0.xy = fragInputs.texCoord0.xy * scale + offset;
|
|
fragInputs.texCoord1.xy = fragInputs.texCoord1.xy * scale + offset;
|
|
fragInputs.texCoord2.xy = fragInputs.texCoord2.xy * scale + offset;
|
|
fragInputs.texCoord3.xy = fragInputs.texCoord3.xy * scale + offset;
|
|
fragInputs.positionRWS = posInput.positionWS;
|
|
fragInputs.tangentToWorld[2].xyz = TransformObjectToWorldDir(float3(0, 1, 0));
|
|
fragInputs.tangentToWorld[1].xyz = TransformObjectToWorldDir(float3(0, 0, 1));
|
|
#else
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
|
#endif
|
|
|
|
float fadeFactor = 1.0;
|
|
#endif
|
|
|
|
ZERO_INITIALIZE(DecalSurfaceData, surfaceData);
|
|
|
|
#ifdef _MATERIAL_AFFECTS_EMISSION
|
|
surfaceData.emissive.rgb = surfaceDescription.Emission.rgb * fadeFactor;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_ALBEDO
|
|
surfaceData.baseColor.xyz = surfaceDescription.BaseColor;
|
|
surfaceData.baseColor.w = surfaceDescription.Alpha * fadeFactor;
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_NORMAL
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR)
|
|
surfaceData.normalWS.xyz = mul((float3x3)normalToWorld, surfaceDescription.NormalTS);
|
|
#elif (SHADERPASS == SHADERPASS_DBUFFER_MESH) || (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
surfaceData.normalWS.xyz = normalize(TransformTangentToWorld(surfaceDescription.NormalTS, fragInputs.tangentToWorld));
|
|
#endif
|
|
|
|
surfaceData.normalWS.w = surfaceDescription.NormalAlpha * fadeFactor;
|
|
#else
|
|
#if (SHADERPASS == SHADERPASS_FORWARD_PREVIEW)
|
|
surfaceData.normalWS.xyz = normalize(TransformTangentToWorld(float3(0.0, 0.0, 0.1), fragInputs.tangentToWorld));
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef _MATERIAL_AFFECTS_MASKMAP
|
|
surfaceData.mask.z = surfaceDescription.Smoothness;
|
|
surfaceData.mask.w = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
|
|
#ifdef DECALS_4RT
|
|
surfaceData.mask.x = surfaceDescription.Metallic;
|
|
surfaceData.mask.y = surfaceDescription.Occlusion;
|
|
surfaceData.MAOSBlend.x = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
surfaceData.MAOSBlend.y = surfaceDescription.MAOSAlpha * fadeFactor;
|
|
#endif
|
|
|
|
#endif
|
|
}
|
|
|
|
PackedVaryingsToPS Vert(AttributesMesh inputMesh )
|
|
{
|
|
PackedVaryingsToPS output;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(inputMesh);
|
|
UNITY_TRANSFER_INSTANCE_ID(inputMesh, output);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
|
|
#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;
|
|
inputMesh.tangentOS = inputMesh.tangentOS;
|
|
|
|
float3 positionRWS = TransformObjectToWorld(inputMesh.positionOS);
|
|
float3 normalWS = TransformObjectToWorldNormal(inputMesh.normalOS);
|
|
float4 tangentWS = float4(TransformObjectToWorldDir(inputMesh.tangentOS.xyz), inputMesh.tangentOS.w);
|
|
|
|
output.interp0.xyz = positionRWS;
|
|
output.positionCS = TransformWorldToHClip(positionRWS);
|
|
output.interp1.xyz = normalWS;
|
|
output.interp2.xyzw = tangentWS;
|
|
output.interp3.xyzw = inputMesh.uv0;
|
|
|
|
return output;
|
|
}
|
|
|
|
void Frag( PackedVaryingsToPS packedInput,
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
OUTPUT_DBUFFER(outDBuffer)
|
|
#else
|
|
out float4 outEmissive : SV_Target0
|
|
#endif
|
|
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
UNITY_SETUP_INSTANCE_ID(packedInput);
|
|
|
|
FragInputs input;
|
|
ZERO_INITIALIZE(FragInputs, input);
|
|
|
|
input.tangentToWorld = k_identity3x3;
|
|
input.positionSS = packedInput.positionCS;
|
|
|
|
input.positionRWS = packedInput.interp0.xyz;
|
|
float3 positionRWS = input.positionRWS;
|
|
|
|
input.tangentToWorld = BuildTangentToWorld(packedInput.interp2.xyzw, packedInput.interp1.xyz);
|
|
input.texCoord0 = packedInput.interp3.xyzw;
|
|
|
|
DecalSurfaceData surfaceData;
|
|
float clipValue = 1.0;
|
|
float angleFadeFactor = 1.0;
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)
|
|
|
|
float depth = LoadCameraDepth(input.positionSS.xy);
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
|
|
|
DecalPrepassData material;
|
|
ZERO_INITIALIZE(DecalPrepassData, material);
|
|
if (_EnableDecalLayers)
|
|
{
|
|
uint decalLayerMask = uint(UNITY_ACCESS_INSTANCED_PROP(Decal, _DecalLayerMaskFromDecal).x);
|
|
|
|
DecodeFromDecalPrepass(posInput.positionSS, material);
|
|
|
|
if ((decalLayerMask & material.decalLayerMask) == 0)
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
float3 positionDS = TransformWorldToObject(posInput.positionWS);
|
|
positionDS = positionDS * float3(1.0, -1.0, 1.0) + float3(0.5, 0.5, 0.5);
|
|
if (!(all(positionDS.xyz > 0.0f) && all(1.0f - positionDS.xyz > 0.0f)))
|
|
{
|
|
clipValue -= 2.0;
|
|
}
|
|
|
|
#ifndef SHADER_API_METAL
|
|
clip(clipValue);
|
|
#else
|
|
if (clipValue > 0.0)
|
|
{
|
|
#endif
|
|
input.texCoord0.xy = positionDS.xz;
|
|
input.texCoord1.xy = positionDS.xz;
|
|
input.texCoord2.xy = positionDS.xz;
|
|
input.texCoord3.xy = positionDS.xz;
|
|
|
|
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
|
|
|
|
if (_EnableDecalLayers)
|
|
{
|
|
float4x4 normalToWorld = UNITY_ACCESS_INSTANCED_PROP(Decal, _NormalToWorld);
|
|
float2 angleFade = float2(normalToWorld[1][3], normalToWorld[2][3]);
|
|
|
|
if (angleFade.x > 0.0f)
|
|
{
|
|
float dotAngle = 1.0 - dot(material.geomNormalWS, normalToWorld[2].xyz);
|
|
angleFadeFactor = 1.0 - saturate(dotAngle * angleFade.x + angleFade.y);
|
|
}
|
|
}
|
|
|
|
#else
|
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, uint2(0, 0));
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
#endif
|
|
|
|
float4 texCoord0 = input.texCoord0;
|
|
float4 texCoord1 = input.texCoord1;
|
|
float4 texCoord2 = input.texCoord2;
|
|
float4 texCoord3 = input.texCoord3;
|
|
|
|
SurfaceDescription surfaceDescription = (SurfaceDescription)0;
|
|
float2 texCoord13 = texCoord0.xy * _Tiling + _Offset;
|
|
float4 tex2DNode6 = tex2D( _Decal_BaseColor, texCoord13 );
|
|
|
|
float4 tex2DNode8 = tex2D( _Decal_MaskMap, texCoord13 );
|
|
|
|
float clampResult29 = clamp( _TimeParameters.y , 0.2 , 1.0 );
|
|
|
|
surfaceDescription.BaseColor = tex2DNode6.rgb;
|
|
surfaceDescription.Alpha = tex2DNode6.a;
|
|
surfaceDescription.NormalTS = UnpackNormalScale( tex2D( _Decal_Normal, texCoord13 ), 1.0f );
|
|
surfaceDescription.NormalAlpha = tex2DNode6.a;
|
|
surfaceDescription.Metallic = tex2DNode8.r;
|
|
surfaceDescription.Occlusion = tex2DNode8.g;
|
|
surfaceDescription.Smoothness = tex2DNode8.a;
|
|
surfaceDescription.MAOSAlpha = tex2DNode6.a;
|
|
surfaceDescription.Emission = ( ( tex2D( _Decal_Emissive, texCoord13 ) * _EmissionTintIntensity ) * clampResult29 ).rgb;
|
|
|
|
GetSurfaceData(surfaceDescription, input, V, posInput, angleFadeFactor, surfaceData);
|
|
|
|
#if ((SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_PROJECTOR)) && defined(SHADER_API_METAL)
|
|
}
|
|
|
|
clip(clipValue);
|
|
#endif
|
|
|
|
#if (SHADERPASS == SHADERPASS_DBUFFER_PROJECTOR) || (SHADERPASS == SHADERPASS_DBUFFER_MESH)
|
|
ENCODE_INTO_DBUFFER(surfaceData, outDBuffer);
|
|
#else
|
|
outEmissive.rgb = surfaceData.emissive * GetCurrentExposureMultiplier();
|
|
outEmissive.a = 1.0;
|
|
#endif
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
}
|
|
CustomEditor "Rendering.HighDefinition.DecalGUI"
|
|
FallBack "Hidden/Shader Graph/FallbackError"
|
|
|
|
|
|
}
|
|
/*ASEBEGIN
|
|
Version=18916
|
|
592;73;931;641;583.4445;643.5959;2.102335;True;False
|
|
Node;AmplifyShaderEditor.CommentaryNode;53;-1418.008,-198.9024;Inherit;False;590.942;364.8;Tile and Offset adjusted manually for each decal.;3;16;15;13;;1,1,1,1;0;0
|
|
Node;AmplifyShaderEditor.Vector2Node;16;-1361.315,1.897572;Inherit;False;Property;_Offset;Offset;6;0;Create;True;0;0;0;False;0;False;0,0;1.67,1.33;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
|
|
Node;AmplifyShaderEditor.Vector2Node;15;-1368.008,-148.9024;Inherit;False;Property;_Tiling;Tiling;5;0;Create;True;0;0;0;False;0;False;0,0;0.33,0.33;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
|
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;13;-1069.066,-74.82935;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.ColorNode;11;-613.8002,501.1999;Inherit;False;Property;_EmissionTintIntensity;Emission Tint - Intensity;4;1;[HDR];Create;True;0;0;0;False;0;False;0,0,0,0;120.3367,20.44959,0.5676273,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SinTimeNode;52;-416.2425,719.7072;Inherit;False;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;7;-632.5001,269.5001;Inherit;True;Property;_Decal_Emissive;Decal_Emissive;1;1;[NoScaleOffset];Create;True;0;0;0;False;0;False;-1;a973f709b92aa76488eb46bdd48fffe4;a973f709b92aa76488eb46bdd48fffe4;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;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;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;12;-220.4,311.4999;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.ClampOpNode;29;-189.8269,557.7254;Inherit;True;3;0;FLOAT;0;False;1;FLOAT;0.2;False;2;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;25;89.97389,312.4143;Inherit;True;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.SamplerNode;9;-606.2,-210.3;Inherit;True;Property;_Decal_Normal;Decal_Normal;3;1;[NoScaleOffset];Create;True;0;0;0;False;0;False;-1;9d098687fb5c01c48bdf5f4cde2f405f;9d098687fb5c01c48bdf5f4cde2f405f;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;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;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;8;-617.7997,8.400007;Inherit;True;Property;_Decal_MaskMap;Decal_MaskMap;2;1;[NoScaleOffset];Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;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;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;6;-602.1999,-456.3;Inherit;True;Property;_Decal_BaseColor;Decal_BaseColor;0;1;[NoScaleOffset];Create;True;0;0;0;False;0;False;-1;a494d020f4020ab4b8ae2aca06660431;a494d020f4020ab4b8ae2aca06660431;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;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;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;57;732.1061,-282.2749;Float;False;False;-1;2;Rendering.HighDefinition.DecalGUI;0;1;New Amplify Shader;d345501910c196f4a81c9eff8a0a5ad7;True;DBufferMesh;0;2;DBufferMesh;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;2;5;False;-1;10;False;-1;1;0;False;-1;10;False;-1;False;False;True;2;5;False;-1;10;False;-1;1;0;False;-1;10;False;-1;False;False;True;2;5;False;-1;10;False;-1;1;0;False;-1;10;False;-1;False;False;True;1;0;False;-1;6;False;-1;0;1;False;-1;0;False;-1;False;False;False;False;False;False;False;True;True;True;True;True;0;True;-15;False;True;True;True;True;True;0;True;-16;False;True;True;True;True;True;0;True;-17;False;True;True;0;True;-7;255;False;-1;255;True;-6;7;False;-1;3;False;-1;1;False;-1;1;False;-1;7;False;-1;3;False;-1;1;False;-1;1;False;-1;False;True;2;False;-1;True;3;False;-1;False;True;1;LightMode=DBufferMesh;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;55;732.1061,-282.2749;Float;False;True;-1;2;Rendering.HighDefinition.DecalGUI;0;10;ASESampleShaders/Decals Scifi Panels/Scifi Panel Decal;d345501910c196f4a81c9eff8a0a5ad7;True;DBufferProjector;0;0;DBufferProjector;12;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;2;5;False;-1;10;False;-1;1;0;False;-1;10;False;-1;False;False;True;2;5;False;-1;10;False;-1;1;0;False;-1;10;False;-1;False;False;True;2;5;False;-1;10;False;-1;1;0;False;-1;10;False;-1;False;False;True;1;0;False;-1;6;False;-1;0;1;False;-1;0;False;-1;False;False;False;True;1;False;-1;False;False;False;True;True;True;True;True;0;True;-15;False;True;True;True;True;True;0;True;-16;False;True;True;True;True;True;0;True;-17;False;True;True;0;True;-7;255;False;-1;255;True;-6;7;False;-1;3;False;-1;1;False;-1;1;False;-1;7;False;-1;3;False;-1;1;False;-1;1;False;-1;False;True;2;False;-1;True;2;False;-1;False;True;1;LightMode=DBufferProjector;False;False;0;;0;0;Standard;8;Affect BaseColor;1;Affect Normal;1;Affect Metal;1;Affect AO;1;Affect Smoothness;1;Affect Emission;1;Support LOD CrossFade;1;Vertex Position,InvertActionOnDeselection;1;0;4;True;True;True;True;False;;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;56;732.1061,-282.2749;Float;False;False;-1;2;Rendering.HighDefinition.DecalGUI;0;1;New Amplify Shader;d345501910c196f4a81c9eff8a0a5ad7;True;DecalProjectorForwardEmissive;0;1;DecalProjectorForwardEmissive;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;8;5;False;-1;1;False;-1;0;1;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;True;1;False;-1;False;False;False;False;False;False;False;False;False;False;False;True;2;False;-1;True;2;False;-1;False;True;1;LightMode=DecalProjectorForwardEmissive;False;False;0;;0;0;Standard;0;False;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;58;732.1061,-282.2749;Float;False;False;-1;2;Rendering.HighDefinition.DecalGUI;0;1;New Amplify Shader;d345501910c196f4a81c9eff8a0a5ad7;True;DecalMeshForwardEmissive;0;3;DecalMeshForwardEmissive;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=HDRenderPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;5;True;7;d3d11;metal;vulkan;xboxone;xboxseries;playstation;switch;0;False;True;8;5;False;-1;1;False;-1;0;1;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;-1;True;3;False;-1;False;True;1;LightMode=DecalMeshForwardEmissive;False;False;0;;0;0;Standard;0;False;0
|
|
WireConnection;13;0;15;0
|
|
WireConnection;13;1;16;0
|
|
WireConnection;7;1;13;0
|
|
WireConnection;12;0;7;0
|
|
WireConnection;12;1;11;0
|
|
WireConnection;29;0;52;4
|
|
WireConnection;25;0;12;0
|
|
WireConnection;25;1;29;0
|
|
WireConnection;9;1;13;0
|
|
WireConnection;8;1;13;0
|
|
WireConnection;6;1;13;0
|
|
WireConnection;55;0;6;0
|
|
WireConnection;55;1;6;4
|
|
WireConnection;55;2;9;0
|
|
WireConnection;55;3;6;4
|
|
WireConnection;55;4;8;1
|
|
WireConnection;55;5;8;2
|
|
WireConnection;55;6;8;4
|
|
WireConnection;55;7;6;4
|
|
WireConnection;55;8;25;0
|
|
ASEEND*/
|
|
//CHKSM=C7CC6101EEDB5EE2FBCCA660F80102B8D56ADB59 |