备份CatanBuilding瘦身独立工程
This commit is contained in:
93
LocalPackages/zzwater/shaders/water_plant.shader
Normal file
93
LocalPackages/zzwater/shaders/water_plant.shader
Normal file
@@ -0,0 +1,93 @@
|
||||
Shader "zzwater/waterPlant"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_TineColor("Tine color", Color) = (1,1,1)
|
||||
_SwayFreq("Sway Frequency", Range(0,5)) = 1.0
|
||||
_SwayIntensity("Sway Intensity", Range(0.05,0.5)) = 0.1
|
||||
_WaterDir("Water Direction", Vector) = (1,0,0,0)
|
||||
// _waterDir.w for wave diff from each other
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"UniversalMaterialType" = "Unlit"
|
||||
"Queue"="Geometry"
|
||||
"DisableBatching"="False"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Universal Forward"
|
||||
|
||||
Tags
|
||||
{
|
||||
// LightMode: <None>
|
||||
}
|
||||
|
||||
// Render State
|
||||
Cull Back
|
||||
Blend One Zero
|
||||
ZTest LEqual
|
||||
ZWrite On
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/WaveObj.hlsl"
|
||||
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float3 _TineColor;
|
||||
half _SwayFreq;
|
||||
half _SwayIntensity;
|
||||
float4 _WaterDir;
|
||||
CBUFFER_END
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
float3 displacement;
|
||||
v.positionOS.xyz += GetObjWaveDisplacement(v.positionOS, _WaterDir, _SwayFreq, _SwayIntensity, v.color.a);
|
||||
|
||||
o.positionHCS = TransformObjectToHClip(v.positionOS.xyz);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
half4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
clip(albedo.a - 0.5);
|
||||
return half4(albedo.rgb * _TineColor, 1.0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user