Added water

This commit is contained in:
raccoon
2025-10-12 10:23:10 +05:00
parent 1d4e9268f9
commit 968c602da9
8 changed files with 516 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: dev_water
m_Shader: {fileID: 4800000, guid: 833e0bc695a32d84b90a01d380391d7c, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DiffuseArray:
m_Texture: {fileID: 18700000, guid: 6d12f12839d65184fb946fc564d7af58, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicArray:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalArray:
m_Texture: {fileID: 18700000, guid: 8567a3f5204099046b774d80cdd69d56, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints:
- _FlipbookFPS: 30
- _FlipbookFrames: 29
m_Floats:
- _BumpScale: 1
- _Bumpyness: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _RefractAmount: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WaveAmplitude: 0.01
- _WaveFrequency: 1
- _WaveSpeed: 1
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 68b940683e1cdd440b42e69fbba0ee1f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
Shader "Custom/Standard Animated Displacement"
{
Properties
{
[NoScaleOffset]_DiffuseArray("Transparent Albedo (RGBA)", 2DArray) = "" {}
_Color("Tint Color", Color) = (1, 1, 1, 1)
[NoScaleOffset]_MetallicArray("Metallic", 2DArray) = "" {}
_Glossiness("Smoothness", Range(0, 1)) = 0.5
[NoScaleOffset]_NormalArray("Normal Map", 2DArray) = "" {}
_Bumpyness("Bumpyness", Float) = 1.0
_FlipbookFPS("Flipbook FPS", Integer) = 30
_FlipbookFrames("Flipbook Frames", Integer) = 30
_WaveAmplitude("Wave Amplitude", Float) = 0.5
_WaveFrequency("Wave Frequency", Float) = 1.0
_WaveSpeed("Wave Speed", Float) = 1.0
_RefractAmount("Refract Amount", Range(0, 1)) = 0.5
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
LOD 300
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull Back
GrabPass { "_GrabTexture" }
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows alpha:fade addshadow vertex:vert
#pragma target 3.5
#pragma shader_feature_local _NORMALMAP
UNITY_DECLARE_TEX2DARRAY(_DiffuseArray);
fixed4 _Color;
UNITY_DECLARE_TEX2DARRAY(_MetallicArray);
half _Glossiness;
UNITY_DECLARE_TEX2DARRAY(_NormalArray);
half _Bumpyness;
int _FlipbookFPS, _FlipbookFrames;
float _WaveAmplitude,_WaveFrequency,_WaveSpeed;
float _RefractAmount;
sampler2D _GrabTexture;
struct Input
{
float2 uv_DiffuseArray;
float4 screenPos;
INTERNAL_DATA // For proper normal handling
};
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
// Sine wave displacement function
float Wave(float3 pos)
{
return sin(pos.x * _WaveFrequency + _Time.y * _WaveSpeed) +
cos(pos.z * _WaveFrequency + _Time.y * _WaveSpeed);
}
#define EPSILON 0.01
void vert(inout appdata_full v)
{
// Get world position
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
// Displacement in world Y direction
float wave = Wave(worldPos);
float displacement = wave * _WaveAmplitude;
worldPos.y += displacement;
// Approximate normal in world space
float3 dx = float3(EPSILON, 0, 0);
float3 dz = float3(0, 0, EPSILON);
float wave_dx = Wave(worldPos + dx) * _WaveAmplitude;
float wave_dz = Wave(worldPos + dz) * _WaveAmplitude;
float3 tangentX = float3(1, (wave_dx - displacement) / EPSILON, 0);
float3 tangentZ = float3(0, (wave_dz - displacement) / EPSILON, 1);
float3 normalWS = normalize(cross(tangentZ, tangentX));
// Transform back to object space
v.vertex = mul(unity_WorldToObject, float4(worldPos, 1.0));
v.normal = mul((float3x3)unity_WorldToObject, normalWS);
}
void surf(Input IN, inout SurfaceOutputStandard o)
{
// Common UV for all texture arrays
float frame = fmod(floor(_Time.y * _FlipbookFPS), _FlipbookFrames); // Cyclic frame value
float3 uvw = float3(IN.uv_DiffuseArray, frame);
// Albedo with alpha
float4 diff = UNITY_SAMPLE_TEX2DARRAY(_DiffuseArray, uvw) * _Color;
//o.Alpha = diff.a;
o.Alpha = 1.0;
// Sample Metallic and smoothness (R = Metallic, A = Smoothness) plus slider variable
float4 metalGloss = UNITY_SAMPLE_TEX2DARRAY(_MetallicArray, uvw);
o.Metallic = metalGloss.r;
o.Smoothness = metalGloss.a * _Glossiness;
// Normal map and it's scale
float4 normalTex = UNITY_SAMPLE_TEX2DARRAY(_NormalArray, uvw);
float3 normalMap = UnpackNormal(normalTex);
normalMap.xy *= _Bumpyness;
float3 finalNormal = normalize(normalMap);
o.Normal = finalNormal;
// Grab screen texture (refraction)
float2 grabUV = IN.screenPos.xy / IN.screenPos.w;
grabUV += finalNormal.xy * _RefractAmount;
fixed4 grab = tex2D(_GrabTexture, grabUV);
o.Albedo = grab.rgb;
}
ENDCG
}
FallBack "Standard"
}

View File

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

Binary file not shown.

View File

@@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 6d12f12839d65184fb946fc564d7af58
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 1
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 4
singleChannelComponent: 0
flipbookRows: 29
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 8567a3f5204099046b774d80cdd69d56
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 1
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 1
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 1
textureShape: 4
singleChannelComponent: 0
flipbookRows: 29
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant: