浏览代码

Fixed vegetation shaders

/main
Andre McGrail 7 年前
当前提交
3e297a4c
共有 14 个文件被更改,包括 547 次插入353 次删除
  1. 2
      Assets/LightweightAsset.asset
  2. 10
      Assets/Objects/environment/Trees/Materials/Softvegetation.mat
  3. 11
      Assets/Objects/environment/Trees/Materials/Trees.mat
  4. 2
      Assets/Objects/props/props/Matr_Props.mat
  5. 3
      Assets/Shaders/CustomTerrain.ShaderGraph
  6. 33
      Assets/Shaders/LWSoftVegetationShader.shader
  7. 318
      Assets/Shaders/LWVegetationShader.shader
  8. 131
      Assets/Shaders/NewUnlitShader.shader
  9. 2
      Assets/Shaders/NewUnlitShader.shader.meta
  10. 3
      Assets/Shaders/PackedPBR.ShaderGraph
  11. 275
      Assets/scenes/Island.unity
  12. 2
      ProjectSettings/ProjectSettings.asset
  13. 99
      Assets/Shaders/Vegetation.hlsl
  14. 9
      Assets/Shaders/Vegetation.hlsl.meta

2
Assets/LightweightAsset.asset


m_SupportsVertexLight: 0
m_RequireDepthTexture: 0
m_RequireSoftParticles: 0
m_RequireOpaqueTexture: 1
m_OpaqueTextureScale: 1
m_SupportsHDR: 0
m_MSAA: 4
m_RenderScale: 1

10
Assets/Objects/environment/Trees/Materials/Softvegetation.mat


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Softvegetation
m_Shader: {fileID: 4800000, guid: 0151397d28b044a90b91825217a9b073, type: 3}
m_ShaderKeywords: _ALPHATEST_ON _METALLICGLOSSMAP _METALLICSPECGLOSSMAP _NORMALMAP
m_Shader: {fileID: 4800000, guid: 1adca499d9899854aa1b4011854d49fb, type: 3}
m_ShaderKeywords: _ALPHATEST_ON _CORRECTNORMALS_OFF _METALLICGLOSSMAP _METALLICSPECGLOSSMAP
_NORMALMAP
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 1

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 1
- _Blend: 0
- _CorrectNormals: 0
- _Cull: 0
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1

11
Assets/Objects/environment/Trees/Materials/Trees.mat


m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 1
m_CustomRenderQueue: 2450
stringTagMap:
RenderType: TransparentCutout
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 1
- _Blend: 0
- _CORRECT_NORMALS_OFF: 1
- _CorrectNormals: 1
- _Cull: 0
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0

- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1

2
Assets/Objects/props/props/Matr_Props.mat


m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _METALLICGLOSSMAP _METALLICSPECGLOSSMAP _NORMALMAP
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}

3
Assets/Shaders/CustomTerrain.ShaderGraph
文件差异内容过多而无法显示
查看文件

33
Assets/Shaders/LWSoftVegetationShader.shader


ENDHLSL
}
Pass
Pass
Cull[_Cull]
#pragma shader_feature _NORMALMAP
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature _GLOSSYREFLECTIONS_OFF
#pragma shader_feature _SPECULAR_SETUP
//--------------------------------------
// GPU Instancing

// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma target 2.0
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
#pragma shader_feature _NORMALMAP
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature _GLOSSYREFLECTIONS_OFF
#pragma shader_feature _SPECULAR_SETUP
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl"
ENDHLSL

318
Assets/Shaders/LWVegetationShader.shader


{
Properties
{
// Specular vs Metallic workflow
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
_Color("Color", Color) = (1,1,1,1)

[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0
[ToggleOff] _CorrectNormals("Correct Normals", Float) = 1.0
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}

_EmissionMap("Emission", 2D) = "white" {}
// Blending state
[HideInInspector] _Mode("__mode", Float) = 0.0
[HideInInspector] _Surface("__surface", Float) = 0.0
[HideInInspector] _Blend("__blend", Float) = 0.0
[HideInInspector] _AlphaClip("__clip", Float) = 0.0
[HideInInspector] _Cull("__cull", Float) = 2.0
}
SubShader

// material work with both Lightweight Pipeline and Builtin Unity Pipeline
Tags{"RenderType" = "Opaque" "RenderPipeline" = "LightweightPipeline"}
Tags{"RenderType" = "Opaque" "RenderPipeline" = "LightweightPipeline" "IgnoreProjector" = "True"}
// ------------------------------------------------------------------
// Base forward pass (directional light, emission, lightmaps, ...)

// 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
#pragma exclude_renderers d3d11_9x
#pragma target 2.0
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _ALPHAPREMULTIPLY_ON
#define _OCCLUSIONMAP
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _CORRECTNORMALS_OFF
#pragma shader_feature _SPECULAR_SETUP
// -------------------------------------

#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile _ FOG_LINEAR FOG_EXP2
#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile_fog
// 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
#include "LWRP/ShaderLibrary/Core.hlsl"
#include "LWRP/ShaderLibrary/Lighting.hlsl"
//#include "LWRP/ShaderLibrary/Core.hlsl"
// 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/InputSurfacePBR.hlsl"
#include "Vegetation.hlsl"
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 );
}
// struct VegetationVertexInput
// {
// float4 vertex : POSITION;
// float3 normal : NORMAL;
// float4 tangent : TANGENT;
// float2 texcoord : TEXCOORD0;
// float2 lightmapUV : TEXCOORD1;
// float4 color : COLOR;
// UNITY_VERTEX_INPUT_INSTANCE_ID
// };
float4 SmoothTriangleWave( float4 x ) {
return SmoothCurve( TriangleWave( x ) );
}
// 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;
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
};
// #if _NORMALMAP
// half3 tangent : TEXCOORD4;
// half3 binormal : TEXCOORD5;
// #endif
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;
// half3 viewDir : TEXCOORD6;
// half4 fogFactorAndVertexLight : TEXCOORD7; // x: fogFactor, yzw: vertex light
// float4 clipPos : SV_POSITION;
// half occlusion : TEXCOORD8;
// UNITY_VERTEX_INPUT_INSTANCE_ID
// };
#if _NORMALMAP
half3 tangent : TEXCOORD4;
half3 binormal : TEXCOORD5;
#endif
// UNITY_INSTANCING_BUFFER_START(Props)
// UNITY_DEFINE_INSTANCED_PROP(half4, _Position)
// UNITY_INSTANCING_BUFFER_END(Props)
half3 viewDir : TEXCOORD6;
half4 fogFactorAndVertexLight : TEXCOORD7; // x: fogFactor, yzw: vertex light
void InitializeInputData(VegetationVertexOutput IN, half3 normalTS, out InputData inputData)
{
inputData = (InputData)0;
float4 clipPos : SV_POSITION;
half occlusion : TEXCOORD8;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
inputData.positionWS = IN.posWS;
// 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"
#ifdef _NORMALMAP
half3 viewDir = half3(IN.normal.w, IN.tangent.w, IN.binormal.w);
inputData.normalWS = TangentToWorldNormal(normalTS, IN.tangent.xyz, IN.binormal.xyz, IN.normal.xyz);
#else
half3 viewDir = IN.viewDir;
inputData.normalWS = FragmentNormalWS(IN.normal);
#endif
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(half4, _Position)
UNITY_INSTANCING_BUFFER_END(Props)
inputData.viewDirectionWS = FragmentViewDirWS(viewDir);
#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);
}
VegetationVertexOutput VegetationVertex(LightweightVertexInput v)
VegetationVertexOutput VegetationVertex(VegetationVertexInput v)
UNITY_TRANSFER_INSTANCE_ID(v, o);
// Pretty much same as builtin Unity shader library.
o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// 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);
o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
float3 posWS = TransformObjectToWorld(v.position.xyz);
o.clipPos = TransformWorldToHClip(posWS);
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);
float3 objectOrigin = UNITY_ACCESS_INSTANCED_PROP(Props, _Position).xyz;
v.position.xyz = VegetationDeformation(v.position.xyz, objectOrigin, v.normal, v.color.x, v.color.z, v.color.y);
o.positionWS = TransformObjectToWorld(v.vertex.xyz);
o.clipPos = TransformWorldToHClip(o.positionWS);
o.viewDir = SafeNormalize(_WorldSpaceCameraPos - o.positionWS);
posWS = TransformObjectToWorld(v.position.xyz);
o.clipPos = TransformWorldToHClip(posWS);
half3 viewDir = VertexViewDirWS(GetCameraPositionWS() - posWS);
// initializes o.normal and if _NORMALMAP also o.tangent and o.binormal
OutputTangentToWorld(v.tangent, v.normal, o.tangent, o.binormal, o.normal);
o.normal.w = viewDir.x;
o.tangent.w = viewDir.y;
o.binormal.w = viewDir.z;
o.normal = TransformObjectToWorldNormal(v.normal);
o.viewDir = viewDir;
// initializes o.normal and if _NORMALMAP also o.tangent and o.binormal
OUTPUT_NORMAL(v, o);
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUVOrVertexSH);
OUTPUT_SH(o.normal, o.lightmapUVOrVertexSH);
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUV);
OUTPUT_SH(o.normal.xyz, o.vertexSH);
half3 vertexLight = VertexLighting(o.positionWS, o.normal);
half fogFactor = ComputeFogFactor(o.clipPos.z);
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
half3 vertexLight = VertexLighting(o.posWS, o.normal.xyz);
half fogFactor = ComputeFogFactor(o.clipPos.z);
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
#ifdef _SHADOWS_ENABLED
#if SHADOWS_SCREEN
o.shadowCoord = ComputeShadowCoord(o.clipPos);
#else
o.shadowCoord = TransformWorldToShadowCoord(posWS);
#endif
#endif
o.occlusion = v.color.a;

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
SurfaceData surfaceData;
InitializeStandardLitSurfaceData(IN.uv, surfaceData);
half3 bakedGI = SampleSH(normalWS);
InputData inputData;
InitializeInputData(IN, surfaceData.normalTS, inputData);
surfaceData.albedo *= IN.occlusion;
#if !defined(_CORRECTNORMALS_OFF)
inputData.normalWS *= facing;
#endif
BRDFData brdfData;
InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData);
half4 color = LightweightFragmentPBR(inputData, surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, min(surfaceData.occlusion, IN.occlusion), surfaceData.emission, surfaceData.alpha);
Light mainLight = GetMainLight(IN.positionWS);
half3 color = GlobalIllumination(brdfData, bakedGI, surfaceData.occlusion, normalWS * facing, IN.viewDir);
float fogFactor = IN.fogFactorAndVertexLight.x;
color += LightingPhysicallyBased(brdfData, mainLight, normalWS * facing, IN.viewDir);
// Computes fog factor per-vertex
ApplyFog(color.rgb, fogFactor);
return half4(color, surfaceData.alpha);
ApplyFog(color.rgb, inputData.fogCoord);
return color;
}
ENDHLSL

ZWrite On
ZTest LEqual
Cull[_Cull]
#pragma exclude_renderers d3d11_9x
#pragma shader_feature _NORMALMAP
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature _GLOSSYREFLECTIONS_OFF
#pragma shader_feature _SPECULAR_SETUP
//--------------------------------------
// GPU Instancing

#pragma fragment ShadowPassFragment
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl"
ENDHLSL
}

ZWrite On
ColorMask 0
Cull[_Cull]
#pragma exclude_renderers d3d11_9x
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
#pragma shader_feature _NORMALMAP
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature _GLOSSYREFLECTIONS_OFF
#pragma shader_feature _SPECULAR_SETUP
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/Core.hlsl"
#include "Vegetation.hlsl"
VegetationVertexOutput DepthOnlyVertex(VegetationVertexInput v)
{
VegetationVertexOutput o = (VegetationVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
/////////////////////////////////////vegetation stuff//////////////////////////////////////////////////
//half phaseOffset = UNITY_ACCESS_INSTANCED_PROP(Props, _PhaseOffset);
float3 objectOrigin = UNITY_ACCESS_INSTANCED_PROP(Props, _Position).xyz;
v.position.xyz = VegetationDeformation(v.position.xyz, objectOrigin, v.normal, v.color.x, v.color.z, v.color.y);
o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
o.clipPos = TransformObjectToHClip(v.position.xyz);
return o;
}
half4 DepthOnlyFragment(VegetationVertexOutput IN) : SV_TARGET
{
Alpha(SampleAlbedoAlpha(IN.uv.xy, TEXTURE2D_PARAM(_MainTex, sampler_MainTex)).a, _Color, _Cutoff);
return 0;
}
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl"
ENDHLSL
}

#pragma shader_feature _SPECGLOSSMAP
#include "LWRP/ShaderLibrary/LightweightPassMeta.hlsl"
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassMetaPBR.hlsl"
//CustomEditor "LightweightStandardGUI"
}

131
Assets/Shaders/NewUnlitShader.shader


Shader "BoatAttack/PackedPBR"
Shader "PBR Master"
[NoScaleOffset] _MainTex("Albedo_Roughness", 2D) = "white" {}
[NoScaleOffset] Texture_AE91C5C2("Albedo_Roughness", 2D) = "white" {}
_Color("Color", Color) = (1, 1, 1, 1)
}
SubShader
{

HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma target 3.0
#pragma target 2.0
// -------------------------------------
// Lightweight Pipeline keywords

#include "CoreRP/ShaderLibrary/UnityInstancing.hlsl"
#include "ShaderGraphLibrary/Functions.hlsl"
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
TEXTURE2D(Texture_AE91C5C2); SAMPLER(samplerTexture_AE91C5C2);
TEXTURE2D(Texture_DE8BF47E); SAMPLER(samplerTexture_DE8BF47E);
struct SurfaceInputs{

SurfaceDescription PopulateSurfaceData(SurfaceInputs IN) {
SurfaceDescription surface = (SurfaceDescription)0;
float4 _SampleTexture2D_903562CE_RGBA = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv0.xy);
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;

struct GraphVertexOutput
{
float4 clipPos : SV_POSITION;
float4 lightmapUVOrVertexSH : TEXCOORD0;
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 0);
half4 fogFactorAndVertexLight : TEXCOORD1; // x: fogFactor, yzw: vertex light
float4 shadowCoord : TEXCOORD2;
float3 WorldSpaceNormal : TEXCOORD3;

float3 lwWorldPos = TransformObjectToWorld(v.vertex.xyz);
float4 clipPos = TransformWorldToHClip(lwWorldPos);
// 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.texcoord1, unity_LightmapST, o.lightmapUVOrVertexSH);
OUTPUT_SH(lwWNormal, o.lightmapUVOrVertexSH);
// 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);

#ifdef _NORMALMAP
inputData.normalWS = TangentToWorldNormal(Normal, WorldSpaceTangent, WorldSpaceBiTangent, WorldSpaceNormal);
#else
#if !SHADER_HINT_NICE_QUALITY
inputData.normalWS = WorldSpaceNormal;
#else
#endif
#ifdef SHADER_API_MOBILE
#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.fogCoord = IN.fogFactorAndVertexLight.x;
inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw;
inputData.bakedGI = SampleGI(IN.lightmapUVOrVertexSH, inputData.normalWS);
inputData.bakedGI = SAMPLE_GI(IN.lightmapUV, IN.vertexSH, inputData.normalWS);
half4 color = LightweightFragmentPBR(
inputData,

Pass
{
Tags{"LightMode" = "ShadowCaster"}
Tags{"LightMode" = "ShadowCaster"}
ZWrite On
ZTest LEqual
Cull Back
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
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma target 2.0
#pragma vertex ShadowPassVertex
#pragma fragment ShadowPassFragment
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl"
ENDHLSL
#pragma vertex ShadowPassVertex
#pragma fragment ShadowPassFragment
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl"
ENDHLSL
Tags{"LightMode" = "DepthOnly"}
Tags{"LightMode" = "DepthOnly"}
ZWrite On
ColorMask 0
ZWrite On
ColorMask 0
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma target 2.0
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 DepthOnlyVertex
#pragma fragment DepthOnlyFragment
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl"
ENDHLSL
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl"
ENDHLSL
Tags{"LightMode" = "Meta"}
Tags{"LightMode" = "Meta"}
Cull Off
Cull Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma vertex LightweightVertexMeta
#pragma fragment LightweightFragmentMetaSimple
#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 _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
#pragma shader_feature _SPECGLOSSMAP
#include "LWRP/ShaderLibrary/LightweightPassMeta.hlsl"
ENDHLSL
#include "LWRP/ShaderLibrary/InputSurfacePBR.hlsl"
#include "LWRP/ShaderLibrary/LightweightPassMetaPBR.hlsl"
ENDHLSL
}
FallBack "Hidden/InternalErrorShader"

2
Assets/Shaders/NewUnlitShader.shader.meta


fileFormatVersion: 2
guid: cb7f609cd69cf4f3ebf931295d1c1a10
guid: 7935162ae16ed4d9ca189f532a35c367
ShaderImporter:
externalObjects: {}
defaultTextures: []

3
Assets/Shaders/PackedPBR.ShaderGraph
文件差异内容过多而无法显示
查看文件

275
Assets/scenes/Island.unity


m_PrefabParentObject: {fileID: 4556663440861136, guid: cf92f64c366a83f42b7636e1086fec18,
type: 2}
m_PrefabInternal: {fileID: 32826906}
--- !u!1 &34428526
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 34428530}
- component: {fileID: 34428529}
- component: {fileID: 34428528}
- component: {fileID: 34428527}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &34428527
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 34428526}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &34428528
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 34428526}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &34428529
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 34428526}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &34428530
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 34428526}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5.53, y: -4.13, z: -8.1}
m_LocalScale: {x: 2.1635647, y: 10, z: 25.203922}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &36986913
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 153441711}
m_LocalRotation: {x: 0.030100528, y: -0.771073, z: 0.065151386, w: 0.6326893}
m_LocalRotation: {x: 0.030520232, y: -0.76821446, z: 0.06470187, w: 0.636183}
m_LocalPosition: {x: -30.877321, y: 3.6038504, z: -57.712322}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

m_PrefabParentObject: {fileID: 4407848929593064, guid: 93a21ad838562455fbfdd84d54fca009,
type: 2}
m_PrefabInternal: {fileID: 312490160}
--- !u!28 &317906979
Texture2D:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 128
m_Height: 1
m_CompleteImageSize: 512
m_TextureFormat: 5
m_MipCount: 1
m_IsReadable: 1
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_LightmapFormat: 0
m_ColorSpace: 1
image data: 512
_typelessdata: ff000000ff000001ff000002ff000003ff000003ff000004ff000005ff000006ff000007ff000008ff000009ff00000aff00000aff00000bff00000cff00000dff00000eff00000fff000010ff000011ff000011ff000012ff000013ff000014ff000015ff000016ff000017ff00001eff000026ff00002eff000036ff00003dff000045ff00004dff000054ff00005cff000064ff00006cff000073ff00007bff000083ff00008bff000092ff00009aff0000a2ff0000a9ff0000b1ff0000b9ff0000c1ff0000c8ff0000d0ff0000d8ff0000dfff0000e7ff0000efff0000f7ff0000feff0007faff000ef5ff0016f0ff001debff0025e6ff002ce1ff0034dbff003bd6ff0043d1ff004bccff0052c7ff005ac2ff0061bcff0069b7ff0070b2ff0078adff007fa8ff0087a3ff008e9eff009698ff009d93ff00a58eff00ac89ff00b484ff00bb7fff00c379ff00ca74ff00d26fff00da6aff00e165ff00e960ff00f05bff00f855ff00ff50ff07fc4eff0ef94cff14f64aff1bf348ff22f046ff28ed44ff2fea41ff36e73fff3de33dff43e03bff4add39ff51da37ff57d735ff5ed433ff65d131ff6bce2eff72cb2cff79c82aff80c528ff86c226ff8dbf24ff94bc22ff9ab920ffa1b61effa8b31bffafb019ffb5ad17ffbca915ffc3a613ffc9a311ffd0a00fffd79d0dffdd9a0bffe49708ffeb9406fff29104fff88e02
m_StreamData:
offset: 0
size: 0
path:
--- !u!1001 &319097133
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1017609894}
m_LocalRotation: {x: 0.030100528, y: -0.771073, z: 0.065151386, w: 0.6326893}
m_LocalRotation: {x: 0.030520232, y: -0.76821446, z: 0.06470187, w: 0.636183}
m_LocalPosition: {x: -30.877321, y: 3.6038504, z: -57.712322}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []

m_PrefabParentObject: {fileID: 4950301651628742, guid: a8cf78d9746e449f69179132e78d867f,
type: 2}
m_PrefabInternal: {fileID: 1038520832}
--- !u!28 &1043837443
Texture2D:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 128
m_Height: 4
m_CompleteImageSize: 2048
m_TextureFormat: 5
m_MipCount: 1
m_IsReadable: 1
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_LightmapFormat: 0
m_ColorSpace: 1
image data: 2048
_typelessdata: ffbcb696ffa3b08eff8aa987ff7ea685ff7aa587ff75a488ff70a48aff6ca38bff67a38dff62a28eff5ea18fff59a191ff55a092ff50a094ff4b9f95ff479f97ff429e98ff3d9d99ff399d9bff359c9cff349b9bff339b9aff329a9aff319999ff2f9898ff2e9898ff2d9797ff2c9697ff2b9596ff2a9495ff289495ff279394ff269294ff259193ff249192ff229092ff218f91ff208e91ff1f8e90ff1e8d8fff1c8c8fff1b8b8eff1a8b8dff198a8dff18898cff17888cff15888bff14878aff13868aff128589ff118489ff0f8488ff0e8387ff0d8287ff0c8186ff0b8186ff098085ff087f84ff077e84ff067e83ff057d82ff047c82ff027b81ff017b81ff007a80ff007980ff00787fff00777fff00767eff00757eff00747eff00747dff00737dff00727dff00717cff00707cff006f7bff006e7bff006d7bff006c7aff006b7aff006b79ff006a79ff006979ff006878ff006778ff006678ff006577ff006477ff006376ff006376ff006276ff006175ff006075ff005f74ff005e74ff005d74ff005c73ff005b73ff005a73ff005a72ff005972ff005871ff005771ff005671ff005570ff005470ff005370ff00526fff00526fff00516eff00506eff004f6eff004e6dff004d6dff004c6cff004b6cff004a6cff00496bff00496bff00486bff00476aff00466aff004569ff004469ff004369ff004268ff004168ff000000ff010201ff030302ff040503ff060604ff070805ff090906ff0a0b07ff0c0c08ff0d0e09ff0f0f0aff10110bff12130cff13140dff15160eff16170fff181910ff191a11ff1b1c11ff1c1d12ff1e1f13ff1f2114ff212215ff222416ff242517ff252718ff262819ff282a1aff292b1bff2b2d1cff2c2e1dff2e301eff2e311fff2e3220ff2e3221ff2e3322ff2e3423ff2e3424ff2e3525ff2e3626ff2e3727ff2e3728ff2e3829ff2e392aff2e3a2bff2e3a2dff2e3b2eff2e3c2fff2e3d30ff2e3d31ff2e3e32ff2e3f33ff2e4034ff2e4035ff2e4136ff2e4237ff2e4338ff2e4339ff2e443aff2e453bff2e453cff2e463dff2e473eff2e483fff2e4840ff2e4941ff2e4a42ff2e4b43ff2e4b44ff2d4c45ff2d4d46ff2d4e47ff2d4e48ff2d4f49ff2d504aff2d514bff2d514cff2d524dff2d534eff2d544fff2d5451ff2d5552ff2d5653ff2d5654ff2d5755ff2d5856ff2d5957ff2d5958ff2d5a59ff2d5b5aff2d5c5bff2d5c5cff2d5d5dff2d5e5eff2d5f5fff2d5f60ff2d6061ff2d6162ff2d6263ff2d6264ff2d6365ff2d6466ff2d6567ff2d6568ff2d6669ff2d676aff2d676bff2d686cff2d696dff2d6a6eff2d6a6fff2d6b70ff2d6c71ff2d6d72ff2d6d74ff2d6e75ff2d6f76ff2d7077ff2d7078ff2d7179ff2d727aff2d737bff2d737cff2d747dff2d757eff2d767fff2d7680ff2d7781ff000000ff000001ff000002ff000003ff000003ff000004ff000005ff000006ff000007ff000008ff000009ff00000aff00000aff00000bff00000cff00000dff00000eff00000fff000010ff000011ff000011ff000012ff000013ff000014ff000015ff000016ff000017ff00001eff000026ff00002eff000036ff00003dff000045ff00004dff000054ff00005cff000064ff00006cff000073ff00007bff000083ff00008bff000092ff00009aff0000a2ff0000a9ff0000b1ff0000b9ff0000c1ff0000c8ff0000d0ff0000d8ff0000dfff0000e7ff0000efff0000f7ff0000feff0007faff000ef5ff0016f0ff001debff0025e6ff002ce1ff0034dbff003bd6ff0043d1ff004bccff0052c7ff005ac2ff0061bcff0069b7ff0070b2ff0078adff007fa8ff0087a3ff008e9eff009698ff009d93ff00a58eff00ac89ff00b484ff00bb7fff00c379ff00ca74ff00d26fff00da6aff00e165ff00e960ff00f05bff00f855ff00ff50ff07fc4eff0ef94cff14f64aff1bf348ff22f046ff28ed44ff2fea41ff36e73fff3de33dff43e03bff4add39ff51da37ff57d735ff5ed433ff65d131ff6bce2eff72cb2cff79c82aff80c528ff86c226ff8dbf24ff94bc22ff9ab920ffa1b61effa8b31bffafb019ffb5ad17ffbca915ffc3a613ffc9a311ffd0a00fffd79d0dffdd9a0bffe49708ffeb9406fff29104fff88e020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
m_StreamData:
offset: 0
size: 0
path:
--- !u!1001 &1051721346
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1143740434}
m_LocalRotation: {x: -0.00038569304, y: 0.9523511, z: -0.0012051339, w: -0.30500138}
m_LocalRotation: {x: -0.00038550817, y: 0.9529047, z: -0.0012127039, w: -0.30326745}
m_LocalPosition: {x: 42, y: 2.51, z: 62.1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

m_PrefabParentObject: {fileID: 4407848929593064, guid: 93a21ad838562455fbfdd84d54fca009,
type: 2}
m_PrefabInternal: {fileID: 1161319334}
--- !u!28 &1163497088
Texture2D:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 128
m_Height: 4
m_CompleteImageSize: 2048
m_TextureFormat: 5
m_MipCount: 1
m_IsReadable: 1
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_LightmapFormat: 0
m_ColorSpace: 1
image data: 2048
_typelessdata: ffffffffffecfcfcffd9f9f9ffc6f5f5ffb3f2f2ffa0efefff8dececff7ae9e9ff67e5e5ff55e2e2ff42dfdfff36dcdcff35d9d9ff33d5d6ff31d2d3ff2fcfd0ff2dcccdff2cc8caff2ac5c6ff28c2c3ff26bec0ff24bbbdff23b8baff21b5b7ff1fb1b4ff1daeb1ff1babaeff19a8abff18a4a8ff16a1a5ff149ea2ff129b9fff10979cff0f9499ff0d9196ff0b8d92ff098a8fff07878cff068489ff048086ff027d83ff007a80ff00797fff00777fff00767eff00757eff00737dff00727dff00717cff006f7cff006e7bff006d7aff006c7aff006a79ff006979ff006878ff006678ff006577ff006477ff006276ff006175ff006075ff005f74ff005d74ff005c73ff005b73ff005972ff005872ff005771ff005570ff005470ff00536fff00526fff00506eff004f6eff004e6dff004c6dff004b6cff004a6bff00486bff00476aff00466aff004469ff004369ff004268ff004167ff003f65ff003e63ff003c61ff003b5eff00395cff00385aff003657ff003555ff003352ff003250ff00304eff002f4bff002e49ff002c47ff002b44ff002942ff002840ff00263dff00253bff002339ff002236ff002034ff001f31ff001d2fff001c2dff001a2aff001928ff001826ff001623ff001521ff00131fff00121cff00101aff000f18ff000d15ff000c13ff000a11ff00090eff00070cff000609ff000407ff000305ff000000ff020706ff030f0cff051613ff061e19ff08251fff092c25ff0b342cff0c3b32ff0e4338ff0f4a3eff115144ff12594bff146051ff156857ff166a59ff166a59ff166b59ff166b5aff166b5aff166c5aff166c5aff176c5aff176d5bff176d5bff176d5bff176e5bff176e5bff176e5cff186f5cff186f5cff186f5cff18705cff18705cff18705dff18715dff19715dff19715dff19725dff19725eff19725eff19735eff19735eff1a735eff1a745fff1a745fff1a7460ff1b7460ff1b7460ff1b7461ff1b7461ff1b7462ff1c7462ff1c7463ff1c7463ff1c7463ff1d7464ff1d7464ff1d7465ff1d7465ff1d7465ff1e7466ff1e7466ff1e7467ff1e7567ff1f7568ff1f7568ff1f7568ff1f7569ff1f7569ff20756aff20756aff20756aff20756bff21756bff21756cff21756cff21756dff21756dff22756dff22756eff22756eff22756fff23756fff237670ff237670ff237670ff247671ff247671ff247672ff247672ff247672ff257673ff257673ff257674ff257674ff267675ff267675ff267675ff267676ff267676ff277677ff277677ff277677ff277778ff287778ff287779ff287779ff28777aff28777aff29777aff29777bff29777bff29777cff2a777cff2a777cff2a777dff2a777dff2a777eff2b777eff2b777fff2b777fff2b777fff2c7780ff2c7880ff2c7881ff2c7881ff2d7881ff000000ff000001ff000002ff000003ff000003ff000004ff000005ff000006ff000007ff000008ff000009ff00000aff00000aff00000bff00000cff00000dff00000eff00000fff000010ff000011ff000011ff000012ff000013ff000014ff000015ff000016ff000017ff00001eff000026ff00002eff000036ff00003dff000045ff00004dff000054ff00005cff000064ff00006cff000073ff00007bff000083ff00008bff000092ff00009aff0000a2ff0000a9ff0000b1ff0000b9ff0000c1ff0000c8ff0000d0ff0000d8ff0000dfff0000e7ff0000efff0000f7ff0000feff0007faff000ef5ff0016f0ff001debff0025e6ff002ce1ff0034dbff003bd6ff0043d1ff004bccff0052c7ff005ac2ff0061bcff0069b7ff0070b2ff0078adff007fa8ff0087a3ff008e9eff009698ff009d93ff00a58eff00ac89ff00b484ff00bb7fff00c379ff00ca74ff00d26fff00da6aff00e165ff00e960ff00f05bff00f855ff00ff50ff07fc4eff0ef94cff14f64aff1bf348ff22f046ff28ed44ff2fea41ff36e73fff3de33dff43e03bff4add39ff51da37ff57d735ff5ed433ff65d131ff6bce2eff72cb2cff79c82aff80c528ff86c226ff8dbf24ff94bc22ff9ab920ffa1b61effa8b31bffafb019ffb5ad17ffbca915ffc3a613ffc9a311ffd0a00fffd79d0dffdd9a0bffe49708ffeb9406fff29104fff88e020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
m_StreamData:
offset: 0
size: 0
path:
--- !u!1 &1170795628
GameObject:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
m_ResolutionMultiplier: 0.333
m_ClipPlaneOffset: 0
m_ClipPlaneOffset: 0.25
m_ReflectLayers:
serializedVersion: 2
m_Bits: 4294966767

m_Name:
m_EditorClassIdentifier:
_waterMaxDepth: 20
_colorRamp: {fileID: 1043837443}
_colorRamp: {fileID: 1163497088}
key0: {r: 0.735849, g: 0.7154964, b: 0.5865966, a: 1}
key1: {r: 0.5066305, g: 0.6509434, b: 0.5198539, a: 1}
key2: {r: 0.21115166, g: 0.6132076, b: 0.6108, a: 0}
key3: {r: 0, g: 0.47764966, b: 0.5019608, a: 0}
key4: {r: 0, g: 0.2528793, b: 0.4056604, a: 0}
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 0.21698113, g: 0.8679245, b: 0.8679245, a: 1}
key2: {r: 0, g: 0.47764966, b: 0.5019608, a: 0}
key3: {r: 0, g: 0.2528793, b: 0.4056604, a: 0}
key4: {r: 0, g: 0.0058618947, b: 0.009433985, a: 0}
ctime1: 1217
ctime2: 9536
ctime3: 32768
ctime1: 5397
ctime2: 21010
ctime3: 43562
ctime4: 65535
ctime5: 0
ctime6: 0

_scatterRampRaw:
serializedVersion: 2
key0: {r: 0, g: 0, b: 0, a: 1}
key1: {r: 0.18030901, g: 0.18867922, b: 0.11836951, a: 1}
key2: {r: 0.1754183, g: 0.46956396, b: 0.509434, a: 0}
key3: {r: 0, g: 0.18992288, b: 0.3019608, a: 0}
key1: {r: 0.08419366, g: 0.41509432, b: 0.34891418, a: 1}
key2: {r: 0.1003916, g: 0.4528302, b: 0.3699492, a: 0}
key3: {r: 0.1754183, g: 0.46956396, b: 0.509434, a: 0}
ctime1: 15907
ctime2: 65535
ctime1: 7325
ctime2: 21974
ctime3: 65535
ctime4: 65535
ctime5: 0

atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 3
m_NumColorKeys: 4
_foamRamp: {fileID: 317906979}
_foamRamp: {fileID: 1869259982}
_foamRampRaw:
serializedVersion: 2
key0: {r: 0, g: 0, b: 0, a: 1}

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1768035350}
m_LocalRotation: {x: 0.0001562276, y: 0.99983907, z: -0.0141332, w: 0.011052165}
m_LocalRotation: {x: 0.0001562315, y: 0.99983907, z: -0.014133553, w: 0.011052165}
m_LocalPosition: {x: -43.19189, y: 4.187497, z: 30.545403}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

