Add WaterParticle shader and minor water shader tweaks

Introduced a new WaterParticle shader for rendering water particles with alpha blending. Made minor formatting and calculation adjustments in Water.shader and DefaultSetup.hlsl, and updated Variables.hlsl. Added corresponding .meta files for new shader assets.
This commit is contained in:
DeMuenu
2025-09-26 20:11:49 +02:00
parent 0f049de062
commit dc939d0ef6
6 changed files with 88 additions and 8 deletions

View File

@@ -4,10 +4,9 @@
\
float distanceFromLight = length(i.worldPos - _LightPositions[LightCounter].xyz); \
if (distanceFromLight > _LightCutoffDistance) continue; \
\
float contrib = 0.0; \
\
float contrib = 0.0;
#endif
#ifndef OutLoopSetup
@@ -15,5 +14,7 @@
int count = (int)_PlayerCount; \
\
float4 dmax = float4(0,0,0,1); \
float dIntensity = 0; \
float dIntensity = 0;
#endif

View File

@@ -10,4 +10,5 @@
float _LightType[MAX_LIGHTS]; /* 0 = sphere, 1 = cone */ \
float _PlayerCount; /* set via SetFloat */ \
\
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c46c91c88f0f9954b9d65378c73103a5
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -146,7 +146,7 @@ Shader "DeMuenu/World/Hoppou/Water"
//Moonlight
float3 N = normalize(i.worldNormal + NormalOffset1 * _NormalMapStrength1 + NormalOffset2 * _NormalMapStrength2 + Wave * _WaveScale); //for lambertian diffuse
//Waterspecific
float3 V = normalize(_WorldSpaceCameraPos - i.worldPos);
@@ -162,7 +162,7 @@ Shader "DeMuenu/World/Hoppou/Water"
Lambert(_LightPositions[LightCounter].xyz ,i, N);
LightTypeCalculations(_LightColors, LightCounter, i, NdotL, dIntensity, _LightPositions[LightCounter].a, _LightPositions[LightCounter].xyz);
LightTypeCalculations(_LightColors, LightCounter, i, 1, dIntensity, _LightPositions[LightCounter].a, _LightPositions[LightCounter].xyz);
@@ -185,7 +185,7 @@ Shader "DeMuenu/World/Hoppou/Water"
float fres = SchlickFresnel(NoV, _F0, _FresnelPower);
dmax.w = 1.0;
dmax.a = dmax.a * _ReflectionStrength * fres;
dmax.a = dmax.a * _ReflectionStrength * fres;
//Moonlight END

View File

@@ -0,0 +1,62 @@
Shader "DeMuenu/World/Hoppou/WaterParticle"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_AlphaMap ("Alpha Map", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Blend SrcAlpha OneMinusSrcAlpha // normal alpha blend (not additive)
ZWrite Off
Lighting Off
Cull Off
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
float4 color : COLOR;
};
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _AlphaMap;
fixed4 _Color;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
float alpha = tex2D(_AlphaMap, i.uv).r;
return col * alpha * i.color; // col.a drives the blend
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 257e74905e73c3a40bcd4a4b35d3d647
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: