修复技能输入并更新战斗资源
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
Shader "GYGame/CCS/AddTexture"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainTexture] _MainTex ("主贴图", 2D) = "white" {}
|
||||
[HideInInspector] _AdditionalTex ("附加贴图", 2D) = "black" {}
|
||||
[HideInInspector] _Rotation ("旋转", Float) = 0
|
||||
[HideInInspector] _Color ("颜色", Color) = (1,1,1,1)
|
||||
[HideInInspector] _MaskTex ("遮罩", 2D) = "white" {}
|
||||
[HideInInspector] _IsNormalTex ("是否为法线贴图", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags {
|
||||
"RenderType"="Opaque"
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
}
|
||||
LOD 100
|
||||
|
||||
Pass // index 0
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_AdditionalTex); SAMPLER(sampler_linear_clamp_AdditionalTex);
|
||||
TEXTURE2D(_MaskTex); SAMPLER(sampler_linear_clamp_MaskTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _AdditionalTex_ST;
|
||||
float4 _MaskTex_ST;
|
||||
float _Rotation;
|
||||
half4 _Color;
|
||||
float _IsNormalTex;
|
||||
CBUFFER_END
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
float2 Rotate2D(float2 UV, float Rotation = 0, float2 Center = float2(0.5, 0.5))
|
||||
{
|
||||
Rotation = Rotation/360*2*PI;
|
||||
UV -= Center;
|
||||
float s = sin(Rotation);
|
||||
float c = cos(Rotation);
|
||||
float2x2 rMatrix = float2x2(c, -s, s, c);
|
||||
rMatrix *= 0.5;
|
||||
rMatrix += 0.5;
|
||||
rMatrix = rMatrix * 2 - 1;
|
||||
UV.xy = mul(UV.xy, rMatrix);
|
||||
UV += Center;
|
||||
return UV;
|
||||
}
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
//
|
||||
float2 uv = Rotate2D((i.uv-_AdditionalTex_ST.zw-0.5)*(1/_AdditionalTex_ST.xy)+0.5, _Rotation);
|
||||
float4 additionalColor = SAMPLE_TEXTURE2D(_AdditionalTex, sampler_linear_clamp_AdditionalTex, uv);
|
||||
float4 maskColor = SAMPLE_TEXTURE2D(_MaskTex, sampler_linear_clamp_MaskTex, uv);
|
||||
//
|
||||
additionalColor *= _Color;
|
||||
additionalColor.a *= maskColor.r;
|
||||
//
|
||||
float4 mainColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
float4 finalColor = float4(0, 0, 0, 0);
|
||||
finalColor.rgb = lerp(mainColor.rgb, additionalColor.rgb, additionalColor.a);
|
||||
finalColor.a = 1;
|
||||
return finalColor;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f54c473c685671d4280c47a62ae02f6d
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,688 @@
|
||||
Shader "G2_Shaders/CutOut_char"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
||||
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
|
||||
[ASEBegin]_AlphaValue("AlphaValue", Range( 0 , 1)) = 0.5
|
||||
_FresnelPow("FresnelPow", Range( 0 , 2)) = 1
|
||||
_Env_Intensity("Env_Intensity", Range( 0 , 30)) = 1
|
||||
[NoScaleOffset]_Main_Tex("Main_Tex", 2D) = "white" {}
|
||||
[NoScaleOffset]_NormalMap("NormalMap", 2D) = "white" {}
|
||||
[NoScaleOffset]_CubeMap("CubeMap", CUBE) = "white" {}
|
||||
_CubeMapMip("CubeMapMip", Range( 0 , 7)) = 0
|
||||
_MinPower("MinPower", Range( 0 , 100)) = 0
|
||||
[ASEEnd]_Color0("XrayColor", Color) = (0,0,1,1)
|
||||
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
LOD 0
|
||||
|
||||
|
||||
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="TransparentCutout" "Queue"="Transparent" }
|
||||
|
||||
Cull Back
|
||||
AlphaToMask Off
|
||||
HLSLINCLUDE
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma only_renderers d3d11 glcore gles3 metal vulkan
|
||||
|
||||
#ifndef ASE_TESS_FUNCS
|
||||
#define ASE_TESS_FUNCS
|
||||
float4 FixedTess( float tessValue )
|
||||
{
|
||||
return tessValue;
|
||||
}
|
||||
|
||||
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 wpos = mul(o2w,vertex).xyz;
|
||||
float dist = distance (wpos, cameraPos);
|
||||
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
|
||||
return f;
|
||||
}
|
||||
|
||||
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
||||
{
|
||||
float4 tess;
|
||||
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
||||
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
||||
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
||||
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
|
||||
float len = distance(wpos0, wpos1);
|
||||
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
|
||||
return f;
|
||||
}
|
||||
|
||||
float DistanceFromPlane (float3 pos, float4 plane)
|
||||
{
|
||||
float d = dot (float4(pos,1.0f), plane);
|
||||
return d;
|
||||
}
|
||||
|
||||
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
|
||||
{
|
||||
float4 planeTest;
|
||||
planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
|
||||
return !all (planeTest);
|
||||
}
|
||||
|
||||
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 f;
|
||||
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
|
||||
|
||||
return CalcTriEdgeTessFactors (f);
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
|
||||
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
|
||||
{
|
||||
tess = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
}
|
||||
return tess;
|
||||
}
|
||||
#endif //ASE_TESS_FUNCS
|
||||
|
||||
ENDHLSL
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ExtraPrePass"
|
||||
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, SrcAlpha OneMinusSrcAlpha
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
ZTest Greater
|
||||
Offset 0,0
|
||||
ColorMask RGBA
|
||||
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#define _RECEIVE_SHADOWS_OFF 1
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
||||
#pragma multi_compile_fog
|
||||
#define ASE_FOG 1
|
||||
#define ASE_SRP_VERSION 110000
|
||||
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
||||
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
|
||||
#ifdef ASE_FOG
|
||||
float fogFactor : TEXCOORD2;
|
||||
#endif
|
||||
float4 ase_texcoord3 : TEXCOORD3;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _Color0;
|
||||
float _AlphaValue;
|
||||
float _MinPower;
|
||||
float _CubeMapMip;
|
||||
float _FresnelPow;
|
||||
float _Env_Intensity;
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessPhongStrength;
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
float _TessEdgeLength;
|
||||
float _TessMaxDisp;
|
||||
#endif
|
||||
CBUFFER_END
|
||||
sampler2D _Main_Tex;
|
||||
|
||||
|
||||
|
||||
VertexOutput VertexFunction( VertexInput v )
|
||||
{
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.ase_texcoord3.xy = v.ase_texcoord.xy;
|
||||
|
||||
//setting value to unused interpolator channels and avoid initialization warnings
|
||||
o.ase_texcoord3.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
|
||||
#ifdef ASE_FOG
|
||||
o.fogFactor = ComputeFogFactor( positionCS.z );
|
||||
#endif
|
||||
o.clipPos = positionCS;
|
||||
return o;
|
||||
}
|
||||
|
||||
#if defined(TESSELLATION_ON)
|
||||
struct VertexControl
|
||||
{
|
||||
float4 vertex : INTERNALTESSPOS;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
VertexControl vert ( VertexInput v )
|
||||
{
|
||||
VertexControl o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.vertex = v.vertex;
|
||||
o.ase_normal = v.ase_normal;
|
||||
o.ase_texcoord = v.ase_texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
||||
{
|
||||
TessellationFactors o;
|
||||
float4 tf = 1;
|
||||
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
||||
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
||||
#if defined(ASE_FIXED_TESSELLATION)
|
||||
tf = FixedTess( tessValue );
|
||||
#elif defined(ASE_DISTANCE_TESSELLATION)
|
||||
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
|
||||
#elif defined(ASE_LENGTH_TESSELLATION)
|
||||
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
|
||||
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
||||
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
||||
#endif
|
||||
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("TessellationFunction")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return patch[id];
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
||||
{
|
||||
VertexInput o = (VertexInput) 0;
|
||||
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
||||
o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
|
||||
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
||||
#if defined(ASE_PHONG_TESSELLATION)
|
||||
float3 pp[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
|
||||
float phongStrength = _TessPhongStrength;
|
||||
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
||||
#endif
|
||||
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
||||
return VertexFunction(o);
|
||||
}
|
||||
#else
|
||||
VertexOutput vert ( VertexInput v )
|
||||
{
|
||||
return VertexFunction( v );
|
||||
}
|
||||
#endif
|
||||
|
||||
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_Main_Tex153 = IN.ase_texcoord3.xy;
|
||||
float4 tex2DNode153 = tex2D( _Main_Tex, uv_Main_Tex153 );
|
||||
float temp_output_167_0 = ( tex2DNode153.a * _AlphaValue );
|
||||
|
||||
float3 Color = (_Color0).rgb;
|
||||
float Alpha = temp_output_167_0;
|
||||
float AlphaClipThreshold = 0.5;
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip( Alpha - AlphaClipThreshold );
|
||||
#endif
|
||||
|
||||
#ifdef LOD_FADE_CROSSFADE
|
||||
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
||||
#endif
|
||||
|
||||
#ifdef ASE_FOG
|
||||
Color = MixFog( Color, IN.fogFactor );
|
||||
#endif
|
||||
|
||||
return half4( Color, Alpha );
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "Forward"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, Zero OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Offset 0,0
|
||||
ColorMask RGBA
|
||||
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#define _RECEIVE_SHADOWS_OFF 1
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
||||
#pragma multi_compile_fog
|
||||
#define ASE_FOG 1
|
||||
#define ASE_SRP_VERSION 110000
|
||||
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#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"
|
||||
#include "../../BadDog/Base/Includes/BadDog_Fog.hlsl"
|
||||
|
||||
#if ASE_SRP_VERSION <= 70108
|
||||
#define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
#define ASE_NEEDS_VERT_NORMAL
|
||||
#define ASE_NEEDS_FRAG_WORLD_POSITION
|
||||
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
float4 ase_tangent : TANGENT;
|
||||
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
|
||||
#ifdef ASE_FOG
|
||||
float fogFactor : TEXCOORD2;
|
||||
#endif
|
||||
float4 ase_texcoord3 : TEXCOORD3;
|
||||
float4 ase_texcoord4 : TEXCOORD4;
|
||||
float4 ase_texcoord5 : TEXCOORD5;
|
||||
float4 ase_texcoord6 : TEXCOORD6;
|
||||
float2 fogAtten : NORMAL;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _Color0;
|
||||
float _AlphaValue;
|
||||
float _MinPower;
|
||||
float _CubeMapMip;
|
||||
float _FresnelPow;
|
||||
float _Env_Intensity;
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessPhongStrength;
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
float _TessEdgeLength;
|
||||
float _TessMaxDisp;
|
||||
#endif
|
||||
CBUFFER_END
|
||||
sampler2D _Main_Tex;
|
||||
sampler2D _NormalMap;
|
||||
samplerCUBE _CubeMap;
|
||||
|
||||
|
||||
|
||||
VertexOutput VertexFunction ( VertexInput v )
|
||||
{
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float3 ase_worldTangent = TransformObjectToWorldDir(v.ase_tangent.xyz);
|
||||
o.ase_texcoord4.xyz = ase_worldTangent;
|
||||
float3 ase_worldNormal = TransformObjectToWorldNormal(v.ase_normal);
|
||||
o.ase_texcoord5.xyz = ase_worldNormal;
|
||||
float ase_vertexTangentSign = v.ase_tangent.w * unity_WorldTransformParams.w;
|
||||
float3 ase_worldBitangent = cross( ase_worldNormal, ase_worldTangent ) * ase_vertexTangentSign;
|
||||
o.ase_texcoord6.xyz = ase_worldBitangent;
|
||||
|
||||
o.ase_texcoord3.xyz = v.ase_texcoord.xyz;
|
||||
|
||||
//setting value to unused interpolator channels and avoid initialization warnings
|
||||
o.ase_texcoord3.w = 0;
|
||||
o.ase_texcoord4.w = 0;
|
||||
o.ase_texcoord5.w = 0;
|
||||
o.ase_texcoord6.w = 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
|
||||
#ifdef ASE_FOG
|
||||
o.fogFactor = ComputeFogFactor( positionCS.z );
|
||||
#endif
|
||||
o.clipPos = positionCS;
|
||||
o.fogAtten = ComputeFogAtten( positionWS);
|
||||
return o;
|
||||
}
|
||||
|
||||
#if defined(TESSELLATION_ON)
|
||||
struct VertexControl
|
||||
{
|
||||
float4 vertex : INTERNALTESSPOS;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
float4 ase_tangent : TANGENT;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
VertexControl vert ( VertexInput v )
|
||||
{
|
||||
VertexControl o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.vertex = v.vertex;
|
||||
o.ase_normal = v.ase_normal;
|
||||
o.ase_texcoord = v.ase_texcoord;
|
||||
o.ase_tangent = v.ase_tangent;
|
||||
return o;
|
||||
}
|
||||
|
||||
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
||||
{
|
||||
TessellationFactors o;
|
||||
float4 tf = 1;
|
||||
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
||||
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
||||
#if defined(ASE_FIXED_TESSELLATION)
|
||||
tf = FixedTess( tessValue );
|
||||
#elif defined(ASE_DISTANCE_TESSELLATION)
|
||||
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
|
||||
#elif defined(ASE_LENGTH_TESSELLATION)
|
||||
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
|
||||
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
||||
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
||||
#endif
|
||||
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("TessellationFunction")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return patch[id];
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
||||
{
|
||||
VertexInput o = (VertexInput) 0;
|
||||
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
||||
o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
|
||||
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
||||
o.ase_tangent = patch[0].ase_tangent * bary.x + patch[1].ase_tangent * bary.y + patch[2].ase_tangent * bary.z;
|
||||
#if defined(ASE_PHONG_TESSELLATION)
|
||||
float3 pp[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
|
||||
float phongStrength = _TessPhongStrength;
|
||||
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
||||
#endif
|
||||
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
||||
return VertexFunction(o);
|
||||
}
|
||||
#else
|
||||
VertexOutput vert ( VertexInput v )
|
||||
{
|
||||
return VertexFunction( v );
|
||||
}
|
||||
#endif
|
||||
|
||||
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_Main_Tex153 = IN.ase_texcoord3.xyz.xy;
|
||||
float4 tex2DNode153 = tex2D( _Main_Tex, uv_Main_Tex153 );
|
||||
float2 uv_NormalMap118 = IN.ase_texcoord3.xyz.xy;
|
||||
float4 tex2DNode118 = tex2D( _NormalMap, uv_NormalMap118 );
|
||||
float2 appendResult119 = (float2(tex2DNode118.r , tex2DNode118.g));
|
||||
float2 temp_cast_0 = (0.5).xx;
|
||||
float3 appendResult124 = (float3(( ( appendResult119 - temp_cast_0 ) / 0.5 ) , 1.0));
|
||||
float3 ase_worldTangent = IN.ase_texcoord4.xyz;
|
||||
float3 ase_worldNormal = IN.ase_texcoord5.xyz;
|
||||
float3 ase_worldBitangent = IN.ase_texcoord6.xyz;
|
||||
float3x3 ase_tangentToWorldFast = float3x3(ase_worldTangent.x,ase_worldBitangent.x,ase_worldNormal.x,ase_worldTangent.y,ase_worldBitangent.y,ase_worldNormal.y,ase_worldTangent.z,ase_worldBitangent.z,ase_worldNormal.z);
|
||||
float3 tangentToWorldDir129 = normalize( mul( ase_tangentToWorldFast, appendResult124 ) );
|
||||
float dotResult135 = dot( _MainLightPosition.xyz , tangentToWorldDir129 );
|
||||
float3 ase_worldViewDir = ( _WorldSpaceCameraPos.xyz - WorldPosition );
|
||||
ase_worldViewDir = normalize(ase_worldViewDir);
|
||||
float dotResult133 = dot( reflect( ( _MainLightPosition.xyz * -1.0 ) , tangentToWorldDir129 ) , ase_worldViewDir );
|
||||
float dotResult130 = dot( tangentToWorldDir129 , ase_worldViewDir );
|
||||
|
||||
float temp_output_167_0 = ( tex2DNode153.a * _AlphaValue );
|
||||
|
||||
float3 BakedAlbedo = 0;
|
||||
float3 BakedEmission = 0;
|
||||
float3 Color = ( ( (( _MainLightColor * _MainLightColor.a )).rgb * ( (tex2DNode153).rgb * ( ( ( saturate( dotResult135 ) * 0.5 ) + 0.5 ) + saturate( pow( saturate( dotResult133 ) , _MinPower ) ) ) ) ) * ( tex2DNode118.b * ( ( (texCUBElod( _CubeMap, float4( reflect( ( ase_worldViewDir * -1.0 ) , tangentToWorldDir129 ), _CubeMapMip) )).rgb * saturate( pow( ( 1.0 - saturate( dotResult130 ) ) , _FresnelPow ) ) ) * _Env_Intensity ) ) );
|
||||
float Alpha = temp_output_167_0;
|
||||
float AlphaClipThreshold = 0.5;
|
||||
float AlphaClipThresholdShadow = 0.5;
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip( Alpha - AlphaClipThreshold );
|
||||
#endif
|
||||
|
||||
#ifdef LOD_FADE_CROSSFADE
|
||||
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
||||
#endif
|
||||
|
||||
#ifdef ASE_FOG
|
||||
Color = MixFog( Color, IN.fogFactor );
|
||||
#endif
|
||||
Color = ApplyFog(Color , IN.fogAtten);
|
||||
|
||||
return half4( Color, Alpha );
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
|
||||
Fallback "Hidden/InternalErrorShader"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fe16f802c99fd048a1f95705d4e9582
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,637 @@
|
||||
Shader "G2_Shaders/CutOut_hair"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
||||
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
|
||||
[ASEBegin]_AlphaValue("AlphaValue", Range( 0 , 1)) = 0.5058824
|
||||
_Color0("XrayColor", Color) = (0,0,1,1)
|
||||
[NoScaleOffset]_Main_Tex("Main_Tex", 2D) = "white" {}
|
||||
[ASEEnd]_Cutoutvalue("Cutoutvalue", Range( 0 , 1)) = 1
|
||||
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
LOD 0
|
||||
|
||||
|
||||
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Transparent" "Queue"="Transparent" }
|
||||
|
||||
Cull Back
|
||||
AlphaToMask Off
|
||||
HLSLINCLUDE
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma only_renderers d3d11 glcore gles3 metal vulkan
|
||||
|
||||
#ifndef ASE_TESS_FUNCS
|
||||
#define ASE_TESS_FUNCS
|
||||
float4 FixedTess( float tessValue )
|
||||
{
|
||||
return tessValue;
|
||||
}
|
||||
|
||||
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 wpos = mul(o2w,vertex).xyz;
|
||||
float dist = distance (wpos, cameraPos);
|
||||
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
|
||||
return f;
|
||||
}
|
||||
|
||||
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
||||
{
|
||||
float4 tess;
|
||||
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
||||
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
||||
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
||||
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
|
||||
float len = distance(wpos0, wpos1);
|
||||
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
|
||||
return f;
|
||||
}
|
||||
|
||||
float DistanceFromPlane (float3 pos, float4 plane)
|
||||
{
|
||||
float d = dot (float4(pos,1.0f), plane);
|
||||
return d;
|
||||
}
|
||||
|
||||
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
|
||||
{
|
||||
float4 planeTest;
|
||||
planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
|
||||
return !all (planeTest);
|
||||
}
|
||||
|
||||
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 f;
|
||||
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
|
||||
|
||||
return CalcTriEdgeTessFactors (f);
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
|
||||
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
|
||||
{
|
||||
tess = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
}
|
||||
return tess;
|
||||
}
|
||||
#endif //ASE_TESS_FUNCS
|
||||
|
||||
ENDHLSL
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ExtraPrePass"
|
||||
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, SrcAlpha OneMinusSrcAlpha
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
ZTest Greater
|
||||
Offset 0,0
|
||||
ColorMask RGBA
|
||||
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#define _RECEIVE_SHADOWS_OFF 1
|
||||
#pragma multi_compile_instancing
|
||||
#define _ALPHATEST_ON 1
|
||||
#define ASE_SRP_VERSION 110000
|
||||
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
||||
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
|
||||
#ifdef ASE_FOG
|
||||
float fogFactor : TEXCOORD2;
|
||||
#endif
|
||||
float4 ase_texcoord3 : TEXCOORD3;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _Color0;
|
||||
float _AlphaValue;
|
||||
float _Cutoutvalue;
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessPhongStrength;
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
float _TessEdgeLength;
|
||||
float _TessMaxDisp;
|
||||
#endif
|
||||
CBUFFER_END
|
||||
sampler2D _Main_Tex;
|
||||
|
||||
|
||||
|
||||
VertexOutput VertexFunction( VertexInput v )
|
||||
{
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.ase_texcoord3.xy = v.ase_texcoord.xy;
|
||||
|
||||
//setting value to unused interpolator channels and avoid initialization warnings
|
||||
o.ase_texcoord3.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
|
||||
#ifdef ASE_FOG
|
||||
o.fogFactor = ComputeFogFactor( positionCS.z );
|
||||
#endif
|
||||
o.clipPos = positionCS;
|
||||
return o;
|
||||
}
|
||||
|
||||
#if defined(TESSELLATION_ON)
|
||||
struct VertexControl
|
||||
{
|
||||
float4 vertex : INTERNALTESSPOS;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
VertexControl vert ( VertexInput v )
|
||||
{
|
||||
VertexControl o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.vertex = v.vertex;
|
||||
o.ase_normal = v.ase_normal;
|
||||
o.ase_texcoord = v.ase_texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
||||
{
|
||||
TessellationFactors o;
|
||||
float4 tf = 1;
|
||||
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
||||
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
||||
#if defined(ASE_FIXED_TESSELLATION)
|
||||
tf = FixedTess( tessValue );
|
||||
#elif defined(ASE_DISTANCE_TESSELLATION)
|
||||
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
|
||||
#elif defined(ASE_LENGTH_TESSELLATION)
|
||||
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
|
||||
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
||||
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
||||
#endif
|
||||
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("TessellationFunction")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return patch[id];
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
||||
{
|
||||
VertexInput o = (VertexInput) 0;
|
||||
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
||||
o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
|
||||
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
||||
#if defined(ASE_PHONG_TESSELLATION)
|
||||
float3 pp[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
|
||||
float phongStrength = _TessPhongStrength;
|
||||
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
||||
#endif
|
||||
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
||||
return VertexFunction(o);
|
||||
}
|
||||
#else
|
||||
VertexOutput vert ( VertexInput v )
|
||||
{
|
||||
return VertexFunction( v );
|
||||
}
|
||||
#endif
|
||||
|
||||
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_Main_Tex20 = IN.ase_texcoord3.xy;
|
||||
float4 tex2DNode20 = tex2D( _Main_Tex, uv_Main_Tex20 );
|
||||
float temp_output_17_0 = ( tex2DNode20.a * _AlphaValue );
|
||||
|
||||
float3 Color = (_Color0).rgb;
|
||||
float Alpha = temp_output_17_0;
|
||||
float AlphaClipThreshold = _Cutoutvalue;
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip( Alpha - AlphaClipThreshold );
|
||||
#endif
|
||||
|
||||
#ifdef LOD_FADE_CROSSFADE
|
||||
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
||||
#endif
|
||||
|
||||
#ifdef ASE_FOG
|
||||
Color = MixFog( Color, IN.fogFactor );
|
||||
#endif
|
||||
|
||||
return half4( Color, Alpha );
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "Forward"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Offset 0,0
|
||||
ColorMask RGBA
|
||||
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#define _RECEIVE_SHADOWS_OFF 1
|
||||
#pragma multi_compile_instancing
|
||||
#define _ALPHATEST_ON 1
|
||||
#define ASE_SRP_VERSION 110000
|
||||
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#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"
|
||||
#include "../../BadDog/Base/Includes/BadDog_Fog.hlsl"
|
||||
|
||||
|
||||
#if ASE_SRP_VERSION <= 70108
|
||||
#define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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
|
||||
#ifdef ASE_FOG
|
||||
float fogFactor : TEXCOORD2;
|
||||
#endif
|
||||
float4 ase_texcoord3 : TEXCOORD3;
|
||||
float2 fogAtten : NORMAL;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _Color0;
|
||||
float _AlphaValue;
|
||||
float _Cutoutvalue;
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessPhongStrength;
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
float _TessEdgeLength;
|
||||
float _TessMaxDisp;
|
||||
#endif
|
||||
CBUFFER_END
|
||||
sampler2D _Main_Tex;
|
||||
|
||||
|
||||
|
||||
VertexOutput VertexFunction ( VertexInput v )
|
||||
{
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.ase_texcoord3.xy = v.ase_texcoord.xy;
|
||||
|
||||
//setting value to unused interpolator channels and avoid initialization warnings
|
||||
o.ase_texcoord3.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
|
||||
#ifdef ASE_FOG
|
||||
o.fogFactor = ComputeFogFactor( positionCS.z );
|
||||
#endif
|
||||
o.clipPos = positionCS;
|
||||
o.fogAtten = ComputeFogAtten( positionWS);
|
||||
return o;
|
||||
}
|
||||
|
||||
#if defined(TESSELLATION_ON)
|
||||
struct VertexControl
|
||||
{
|
||||
float4 vertex : INTERNALTESSPOS;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
VertexControl vert ( VertexInput v )
|
||||
{
|
||||
VertexControl o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.vertex = v.vertex;
|
||||
o.ase_normal = v.ase_normal;
|
||||
o.ase_texcoord = v.ase_texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
||||
{
|
||||
TessellationFactors o;
|
||||
float4 tf = 1;
|
||||
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
||||
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
||||
#if defined(ASE_FIXED_TESSELLATION)
|
||||
tf = FixedTess( tessValue );
|
||||
#elif defined(ASE_DISTANCE_TESSELLATION)
|
||||
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
|
||||
#elif defined(ASE_LENGTH_TESSELLATION)
|
||||
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
|
||||
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
||||
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
||||
#endif
|
||||
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("TessellationFunction")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return patch[id];
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
||||
{
|
||||
VertexInput o = (VertexInput) 0;
|
||||
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
||||
o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
|
||||
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
||||
#if defined(ASE_PHONG_TESSELLATION)
|
||||
float3 pp[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
|
||||
float phongStrength = _TessPhongStrength;
|
||||
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
||||
#endif
|
||||
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
||||
return VertexFunction(o);
|
||||
}
|
||||
#else
|
||||
VertexOutput vert ( VertexInput v )
|
||||
{
|
||||
return VertexFunction( v );
|
||||
}
|
||||
#endif
|
||||
|
||||
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_Main_Tex20 = IN.ase_texcoord3.xy;
|
||||
float4 tex2DNode20 = tex2D( _Main_Tex, uv_Main_Tex20 );
|
||||
|
||||
float temp_output_17_0 = ( tex2DNode20.a * _AlphaValue );
|
||||
|
||||
float3 BakedAlbedo = 0;
|
||||
float3 BakedEmission = 0;
|
||||
float3 Color = (tex2DNode20).rgb;
|
||||
float Alpha = temp_output_17_0;
|
||||
float AlphaClipThreshold = _Cutoutvalue;
|
||||
float AlphaClipThresholdShadow = 0.5;
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip( Alpha - AlphaClipThreshold );
|
||||
#endif
|
||||
|
||||
#ifdef LOD_FADE_CROSSFADE
|
||||
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
||||
#endif
|
||||
|
||||
#ifdef ASE_FOG
|
||||
Color = MixFog( Color, IN.fogFactor );
|
||||
#endif
|
||||
Color = ApplyFog(Color , IN.fogAtten);
|
||||
|
||||
return half4( Color, Alpha );
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
|
||||
Fallback "Hidden/InternalErrorShader"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fb83c7ea0abe1848a1631ddaf727503
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,726 @@
|
||||
Shader "G2_Shaders/Grass"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
||||
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
|
||||
[ASEBegin]_WindDirection("WindDirection", Vector) = (1,0,1,0)
|
||||
_WindIntensity("WindIntensity", Range( 0 , 10)) = 0
|
||||
_WindSpeed("WindSpeed", Range( 0 , 10)) = 0
|
||||
_WindTiling("WindTiling", Range( 0 , 1)) = 0
|
||||
[NoScaleOffset]_WindNoiseTex("WindNoiseTex", 2D) = "white" {}
|
||||
_Softness("Softness", Range( 0 , 1)) = 1
|
||||
[NoScaleOffset]_AlbedoTex("AlbedoTex", 2D) = "white" {}
|
||||
_AlphaClipThreshold("AlphaClipThreshold", Range( 0 , 1)) = 0
|
||||
_Translucent("Translucent", Range( 0 , 1)) = 0
|
||||
_AmbientOcclusionLuminance("AmbientOcclusionLuminance", Range( 0 , 1)) = 0
|
||||
[ASEEnd]_AmbientOcclusionFade("AmbientOcclusionFade", Range( 0 , 10)) = 0
|
||||
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
||||
|
||||
//_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
|
||||
//_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
|
||||
//_TessMin( "Tess Min Distance", Float ) = 10
|
||||
//_TessMax( "Tess Max Distance", Float ) = 25
|
||||
//_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
|
||||
//_TessMaxDisp( "Tess Max Displacement", Float ) = 25
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
LOD 0
|
||||
|
||||
|
||||
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="TransparentCutout" "Queue"="AlphaTest" }
|
||||
|
||||
Cull Off
|
||||
AlphaToMask Off
|
||||
HLSLINCLUDE
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma only_renderers d3d11 glcore gles3 metal vulkan
|
||||
|
||||
#ifndef ASE_TESS_FUNCS
|
||||
#define ASE_TESS_FUNCS
|
||||
float4 FixedTess( float tessValue )
|
||||
{
|
||||
return tessValue;
|
||||
}
|
||||
|
||||
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 wpos = mul(o2w,vertex).xyz;
|
||||
float dist = distance (wpos, cameraPos);
|
||||
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
|
||||
return f;
|
||||
}
|
||||
|
||||
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
||||
{
|
||||
float4 tess;
|
||||
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
||||
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
||||
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
||||
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
|
||||
float len = distance(wpos0, wpos1);
|
||||
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
|
||||
return f;
|
||||
}
|
||||
|
||||
float DistanceFromPlane (float3 pos, float4 plane)
|
||||
{
|
||||
float d = dot (float4(pos,1.0f), plane);
|
||||
return d;
|
||||
}
|
||||
|
||||
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
|
||||
{
|
||||
float4 planeTest;
|
||||
planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
|
||||
return !all (planeTest);
|
||||
}
|
||||
|
||||
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 f;
|
||||
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
|
||||
|
||||
return CalcTriEdgeTessFactors (f);
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
|
||||
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
|
||||
{
|
||||
tess = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
}
|
||||
return tess;
|
||||
}
|
||||
#endif //ASE_TESS_FUNCS
|
||||
|
||||
ENDHLSL
|
||||
|
||||
|
||||
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
|
||||
#define _ALPHATEST_ON 1
|
||||
#define ASE_SRP_VERSION 100501
|
||||
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#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"
|
||||
#include "../../BadDog/Base/Includes/BadDog_Fog.hlsl"
|
||||
|
||||
#if ASE_SRP_VERSION <= 70108
|
||||
#define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
#define ASE_NEEDS_FRAG_WORLD_POSITION
|
||||
#define ASE_NEEDS_FRAG_SHADOWCOORDS
|
||||
#define ASE_NEEDS_VERT_NORMAL
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
|
||||
half3 _ShadowColor;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
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
|
||||
#ifdef ASE_FOG
|
||||
float fogFactor : TEXCOORD2;
|
||||
#endif
|
||||
float4 ase_texcoord3 : TEXCOORD3;
|
||||
float4 lightmapUVOrVertexSH : TEXCOORD4;
|
||||
float4 ase_texcoord5 : TEXCOORD5;
|
||||
float4 ase_texcoord6 : TEXCOORD6;
|
||||
|
||||
//half4 fogFactorAndVertexLight : COLOR;
|
||||
float2 fogAtten : NORMAL;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _WindDirection;
|
||||
float _WindSpeed;
|
||||
float _WindTiling;
|
||||
float _WindIntensity;
|
||||
float _Softness;
|
||||
float _Translucent;
|
||||
float _AmbientOcclusionFade;
|
||||
float _AmbientOcclusionLuminance;
|
||||
float _AlphaClipThreshold;
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessPhongStrength;
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
float _TessEdgeLength;
|
||||
float _TessMaxDisp;
|
||||
#endif
|
||||
CBUFFER_END
|
||||
sampler2D _WindNoiseTex;
|
||||
sampler2D _AlbedoTex;
|
||||
|
||||
|
||||
float3 ASEIndirectDiffuse( float2 uvStaticLightmap, float3 normalWS )
|
||||
{
|
||||
#ifdef LIGHTMAP_ON
|
||||
return SampleLightmap( uvStaticLightmap, normalWS );
|
||||
#else
|
||||
return SampleSH(normalWS);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
VertexOutput VertexFunction ( VertexInput v )
|
||||
{
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float3 ase_worldPos = mul(GetObjectToWorldMatrix(), v.vertex).xyz;
|
||||
float2 appendResult70 = (float2(ase_worldPos.x , ase_worldPos.z));
|
||||
float mulTime68 = _TimeParameters.x * _WindSpeed;
|
||||
float2 normalizeResult69 = normalize( (_WindDirection).xz );
|
||||
float2 texCoord96 = v.ase_texcoord.xy * float2( 1,1 ) + float2( 0,0 );
|
||||
float3 worldToObjDir81 = mul( GetWorldToObjectMatrix(), float4( (_WindDirection).xyz, 0 ) ).xyz;
|
||||
float3 normalizeResult84 = normalize( worldToObjDir81 );
|
||||
|
||||
float3 ase_worldNormal = TransformObjectToWorldNormal(v.ase_normal);
|
||||
OUTPUT_LIGHTMAP_UV( v.texcoord1, unity_LightmapST, o.lightmapUVOrVertexSH.xy );
|
||||
OUTPUT_SH( ase_worldNormal, o.lightmapUVOrVertexSH.xyz );
|
||||
o.ase_texcoord5.xyz = ase_worldNormal;
|
||||
float3 objToWorld112 = mul( GetObjectToWorldMatrix(), float4( float3(0,0,0), 1 ) ).xyz;
|
||||
float3 vertexToFrag120 = saturate( ( frac( ( abs( objToWorld112 ) * 100.0 ) ) * 10.0 ) );
|
||||
o.ase_texcoord6.xyz = vertexToFrag120;
|
||||
|
||||
o.ase_texcoord3.xy = v.ase_texcoord.xy;
|
||||
|
||||
//setting value to unused interpolator channels and avoid initialization warnings
|
||||
o.ase_texcoord3.zw = 0;
|
||||
o.ase_texcoord5.w = 0;
|
||||
o.ase_texcoord6.w = 0;
|
||||
#ifdef ASE_ABSOLUTE_VERTEX_POS
|
||||
float3 defaultVertexValue = v.vertex.xyz;
|
||||
#else
|
||||
float3 defaultVertexValue = float3(0, 0, 0);
|
||||
#endif
|
||||
float3 vertexValue = ( ( ( ( ( tex2Dlod( _WindNoiseTex, float4( ( ( appendResult70 + ( mulTime68 * normalizeResult69 ) ) * _WindTiling ), 0, 0.0) ).r - 0.5 ) / 0.5 ) * _WindIntensity ) * saturate( ( texCoord96.y * _Softness ) ) ) * normalizeResult84 );
|
||||
#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
|
||||
#ifdef ASE_FOG
|
||||
o.fogFactor = ComputeFogFactor( positionCS.z );
|
||||
#endif
|
||||
o.clipPos = positionCS;
|
||||
|
||||
o.fogAtten = ComputeFogAtten(ase_worldPos);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
#if defined(TESSELLATION_ON)
|
||||
struct VertexControl
|
||||
{
|
||||
float4 vertex : INTERNALTESSPOS;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
VertexControl vert ( VertexInput v )
|
||||
{
|
||||
VertexControl o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.vertex = v.vertex;
|
||||
o.ase_normal = v.ase_normal;
|
||||
o.ase_texcoord = v.ase_texcoord;
|
||||
o.texcoord1 = v.texcoord1;
|
||||
return o;
|
||||
}
|
||||
|
||||
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
||||
{
|
||||
TessellationFactors o;
|
||||
float4 tf = 1;
|
||||
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
||||
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
||||
#if defined(ASE_FIXED_TESSELLATION)
|
||||
tf = FixedTess( tessValue );
|
||||
#elif defined(ASE_DISTANCE_TESSELLATION)
|
||||
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
|
||||
#elif defined(ASE_LENGTH_TESSELLATION)
|
||||
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
|
||||
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
||||
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
||||
#endif
|
||||
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("TessellationFunction")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return patch[id];
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
||||
{
|
||||
VertexInput o = (VertexInput) 0;
|
||||
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
||||
o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
|
||||
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
||||
o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
|
||||
#if defined(ASE_PHONG_TESSELLATION)
|
||||
float3 pp[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
|
||||
float phongStrength = _TessPhongStrength;
|
||||
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
||||
#endif
|
||||
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
||||
return VertexFunction(o);
|
||||
}
|
||||
#else
|
||||
VertexOutput vert ( VertexInput v )
|
||||
{
|
||||
return VertexFunction( v );
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
float3 objToWorldDir95 = mul( GetObjectToWorldMatrix(), float4( float3(0,1,0), 0 ) ).xyz;
|
||||
float dotResult20 = dot( objToWorldDir95 , _MainLightPosition.xyz );
|
||||
float ase_lightAtten = 0;
|
||||
Light ase_lightAtten_mainLight = GetMainLight( ShadowCoords );
|
||||
ase_lightAtten = ase_lightAtten_mainLight.distanceAttenuation * ase_lightAtten_mainLight.shadowAttenuation;
|
||||
float2 texCoord97 = IN.ase_texcoord3.xy * float2( 1,1 ) + float2( 0,0 );
|
||||
float temp_output_27_0 = saturate( ( texCoord97.y * _AmbientOcclusionFade ) );
|
||||
float3 ase_worldNormal = IN.ase_texcoord5.xyz;
|
||||
float3 bakedGI18 = ASEIndirectDiffuse( IN.lightmapUVOrVertexSH.xy, ase_worldNormal);
|
||||
float2 uv_AlbedoTex5 = IN.ase_texcoord3.xy;
|
||||
float4 tex2DNode5 = tex2D( _AlbedoTex, uv_AlbedoTex5 );
|
||||
float3 vertexToFrag120 = IN.ase_texcoord6.xyz;
|
||||
|
||||
float3 BakedAlbedo = 0;
|
||||
float3 BakedEmission = 0;
|
||||
float3 Color = ( ( ( ( ( saturate( dotResult20 ) * max( ase_lightAtten , _Translucent ) ) * max( ( temp_output_27_0 * temp_output_27_0 ) , _AmbientOcclusionLuminance ) ) * ( ( (_MainLightColor).rgb * _MainLightColor.a ) / PI ) ) + bakedGI18 ) * ( (tex2DNode5).rgb * vertexToFrag120 ) );
|
||||
float Alpha = tex2DNode5.a;
|
||||
float AlphaClipThreshold = _AlphaClipThreshold;
|
||||
float AlphaClipThresholdShadow = 0.5;
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip( Alpha - AlphaClipThreshold );
|
||||
#endif
|
||||
|
||||
#ifdef LOD_FADE_CROSSFADE
|
||||
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
||||
#endif
|
||||
|
||||
#ifdef ASE_FOG
|
||||
Color = MixFog( Color, IN.fogFactor );
|
||||
#endif
|
||||
|
||||
Color = ApplyFog(Color * _GlobalBrightness, IN.fogAtten);
|
||||
|
||||
return half4( Color, Alpha );
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
AlphaToMask Off
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#define _ALPHATEST_ON 1
|
||||
#define ASE_SRP_VERSION 100501
|
||||
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#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"
|
||||
|
||||
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _WindDirection;
|
||||
float _WindSpeed;
|
||||
float _WindTiling;
|
||||
float _WindIntensity;
|
||||
float _Softness;
|
||||
float _Translucent;
|
||||
float _AmbientOcclusionFade;
|
||||
float _AmbientOcclusionLuminance;
|
||||
float _AlphaClipThreshold;
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessPhongStrength;
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
float _TessEdgeLength;
|
||||
float _TessMaxDisp;
|
||||
#endif
|
||||
CBUFFER_END
|
||||
sampler2D _WindNoiseTex;
|
||||
sampler2D _AlbedoTex;
|
||||
|
||||
|
||||
|
||||
float3 _LightDirection;
|
||||
|
||||
VertexOutput VertexFunction( VertexInput v )
|
||||
{
|
||||
VertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
||||
|
||||
float3 ase_worldPos = mul(GetObjectToWorldMatrix(), v.vertex).xyz;
|
||||
float2 appendResult70 = (float2(ase_worldPos.x , ase_worldPos.z));
|
||||
float mulTime68 = _TimeParameters.x * _WindSpeed;
|
||||
float2 normalizeResult69 = normalize( (_WindDirection).xz );
|
||||
float2 texCoord96 = v.ase_texcoord.xy * float2( 1,1 ) + float2( 0,0 );
|
||||
float3 worldToObjDir81 = mul( GetWorldToObjectMatrix(), float4( (_WindDirection).xyz, 0 ) ).xyz;
|
||||
float3 normalizeResult84 = normalize( worldToObjDir81 );
|
||||
|
||||
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 = ( ( ( ( ( tex2Dlod( _WindNoiseTex, float4( ( ( appendResult70 + ( mulTime68 * normalizeResult69 ) ) * _WindTiling ), 0, 0.0) ).r - 0.5 ) / 0.5 ) * _WindIntensity ) * saturate( ( texCoord96.y * _Softness ) ) ) * normalizeResult84 );
|
||||
#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;
|
||||
}
|
||||
|
||||
#if defined(TESSELLATION_ON)
|
||||
struct VertexControl
|
||||
{
|
||||
float4 vertex : INTERNALTESSPOS;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
VertexControl vert ( VertexInput v )
|
||||
{
|
||||
VertexControl o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.vertex = v.vertex;
|
||||
o.ase_normal = v.ase_normal;
|
||||
o.ase_texcoord = v.ase_texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
||||
{
|
||||
TessellationFactors o;
|
||||
float4 tf = 1;
|
||||
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
||||
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
||||
#if defined(ASE_FIXED_TESSELLATION)
|
||||
tf = FixedTess( tessValue );
|
||||
#elif defined(ASE_DISTANCE_TESSELLATION)
|
||||
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
|
||||
#elif defined(ASE_LENGTH_TESSELLATION)
|
||||
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
|
||||
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
||||
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
||||
#endif
|
||||
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("TessellationFunction")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return patch[id];
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
||||
{
|
||||
VertexInput o = (VertexInput) 0;
|
||||
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
||||
o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
|
||||
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
||||
#if defined(ASE_PHONG_TESSELLATION)
|
||||
float3 pp[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
|
||||
float phongStrength = _TessPhongStrength;
|
||||
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
||||
#endif
|
||||
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
||||
return VertexFunction(o);
|
||||
}
|
||||
#else
|
||||
VertexOutput vert ( VertexInput v )
|
||||
{
|
||||
return VertexFunction( v );
|
||||
}
|
||||
#endif
|
||||
|
||||
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_AlbedoTex5 = IN.ase_texcoord2.xy;
|
||||
float4 tex2DNode5 = tex2D( _AlbedoTex, uv_AlbedoTex5 );
|
||||
|
||||
float Alpha = tex2DNode5.a;
|
||||
float AlphaClipThreshold = _AlphaClipThreshold;
|
||||
float AlphaClipThresholdShadow = 0.5;
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
#ifdef _ALPHATEST_SHADOW_ON
|
||||
clip(Alpha - AlphaClipThresholdShadow);
|
||||
#else
|
||||
clip(Alpha - AlphaClipThreshold);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LOD_FADE_CROSSFADE
|
||||
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
|
||||
Fallback "Hidden/InternalErrorShader"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cec0166add14f047a0e1c76c07551fc
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,386 @@
|
||||
|
||||
Shader "G2_Shaders/SceneFar"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
|
||||
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
|
||||
[ASEEnd][ASEBegin]_Texture("Texture", 2D) = "white" {}
|
||||
[ASEEnd]_Float0("brightness", Range( -1 , 1)) = 0
|
||||
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
||||
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
LOD 0
|
||||
|
||||
|
||||
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
|
||||
|
||||
Cull Back
|
||||
AlphaToMask Off
|
||||
HLSLINCLUDE
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma only_renderers d3d11 glcore gles3 metal vulkan
|
||||
|
||||
#ifndef ASE_TESS_FUNCS
|
||||
#define ASE_TESS_FUNCS
|
||||
float4 FixedTess( float tessValue )
|
||||
{
|
||||
return tessValue;
|
||||
}
|
||||
|
||||
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 wpos = mul(o2w,vertex).xyz;
|
||||
float dist = distance (wpos, cameraPos);
|
||||
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
|
||||
return f;
|
||||
}
|
||||
|
||||
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
||||
{
|
||||
float4 tess;
|
||||
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
||||
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
||||
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
||||
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
|
||||
float len = distance(wpos0, wpos1);
|
||||
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
|
||||
return f;
|
||||
}
|
||||
|
||||
float DistanceFromPlane (float3 pos, float4 plane)
|
||||
{
|
||||
float d = dot (float4(pos,1.0f), plane);
|
||||
return d;
|
||||
}
|
||||
|
||||
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
|
||||
{
|
||||
float4 planeTest;
|
||||
planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
|
||||
planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
|
||||
(( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
|
||||
return !all (planeTest);
|
||||
}
|
||||
|
||||
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
|
||||
{
|
||||
float3 f;
|
||||
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
|
||||
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
|
||||
|
||||
return CalcTriEdgeTessFactors (f);
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
|
||||
{
|
||||
float3 pos0 = mul(o2w,v0).xyz;
|
||||
float3 pos1 = mul(o2w,v1).xyz;
|
||||
float3 pos2 = mul(o2w,v2).xyz;
|
||||
float4 tess;
|
||||
|
||||
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
|
||||
{
|
||||
tess = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
|
||||
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
|
||||
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
|
||||
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
|
||||
}
|
||||
return tess;
|
||||
}
|
||||
#endif //ASE_TESS_FUNCS
|
||||
|
||||
ENDHLSL
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "Forward"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
Blend Off
|
||||
ZWrite On
|
||||
ZTest Less
|
||||
Offset 0,0
|
||||
ColorMask RGBA
|
||||
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#define _RECEIVE_SHADOWS_OFF 1
|
||||
#define ASE_SRP_VERSION 110000
|
||||
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#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"
|
||||
#include "../../BadDog/Base/Includes/BadDog_Fog.hlsl"
|
||||
#if ASE_SRP_VERSION <= 70108
|
||||
#define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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
|
||||
#ifdef ASE_FOG
|
||||
float fogFactor : TEXCOORD2;
|
||||
#endif
|
||||
float4 ase_texcoord3 : TEXCOORD3;
|
||||
float2 fogAtten : NORMAL;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
half4 _Texture_ST;
|
||||
half _Float0;
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessPhongStrength;
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
float _TessEdgeLength;
|
||||
float _TessMaxDisp;
|
||||
#endif
|
||||
CBUFFER_END
|
||||
sampler2D _Texture;
|
||||
|
||||
|
||||
|
||||
VertexOutput VertexFunction ( VertexInput v )
|
||||
{
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.ase_texcoord3.xy = v.ase_texcoord.xy;
|
||||
|
||||
|
||||
o.ase_texcoord3.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
|
||||
#ifdef ASE_FOG
|
||||
o.fogFactor = ComputeFogFactor( positionCS.z );
|
||||
#endif
|
||||
o.clipPos = positionCS;
|
||||
o.fogAtten = ComputeFogAtten(positionWS);
|
||||
return o;
|
||||
}
|
||||
|
||||
#if defined(TESSELLATION_ON)
|
||||
struct VertexControl
|
||||
{
|
||||
float4 vertex : INTERNALTESSPOS;
|
||||
float3 ase_normal : NORMAL;
|
||||
float4 ase_texcoord : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
VertexControl vert ( VertexInput v )
|
||||
{
|
||||
VertexControl o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.vertex = v.vertex;
|
||||
o.ase_normal = v.ase_normal;
|
||||
o.ase_texcoord = v.ase_texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
|
||||
{
|
||||
TessellationFactors o;
|
||||
float4 tf = 1;
|
||||
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
|
||||
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
|
||||
#if defined(ASE_FIXED_TESSELLATION)
|
||||
tf = FixedTess( tessValue );
|
||||
#elif defined(ASE_DISTANCE_TESSELLATION)
|
||||
tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
|
||||
#elif defined(ASE_LENGTH_TESSELLATION)
|
||||
tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
|
||||
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
|
||||
tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
|
||||
#endif
|
||||
o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("TessellationFunction")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return patch[id];
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
|
||||
{
|
||||
VertexInput o = (VertexInput) 0;
|
||||
o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
|
||||
o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
|
||||
o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
|
||||
#if defined(ASE_PHONG_TESSELLATION)
|
||||
float3 pp[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
|
||||
float phongStrength = _TessPhongStrength;
|
||||
o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
|
||||
#endif
|
||||
UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
|
||||
return VertexFunction(o);
|
||||
}
|
||||
#else
|
||||
VertexOutput vert ( VertexInput v )
|
||||
{
|
||||
return VertexFunction( v );
|
||||
}
|
||||
#endif
|
||||
|
||||
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_Texture = IN.ase_texcoord3.xy * _Texture_ST.xy + _Texture_ST.zw;
|
||||
|
||||
float3 BakedAlbedo = 0;
|
||||
float3 BakedEmission = 0;
|
||||
float3 Color = ( ( (( _MainLightColor * _MainLightColor.a )).rgb * (tex2D( _Texture, uv_Texture )).rgb ) * _Float0 );
|
||||
float Alpha = 1;
|
||||
float AlphaClipThreshold = 0.5;
|
||||
float AlphaClipThresholdShadow = 0.5;
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip( Alpha - AlphaClipThreshold );
|
||||
#endif
|
||||
|
||||
#ifdef LOD_FADE_CROSSFADE
|
||||
LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
|
||||
#endif
|
||||
|
||||
#ifdef ASE_FOG
|
||||
Color = MixFog( Color, IN.fogFactor );
|
||||
#endif
|
||||
Color = ApplyFog(Color , IN.fogAtten);
|
||||
|
||||
return half4( Color , Alpha );
|
||||
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
|
||||
Fallback "Hidden/InternalErrorShader"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6afe976f88e6612489b75390d9b943b8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user