m_PrefabParentObject: {fileID: 4656579744416828, guid: 6108635b0aac04aada0cdeaae825f776,
type: 2}
m_PrefabInternal: {fileID: 1869022717}
--- !u!28 &1869259982
Texture2D:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 128
m_Height: 1
m_CompleteImageSize: 512
m_TextureFormat: 5
m_MipCount: 1
m_IsReadable: 1
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_LightmapFormat: 0
m_ColorSpace: 1
image data: 512
_typelessdata: ff000000ff000001ff000002ff000003ff000003ff000004ff000005ff000006ff000007ff000008ff000009ff00000aff00000aff00000bff00000cff00000dff00000eff00000fff000010ff000011ff000011ff000012ff000013ff000014ff000015ff000016ff000017ff00001eff000026ff00002eff000036ff00003dff000045ff00004dff000054ff00005cff000064ff00006cff000073ff00007bff000083ff00008bff000092ff00009aff0000a2ff0000a9ff0000b1ff0000b9ff0000c1ff0000c8ff0000d0ff0000d8ff0000dfff0000e7ff0000efff0000f7ff0000feff0007faff000ef5ff0016f0ff001debff0025e6ff002ce1ff0034dbff003bd6ff0043d1ff004bccff0052c7ff005ac2ff0061bcff0069b7ff0070b2ff0078adff007fa8ff0087a3ff008e9eff009698ff009d93ff00a58eff00ac89ff00b484ff00bb7fff00c379ff00ca74ff00d26fff00da6aff00e165ff00e960ff00f05bff00f855ff00ff50ff07fc4eff0ef94cff14f64aff1bf348ff22f046ff28ed44ff2fea41ff36e73fff3de33dff43e03bff4add39ff51da37ff57d735ff5ed433ff65d131ff6bce2eff72cb2cff79c82aff80c528ff86c226ff8dbf24ff94bc22ff9ab920ffa1b61effa8b31bffafb019ffb5ad17ffbca915ffc3a613ffc9a311ffd0a00fffd79d0dffdd9a0bffe49708ffeb9406fff29104fff88e02
m_StreamData:
offset: 0
size: 0
path:
--- !u!1 &1907062045
GameObject:
m_ObjectHideFlags: 0

