Minor - Add Assets And Support Dual Screen

This commit is contained in:
2026-02-03 16:15:50 +01:00
parent 76132c2cbe
commit 7a3d9e54c4
1039 changed files with 149985 additions and 21327 deletions

View File

@@ -0,0 +1,186 @@
Shader "Custom/Water/Depth/DiffuseColorWater"
{
Properties
{
_Color ("Color", Color) = (1, 1, 1, 1)
[Space(20)]
_WaterColor ("Water color", Color) = (1, 1, 1, 1)
_WaterTex("Water texture", 2D) = "white" {}
_Tiling ("Water tiling", Vector) = (1, 1, 1, 1)
_TextureVisibility ("Texture visibility", Range(0, 1)) = 1
[Space(20)]
_DistTex ("Distortion", 2D) = "white" {}
_DistTiling ("Distortion tiling", Vector) = (1, 1, 1, 1)
[Space(20)]
//_DeepColor ("Water deep color", Color) = (1, 1, 1, 1)
_WaterHeight ("Water height", Float) = 0
_WaterDeep ("Water deep", Float) = 0
_WaterDepth ("Water depth param", Range(0, 0.1)) = 0
_WaterMinAlpha ("Water min alpha", Range(0, 1)) = 0
[Space(20)]
_BorderColor ("Border color", Color) = (1, 1, 1, 1)
_BorderWidth ("Border width", Range(0, 1)) = 0
[Space(20)]
_MoveDirection ("Direction", Vector) = (0, 0, 0, 0)
}
SubShader
{
Tags { "RenderType" = "Opaque" "BW" = "TrueProbes" "LightMode" = "ForwardBase" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityLightingCommon.cginc"
#pragma multi_compile_fog
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
struct appdata
{
float4 vertex : POSITION;
float4 normal : NORMAL;
float2 uv : TEXCOORD0;
#if LIGHTMAP_ON
float2 lightmap_uv : TEXCOORD1;
#endif
};
struct v2f
{
fixed4 worldPos : TEXCOORD0;
fixed camHeightOverWater : TEXCOORD1;
fixed waterDepth : TEXCOORD2;
UNITY_FOG_COORDS(3)
#if LIGHTMAP_ON
fixed2 lightmap_uv : TEXCOORD4;
#else
fixed4 diffuseLight : TEXCOORD4;
#endif
float4 vertex : SV_POSITION;
};
fixed4 _Color;
sampler2D _WaterTex;
fixed2 _Tiling;
fixed4 _WaterColor;
sampler2D _DistTex;
fixed2 _DistTiling;
fixed4 _DeepColor;
fixed _WaterHeight;
fixed _TextureVisibility;
fixed _WaterDeep;
fixed _WaterDepth;
fixed _WaterMinAlpha;
fixed4 _BorderColor;
fixed _BorderWidth;
fixed _BorderVisibility;
fixed3 _MoveDirection;
fixed4 DiffuseLight(fixed3 worldNormal)
{
half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
fixed4 diff = nl * _LightColor0;
diff.rgb += ShadeSH9(half4(worldNormal, 1));
return diff;
}
fixed2 WaterPlaneUV(fixed3 worldPos, fixed camHeightOverWater)
{
fixed3 camToWorldRay = worldPos - _WorldSpaceCameraPos;
fixed3 rayToWaterPlane = (camHeightOverWater / camToWorldRay.y * camToWorldRay);
return rayToWaterPlane.xz - _WorldSpaceCameraPos.xz;
}
fixed3 LightmapColor(fixed2 lightmap_uv)
{
fixed4 lightmapCol = UNITY_SAMPLE_TEX2D(unity_Lightmap, lightmap_uv);
return DecodeLightmap(lightmapCol);
}
fixed4 MainColor(v2f i)
{
fixed4 mainCol = _Color;
#if LIGHTMAP_ON
mainCol.rgb *= LightmapColor(i.lightmap_uv);
#else
mainCol.rgb *= i.diffuseLight;
#endif
return mainCol;
}
v2f vert (appdata v)
{
v2f o;
o.worldPos = mul(UNITY_MATRIX_M, v.vertex);
o.vertex = mul(UNITY_MATRIX_VP, o.worldPos);
fixed3 camToWorldRay = o.worldPos - _WorldSpaceCameraPos;
o.camHeightOverWater = _WorldSpaceCameraPos.y - _WaterHeight;
fixed3 rayToWaterPlane = o.camHeightOverWater / (-camToWorldRay.y) * camToWorldRay;
fixed depth = length(camToWorldRay - rayToWaterPlane);
o.waterDepth = depth * _WaterDepth * saturate(rayToWaterPlane.y - camToWorldRay.y);
#if LIGHTMAP_ON
o.lightmap_uv = v.lightmap_uv.xy * unity_LightmapST.xy + unity_LightmapST.zw;
#else
fixed4 worldNormal = normalize(mul(UNITY_MATRIX_M, float4(v.normal.xyz, 0)));
o.diffuseLight = DiffuseLight(worldNormal.xyz);
#endif
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
fixed3 worldPosOnPlane = _WorldSpaceCameraPos + rayToWaterPlane;
fixed3 positionForFog = lerp(worldPosOnPlane, o.worldPos.xyz, o.worldPos.y > _WaterHeight);
fixed4 waterVertex = mul(UNITY_MATRIX_VP, fixed4(positionForFog, 1));
UNITY_TRANSFER_FOG(o, waterVertex);
#endif
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed lengthUnderWater = max(0, _WaterHeight - i.worldPos.y);
fixed underWater = lerp(0, 1, lengthUnderWater > 0);
fixed borderAlpha = lerp(underWater * _BorderColor.a, 0, saturate(lengthUnderWater / _BorderWidth));
fixed waterAlpha = saturate(lengthUnderWater / _WaterDeep + _WaterMinAlpha + i.waterDepth);
fixed4 mainCol = MainColor(i);
fixed2 water_uv = WaterPlaneUV(i.worldPos, i.camHeightOverWater);
fixed4 distortion = tex2D(_DistTex, water_uv * _DistTiling) * 2 - 1;
fixed2 distorted_uv = ((water_uv + distortion.rg) - _Time.y * _MoveDirection.xz) * _Tiling;
fixed4 waterCol = tex2D(_WaterTex, distorted_uv);
waterCol = lerp(_WaterColor, fixed4(1, 1, 1, 1), waterCol.r * _TextureVisibility);
fixed4 finalCol = lerp(mainCol, waterCol, _WaterColor.a * waterAlpha * underWater);
finalCol.rgb = lerp(finalCol.rgb, _BorderColor.rgb, borderAlpha);
UNITY_APPLY_FOG(i.fogCoord, finalCol);
//return fixed4(i.waterDepth, 0, 0, 1);
return finalCol;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,16 @@
fileFormatVersion: 2
guid: fb270c1e5be780e46b05d4a023cd7e73
timeCreated: 1493134247
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 89541
packageName: Mobile depth water shader
packageVersion: 1.0
assetPath: Assets/MobileDepthWater/Shaders/WaterOpaque/Depth/DiffuseColorDepthWater.shader
uploadId: 179707

View File

@@ -0,0 +1,192 @@
Shader "Custom/Water/Depth/DiffuseWater"
{
Properties
{
_Color ("Color", Color) = (1, 1, 1, 1)
_MainTex ("Texture", 2D) = "white" {}
[Space(20)]
_WaterColor ("Water color", Color) = (1, 1, 1, 1)
_WaterTex("Water texture", 2D) = "white" {}
_Tiling ("Water tiling", Vector) = (1, 1, 1, 1)
_TextureVisibility ("Texture visibility", Range(0, 1)) = 1
[Space(20)]
_DistTex ("Distortion", 2D) = "white" {}
_DistTiling ("Distortion tiling", Vector) = (1, 1, 1, 1)
[Space(20)]
//_DeepColor ("Water deep color", Color) = (1, 1, 1, 1)
_WaterHeight ("Water height", Float) = 0
_WaterDeep ("Water deep", Float) = 0
_WaterDepth ("Water depth param", Range(0, 0.1)) = 0
_WaterMinAlpha ("Water min alpha", Range(0, 1)) = 0
[Space(20)]
_BorderColor ("Border color", Color) = (1, 1, 1, 1)
_BorderWidth ("Border width", Range(0, 1)) = 0
[Space(20)]
_MoveDirection ("Direction", Vector) = (0, 0, 0, 0)
}
SubShader
{
Tags { "RenderType" = "Opaque" "BW" = "TrueProbes" "LightMode" = "ForwardBase" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityLightingCommon.cginc"
#pragma multi_compile_fog
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
struct appdata
{
float4 vertex : POSITION;
float4 normal : NORMAL;
float2 uv : TEXCOORD0;
#if LIGHTMAP_ON
float2 lightmap_uv : TEXCOORD1;
#endif
};
struct v2f
{
float2 uv : TEXCOORD0;
fixed4 worldPos : TEXCOORD1;
fixed camHeightOverWater : TEXCOORD2;
fixed waterDepth : TEXCOORD3;
UNITY_FOG_COORDS(4)
#if LIGHTMAP_ON
fixed2 lightmap_uv : TEXCOORD5;
#else
fixed4 diffuseLight : TEXCOORD5;
#endif
float4 vertex : SV_POSITION;
};
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _WaterTex;
fixed2 _Tiling;
fixed4 _WaterColor;
sampler2D _DistTex;
fixed2 _DistTiling;
fixed4 _DeepColor;
fixed _WaterHeight;
fixed _TextureVisibility;
fixed _WaterDeep;
fixed _WaterDepth;
fixed _WaterMinAlpha;
fixed4 _BorderColor;
fixed _BorderWidth;
fixed _BorderVisibility;
fixed3 _MoveDirection;
fixed4 DiffuseLight(fixed3 worldNormal)
{
half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
fixed4 diff = nl * _LightColor0;
diff.rgb += ShadeSH9(half4(worldNormal, 1));
return diff;
}
fixed2 WaterPlaneUV(fixed3 worldPos, fixed camHeightOverWater)
{
fixed3 camToWorldRay = worldPos - _WorldSpaceCameraPos;
fixed3 rayToWaterPlane = (camHeightOverWater / camToWorldRay.y * camToWorldRay);
return rayToWaterPlane.xz - _WorldSpaceCameraPos.xz;
}
fixed3 LightmapColor(fixed2 lightmap_uv)
{
fixed4 lightmapCol = UNITY_SAMPLE_TEX2D(unity_Lightmap, lightmap_uv);
return DecodeLightmap(lightmapCol);
}
fixed4 MainColor(v2f i)
{
fixed4 mainCol = tex2D(_MainTex, i.uv) * _Color;
#if LIGHTMAP_ON
mainCol.rgb *= LightmapColor(i.lightmap_uv);
#else
mainCol.rgb *= i.diffuseLight;
#endif
return mainCol;
}
v2f vert (appdata v)
{
v2f o;
o.worldPos = mul(UNITY_MATRIX_M, v.vertex);
o.vertex = mul(UNITY_MATRIX_VP, o.worldPos);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
fixed3 camToWorldRay = o.worldPos - _WorldSpaceCameraPos;
o.camHeightOverWater = _WorldSpaceCameraPos.y - _WaterHeight;
fixed3 rayToWaterPlane = o.camHeightOverWater / (-camToWorldRay.y) * camToWorldRay;
fixed depth = length(camToWorldRay - rayToWaterPlane);
o.waterDepth = depth * _WaterDepth * saturate(rayToWaterPlane.y - camToWorldRay.y);;
#if LIGHTMAP_ON
o.lightmap_uv = v.lightmap_uv.xy * unity_LightmapST.xy + unity_LightmapST.zw;
#else
fixed4 worldNormal = normalize(mul(UNITY_MATRIX_M, float4(v.normal.xyz, 0)));
o.diffuseLight = DiffuseLight(worldNormal.xyz);
#endif
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
fixed3 worldPosOnPlane = _WorldSpaceCameraPos + rayToWaterPlane;
fixed3 positionForFog = lerp(worldPosOnPlane, o.worldPos.xyz, o.worldPos.y > _WaterHeight);
fixed4 waterVertex = mul(UNITY_MATRIX_VP, fixed4(positionForFog, 1));
UNITY_TRANSFER_FOG(o, waterVertex);
#endif
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed lengthUnderWater = max(0, _WaterHeight - i.worldPos.y);
fixed underWater = lerp(0, 1, lengthUnderWater > 0);
fixed borderAlpha = lerp(underWater * _BorderColor.a, 0, saturate(lengthUnderWater / _BorderWidth));
fixed waterAlpha = saturate(lengthUnderWater / _WaterDeep + _WaterMinAlpha + i.waterDepth);
fixed4 mainCol = MainColor(i);
fixed2 water_uv = WaterPlaneUV(i.worldPos, i.camHeightOverWater);
fixed4 distortion = tex2D(_DistTex, water_uv * _DistTiling) * 2 - 1;
fixed2 distorted_uv = ((water_uv + distortion.rg) - _Time.y * _MoveDirection.xz) * _Tiling;
fixed4 waterCol = tex2D(_WaterTex, distorted_uv);
waterCol = lerp(_WaterColor, fixed4(1, 1, 1, 1), waterCol.r * _TextureVisibility);
fixed4 finalCol = lerp(mainCol, waterCol, _WaterColor.a * waterAlpha * underWater);
finalCol.rgb = lerp(finalCol.rgb, _BorderColor.rgb, borderAlpha);
UNITY_APPLY_FOG(i.fogCoord, finalCol);
//return fixed4(reflection, 0, 0, 1);
return finalCol;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,16 @@
fileFormatVersion: 2
guid: e7e85ac45d06bba48b3f9c38ef023f7b
timeCreated: 1493134247
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 89541
packageName: Mobile depth water shader
packageVersion: 1.0
assetPath: Assets/MobileDepthWater/Shaders/WaterOpaque/Depth/DiffuseDepthWater.shader
uploadId: 179707