[WIP] water plant
This commit is contained in:
90
Assets/Test/UnderWater/testshader.shader
Normal file
90
Assets/Test/UnderWater/testshader.shader
Normal file
@@ -0,0 +1,90 @@
|
||||
|
||||
Shader "zzwater/testshader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_SwayFreq("Sway Frequency", Range(0,10)) = 1.0
|
||||
_SubFreq("sub Frequency", Range(0,100)) = 1.0
|
||||
_SwayIntensity("Sway Intensity", Range(0,2)) = 0.1
|
||||
_WindDir("Wind Direction", Vector) = (1,0,0,0)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"UniversalMaterialType" = "Lit"
|
||||
"IgnoreProjector" = "True"
|
||||
}
|
||||
LOD 300
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode" = "UniversalForward" }
|
||||
ZCLIP On
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 normalWS : TEXCOORD1;
|
||||
float4 color : TEXCOORD2;
|
||||
float r1 : TEXCOORD3;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
half _SwayFreq;
|
||||
half _SubFreq;
|
||||
half _SwayIntensity;
|
||||
float4 _WindDir;
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
o.positionHCS = TransformObjectToHClip(v.positionOS.xyz);
|
||||
o.normalWS = TransformObjectToWorldNormal(v.normalOS);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.color = v.color;
|
||||
//o.r1 = dot(unity_ObjectToWorld[3].xyz, 1);;
|
||||
|
||||
float3 positionWS = TransformObjectToWorld(v.positionOS.xyz);
|
||||
o.r1 = frac(dot(positionWS, 1));
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
half4 albedo = tex2D(_MainTex, i.uv);
|
||||
//clip(albedo.a - 0.5);
|
||||
return half4(i.r1,0,0, 1.0);
|
||||
return half4(albedo.rgb, 1.0);
|
||||
//Light mainLight = GetMainLight(TransformWorldToShadowCoord(i.positionHCS));
|
||||
|
||||
// 简易光照模型[^2]
|
||||
//half3 diffuse = mainLight.color * saturate(dot(i.normalWS, mainLight.direction));
|
||||
//return half4(albedo.rgb * diffuse, 1.0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user