2
ProjectSettings/ProjectSettings.asset


m_DynamicBatching: 0
- m_BuildTarget: Standalone
m_StaticBatching: 1
m_DynamicBatching: 0
m_DynamicBatching: 1
m_BuildTargetGraphicsAPIs:
- m_BuildTarget: iOSSupport
m_APIs: 10000000

99
Assets/Shaders/Vegetation.hlsl


#include "LWRP/ShaderLibrary/Lighting.hlsl"
struct VegetationVertexInput
{
float4 position : 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
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1);
float3 posWS : TEXCOORD2;
#ifdef _NORMALMAP
half4 normal : TEXCOORD3; // xyz: normal, w: viewDir.x
half4 tangent : TEXCOORD4; // xyz: tangent, w: viewDir.y
half4 binormal : TEXCOORD5; // xyz: binormal, w: viewDir.z
#else
half3 normal : TEXCOORD3;
half3 viewDir : TEXCOORD4;
#endif
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light
#ifdef _SHADOWS_ENABLED
float4 shadowCoord : TEXCOORD7;
#endif
float4 clipPos : SV_POSITION;
half occlusion : TEXCOORD8;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(half4, _Position)
UNITY_INSTANCING_BUFFER_END(Props)
/////////////////////////////////////vegetation stuff//////////////////////////////////////////////////
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 ) );
}
float3 VegetationDeformation(float3 position, float3 origin, float3 normal, half leafStiffness, half branchStiffness, half phaseOffset)
{
///////Main Bending
float fBendScale = 0.05;//main bend opacity
float fLength = length(position);//distance to origin
float2 vWind = float2(sin(_Time.y + origin.x) * 0.1, sin(_Time.y + origin.z) * 0.1);//wind direction
// Bend factor - Wind variation is done on the CPU.
float fBF = position.y * fBendScale;
// Smooth bending factor and increase its nearby height limit.
fBF += 1.0;
fBF *= fBF;
fBF = fBF * fBF - fBF;
// Displace position
float3 vNewPos = position;
vNewPos.xz += vWind.xy * fBF;
// Rescale
position = normalize(vNewPos.xyz) * fLength;
////////Detail blending
float fSpeed = 0.25;//leaf occil
float fDetailFreq = 0.3;//detail leaf occil
float fEdgeAtten = leafStiffness;//leaf stiffness(red)
float fDetailAmp = 0.1;//leaf edge amplitude of movement
float fBranchAtten = 1 - branchStiffness;//branch stiffness(blue)
float fBranchAmp = 1.5;//branch amplitude of movement
float fBranchPhase = phaseOffset * 3.3;//leaf phase(green)
// Phases (object, vertex, branch)
float fObjPhase = dot(origin, 1);
fBranchPhase += fObjPhase;
float fVtxPhase = dot(position, phaseOffset + 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)
return position + vWavesSum.xyx * float3(fEdgeAtten * fDetailAmp * normal.x, fBranchAtten * fBranchAmp, fEdgeAtten * fDetailAmp * normal.z);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////

9
Assets/Shaders/Vegetation.hlsl.meta


fileFormatVersion: 2
guid: 372bb067f678c44e6ba03e6852450096
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存