95 lines
2.9 KiB
HLSL
95 lines
2.9 KiB
HLSL
#ifndef UNIVERSAL_UNLIT_META_PASS_INCLUDED
|
|
#define UNIVERSAL_UNLIT_META_PASS_INCLUDED
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
|
|
|
|
struct Attributes
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float2 uv0 : TEXCOORD0;
|
|
float2 uv1 : TEXCOORD1;
|
|
float2 uv2 : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
#ifdef EDITOR_VISUALIZATION
|
|
float2 VizUV : TEXCOORD1;
|
|
float4 LightCoord : TEXCOORD2;
|
|
#endif
|
|
|
|
//Advanced Dissolve
|
|
float3 positionOS : TEXCOORD3;
|
|
float3 normalOS : TEXCOORD4;
|
|
|
|
ADVANCED_DISSOLVE_UV(5)
|
|
};
|
|
|
|
Varyings UniversalVertexMeta(Attributes input)
|
|
{
|
|
Varyings output = (Varyings)0;
|
|
output.positionCS = UnityMetaVertexPosition(input.positionOS.xyz, input.uv1, input.uv2);
|
|
output.uv = TRANSFORM_TEX(input.uv0, _BaseMap);
|
|
#ifdef EDITOR_VISUALIZATION
|
|
UnityEditorVizData(input.positionOS.xyz, input.uv0, input.uv1, input.uv2, output.VizUV, output.LightCoord);
|
|
#endif
|
|
|
|
//Advanced Dissolve
|
|
output.positionOS = input.positionOS.xyz;
|
|
output.normalOS = input.normalOS;
|
|
|
|
ADVANCED_DISSOLVE_INIT_UV(output, input.uv0, output.positionCS)
|
|
|
|
return output;
|
|
}
|
|
|
|
half4 UniversalFragmentMeta(Varyings fragIn, MetaInput metaInput)
|
|
{
|
|
#ifdef EDITOR_VISUALIZATION
|
|
metaInput.VizUV = fragIn.VizUV;
|
|
metaInput.LightCoord = fragIn.LightCoord;
|
|
#endif
|
|
|
|
return UnityMetaFragment(metaInput);
|
|
}
|
|
|
|
half4 UniversalFragmentMetaUnlit(Varyings input) : SV_Target
|
|
{
|
|
//Advanced Dissolve////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#if defined(_AD_STATE_ENABLED)
|
|
|
|
float4 dissolveBase = 0;
|
|
#if defined(_AD_CUTOUT_STANDARD_SOURCE_BASE_ALPHA) || defined(_AD_EDGE_ADDITIONAL_COLOR_BASE_COLOR)
|
|
dissolveBase = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv);
|
|
dissolveBase.rgb *= _BaseColor.rgb;
|
|
#endif
|
|
|
|
ADVANCED_DISSOLVE_SETUP_CUTOUT_SOURCE_USING_OS(input, dissolveBase, input.positionOS, input.normalOS)
|
|
|
|
float3 dissolveAlbedo = 0;
|
|
float3 dissolveEmission = 0;
|
|
float dissolveBlend = AdvancedDissolveAlbedoEmission(cutoutSource, dissolveBase, dissolveAlbedo, dissolveEmission, input.uv);
|
|
|
|
#endif
|
|
//Advanced Dissolve/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
MetaInput metaInput = (MetaInput)0;
|
|
metaInput.Albedo = _BaseColor.rgb * SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv).rgb;
|
|
|
|
|
|
//Advanced Dissolve/////////////////////////////////////////
|
|
#if defined(_AD_STATE_ENABLED)
|
|
metaInput.Albedo = lerp(metaInput.Albedo, dissolveAlbedo, dissolveBlend);
|
|
metaInput.Emission = lerp(metaInput.Emission, dissolveEmission, dissolveBlend);
|
|
#endif
|
|
|
|
|
|
return UniversalFragmentMeta(input, metaInput);
|
|
}
|
|
#endif
|