当前提交
40418733
共有 17 个文件被更改,包括 873 次插入 和 1736 次删除
-
2Assets/Objects/environment/Trees/Materials/Softvegetation.mat
-
35Assets/Objects/environment/Trees/Prefabs/Bush_Large_01.prefab
-
2Assets/Scripts/Effects/LODLightmaps.cs
-
113Assets/Shaders/CustomTerrain.ShaderGraph
-
63Assets/Shaders/LWVegetationShader.shader
-
3Assets/Shaders/PackedPBR.ShaderGraph
-
7Assets/Textures/Island/Materials/BushTest.mat
-
385Assets/scenes/Island.unity
-
677Assets/scenes/Testing/WaterPerf.unity
-
52Assets/Shaders/LWDitheredVegetation.ShaderGraph
-
10Assets/Shaders/LWDitheredVegetation.ShaderGraph.meta
-
9Assets/Shaders/LWSoftVegetationShader.shader.meta
-
502Assets/Shaders/dumpingGround.shader
-
9Assets/Shaders/dumpingGround.shader.meta
-
372Assets/Shaders/LWSoftVegetationShader.shader
-
359Assets/Shaders/NewUnlitShader.shader
-
9Assets/Shaders/NewUnlitShader.shader.meta
113
Assets/Shaders/CustomTerrain.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
3
Assets/Shaders/PackedPBR.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
52
Assets/Shaders/LWDitheredVegetation.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: b614448952ccc5649bd45c3dd2e53744 |
|||
ScriptedImporter: |
|||
fileIDToRecycleName: |
|||
4800000: MainAsset |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0151397d28b044a90b91825217a9b073 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "PBR Master" |
|||
{ |
|||
Properties |
|||
{ |
|||
[NoScaleOffset] Texture_4CCF661D("splat01", 2D) = "white" {} |
|||
[NoScaleOffset] Texture_E3D097C6("Bush", 2D) = "white" {} |
|||
[NoScaleOffset] Texture_2D2A40E("BushNormal", 2D) = "white" {} |
|||
|
|||
} |
|||
SubShader |
|||
{ |
|||
Tags{ "RenderPipeline" = "LightweightPipeline"} |
|||
Tags |
|||
{ |
|||
"RenderType"="Opaque" |
|||
"Queue"="Geometry" |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "LightweightForward"} |
|||
|
|||
Blend One Zero |
|||
|
|||
Cull Back |
|||
|
|||
ZTest LEqual |
|||
|
|||
ZWrite On |
|||
|
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
// ------------------------------------- |
|||
// Lightweight Pipeline keywords |
|||
#pragma multi_compile _ _ADDITIONAL_LIGHTS |
|||
#pragma multi_compile _ _VERTEX_LIGHTS |
|||
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE |
|||
#pragma multi_compile _ _SHADOWS_ENABLED |
|||
|
|||
// ------------------------------------- |
|||
// Unity defined keywords |
|||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile _ LIGHTMAP_ON |
|||
#pragma multi_compile_fog |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
|
|||
|
|||
#include "LWRP/ShaderLibrary/Core.hlsl" |
|||
#include "LWRP/ShaderLibrary/Lighting.hlsl" |
|||
#include "CoreRP/ShaderLibrary/Color.hlsl" |
|||
#include "CoreRP/ShaderLibrary/UnityInstancing.hlsl" |
|||
#include "ShaderGraphLibrary/Functions.hlsl" |
|||
|
|||
TEXTURE2D(Texture_4CCF661D); SAMPLER(samplerTexture_4CCF661D); |
|||
TEXTURE2D(Texture_E3D097C6); SAMPLER(samplerTexture_E3D097C6); |
|||
TEXTURE2D(Texture_2D2A40E); SAMPLER(samplerTexture_2D2A40E); |
|||
|
|||
struct SurfaceInputs{ |
|||
float3 ObjectSpaceNormal; |
|||
float3 TangentSpaceNormal; |
|||
float3 ObjectSpaceTangent; |
|||
float3 ObjectSpaceBiTangent; |
|||
float3 WorldSpacePosition; |
|||
}; |
|||
|
|||
|
|||
void Unity_Combine_float(float R, float G, float B, float A, out float4 RGBA, out float3 RGB, out float2 RG) |
|||
{ |
|||
RGBA = float4(R, G, B, A); |
|||
RGB = float3(R, G, B); |
|||
RG = float2(R, G); |
|||
} |
|||
|
|||
struct GraphVertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float3 normal : NORMAL; |
|||
float4 tangent : TANGENT; |
|||
float4 texcoord1 : TEXCOORD1; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct SurfaceDescription{ |
|||
float3 Albedo; |
|||
float3 Normal; |
|||
float3 Emission; |
|||
float Metallic; |
|||
float Smoothness; |
|||
float Occlusion; |
|||
float Alpha; |
|||
float AlphaClipThreshold; |
|||
}; |
|||
|
|||
GraphVertexInput PopulateVertexData(GraphVertexInput v){ |
|||
return v; |
|||
} |
|||
|
|||
SurfaceDescription PopulateSurfaceData(SurfaceInputs IN) { |
|||
SurfaceDescription surface = (SurfaceDescription)0; |
|||
float _Split_67AEB824_R = IN.WorldSpacePosition[0]; |
|||
float _Split_67AEB824_G = IN.WorldSpacePosition[1]; |
|||
float _Split_67AEB824_B = IN.WorldSpacePosition[2]; |
|||
float _Split_67AEB824_A = 0; |
|||
float4 _Combine_77E891A3_RGBA; |
|||
float3 _Combine_77E891A3_RGB; |
|||
float2 _Combine_77E891A3_RG; |
|||
Unity_Combine_float(_Split_67AEB824_R, _Split_67AEB824_B, 0, 0, _Combine_77E891A3_RGBA, _Combine_77E891A3_RGB, _Combine_77E891A3_RG); |
|||
float4 _SampleTexture2D_DC0075E6_RGBA = SAMPLE_TEXTURE2D(Texture_E3D097C6, samplerTexture_E3D097C6, _Combine_77E891A3_RG); |
|||
float _SampleTexture2D_DC0075E6_R = _SampleTexture2D_DC0075E6_RGBA.r; |
|||
float _SampleTexture2D_DC0075E6_G = _SampleTexture2D_DC0075E6_RGBA.g; |
|||
float _SampleTexture2D_DC0075E6_B = _SampleTexture2D_DC0075E6_RGBA.b; |
|||
float _SampleTexture2D_DC0075E6_A = _SampleTexture2D_DC0075E6_RGBA.a; |
|||
surface.Albedo = (_SampleTexture2D_DC0075E6_RGBA.xyz); |
|||
surface.Normal = IN.TangentSpaceNormal; |
|||
surface.Emission = IsGammaSpace() ? float3(0, 0, 0) : SRGBToLinear(float3(0, 0, 0)); |
|||
surface.Metallic = 0; |
|||
surface.Smoothness = 0.5; |
|||
surface.Occlusion = 1; |
|||
surface.Alpha = 1; |
|||
surface.AlphaClipThreshold = 0; |
|||
return surface; |
|||
} |
|||
|
|||
|
|||
|
|||
struct GraphVertexOutput |
|||
{ |
|||
float4 clipPos : SV_POSITION; |
|||
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 0); |
|||
half4 fogFactorAndVertexLight : TEXCOORD1; // x: fogFactor, yzw: vertex light |
|||
#ifdef _SHADOWS_ENABLED |
|||
float4 shadowCoord : TEXCOORD2; |
|||
#endif |
|||
float3 WorldSpaceNormal : TEXCOORD3; |
|||
float3 WorldSpaceTangent : TEXCOORD4; |
|||
float3 WorldSpaceBiTangent : TEXCOORD5; |
|||
float3 WorldSpaceViewDirection : TEXCOORD6; |
|||
float3 WorldSpacePosition : TEXCOORD7; |
|||
half4 uv1 : TEXCOORD8; |
|||
|
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
GraphVertexOutput vert (GraphVertexInput v) |
|||
{ |
|||
v = PopulateVertexData(v); |
|||
|
|||
GraphVertexOutput o = (GraphVertexOutput)0; |
|||
|
|||
UNITY_SETUP_INSTANCE_ID(v); |
|||
UNITY_TRANSFER_INSTANCE_ID(v, o); |
|||
|
|||
o.WorldSpaceNormal = mul(v.normal,(float3x3)UNITY_MATRIX_I_M); |
|||
o.WorldSpaceTangent = mul((float3x3)UNITY_MATRIX_M,v.tangent); |
|||
o.WorldSpaceBiTangent = normalize(cross(o.WorldSpaceNormal, o.WorldSpaceTangent.xyz) * v.tangent.w); |
|||
o.WorldSpaceViewDirection = SafeNormalize(_WorldSpaceCameraPos.xyz - mul(GetObjectToWorldMatrix(), float4(v.vertex.xyz, 1.0)).xyz); |
|||
o.WorldSpacePosition = mul(UNITY_MATRIX_M,v.vertex); |
|||
o.uv1 = v.texcoord1; |
|||
|
|||
|
|||
float3 lwWNormal = TransformObjectToWorldNormal(v.normal); |
|||
float3 lwWorldPos = TransformObjectToWorld(v.vertex.xyz); |
|||
float4 clipPos = TransformWorldToHClip(lwWorldPos); |
|||
|
|||
// We either sample GI from lightmap or SH. |
|||
// Lightmap UV and vertex SH coefficients use the same interpolator ("float2 lightmapUV" for lightmap or "half3 vertexSH" for SH) |
|||
// see DECLARE_LIGHTMAP_OR_SH macro. |
|||
// The following funcions initialize the correct variable with correct data |
|||
OUTPUT_LIGHTMAP_UV(v.texcoord1, unity_LightmapST, o.lightmapUV); |
|||
OUTPUT_SH(lwWNormal, o.vertexSH); |
|||
|
|||
half3 vertexLight = VertexLighting(lwWorldPos, lwWNormal); |
|||
half fogFactor = ComputeFogFactor(clipPos.z); |
|||
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight); |
|||
o.clipPos = clipPos; |
|||
|
|||
#ifdef _SHADOWS_ENABLED |
|||
#if SHADOWS_SCREEN |
|||
o.shadowCoord = ComputeShadowCoord(o.clipPos); |
|||
#else |
|||
o.shadowCoord = TransformWorldToShadowCoord(posWS); |
|||
#endif |
|||
#endif |
|||
return o; |
|||
} |
|||
|
|||
half4 frag (GraphVertexOutput IN) : SV_Target |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(IN); |
|||
|
|||
float3 WorldSpaceNormal = normalize(IN.WorldSpaceNormal); |
|||
float3 WorldSpaceTangent = IN.WorldSpaceTangent; |
|||
float3 WorldSpaceBiTangent = IN.WorldSpaceBiTangent; |
|||
float3 WorldSpaceViewDirection = normalize(IN.WorldSpaceViewDirection); |
|||
float3 WorldSpacePosition = IN.WorldSpacePosition; |
|||
float3x3 tangentSpaceTransform = float3x3(WorldSpaceTangent,WorldSpaceBiTangent,WorldSpaceNormal); |
|||
float3 ObjectSpaceNormal = mul(WorldSpaceNormal,(float3x3)UNITY_MATRIX_M); |
|||
float3 TangentSpaceNormal = mul(WorldSpaceNormal,(float3x3)tangentSpaceTransform); |
|||
float3 ObjectSpaceTangent = mul((float3x3)UNITY_MATRIX_I_M,WorldSpaceTangent); |
|||
float3 ObjectSpaceBiTangent = mul((float3x3)UNITY_MATRIX_I_M,WorldSpaceBiTangent); |
|||
float4 uv1 = IN.uv1; |
|||
|
|||
|
|||
SurfaceInputs surfaceInput = (SurfaceInputs)0; |
|||
surfaceInput.ObjectSpaceNormal = ObjectSpaceNormal; |
|||
surfaceInput.TangentSpaceNormal = TangentSpaceNormal; |
|||
surfaceInput.ObjectSpaceTangent = ObjectSpaceTangent; |
|||
surfaceInput.ObjectSpaceBiTangent = ObjectSpaceBiTangent; |
|||
surfaceInput.WorldSpacePosition = WorldSpacePosition; |
|||
|
|||
|
|||
SurfaceDescription surf = PopulateSurfaceData(surfaceInput); |
|||
|
|||
float3 Albedo = float3(0.5, 0.5, 0.5); |
|||
float3 Specular = float3(0, 0, 0); |
|||
float Metallic = 1; |
|||
float3 Normal = float3(0, 0, 1); |
|||
float3 Emission = 0; |
|||
float Smoothness = 0.5; |
|||
float Occlusion = 1; |
|||
float Alpha = 1; |
|||
float AlphaClipThreshold = 0; |
|||
|
|||
Albedo = surf.Albedo; |
|||
Normal = surf.Normal; |
|||
Emission = surf.Emission; |
|||
Metallic = surf.Metallic; |
|||
Smoothness = surf.Smoothness; |
|||
Occlusion = surf.Occlusion; |
|||
Alpha = surf.Alpha; |
|||
AlphaClipThreshold = surf.AlphaClipThreshold; |
|||
|
|||
|
|||
InputData inputData; |
|||
inputData.positionWS = WorldSpacePosition; |
|||
|
|||
#ifdef _NORMALMAP |
|||
inputData.normalWS = TangentToWorldNormal(Normal, WorldSpaceTangent, WorldSpaceBiTangent, WorldSpaceNormal); |
|||
#else |
|||
#if !SHADER_HINT_NICE_QUALITY |
|||
inputData.normalWS = WorldSpaceNormal; |
|||
#else |
|||
inputData.normalWS = normalize(WorldSpaceNormal); |
|||
#endif |
|||
#endif |
|||
|
|||
#if !SHADER_HINT_NICE_QUALITY |
|||
// viewDirection should be normalized here, but we avoid doing it as it's close enough and we save some ALU. |
|||
inputData.viewDirectionWS = WorldSpaceViewDirection; |
|||
#else |
|||
inputData.viewDirectionWS = normalize(WorldSpaceViewDirection); |
|||
#endif |
|||
|
|||
#ifdef _SHADOWS_ENABLED |
|||
inputData.shadowCoord = IN.shadowCoord; |
|||
#else |
|||
inputData.shadowCoord = float4(0, 0, 0, 0); |
|||
#endif |
|||
|
|||
inputData.fogCoord = IN.fogFactorAndVertexLight.x; |
|||
inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw; |
|||
inputData.bakedGI = SAMPLE_GI(IN.lightmapUV, IN.vertexSH, inputData.normalWS); |
|||
|
|||
half4 color = LightweightFragmentPBR( |
|||
inputData, |
|||
Albedo, |
|||
Metallic, |
|||
Specular, |
|||
Smoothness, |
|||
Occlusion, |
|||
Emission, |
|||
Alpha); |
|||
|
|||
// Computes fog factor per-vertex |
|||
ApplyFog(color.rgb, IN.fogFactorAndVertexLight.x); |
|||
|
|||
#if _AlphaClip |
|||
clip(Alpha - AlphaClipThreshold); |
|||
#endif |
|||
return color; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "ShadowCaster"} |
|||
|
|||
ZWrite On |
|||
ZTest LEqual |
|||
Cull Back |
|||
|
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#pragma vertex ShadowPassVertex |
|||
#pragma fragment ShadowPassFragment |
|||
|
|||
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl" |
|||
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "DepthOnly"} |
|||
|
|||
ZWrite On |
|||
Cull Back |
|||
|
|||
ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
#pragma vertex DepthOnlyVertex |
|||
#pragma fragment DepthOnlyFragment |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl" |
|||
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
// This pass it not used during regular rendering, only for lightmap baking. |
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "Meta"} |
|||
|
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
|
|||
#pragma shader_feature _SPECULAR_SETUP |
|||
#pragma shader_feature _EMISSION |
|||
#pragma shader_feature _METALLICSPECGLOSSMAP |
|||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature EDITOR_VISUALIZATION |
|||
|
|||
#pragma vertex LightweightVertexMeta |
|||
#pragma fragment LightweightFragmentMeta |
|||
|
|||
#pragma shader_feature _SPECGLOSSMAP |
|||
|
|||
// new |
|||
|
|||
//#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl" |
|||
#include "LWRP/ShaderLibrary/Core.hlsl" |
|||
#include "LWRP/ShaderLibrary/LightweightPassMetaCommon.hlsl" |
|||
#include "CoreRP/ShaderLibrary/Color.hlsl" |
|||
#include "CoreRP/ShaderLibrary/UnityInstancing.hlsl" |
|||
#include "ShaderGraphLibrary/Functions.hlsl" |
|||
//#include "LWRP/ShaderLibrary/LightweightPassMetaPBR.hlsl" |
|||
|
|||
TEXTURE2D(Texture_4CCF661D); SAMPLER(samplerTexture_4CCF661D); |
|||
TEXTURE2D(Texture_E3D097C6); SAMPLER(samplerTexture_E3D097C6); |
|||
TEXTURE2D(Texture_2D2A40E); SAMPLER(samplerTexture_2D2A40E); |
|||
|
|||
struct SurfaceInputs{ |
|||
float3 ObjectSpaceNormal; |
|||
float3 TangentSpaceNormal; |
|||
float3 ObjectSpaceTangent; |
|||
float3 ObjectSpaceBiTangent; |
|||
float3 WorldSpacePosition; |
|||
}; |
|||
|
|||
|
|||
void Unity_Combine_float(float R, float G, float B, float A, out float4 RGBA, out float3 RGB, out float2 RG) |
|||
{ |
|||
RGBA = float4(R, G, B, A); |
|||
RGB = float3(R, G, B); |
|||
RG = float2(R, G); |
|||
} |
|||
|
|||
struct GraphVertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float3 normal : NORMAL; |
|||
float4 tangent : TANGENT; |
|||
float4 texcoord1 : TEXCOORD1; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct SurfaceDescription{ |
|||
float3 Albedo; |
|||
float3 Normal; |
|||
float3 Emission; |
|||
float Metallic; |
|||
float Smoothness; |
|||
float Occlusion; |
|||
float Alpha; |
|||
float AlphaClipThreshold; |
|||
}; |
|||
|
|||
GraphVertexInput PopulateVertexData(GraphVertexInput v){ |
|||
return v; |
|||
} |
|||
|
|||
SurfaceDescription PopulateSurfaceData(SurfaceInputs IN) { |
|||
SurfaceDescription surface = (SurfaceDescription)0; |
|||
float _Split_67AEB824_R = IN.WorldSpacePosition[0]; |
|||
float _Split_67AEB824_G = IN.WorldSpacePosition[1]; |
|||
float _Split_67AEB824_B = IN.WorldSpacePosition[2]; |
|||
float _Split_67AEB824_A = 0; |
|||
float4 _Combine_77E891A3_RGBA; |
|||
float3 _Combine_77E891A3_RGB; |
|||
float2 _Combine_77E891A3_RG; |
|||
Unity_Combine_float(_Split_67AEB824_R, _Split_67AEB824_B, 0, 0, _Combine_77E891A3_RGBA, _Combine_77E891A3_RGB, _Combine_77E891A3_RG); |
|||
float4 _SampleTexture2D_DC0075E6_RGBA = SAMPLE_TEXTURE2D(Texture_E3D097C6, samplerTexture_E3D097C6, _Combine_77E891A3_RG); |
|||
float _SampleTexture2D_DC0075E6_R = _SampleTexture2D_DC0075E6_RGBA.r; |
|||
float _SampleTexture2D_DC0075E6_G = _SampleTexture2D_DC0075E6_RGBA.g; |
|||
float _SampleTexture2D_DC0075E6_B = _SampleTexture2D_DC0075E6_RGBA.b; |
|||
float _SampleTexture2D_DC0075E6_A = _SampleTexture2D_DC0075E6_RGBA.a; |
|||
surface.Albedo = (_SampleTexture2D_DC0075E6_RGBA.xyz); |
|||
surface.Normal = IN.TangentSpaceNormal; |
|||
surface.Emission = IsGammaSpace() ? float3(0, 0, 0) : SRGBToLinear(float3(0, 0, 0)); |
|||
surface.Metallic = 0; |
|||
surface.Smoothness = 0.5; |
|||
surface.Occlusion = 1; |
|||
surface.Alpha = 1; |
|||
surface.AlphaClipThreshold = 0; |
|||
return surface; |
|||
} |
|||
|
|||
// new |
|||
|
|||
half4 LightweightFragmentMeta(MetaVertexOuput IN) : SV_Target |
|||
{ |
|||
float4 uv0 = float4(IN.uv, 0, 0); |
|||
|
|||
SurfaceInputs surfaceInput = (SurfaceInputs)0; |
|||
surfaceInput.ObjectSpaceNormal = ObjectSpaceNormal; |
|||
surfaceInput.TangentSpaceNormal = TangentSpaceNormal; |
|||
surfaceInput.ObjectSpaceTangent = ObjectSpaceTangent; |
|||
surfaceInput.ObjectSpaceBiTangent = ObjectSpaceBiTangent; |
|||
surfaceInput.WorldSpacePosition = WorldSpacePosition; |
|||
|
|||
|
|||
SurfaceDescription surf = PopulateSurfaceData(surfaceInput); |
|||
|
|||
float3 Albedo = float3(0.5, 0.5, 0.5); |
|||
float3 Specular = float3(0, 0, 0); |
|||
float Metallic = 1; |
|||
float3 Normal = float3(0, 0, 1); |
|||
float3 Emission = 0; |
|||
float Smoothness = 0.5; |
|||
float Occlusion = 1; |
|||
float Alpha = 1; |
|||
float AlphaClipThreshold = 0; |
|||
|
|||
Albedo = surf.Albedo; |
|||
Normal = surf.Normal; |
|||
Emission = surf.Emission; |
|||
Metallic = surf.Metallic; |
|||
Smoothness = surf.Smoothness; |
|||
Occlusion = surf.Occlusion; |
|||
Alpha = surf.Alpha; |
|||
AlphaClipThreshold = surf.AlphaClipThreshold; |
|||
|
|||
|
|||
MetaInput o; |
|||
o.Albedo = surf.Albedo; |
|||
o.SpecularColor = 0; |
|||
o.Emission = surf.Emission; |
|||
|
|||
return MetaFragment(o); |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
} |
|||
|
|||
FallBack "Hidden/InternalErrorShader" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 241213a2f4dea44e59579a119fdad932 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "BoatAttack/LWSoftVegetationShader" |
|||
{ |
|||
Properties |
|||
{ |
|||
// Specular vs Metallic workflow |
|||
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0 |
|||
|
|||
_Color("Color", Color) = (1,1,1,1) |
|||
_MainTex("Albedo", 2D) = "white" {} |
|||
|
|||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 |
|||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0 |
|||
_SmoothnessTextureChannel("Smoothness texture channel", Float) = 0 |
|||
|
|||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0 |
|||
_MetallicGlossMap("Metallic", 2D) = "white" {} |
|||
|
|||
_SpecColor("Specular", Color) = (0.2, 0.2, 0.2) |
|||
_SpecGlossMap("Specular", 2D) = "white" {} |
|||
|
|||
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 |
|||
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0 |
|||
|
|||
_BumpScale("Scale", Float) = 1.0 |
|||
_BumpMap("Normal Map", 2D) = "bump" {} |
|||
|
|||
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 |
|||
_OcclusionMap("Occlusion", 2D) = "white" {} |
|||
|
|||
_EmissionColor("Color", Color) = (0,0,0) |
|||
_EmissionMap("Emission", 2D) = "white" {} |
|||
|
|||
// Blending state |
|||
[HideInInspector] _Mode("__mode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite("__zw", Float) = 1.0 |
|||
} |
|||
|
|||
SubShader |
|||
{ |
|||
// Lightweight Pipeline tag is required. If Lightweight pipeline is not set in the graphics settings |
|||
// this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this |
|||
// material work with both Lightweight Pipeline and Builtin Unity Pipeline |
|||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "LightweightPipeline"} |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Base forward pass (directional light, emission, lightmaps, ...) |
|||
Pass |
|||
{ |
|||
// Lightmode matches the ShaderPassName set in LightweightPipeline.cs. SRPDefaultUnlit and passes with |
|||
// no LightMode tag are also rendered by Lightweight Pipeline |
|||
Tags{"LightMode" = "LightweightForward"} |
|||
|
|||
Blend[_SrcBlend][_DstBlend] |
|||
ZWrite[_ZWrite] |
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard SRP library |
|||
// All shaders must be compiled with HLSLcc and currently only gles is not using HLSLcc by default |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 3.0 |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON |
|||
#pragma shader_feature _EMISSION |
|||
#pragma shader_feature _METALLICSPECGLOSSMAP |
|||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#define _OCCLUSIONMAP |
|||
|
|||
#pragma shader_feature _SPECULARHIGHLIGHTS_OFF |
|||
#pragma shader_feature _GLOSSYREFLECTIONS_OFF |
|||
#pragma shader_feature _SPECULAR_SETUP |
|||
|
|||
// ------------------------------------- |
|||
// Lightweight Pipeline keywords |
|||
#pragma multi_compile _ _ADDITIONAL_LIGHTS |
|||
#pragma multi_compile _ _VERTEX_LIGHTS |
|||
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE |
|||
#pragma multi_compile _ FOG_LINEAR FOG_EXP2 |
|||
|
|||
// ------------------------------------- |
|||
// Unity defined keywords |
|||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile _ LIGHTMAP_ON |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
// LW doesn't support dynamic GI. So we save 30% shader variants if we assume |
|||
// LIGHTMAP_ON when DIRLIGHTMAP_COMBINED is set |
|||
#ifdef DIRLIGHTMAP_COMBINED |
|||
#define LIGHTMAP_ON |
|||
#endif |
|||
|
|||
// Including the following two function is enought for shading with Lightweight Pipeline. Everything is included in them. |
|||
// Core.hlsl will include SRP shader library, all constant buffers not related to materials (perobject, percamera, perframe). |
|||
// It also includes matrix/space conversion functions and fog. |
|||
// Lighting.hlsl will include the light functions/data to abstract light constants. You should use GetMainLight and GetLight functions |
|||
// that initialize Light struct. Lighting.hlsl also include GI, Light BDRF functions. It also includes Shadows. |
|||
#include "LWRP/ShaderLibrary/Core.hlsl" |
|||
#include "LWRP/ShaderLibrary/Lighting.hlsl" |
|||
|
|||
#pragma vertex VegetationVertex |
|||
#pragma fragment LitPassFragment |
|||
|
|||
float4 SmoothCurve( float4 x ) { |
|||
return x * x *( 3.0 - 2.0 * x ); |
|||
} |
|||
|
|||
float4 TriangleWave( float4 x ) { |
|||
return abs( frac( x + 0.5 ) * 2.0 - 1.0 ); |
|||
} |
|||
|
|||
float4 SmoothTriangleWave( float4 x ) { |
|||
return SmoothCurve( TriangleWave( x ) ); |
|||
} |
|||
|
|||
struct LightweightVertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float3 normal : NORMAL; |
|||
float4 tangent : TANGENT; |
|||
float2 texcoord : TEXCOORD0; |
|||
float2 lightmapUV : TEXCOORD1; |
|||
float4 color : COLOR; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct VegetationVertexOutput |
|||
{ |
|||
float3 uv : TEXCOORD0;//z holds vert AO |
|||
float4 lightmapUVOrVertexSH : TEXCOORD1; // holds either lightmapUV or vertex SH. depending on LIGHTMAP_ON |
|||
float3 positionWS : TEXCOORD2; |
|||
half3 normal : TEXCOORD3; |
|||
|
|||
#if _NORMALMAP |
|||
half3 tangent : TEXCOORD4; |
|||
half3 binormal : TEXCOORD5; |
|||
#endif |
|||
|
|||
half3 viewDir : TEXCOORD6; |
|||
half4 fogFactorAndVertexLight : TEXCOORD7; // x: fogFactor, yzw: vertex light |
|||
|
|||
float4 clipPos : SV_POSITION; |
|||
half occlusion : TEXCOORD8; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
// Not required but included here for simplicity. This defines all material related constants for the Standard surface shader like _Color, _MainTex, and so on. |
|||
// These are specific to this shader. You should define your own constants. |
|||
#include "LWRP/ShaderLibrary/InputSurface.hlsl" |
|||
|
|||
UNITY_INSTANCING_BUFFER_START(Props) |
|||
UNITY_DEFINE_INSTANCED_PROP(half4, _Position) |
|||
UNITY_INSTANCING_BUFFER_END(Props) |
|||
|
|||
//vert |
|||
VegetationVertexOutput VegetationVertex(LightweightVertexInput v) |
|||
{ |
|||
VegetationVertexOutput o = (VegetationVertexOutput)0; |
|||
|
|||
UNITY_SETUP_INSTANCE_ID(v); |
|||
UNITY_TRANSFER_INSTANCE_ID(v, o); |
|||
// Pretty much same as builtin Unity shader library. |
|||
o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); |
|||
|
|||
// SRP shader library adds some functions to convert between spaces. |
|||
// TransformObjectToHClip and some other functions are defined. |
|||
o.positionWS = TransformObjectToWorld(v.vertex.xyz); |
|||
o.clipPos = TransformWorldToHClip(o.positionWS); |
|||
|
|||
/////////////////////////////////////vegetation stuff////////////////////////////////////////////////// |
|||
//half phaseOffset = UNITY_ACCESS_INSTANCED_PROP(Props, _PhaseOffset); |
|||
float4 objectOrigin = UNITY_ACCESS_INSTANCED_PROP(Props, _Position); |
|||
|
|||
///////Main Bending |
|||
float fBendScale = 0.05;//main bend opacity |
|||
float fLength = length(v.vertex.xyz);//distance to origin |
|||
float2 vWind = float2(sin(_Time.y + objectOrigin.x) * 0.1, sin(_Time.y + objectOrigin.z) * 0.1);//wind direction |
|||
|
|||
// Bend factor - Wind variation is done on the CPU. |
|||
float fBF = v.vertex.y * fBendScale; |
|||
// Smooth bending factor and increase its nearby height limit. |
|||
fBF += 1.0; |
|||
fBF *= fBF; |
|||
fBF = fBF * fBF - fBF; |
|||
// Displace position |
|||
float3 vNewPos = v.vertex.xyz; |
|||
vNewPos.xz += vWind.xy * fBF; |
|||
// Rescale |
|||
v.vertex.xyz = normalize(vNewPos.xyz) * fLength; |
|||
|
|||
////////Detail blending |
|||
float fSpeed = 0.25;//leaf occil |
|||
float fDetailFreq = 0.3;//detail leaf occil |
|||
float fEdgeAtten = v.color.x;//leaf stiffness(red) |
|||
float fDetailAmp = 0.1;//leaf edge amplitude of movement |
|||
float fBranchAtten = 1 - v.color.z;//branch stiffness(blue) |
|||
float fBranchAmp = 1.5;//branch amplitude of movement |
|||
float fBranchPhase = v.color.y * 3.3;//leaf phase(green) |
|||
|
|||
// Phases (object, vertex, branch) |
|||
float fObjPhase = dot(objectOrigin.xyz, 1); |
|||
fBranchPhase += fObjPhase; |
|||
float fVtxPhase = dot(v.vertex.xyz, v.color.y + fBranchPhase); |
|||
// x is used for edges; y is used for branches |
|||
float2 vWavesIn = _Time.y + float2(fVtxPhase, fBranchPhase ); |
|||
// 1.975, 0.793, 0.375, 0.193 are good frequencies |
|||
float4 vWaves = (frac( vWavesIn.xxyy * float4(1.975, 0.793, 0.375, 0.193) ) * 2.0 - 1.0 ) * fSpeed * fDetailFreq; |
|||
vWaves = SmoothTriangleWave( vWaves ); |
|||
float2 vWavesSum = vWaves.xz + vWaves.yw; |
|||
// Edge (xy) and branch bending (z) |
|||
v.vertex.xyz += vWavesSum.xyx * float3(fEdgeAtten * fDetailAmp * v.normal.x, fBranchAtten * fBranchAmp, fEdgeAtten * fDetailAmp * v.normal.z); |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
o.positionWS = TransformObjectToWorld(v.vertex.xyz); |
|||
o.clipPos = TransformWorldToHClip(o.positionWS); |
|||
o.viewDir = SafeNormalize(_WorldSpaceCameraPos - o.positionWS); |
|||
|
|||
// initializes o.normal and if _NORMALMAP also o.tangent and o.binormal |
|||
#ifdef _NORMALMAP |
|||
OutputTangentToWorld(v.tangent, v.normal, o.tangent, o.binormal, o.normal); |
|||
#else |
|||
o.normal = TransformObjectToWorldNormal(v.normal); |
|||
#endif |
|||
|
|||
// We either sample GI from lightmap or SH. lightmap UV and vertex SH coefficients |
|||
// are packed in lightmapUVOrVertexSH to save interpolator. |
|||
// The following funcions initialize |
|||
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUVOrVertexSH); |
|||
OUTPUT_SH(o.normal, o.lightmapUVOrVertexSH); |
|||
|
|||
half3 vertexLight = VertexLighting(o.positionWS, o.normal); |
|||
half fogFactor = ComputeFogFactor(o.clipPos.z); |
|||
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight); |
|||
|
|||
o.occlusion = v.color.a; |
|||
|
|||
return o; |
|||
} |
|||
|
|||
//frag |
|||
half4 LitPassFragment(VegetationVertexOutput IN, half facing : VFACE) : SV_Target |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(IN); |
|||
SurfaceData surfaceData; |
|||
InitializeStandardLitSurfaceData(IN.uv.xy, surfaceData); |
|||
|
|||
#if _NORMALMAP |
|||
half3 normalWS = TangentToWorldNormal(surfaceData.normalTS, IN.tangent, IN.binormal, IN.normal); |
|||
#else |
|||
half3 normalWS = normalize(IN.normal); |
|||
#endif |
|||
|
|||
half3 bakedGI = SampleSH(normalWS); |
|||
|
|||
surfaceData.albedo *= IN.occlusion; |
|||
|
|||
BRDFData brdfData; |
|||
InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData); |
|||
|
|||
Light mainLight = GetMainLight(IN.positionWS); |
|||
|
|||
half3 color = GlobalIllumination(brdfData, bakedGI, surfaceData.occlusion, normalWS, IN.viewDir); |
|||
|
|||
float fogFactor = IN.fogFactorAndVertexLight.x; |
|||
|
|||
color += LightingPhysicallyBased(brdfData, mainLight, normalWS, IN.viewDir); |
|||
|
|||
// Computes fog factor per-vertex |
|||
ApplyFog(color.rgb, fogFactor); |
|||
return half4(color, surfaceData.alpha); |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "ShadowCaster"} |
|||
|
|||
ZWrite On |
|||
ZTest LEqual |
|||
Cull[_Cull] |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature _ALPHATEST_ON |
|||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#pragma vertex ShadowPassVertex |
|||
#pragma fragment ShadowPassFragment |
|||
|
|||
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "DepthOnly"} |
|||
|
|||
ZWrite On |
|||
ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
#pragma vertex DepthOnlyVertex |
|||
#pragma fragment DepthOnlyFragment |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature _ALPHATEST_ON |
|||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
// This pass it not used during regular rendering, only for lightmap baking. |
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "Meta"} |
|||
|
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
|
|||
#pragma vertex LightweightVertexMeta |
|||
#pragma fragment LightweightFragmentMeta |
|||
|
|||
#pragma shader_feature _SPECULAR_SETUP |
|||
#pragma shader_feature _EMISSION |
|||
#pragma shader_feature _METALLICSPECGLOSSMAP |
|||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature EDITOR_VISUALIZATION |
|||
|
|||
#pragma shader_feature _SPECGLOSSMAP |
|||
|
|||
#include "LWRP/ShaderLibrary/LightweightPassMeta.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
} |
|||
FallBack "Hidden/InternalErrorShader" |
|||
} |
|
|||
Shader "PBR Master" |
|||
{ |
|||
Properties |
|||
{ |
|||
[NoScaleOffset] Texture_AE91C5C2("Albedo_Roughness", 2D) = "white" {} |
|||
[NoScaleOffset] Texture_DE8BF47E("Normal_AO", 2D) = "white" {} |
|||
|
|||
} |
|||
SubShader |
|||
{ |
|||
Tags{ "RenderPipeline" = "LightweightPipeline"} |
|||
Tags |
|||
{ |
|||
"RenderType"="Opaque" |
|||
"Queue"="Geometry" |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "LightweightForward"} |
|||
|
|||
Blend One Zero |
|||
|
|||
Cull Back |
|||
|
|||
ZTest LEqual |
|||
|
|||
ZWrite On |
|||
|
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
// ------------------------------------- |
|||
// Lightweight Pipeline keywords |
|||
#pragma multi_compile _ _ADDITIONAL_LIGHTS |
|||
#pragma multi_compile _ _VERTEX_LIGHTS |
|||
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE |
|||
#pragma multi_compile _ FOG_LINEAR FOG_EXP2 |
|||
|
|||
// ------------------------------------- |
|||
// Unity defined keywords |
|||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile _ LIGHTMAP_ON |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#define _NORMALMAP 1 |
|||
|
|||
|
|||
#include "LWRP/ShaderLibrary/Core.hlsl" |
|||
#include "LWRP/ShaderLibrary/Lighting.hlsl" |
|||
#include "CoreRP/ShaderLibrary/Color.hlsl" |
|||
#include "CoreRP/ShaderLibrary/UnityInstancing.hlsl" |
|||
#include "ShaderGraphLibrary/Functions.hlsl" |
|||
|
|||
TEXTURE2D(Texture_AE91C5C2); SAMPLER(samplerTexture_AE91C5C2); |
|||
TEXTURE2D(Texture_DE8BF47E); SAMPLER(samplerTexture_DE8BF47E); |
|||
|
|||
struct SurfaceInputs{ |
|||
half4 uv0; |
|||
}; |
|||
|
|||
|
|||
void Unity_Subtract_float4(float4 A, float4 B, out float4 Out) |
|||
{ |
|||
Out = A - B; |
|||
} |
|||
|
|||
void Unity_Multiply_float (float4 A, float4 B, out float4 Out) |
|||
{ |
|||
Out = A * B; |
|||
} |
|||
|
|||
struct GraphVertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float3 normal : NORMAL; |
|||
float4 tangent : TANGENT; |
|||
float4 texcoord0 : TEXCOORD0; |
|||
float4 texcoord1 : TEXCOORD1; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct SurfaceDescription{ |
|||
float3 Albedo; |
|||
float3 Normal; |
|||
float3 Emission; |
|||
float Metallic; |
|||
float Smoothness; |
|||
float Occlusion; |
|||
float Alpha; |
|||
float AlphaClipThreshold; |
|||
}; |
|||
|
|||
GraphVertexInput PopulateVertexData(GraphVertexInput v){ |
|||
return v; |
|||
} |
|||
|
|||
SurfaceDescription PopulateSurfaceData(SurfaceInputs IN) { |
|||
SurfaceDescription surface = (SurfaceDescription)0; |
|||
float4 _SampleTexture2D_903562CE_RGBA = SAMPLE_TEXTURE2D(Texture_AE91C5C2, samplerTexture_AE91C5C2, IN.uv0.xy); |
|||
float _SampleTexture2D_903562CE_R = _SampleTexture2D_903562CE_RGBA.r; |
|||
float _SampleTexture2D_903562CE_G = _SampleTexture2D_903562CE_RGBA.g; |
|||
float _SampleTexture2D_903562CE_B = _SampleTexture2D_903562CE_RGBA.b; |
|||
float _SampleTexture2D_903562CE_A = _SampleTexture2D_903562CE_RGBA.a; |
|||
float4 _SampleTexture2D_D53F4AE6_RGBA = SAMPLE_TEXTURE2D(Texture_DE8BF47E, samplerTexture_DE8BF47E, IN.uv0.xy); |
|||
float _SampleTexture2D_D53F4AE6_R = _SampleTexture2D_D53F4AE6_RGBA.r; |
|||
float _SampleTexture2D_D53F4AE6_G = _SampleTexture2D_D53F4AE6_RGBA.g; |
|||
float _SampleTexture2D_D53F4AE6_B = _SampleTexture2D_D53F4AE6_RGBA.b; |
|||
float _SampleTexture2D_D53F4AE6_A = _SampleTexture2D_D53F4AE6_RGBA.a; |
|||
float4 _Subtract_2BA4AC9D_Out; |
|||
Unity_Subtract_float4(_SampleTexture2D_D53F4AE6_RGBA, float4(0.5, 0.5, 0.5, 0.5), _Subtract_2BA4AC9D_Out); |
|||
float4 _Multiply_2407F12D_Out; |
|||
Unity_Multiply_float(_Subtract_2BA4AC9D_Out, float4(2, 2, 2, 0), _Multiply_2407F12D_Out); |
|||
|
|||
surface.Albedo = (_SampleTexture2D_903562CE_RGBA.xyz); |
|||
surface.Normal = (_Multiply_2407F12D_Out.xyz); |
|||
surface.Emission = IsGammaSpace() ? float3(0, 0, 0) : SRGBToLinear(float3(0, 0, 0)); |
|||
surface.Metallic = 0; |
|||
surface.Smoothness = _SampleTexture2D_903562CE_A; |
|||
surface.Occlusion = _SampleTexture2D_D53F4AE6_A; |
|||
surface.Alpha = 1; |
|||
surface.AlphaClipThreshold = 0; |
|||
return surface; |
|||
} |
|||
|
|||
|
|||
|
|||
struct GraphVertexOutput |
|||
{ |
|||
float4 clipPos : SV_POSITION; |
|||
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 0); |
|||
half4 fogFactorAndVertexLight : TEXCOORD1; // x: fogFactor, yzw: vertex light |
|||
float4 shadowCoord : TEXCOORD2; |
|||
float3 WorldSpaceNormal : TEXCOORD3; |
|||
float3 WorldSpaceTangent : TEXCOORD4; |
|||
float3 WorldSpaceBiTangent : TEXCOORD5; |
|||
float3 WorldSpaceViewDirection : TEXCOORD6; |
|||
float3 WorldSpacePosition : TEXCOORD7; |
|||
half4 uv0 : TEXCOORD8; |
|||
half4 uv1 : TEXCOORD9; |
|||
|
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
GraphVertexOutput vert (GraphVertexInput v) |
|||
{ |
|||
v = PopulateVertexData(v); |
|||
|
|||
GraphVertexOutput o = (GraphVertexOutput)0; |
|||
|
|||
UNITY_SETUP_INSTANCE_ID(v); |
|||
UNITY_TRANSFER_INSTANCE_ID(v, o); |
|||
|
|||
o.WorldSpaceNormal = mul(v.normal,(float3x3)UNITY_MATRIX_I_M); |
|||
o.WorldSpaceTangent = mul((float3x3)UNITY_MATRIX_M,v.tangent); |
|||
o.WorldSpaceBiTangent = normalize(cross(o.WorldSpaceNormal, o.WorldSpaceTangent.xyz) * v.tangent.w); |
|||
o.WorldSpaceViewDirection = SafeNormalize(_WorldSpaceCameraPos.xyz - mul(GetObjectToWorldMatrix(), float4(v.vertex.xyz, 1.0)).xyz); |
|||
o.WorldSpacePosition = mul(UNITY_MATRIX_M,v.vertex); |
|||
o.uv0 = v.texcoord0; |
|||
o.uv1 = v.texcoord1; |
|||
|
|||
|
|||
float3 lwWNormal = TransformObjectToWorldNormal(v.normal); |
|||
float3 lwWorldPos = TransformObjectToWorld(v.vertex.xyz); |
|||
float4 clipPos = TransformWorldToHClip(lwWorldPos); |
|||
|
|||
// We either sample GI from lightmap or SH. |
|||
// Lightmap UV and vertex SH coefficients use the same interpolator ("float2 lightmapUV" for lightmap or "half3 vertexSH" for SH) |
|||
// see DECLARE_LIGHTMAP_OR_SH macro. |
|||
// The following funcions initialize the correct variable with correct data |
|||
OUTPUT_LIGHTMAP_UV(v.texcoord1, unity_LightmapST, o.lightmapUV); |
|||
OUTPUT_SH(lwWNormal, o.vertexSH); |
|||
|
|||
half3 vertexLight = VertexLighting(lwWorldPos, lwWNormal); |
|||
half fogFactor = ComputeFogFactor(clipPos.z); |
|||
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight); |
|||
o.clipPos = clipPos; |
|||
|
|||
o.shadowCoord = ComputeShadowCoord(o.clipPos); |
|||
return o; |
|||
} |
|||
|
|||
half4 frag (GraphVertexOutput IN) : SV_Target |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(IN); |
|||
|
|||
float3 WorldSpaceNormal = normalize(IN.WorldSpaceNormal); |
|||
float3 WorldSpaceTangent = IN.WorldSpaceTangent; |
|||
float3 WorldSpaceBiTangent = IN.WorldSpaceBiTangent; |
|||
float3 WorldSpaceViewDirection = normalize(IN.WorldSpaceViewDirection); |
|||
float3 WorldSpacePosition = IN.WorldSpacePosition; |
|||
float4 uv0 = IN.uv0; |
|||
float4 uv1 = IN.uv1; |
|||
|
|||
|
|||
SurfaceInputs surfaceInput = (SurfaceInputs)0; |
|||
surfaceInput.uv0 = uv0; |
|||
|
|||
|
|||
SurfaceDescription surf = PopulateSurfaceData(surfaceInput); |
|||
|
|||
float3 Albedo = float3(0.5, 0.5, 0.5); |
|||
float3 Specular = float3(0, 0, 0); |
|||
float Metallic = 1; |
|||
float3 Normal = float3(0, 0, 1); |
|||
float3 Emission = 0; |
|||
float Smoothness = 0.5; |
|||
float Occlusion = 1; |
|||
float Alpha = 1; |
|||
float AlphaClipThreshold = 0; |
|||
|
|||
Albedo = surf.Albedo; |
|||
Normal = surf.Normal; |
|||
Emission = surf.Emission; |
|||
Metallic = surf.Metallic; |
|||
Smoothness = surf.Smoothness; |
|||
Occlusion = surf.Occlusion; |
|||
Alpha = surf.Alpha; |
|||
AlphaClipThreshold = surf.AlphaClipThreshold; |
|||
|
|||
|
|||
InputData inputData; |
|||
inputData.positionWS = WorldSpacePosition; |
|||
|
|||
#ifdef _NORMALMAP |
|||
inputData.normalWS = TangentToWorldNormal(Normal, WorldSpaceTangent, WorldSpaceBiTangent, WorldSpaceNormal); |
|||
#else |
|||
#if !SHADER_HINT_NICE_QUALITY |
|||
inputData.normalWS = WorldSpaceNormal; |
|||
#else |
|||
inputData.normalWS = normalize(WorldSpaceNormal); |
|||
#endif |
|||
#endif |
|||
|
|||
#if !SHADER_HINT_NICE_QUALITY |
|||
// viewDirection should be normalized here, but we avoid doing it as it's close enough and we save some ALU. |
|||
inputData.viewDirectionWS = WorldSpaceViewDirection; |
|||
#else |
|||
inputData.viewDirectionWS = normalize(WorldSpaceViewDirection); |
|||
#endif |
|||
|
|||
inputData.shadowCoord = IN.shadowCoord; |
|||
|
|||
inputData.fogCoord = IN.fogFactorAndVertexLight.x; |
|||
inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw; |
|||
inputData.bakedGI = SAMPLE_GI(IN.lightmapUV, IN.vertexSH, inputData.normalWS); |
|||
|
|||
half4 color = LightweightFragmentPBR( |
|||
inputData, |
|||
Albedo, |
|||
Metallic, |
|||
Specular, |
|||
Smoothness, |
|||
Occlusion, |
|||
Emission, |
|||
Alpha); |
|||
|
|||
// Computes fog factor per-vertex |
|||
ApplyFog(color.rgb, IN.fogFactorAndVertexLight.x); |
|||
|
|||
#if _AlphaClip |
|||
clip(Alpha - AlphaClipThreshold); |
|||
#endif |
|||
return color; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "ShadowCaster"} |
|||
|
|||
ZWrite On |
|||
ZTest LEqual |
|||
Cull Back |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#pragma vertex ShadowPassVertex |
|||
#pragma fragment ShadowPassFragment |
|||
|
|||
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl" |
|||
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "DepthOnly"} |
|||
|
|||
ZWrite On |
|||
ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma target 2.0 |
|||
|
|||
#pragma vertex DepthOnlyVertex |
|||
#pragma fragment DepthOnlyFragment |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl" |
|||
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
// This pass it not used during regular rendering, only for lightmap baking. |
|||
Pass |
|||
{ |
|||
Tags{"LightMode" = "Meta"} |
|||
|
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
|
|||
#pragma vertex LightweightVertexMeta |
|||
#pragma fragment LightweightFragmentMeta |
|||
|
|||
#pragma shader_feature _SPECULAR_SETUP |
|||
#pragma shader_feature _EMISSION |
|||
#pragma shader_feature _METALLICSPECGLOSSMAP |
|||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature EDITOR_VISUALIZATION |
|||
|
|||
#pragma shader_feature _SPECGLOSSMAP |
|||
|
|||
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl" |
|||
#include "LWRP/ShaderLibrary/LightweightPassMetaPBR.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
} |
|||
|
|||
FallBack "Hidden/InternalErrorShader" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7935162ae16ed4d9ca189f532a35c367 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue