1090 lines
38 KiB
Plaintext
1090 lines
38 KiB
Plaintext
// Made with Amplify Shader Editor
|
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
|
Shader "ASESampleShaders/SRP Universal/TerrainBasePass"
|
|
{
|
|
Properties
|
|
{
|
|
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
|
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
|
|
_MainTex("MainTex", 2D) = "white" {}
|
|
_MetallicTex("MetallicTex", 2D) = "white" {}
|
|
_Color("Color", Color) = (0,0,0,0)
|
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
|
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
LOD 0
|
|
|
|
|
|
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry-100" }
|
|
|
|
Cull Back
|
|
HLSLINCLUDE
|
|
#pragma target 3.0
|
|
ENDHLSL
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "Forward"
|
|
Tags { "LightMode"="UniversalForward" }
|
|
|
|
Blend One Zero , One Zero
|
|
ZWrite On
|
|
ZTest LEqual
|
|
Offset 0 , 0
|
|
ColorMask RGBA
|
|
|
|
|
|
HLSLPROGRAM
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#pragma multi_compile_fog
|
|
#define ASE_FOG 1
|
|
#define ASE_SRP_VERSION 999999
|
|
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
|
|
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
|
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
|
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
|
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
|
#pragma multi_compile _ _SHADOWS_SOFT
|
|
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
|
|
|
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
|
#pragma multi_compile _ LIGHTMAP_ON
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#define SHADERPASS_FORWARD
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
#if ASE_SRP_VERSION <= 70108
|
|
#define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
|
|
#endif
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#define TERRAIN_SPLAT_BASEPASS 1
|
|
|
|
|
|
sampler2D _MainTex;
|
|
sampler2D _MetallicTex;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Color;
|
|
float4 _MainTex_ST;
|
|
float4 _MetallicTex_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
struct VertexInput
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 ase_normal : NORMAL;
|
|
float4 ase_tangent : TANGENT;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 clipPos : SV_POSITION;
|
|
float4 lightmapUVOrVertexSH : TEXCOORD0;
|
|
half4 fogFactorAndVertexLight : TEXCOORD1;
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
float4 shadowCoord : TEXCOORD2;
|
|
#endif
|
|
float4 tSpace0 : TEXCOORD3;
|
|
float4 tSpace1 : TEXCOORD4;
|
|
float4 tSpace2 : TEXCOORD5;
|
|
float4 ase_texcoord6 : TEXCOORD6;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexInput ApplyMeshModification( VertexInput v )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = v.vertex.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
v.vertex.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
v.vertex.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_normal = float3(0, 1, 0);
|
|
#else
|
|
v.ase_normal = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_texcoord.xy = sampleCoords;
|
|
#else
|
|
v.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
#endif
|
|
return v;
|
|
}
|
|
|
|
|
|
VertexOutput vert ( VertexInput v )
|
|
{
|
|
VertexOutput o = (VertexOutput)0;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
v = ApplyMeshModification(v);
|
|
o.ase_texcoord6.xy = v.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
o.ase_texcoord6.zw = 0;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
v.ase_normal = v.ase_normal;
|
|
|
|
float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
|
|
float3 positionVS = TransformWorldToView( positionWS );
|
|
float4 positionCS = TransformWorldToHClip( positionWS );
|
|
|
|
VertexNormalInputs normalInput = GetVertexNormalInputs( v.ase_normal, v.ase_tangent );
|
|
|
|
o.tSpace0 = float4( normalInput.normalWS, positionWS.x);
|
|
o.tSpace1 = float4( normalInput.tangentWS, positionWS.y);
|
|
o.tSpace2 = float4( normalInput.bitangentWS, positionWS.z);
|
|
|
|
OUTPUT_LIGHTMAP_UV( v.texcoord1, unity_LightmapST, o.lightmapUVOrVertexSH.xy );
|
|
OUTPUT_SH( normalInput.normalWS.xyz, o.lightmapUVOrVertexSH.xyz );
|
|
|
|
half3 vertexLight = VertexLighting( positionWS, normalInput.normalWS );
|
|
#ifdef ASE_FOG
|
|
half fogFactor = ComputeFogFactor( positionCS.z );
|
|
#else
|
|
half fogFactor = 0;
|
|
#endif
|
|
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
|
|
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
VertexPositionInputs vertexInput = (VertexPositionInputs)0;
|
|
vertexInput.positionWS = positionWS;
|
|
vertexInput.positionCS = positionCS;
|
|
o.shadowCoord = GetShadowCoord( vertexInput );
|
|
#endif
|
|
|
|
o.clipPos = positionCS;
|
|
return o;
|
|
}
|
|
|
|
half4 frag ( VertexOutput IN ) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
|
|
|
float3 WorldNormal = normalize( IN.tSpace0.xyz );
|
|
float3 WorldTangent = IN.tSpace1.xyz;
|
|
float3 WorldBiTangent = IN.tSpace2.xyz;
|
|
float3 WorldPosition = float3(IN.tSpace0.w,IN.tSpace1.w,IN.tSpace2.w);
|
|
float3 WorldViewDirection = _WorldSpaceCameraPos.xyz - WorldPosition;
|
|
float4 ShadowCoords = float4( 0, 0, 0, 0 );
|
|
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
ShadowCoords = IN.shadowCoord;
|
|
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
|
ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
|
|
#endif
|
|
|
|
#if SHADER_HINT_NICE_QUALITY
|
|
WorldViewDirection = SafeNormalize( WorldViewDirection );
|
|
#endif
|
|
|
|
float2 uv_MainTex = IN.ase_texcoord6.xy * _MainTex_ST.xy + _MainTex_ST.zw;
|
|
float4 tex2DNode6 = tex2D( _MainTex, uv_MainTex );
|
|
float4 lerpResult7 = lerp( _Color , tex2DNode6 , 1.0);
|
|
|
|
float2 uv_MetallicTex = IN.ase_texcoord6.xy * _MetallicTex_ST.xy + _MetallicTex_ST.zw;
|
|
|
|
float3 Albedo = lerpResult7.rgb;
|
|
float3 Normal = float3(0, 0, 1);
|
|
float3 Emission = 0;
|
|
float3 Specular = 0.5;
|
|
float Metallic = tex2D( _MetallicTex, uv_MetallicTex ).r;
|
|
float Smoothness = tex2DNode6.a;
|
|
float Occlusion = 1;
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0.5;
|
|
float3 BakedGI = 0;
|
|
|
|
InputData inputData;
|
|
inputData.positionWS = WorldPosition;
|
|
inputData.viewDirectionWS = WorldViewDirection;
|
|
inputData.shadowCoord = ShadowCoords;
|
|
|
|
#ifdef _NORMALMAP
|
|
inputData.normalWS = normalize(TransformTangentToWorld(Normal, half3x3( WorldTangent, WorldBiTangent, WorldNormal )));
|
|
#else
|
|
#if !SHADER_HINT_NICE_QUALITY
|
|
inputData.normalWS = WorldNormal;
|
|
#else
|
|
inputData.normalWS = normalize( WorldNormal );
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef ASE_FOG
|
|
inputData.fogCoord = IN.fogFactorAndVertexLight.x;
|
|
#endif
|
|
|
|
inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw;
|
|
inputData.bakedGI = SAMPLE_GI( IN.lightmapUVOrVertexSH.xy, IN.lightmapUVOrVertexSH.xyz, inputData.normalWS );
|
|
#ifdef _ASE_BAKEDGI
|
|
inputData.bakedGI = BakedGI;
|
|
#endif
|
|
half4 color = UniversalFragmentPBR(
|
|
inputData,
|
|
Albedo,
|
|
Metallic,
|
|
Specular,
|
|
Smoothness,
|
|
Occlusion,
|
|
Emission,
|
|
Alpha);
|
|
|
|
#ifdef ASE_FOG
|
|
#ifdef TERRAIN_SPLAT_ADDPASS
|
|
color.rgb = MixFogColor(color.rgb, half3( 0, 0, 0 ), IN.fogFactorAndVertexLight.x );
|
|
#else
|
|
color.rgb = MixFog(color.rgb, IN.fogFactorAndVertexLight.x);
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
|
#endif
|
|
|
|
return color;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "ShadowCaster"
|
|
Tags { "LightMode"="ShadowCaster" }
|
|
|
|
ZWrite On
|
|
ZTest LEqual
|
|
|
|
HLSLPROGRAM
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#pragma multi_compile_fog
|
|
#define ASE_FOG 1
|
|
#define ASE_SRP_VERSION 999999
|
|
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
|
|
#pragma vertex ShadowPassVertex
|
|
#pragma fragment ShadowPassFragment
|
|
|
|
#define SHADERPASS_SHADOWCASTER
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#define TERRAIN_SPLAT_BASEPASS 1
|
|
|
|
|
|
struct VertexInput
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 ase_normal : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Color;
|
|
float4 _MainTex_ST;
|
|
float4 _MetallicTex_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 clipPos : SV_POSITION;
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 worldPos : TEXCOORD0;
|
|
#endif
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
float4 shadowCoord : TEXCOORD1;
|
|
#endif
|
|
float4 ase_texcoord2 : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexInput ApplyMeshModification( VertexInput v )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = v.vertex.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
v.vertex.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
v.vertex.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_normal = float3(0, 1, 0);
|
|
#else
|
|
v.ase_normal = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_texcoord.xy = sampleCoords;
|
|
#else
|
|
v.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
#endif
|
|
return v;
|
|
}
|
|
|
|
|
|
float3 _LightDirection;
|
|
|
|
VertexOutput ShadowPassVertex( VertexInput v )
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
v = ApplyMeshModification(v);
|
|
o.ase_texcoord2 = v.ase_texcoord;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
|
|
v.ase_normal = v.ase_normal;
|
|
|
|
float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
o.worldPos = positionWS;
|
|
#endif
|
|
float3 normalWS = TransformObjectToWorldDir(v.ase_normal);
|
|
|
|
float4 clipPos = TransformWorldToHClip( ApplyShadowBias( positionWS, normalWS, _LightDirection ) );
|
|
|
|
#if UNITY_REVERSED_Z
|
|
clipPos.z = min(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
|
|
#else
|
|
clipPos.z = max(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
|
|
#endif
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
VertexPositionInputs vertexInput = (VertexPositionInputs)0;
|
|
vertexInput.positionWS = positionWS;
|
|
vertexInput.positionCS = clipPos;
|
|
o.shadowCoord = GetShadowCoord( vertexInput );
|
|
#endif
|
|
o.clipPos = clipPos;
|
|
return o;
|
|
}
|
|
|
|
half4 ShadowPassFragment(VertexOutput IN ) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( IN );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 WorldPosition = IN.worldPos;
|
|
#endif
|
|
float4 ShadowCoords = float4( 0, 0, 0, 0 );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
ShadowCoords = IN.shadowCoord;
|
|
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
|
ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
|
|
#endif
|
|
#endif
|
|
|
|
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0.5;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "DepthOnly"
|
|
Tags { "LightMode"="DepthOnly" }
|
|
|
|
ZWrite On
|
|
ColorMask 0
|
|
|
|
HLSLPROGRAM
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#pragma multi_compile_fog
|
|
#define ASE_FOG 1
|
|
#define ASE_SRP_VERSION 999999
|
|
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#define SHADERPASS_DEPTHONLY
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#define TERRAIN_SPLAT_BASEPASS 1
|
|
|
|
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Color;
|
|
float4 _MainTex_ST;
|
|
float4 _MetallicTex_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
struct VertexInput
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 ase_normal : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 clipPos : SV_POSITION;
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 worldPos : TEXCOORD0;
|
|
#endif
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
float4 shadowCoord : TEXCOORD1;
|
|
#endif
|
|
float4 ase_texcoord2 : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexInput ApplyMeshModification( VertexInput v )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = v.vertex.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
v.vertex.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
v.vertex.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_normal = float3(0, 1, 0);
|
|
#else
|
|
v.ase_normal = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_texcoord.xy = sampleCoords;
|
|
#else
|
|
v.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
#endif
|
|
return v;
|
|
}
|
|
|
|
|
|
VertexOutput vert( VertexInput v )
|
|
{
|
|
VertexOutput o = (VertexOutput)0;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
v = ApplyMeshModification(v);
|
|
o.ase_texcoord2 = v.ase_texcoord;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
|
|
v.ase_normal = v.ase_normal;
|
|
float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
|
|
float4 positionCS = TransformWorldToHClip( positionWS );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
o.worldPos = positionWS;
|
|
#endif
|
|
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
VertexPositionInputs vertexInput = (VertexPositionInputs)0;
|
|
vertexInput.positionWS = positionWS;
|
|
vertexInput.positionCS = positionCS;
|
|
o.shadowCoord = GetShadowCoord( vertexInput );
|
|
#endif
|
|
o.clipPos = positionCS;
|
|
return o;
|
|
}
|
|
|
|
half4 frag(VertexOutput IN ) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 WorldPosition = IN.worldPos;
|
|
#endif
|
|
float4 ShadowCoords = float4( 0, 0, 0, 0 );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
ShadowCoords = IN.shadowCoord;
|
|
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
|
ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
|
|
#endif
|
|
#endif
|
|
|
|
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0.5;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
|
|
#ifdef LOD_FADE_CROSSFADE
|
|
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
|
#endif
|
|
return 0;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "Meta"
|
|
Tags { "LightMode"="Meta" }
|
|
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#pragma multi_compile_fog
|
|
#define ASE_FOG 1
|
|
#define ASE_SRP_VERSION 999999
|
|
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#define SHADERPASS_META
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#define TERRAIN_SPLAT_BASEPASS 1
|
|
|
|
|
|
sampler2D _MainTex;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Color;
|
|
float4 _MainTex_ST;
|
|
float4 _MetallicTex_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
|
|
struct VertexInput
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 ase_normal : NORMAL;
|
|
float4 texcoord1 : TEXCOORD1;
|
|
float4 texcoord2 : TEXCOORD2;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 clipPos : SV_POSITION;
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 worldPos : TEXCOORD0;
|
|
#endif
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
float4 shadowCoord : TEXCOORD1;
|
|
#endif
|
|
float4 ase_texcoord2 : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexInput ApplyMeshModification( VertexInput v )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = v.vertex.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
v.vertex.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
v.vertex.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_normal = float3(0, 1, 0);
|
|
#else
|
|
v.ase_normal = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_texcoord.xy = sampleCoords;
|
|
#else
|
|
v.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
#endif
|
|
return v;
|
|
}
|
|
|
|
|
|
VertexOutput vert( VertexInput v )
|
|
{
|
|
VertexOutput o = (VertexOutput)0;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
v = ApplyMeshModification(v);
|
|
o.ase_texcoord2.xy = v.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
o.ase_texcoord2.zw = 0;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
|
|
v.ase_normal = v.ase_normal;
|
|
|
|
float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
o.worldPos = positionWS;
|
|
#endif
|
|
|
|
o.clipPos = MetaVertexPosition( v.vertex, v.texcoord1.xy, v.texcoord1.xy, unity_LightmapST, unity_DynamicLightmapST );
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
VertexPositionInputs vertexInput = (VertexPositionInputs)0;
|
|
vertexInput.positionWS = positionWS;
|
|
vertexInput.positionCS = o.clipPos;
|
|
o.shadowCoord = GetShadowCoord( vertexInput );
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
half4 frag(VertexOutput IN ) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 WorldPosition = IN.worldPos;
|
|
#endif
|
|
float4 ShadowCoords = float4( 0, 0, 0, 0 );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
ShadowCoords = IN.shadowCoord;
|
|
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
|
ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
|
|
#endif
|
|
#endif
|
|
|
|
float2 uv_MainTex = IN.ase_texcoord2.xy * _MainTex_ST.xy + _MainTex_ST.zw;
|
|
float4 tex2DNode6 = tex2D( _MainTex, uv_MainTex );
|
|
float4 lerpResult7 = lerp( _Color , tex2DNode6 , 1.0);
|
|
|
|
|
|
float3 Albedo = lerpResult7.rgb;
|
|
float3 Emission = 0;
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0.5;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
|
|
MetaInput metaInput = (MetaInput)0;
|
|
metaInput.Albedo = Albedo;
|
|
metaInput.Emission = Emission;
|
|
|
|
return MetaFragment(metaInput);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
|
|
|
Pass
|
|
{
|
|
|
|
Name "Universal2D"
|
|
Tags { "LightMode"="Universal2D" }
|
|
|
|
Blend One Zero , One Zero
|
|
ZWrite On
|
|
ZTest LEqual
|
|
Offset 0 , 0
|
|
ColorMask RGBA
|
|
|
|
HLSLPROGRAM
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
|
#pragma multi_compile_fog
|
|
#define ASE_FOG 1
|
|
#define ASE_SRP_VERSION 999999
|
|
|
|
#pragma enable_d3d11_debug_symbols
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#define SHADERPASS_2D
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
|
|
#define ASE_NEEDS_VERT_NORMAL
|
|
#define ASE_NEEDS_VERT_POSITION
|
|
#pragma multi_compile_instancing
|
|
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
|
|
#define TERRAIN_SPLAT_BASEPASS 1
|
|
|
|
|
|
sampler2D _MainTex;
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
TEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing
|
|
TEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing
|
|
UNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing
|
|
UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing
|
|
CBUFFER_START( UnityTerrain)//ASE Terrain Instancing
|
|
#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing
|
|
float4 _TerrainHeightmapScale;//ASE Terrain Instancing
|
|
#endif//ASE Terrain Instancing
|
|
CBUFFER_END//ASE Terrain Instancing
|
|
CBUFFER_START( UnityPerMaterial )
|
|
float4 _Color;
|
|
float4 _MainTex_ST;
|
|
float4 _MetallicTex_ST;
|
|
CBUFFER_END
|
|
|
|
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
|
|
struct VertexInput
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 ase_normal : NORMAL;
|
|
float4 ase_texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
float4 clipPos : SV_POSITION;
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 worldPos : TEXCOORD0;
|
|
#endif
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
float4 shadowCoord : TEXCOORD1;
|
|
#endif
|
|
float4 ase_texcoord2 : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexInput ApplyMeshModification( VertexInput v )
|
|
{
|
|
#ifdef UNITY_INSTANCING_ENABLED
|
|
float2 patchVertex = v.vertex.xy;
|
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );
|
|
float2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;
|
|
float height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );
|
|
v.vertex.xz = sampleCoords* _TerrainHeightmapScale.xz;
|
|
v.vertex.y = height* _TerrainHeightmapScale.y;
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_normal = float3(0, 1, 0);
|
|
#else
|
|
v.ase_normal = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;
|
|
#endif
|
|
#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
|
|
v.ase_texcoord.xy = sampleCoords;
|
|
#else
|
|
v.ase_texcoord.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;
|
|
#endif
|
|
#endif
|
|
return v;
|
|
}
|
|
|
|
|
|
VertexOutput vert( VertexInput v )
|
|
{
|
|
VertexOutput o = (VertexOutput)0;
|
|
UNITY_SETUP_INSTANCE_ID( v );
|
|
UNITY_TRANSFER_INSTANCE_ID( v, o );
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
|
|
v = ApplyMeshModification(v);
|
|
o.ase_texcoord2.xy = v.ase_texcoord.xy;
|
|
|
|
//setting value to unused interpolator channels and avoid initialization warnings
|
|
o.ase_texcoord2.zw = 0;
|
|
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
float3 defaultVertexValue = v.vertex.xyz;
|
|
#else
|
|
float3 defaultVertexValue = float3(0, 0, 0);
|
|
#endif
|
|
float3 vertexValue = defaultVertexValue;
|
|
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
|
v.vertex.xyz = vertexValue;
|
|
#else
|
|
v.vertex.xyz += vertexValue;
|
|
#endif
|
|
|
|
v.ase_normal = v.ase_normal;
|
|
|
|
float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
|
|
float4 positionCS = TransformWorldToHClip( positionWS );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
o.worldPos = positionWS;
|
|
#endif
|
|
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
VertexPositionInputs vertexInput = (VertexPositionInputs)0;
|
|
vertexInput.positionWS = positionWS;
|
|
vertexInput.positionCS = positionCS;
|
|
o.shadowCoord = GetShadowCoord( vertexInput );
|
|
#endif
|
|
|
|
o.clipPos = positionCS;
|
|
return o;
|
|
}
|
|
|
|
half4 frag(VertexOutput IN ) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( IN );
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
|
|
float3 WorldPosition = IN.worldPos;
|
|
#endif
|
|
float4 ShadowCoords = float4( 0, 0, 0, 0 );
|
|
|
|
#if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
|
|
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
ShadowCoords = IN.shadowCoord;
|
|
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
|
ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
|
|
#endif
|
|
#endif
|
|
|
|
float2 uv_MainTex = IN.ase_texcoord2.xy * _MainTex_ST.xy + _MainTex_ST.zw;
|
|
float4 tex2DNode6 = tex2D( _MainTex, uv_MainTex );
|
|
float4 lerpResult7 = lerp( _Color , tex2DNode6 , 1.0);
|
|
|
|
|
|
float3 Albedo = lerpResult7.rgb;
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0.5;
|
|
|
|
half4 color = half4( Albedo, Alpha );
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
|
|
return color;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
}
|
|
CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
|
|
Fallback "Hidden/InternalErrorShader"
|
|
|
|
}
|
|
/*ASEBEGIN
|
|
Version=17803
|
|
-1752;-428;1530;885;1370.011;328.441;1;True;False
|
|
Node;AmplifyShaderEditor.ColorNode;5;-855.9635,-176.0151;Float;False;Property;_Color;Color;2;0;Create;True;0;0;False;0;0,0,0,0;0,0,0,0;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.RangedFloatNode;4;-595.5383,57.15771;Float;False;Constant;_Float0;Float 0;3;0;Create;True;0;0;False;0;1;0;0;0;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SamplerNode;6;-922.2748,32.78433;Inherit;True;Property;_MainTex;MainTex;0;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;7;-468.5384,-119.8423;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;8;-917.7739,265.0548;Inherit;True;Property;_MetallicTex;MetallicTex;1;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.TemplateMultiPassMasterNode;10;-250,-110;Float;False;True;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;2;ASESampleShaders/SRP Universal/TerrainBasePass;94348b07e5e8bab40bd6c8a1e3df54cd;True;Forward;0;1;Forward;12;False;False;False;True;0;False;-1;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=-100;True;2;0;True;1;1;False;-1;0;False;-1;1;1;False;-1;0;False;-1;False;False;False;True;True;True;True;True;0;False;-1;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;LightMode=UniversalForward;False;2;Include;;False;;Native;Define;TERRAIN_SPLAT_BASEPASS 1;False;;Custom;Hidden/InternalErrorShader;0;0;Standard;13;Workflow;1;Surface;0; Blend;0;Two Sided;1;Cast Shadows;1;Receive Shadows;1;GPU Instancing;1;LOD CrossFade;1;Built-in Fog;1;Meta Pass;1;Override Baked GI;0;Extra Pre Pass;0;Vertex Position,InvertActionOnDeselection;1;0;6;False;True;True;True;True;True;True;;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;11;-250,-110;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;ShadowCaster;0;2;ShadowCaster;0;False;False;False;True;0;False;-1;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;2;0;False;False;False;False;False;False;True;1;False;-1;True;3;False;-1;False;True;1;LightMode=ShadowCaster;False;0;Hidden/InternalErrorShader;0;0;Standard;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;12;-250,-110;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;DepthOnly;0;3;DepthOnly;0;False;False;False;True;0;False;-1;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;2;0;False;False;False;False;True;False;False;False;False;0;False;-1;False;True;1;False;-1;False;False;True;1;LightMode=DepthOnly;False;0;Hidden/InternalErrorShader;0;0;Standard;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;13;-250,-110;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;Meta;0;4;Meta;0;False;False;False;True;0;False;-1;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;2;0;False;False;False;True;2;False;-1;False;False;False;False;False;True;1;LightMode=Meta;False;0;Hidden/InternalErrorShader;0;0;Standard;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;14;-250,-110;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;Universal2D;0;5;Universal2D;0;False;False;False;True;0;False;-1;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;2;0;True;1;1;False;-1;0;False;-1;1;1;False;-1;0;False;-1;False;False;False;True;True;True;True;True;0;False;-1;False;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;LightMode=Universal2D;False;0;Hidden/InternalErrorShader;0;0;Standard;0;0
|
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;15;-250,-110;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;ExtraPrePass;0;0;ExtraPrePass;0;False;False;False;True;0;False;-1;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;True;0;False;-1;True;True;True;True;True;0;False;-1;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;0;False;0;Hidden/InternalErrorShader;0;0;Standard;0;0
|
|
WireConnection;7;0;5;0
|
|
WireConnection;7;1;6;0
|
|
WireConnection;7;2;4;0
|
|
WireConnection;10;0;7;0
|
|
WireConnection;10;3;8;1
|
|
WireConnection;10;4;6;4
|
|
ASEEND*/
|
|
//CHKSM=5D4422912BB8D06FC39879145584AC06F1CAA513 |