112 lines
3.3 KiB
Plaintext
112 lines
3.3 KiB
Plaintext
Shader "NLD_URP/NLD_Scene_Water"
|
|
{
|
|
Properties
|
|
{
|
|
[MainTexture]_BaseMap ("主贴图", 2D) = "white" {}
|
|
[MainColor] _BaseColor("基础颜色", Color) = (1, 1, 1, 1)
|
|
_BaseMapUVMoving("主贴图UV移动", Vector) = (0.1, 0.1, 0, 0)
|
|
|
|
_AddMap("附加贴图", 2D) = "white" {}
|
|
_AddColor("附加颜色", Color) = (1, 1, 1, 1)
|
|
_AddUVMoving("附加UV移动", Vector) = (0.1, 0.1, 0, 0)
|
|
_AddColorIntensity("附加颜色强度", Range(0, 10)) = 1
|
|
|
|
_NoiseMap("噪声贴图", 2D) = "white" {}
|
|
_NoiseUVMoving("噪声UV移动", Vector) = (0.1, 0.1, 0, 0)
|
|
_NoiseIntensity("噪声强度", Range(0, 1)) = 0.5
|
|
}
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderType" = "Transparent"
|
|
"RenderPipeline" = "UniversalPipeline"
|
|
}
|
|
LOD 100
|
|
|
|
HLSLINCLUDE
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
struct Attributes_LT {
|
|
float4 positionOS : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
struct Varyings_LT {
|
|
float4 positionCS : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
TEXTURE2D(_BaseMap);
|
|
SAMPLER(sampler_BaseMap);
|
|
|
|
TEXTURE2D(_AddMap);
|
|
SAMPLER(sampler_AddMap);
|
|
|
|
TEXTURE2D(_NoiseMap);
|
|
SAMPLER(sampler_NoiseMap);
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _BaseMap_ST;
|
|
float4 _AddMap_ST;
|
|
float4 _NoiseMap_ST;
|
|
|
|
float4 _BaseColor;
|
|
float4 _AddColor;
|
|
|
|
float4 _BaseMapUVMoving;
|
|
float4 _AddUVMoving;
|
|
float4 _NoiseUVMoving;
|
|
|
|
float _AddColorIntensity;
|
|
float _NoiseIntensity;
|
|
CBUFFER_END
|
|
|
|
ENDHLSL
|
|
|
|
Pass
|
|
{
|
|
Cull Back
|
|
ZWrite Off
|
|
ZTest LEqual
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
Name "Water"
|
|
Tags
|
|
{
|
|
"LightMode" = "SRPDefaultUnlit"
|
|
}
|
|
|
|
HLSLPROGRAM
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
Varyings_LT vert(Attributes_LT input)
|
|
{
|
|
Varyings_LT output;
|
|
output.positionCS = TransformObjectToHClip(input.positionOS);
|
|
output.uv = input.uv;
|
|
return output;
|
|
}
|
|
|
|
float4 frag(Varyings_LT input) : SV_Target
|
|
{
|
|
float noise = SAMPLE_TEXTURE2D(_NoiseMap, sampler_NoiseMap, (input.uv + _NoiseUVMoving.xy * _Time.y) * _NoiseMap_ST.xy + _NoiseMap_ST.zw).r;
|
|
noise *= _NoiseIntensity;
|
|
float2 finalUVBase = (input.uv + noise + _BaseMapUVMoving.xy * _Time.y) * _BaseMap_ST.xy + _BaseMap_ST.zw;
|
|
float4 baseColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, finalUVBase);
|
|
float4 finalColor = baseColor * _BaseColor;
|
|
|
|
float2 finalUVAdd = (input.uv + noise + _AddUVMoving.xy * _Time.y) * _AddMap_ST.xy + _AddMap_ST.zw;
|
|
float4 addColor = SAMPLE_TEXTURE2D(_AddMap, sampler_AddMap, finalUVAdd);
|
|
finalColor += addColor * _AddColor * finalColor.a * _AddColorIntensity;
|
|
|
|
return finalColor;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
}
|
|
} |