fix:1
This commit is contained in:
8
Assets/Artwork/MeiGongZiYuan/Model/Water/Materials.meta
Normal file
8
Assets/Artwork/MeiGongZiYuan/Model/Water/Materials.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e195c05d74cab840bc66c4c3c6d9c44
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
111
Assets/Artwork/MeiGongZiYuan/Model/Water/Materials/water2.mat
Normal file
111
Assets/Artwork/MeiGongZiYuan/Model/Water/Materials/water2.mat
Normal file
@@ -0,0 +1,111 @@
|
||||
%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: water2
|
||||
m_Shader: {fileID: 4800000, guid: 388eebb4dcdd667488cf5cbae2859247, type: 3}
|
||||
m_ValidKeywords:
|
||||
- _BGWATER_SSR_ON
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
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}
|
||||
- _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}
|
||||
- _MainWave:
|
||||
m_Texture: {fileID: 2800000, guid: 3886b9ead27a5cf43a9df9c03c98f1b6, type: 3}
|
||||
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}
|
||||
- _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}
|
||||
- _SecondWave:
|
||||
m_Texture: {fileID: 2800000, guid: 4457dafb0271e844095acf636990e620, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BGWATER_DISNEY_DIFFUSE: 0
|
||||
- _BGWATER_ORTHO: 0
|
||||
- _BGWATER_SSR: 1
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _EnviromentIntensity: 2.48
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _MainWaveBumpScale: 1.24
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Roughness: 0.278
|
||||
- _SSRIntensity: 0.73
|
||||
- _SSRMaxSampleCount: 0
|
||||
- _SSRMaxSampleDistance: 12
|
||||
- _SSRSampleStep: 13.1
|
||||
- _SecondWaveBumpScale: 0.938
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SpecularIntensity: 1.03
|
||||
- _SpecularOffset: -0.213
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _UseSSR: 1
|
||||
- _WaterDepthOffset: 0.192
|
||||
- _WaterDistortScale: 4.92
|
||||
- _WaterMuddyScale: 0.87
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _MainWaveTilingOffset: {r: 20, g: 20, b: 8.32, a: 4}
|
||||
- _SecondWaveTilingOffset: {r: 20, g: 20, b: -4, a: -4}
|
||||
- _ThirdWaveTilingOffset: {r: 20, g: 20, b: -8, a: 2}
|
||||
- _WaterBaseColor: {r: 0.21658063, g: 0.2924528, b: 0.24085972, a: 1}
|
||||
- _WaterMuddyColor: {r: 0, g: 0.21673915, b: 0.3018868, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21c117254126c224ab8091c89fd69ffb
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Artwork/MeiGongZiYuan/Model/Water/Shaders.meta
Normal file
8
Assets/Artwork/MeiGongZiYuan/Model/Water/Shaders.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d896e78ee1d7744d845b5309824c056
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
Shader "BadDog/URP/BGWater"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Three Direction Wave)]
|
||||
_MainWave("Main Wave", 2D) = "white" {}
|
||||
_MainWaveBumpScale("Main Wave Bump Scale", Range(0, 2)) = 1
|
||||
_SecondWave("Second Wave", 2D) = "white" {}
|
||||
_SecondWaveBumpScale("Second Normal Bump Scale", Range(0, 2)) = 1
|
||||
_MainWaveTilingOffset("Main Wave Tiling Offset", Vector) = (1, 1, 1, 1)
|
||||
_SecondWaveTilingOffset("Second Wave Tiling Offset", Vector) = (1, 1, -1, 1)
|
||||
_ThirdWaveTilingOffset("Third Wave Tiling Offset", Vector) = (1, 1, 1, -1)
|
||||
|
||||
[Header(Water)]
|
||||
_WaterBaseColor("Water Base Color", Color) = (1.0, 1.0, 1.0, 1)
|
||||
|
||||
[Header(Muddy)]
|
||||
_WaterMuddyColor("Water Muddy Color", Color) = (1.0, 1.0, 1.0, 1)
|
||||
_WaterMuddyScale("Water Muddy Scale", Range(0, 2)) = 1
|
||||
_WaterDepthOffset("Water Depth Offset", Range(0, 1)) = 1
|
||||
|
||||
[Header(Specular)]
|
||||
_SpecularIntensity("Specular Intensity", Range(0, 8)) = 1
|
||||
|
||||
[Header(Refraction)]
|
||||
_WaterDistortScale("Distort Scale", Range(0, 10)) = 1
|
||||
|
||||
[Header(Enviroment Reflection)]
|
||||
_EnviromentIntensity("Enviroment Intensity", Range(0, 10)) = 1
|
||||
|
||||
[Header(Screen Space Reflection)]
|
||||
[Toggle] _BGWATER_SSR("Screen Space Reflection", Float) = 1.0
|
||||
_SSRMaxSampleCount("SSR Max Sample Count", Range(0, 64)) = 12
|
||||
_SSRSampleStep("SSR Sample Step", Range(4, 32)) = 16
|
||||
_SSRIntensity("SSR Intensity", Range(0, 2)) = 0.5
|
||||
|
||||
[Toggle] _BGWATER_ORTHO("Orthographic Camera", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"IgnoreProjector"="True"
|
||||
"Queue"="Transparent"
|
||||
"RenderType"="Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode" = "UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#if !defined(UNITY_PASS_FORWARDBASE)
|
||||
#define UNITY_PASS_FORWARDBASE
|
||||
#endif
|
||||
|
||||
#pragma vertex VertexForward
|
||||
#pragma fragment FragForward
|
||||
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ _BGWATER_SSR_ON
|
||||
#pragma multi_compile _ _BGWATER_ORTHO_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "./BGWaterBase.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "VertexLit"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 388eebb4dcdd667488cf5cbae2859247
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,98 @@
|
||||
#ifndef BADDOG_WATER_BASE
|
||||
#define BADDOG_WATER_BASE
|
||||
|
||||
sampler2D _MainWave;
|
||||
float4 _MainWave_ST;
|
||||
|
||||
sampler2D _SecondWave;
|
||||
float4 _SecondWave_ST;
|
||||
|
||||
half _MainWaveBumpScale;
|
||||
half _SecondWaveBumpScale;
|
||||
|
||||
half4 _MainWaveTilingOffset;
|
||||
half4 _SecondWaveTilingOffset;
|
||||
half4 _ThirdWaveTilingOffset;
|
||||
|
||||
half _WaterDepthOffset;
|
||||
half _WaterMuddyScale;
|
||||
half _WaterDistortScale;
|
||||
|
||||
half4 _WaterBaseColor;
|
||||
half4 _WaterMuddyColor;
|
||||
|
||||
half _SpecularIntensity;
|
||||
half _EnviromentIntensity;
|
||||
|
||||
half _SSRMaxSampleCount;
|
||||
half _SSRSampleStep;
|
||||
half _SSRIntensity;
|
||||
|
||||
TEXTURE2D(_CameraDepthTexture); SAMPLER(sampler_CameraDepthTexture);
|
||||
TEXTURE2D(_CameraOpaqueTexture); SAMPLER(sampler_CameraOpaqueTexture);
|
||||
|
||||
|
||||
#include "./BGWaterOrtho.hlsl"
|
||||
#include "./BGWaterStruct.hlsl"
|
||||
#include "./BGWaterSSR.hlsl"
|
||||
#include "./BGWaterLighting.hlsl"
|
||||
|
||||
|
||||
BGWaterVertexOutput VertexCommon(BGWaterVertexInput v)
|
||||
{
|
||||
BGWaterVertexOutput o = (BGWaterVertexOutput)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.pos = TransformObjectToHClip(v.vertex);
|
||||
|
||||
o.mainWaveUV.xy = v.texcoord * _MainWaveTilingOffset.xy + _Time.r * _MainWaveTilingOffset.zw * 0.1;
|
||||
o.secondWaveUV.xy = v.texcoord * _SecondWaveTilingOffset.xy + _Time.r * _SecondWaveTilingOffset.zw * 0.1;
|
||||
o.secondWaveUV.zw = v.texcoord * _ThirdWaveTilingOffset.xy + _Time.r * _ThirdWaveTilingOffset.zw * 0.1;
|
||||
|
||||
float3 worldPos = TransformObjectToWorld(v.vertex);
|
||||
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(v.normal, v.tangent);
|
||||
|
||||
o.worldNormalDir = float4(normalInput.normalWS, worldPos.x);
|
||||
o.worldTangentDir = float4(normalInput.tangentWS, worldPos.y);
|
||||
o.worldBitangentDir = float4(normalInput.bitangentWS, worldPos.z);
|
||||
|
||||
o.mainWaveUV.z = ComputeFogFactor(o.pos.z);
|
||||
|
||||
o.screenPos = ComputeScreenPos(o.pos);
|
||||
o.screenPos.z = -TransformWorldToView(worldPos).z;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
BGWaterVertexOutput VertexForward(BGWaterVertexInput vertexInput)
|
||||
{
|
||||
BGWaterVertexOutput vertexOutput = VertexCommon(vertexInput);
|
||||
return vertexOutput;
|
||||
}
|
||||
|
||||
half4 FragForward(BGWaterVertexOutput vertexOutput) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(vertexOutput);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(vertexOutput);
|
||||
|
||||
BGLightingData lightingData = PrepareLighting(vertexOutput);
|
||||
|
||||
// reflection + fog
|
||||
half3 reflection = GetReflectionWithSSR(vertexOutput, lightingData);
|
||||
reflection = MixFog(reflection, vertexOutput.mainWaveUV.z);
|
||||
|
||||
// refraction
|
||||
half4 refraction = GetRefraction(vertexOutput, lightingData);
|
||||
|
||||
// final
|
||||
half3 finalColor = lerp(refraction.rgb, reflection, refraction.a);
|
||||
|
||||
return half4(finalColor, 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6a7804a76d40ba41af23fff2a321be9
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,162 @@
|
||||
#ifndef BADDOG_WATER_LIGHTING
|
||||
#define BADDOG_WATER_LIGHTING
|
||||
|
||||
float3 WaveNormal(BGWaterVertexOutput vertexOutput)
|
||||
{
|
||||
half3 waterNormal1 = tex2D(_MainWave, vertexOutput.mainWaveUV.xy).xyz;
|
||||
half3 waterNormal2 = tex2D(_MainWave, vertexOutput.secondWaveUV.xy).xyz;
|
||||
half3 waterNormal3 = tex2D(_SecondWave, vertexOutput.secondWaveUV.zw).xyz;
|
||||
|
||||
half3 waterNormal = ((waterNormal1 + waterNormal2) * 0.6667 - 0.6667) * half3(_SecondWaveBumpScale, _SecondWaveBumpScale, 1);
|
||||
|
||||
waterNormal3 = waterNormal3 * 2 - 1;
|
||||
waterNormal += (waterNormal3 * half3(_MainWaveBumpScale, _MainWaveBumpScale, 1));
|
||||
|
||||
return normalize(TransformTangentToWorld(waterNormal, float3x3(vertexOutput.worldTangentDir.xyz, vertexOutput.worldBitangentDir.xyz, vertexOutput.worldNormalDir.xyz)));
|
||||
}
|
||||
|
||||
BGLightingData PrepareLighting(BGWaterVertexOutput vertexOutput)
|
||||
{
|
||||
BGLightingData lightingData = (BGLightingData)0;
|
||||
|
||||
lightingData.worldPos = float3(vertexOutput.worldNormalDir.w, vertexOutput.worldTangentDir.w, vertexOutput.worldBitangentDir.w);
|
||||
lightingData.worldNormal = WaveNormal(vertexOutput);
|
||||
lightingData.worldLightDir = normalize(_MainLightPosition.xyz);
|
||||
|
||||
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
lightingData.worldViewDir = normalize(UNITY_MATRIX_V[2].xyz);
|
||||
#else
|
||||
lightingData.worldViewDir = normalize(_WorldSpaceCameraPos.xyz - lightingData.worldPos);
|
||||
#endif
|
||||
|
||||
half3 H = normalize(lightingData.worldLightDir + lightingData.worldViewDir);
|
||||
|
||||
lightingData.NoL = saturate(dot(lightingData.worldLightDir, lightingData.worldNormal));
|
||||
lightingData.NoV = saturate(dot(lightingData.worldNormal, lightingData.worldViewDir));
|
||||
lightingData.NoH = saturate(dot(lightingData.worldNormal, H));
|
||||
lightingData.LoH = saturate(dot(lightingData.worldLightDir, H));
|
||||
lightingData.R = normalize(reflect(-lightingData.worldViewDir, lightingData.worldNormal));
|
||||
|
||||
lightingData.diffuseColor = _WaterBaseColor;
|
||||
lightingData.specularColor = half3(0.04, 0.04, 0.04);
|
||||
lightingData.lightColor = _MainLightColor.rgb;
|
||||
|
||||
lightingData.screenUV = vertexOutput.screenPos.xy / vertexOutput.screenPos.w;
|
||||
|
||||
#if defined(UNITY_SINGLE_PASS_STEREO)
|
||||
lightingData.screenUV.xy = UnityStereoTransformScreenSpaceTex(lightingData.screenUV.xy);
|
||||
#endif
|
||||
|
||||
return lightingData;
|
||||
}
|
||||
|
||||
half3 IndirectDiffuse(BGLightingData lightingData)
|
||||
{
|
||||
return SampleSH(lightingData.worldNormal);
|
||||
}
|
||||
|
||||
half3 Diffuse(BGLightingData lightingData)
|
||||
{
|
||||
return lightingData.lightColor * lightingData.NoL;
|
||||
}
|
||||
|
||||
half3 Specular(BGLightingData lightingData)
|
||||
{
|
||||
float D = (-0.004) / (lightingData.NoH * lightingData.NoH - 1.005);
|
||||
D *= D;
|
||||
|
||||
half x = 1 - lightingData.LoH;
|
||||
half x2 = x * x;
|
||||
half x5 = x2 * x2 * x;
|
||||
|
||||
float F = lightingData.specularColor + (1 - lightingData.specularColor) * x5;
|
||||
|
||||
return lightingData.lightColor * D * F * PI * _SpecularIntensity;
|
||||
}
|
||||
|
||||
half3 IndirectSpecular(BGLightingData lightingData)
|
||||
{
|
||||
half3 probe = GlossyEnvironmentReflection(lightingData.R, 0, 1);
|
||||
|
||||
half fresnelTerm = 1.0 - saturate(dot(lightingData.worldNormal, lightingData.worldViewDir));
|
||||
fresnelTerm *= fresnelTerm;
|
||||
fresnelTerm *= fresnelTerm;
|
||||
|
||||
return probe.rgb * lerp(lightingData.specularColor, 1, fresnelTerm);
|
||||
}
|
||||
|
||||
half4 GetSSRLighting(BGWaterVertexOutput vertexOutput, BGLightingData lightingData)
|
||||
{
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
float3 uvz = GetSSRUVZOrtho(vertexOutput, lightingData);
|
||||
#else
|
||||
float3 uvz = GetSSRUVZ(vertexOutput, lightingData);
|
||||
#endif
|
||||
|
||||
half3 ssrColor = lerp(half3(0, 0, 0), SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uvz.xy) * _SSRIntensity, uvz.z > 0);
|
||||
|
||||
return half4(ssrColor, uvz.z);
|
||||
}
|
||||
|
||||
half3 GetReflectionWithSSR(BGWaterVertexOutput vertexOutput, BGLightingData lightingData)
|
||||
{
|
||||
half3 indirectDiffuse = IndirectDiffuse(lightingData);
|
||||
half3 diffuse = Diffuse(lightingData);
|
||||
half3 specular = Specular(lightingData);
|
||||
half3 indirectSpecular = IndirectSpecular(lightingData);
|
||||
|
||||
#if defined(_BGWATER_SSR_ON)
|
||||
half4 ssrLighting = GetSSRLighting(vertexOutput, lightingData);
|
||||
indirectSpecular = lerp(lerp(indirectSpecular, ssrLighting.rgb, ssrLighting.a), ssrLighting, ssrLighting.a > 0.99);
|
||||
#endif
|
||||
|
||||
indirectSpecular *= _EnviromentIntensity;
|
||||
|
||||
return (indirectDiffuse + diffuse) * lightingData.diffuseColor + specular + indirectSpecular;
|
||||
}
|
||||
|
||||
half4 GetRefraction(BGWaterVertexOutput vertexOutput, BGLightingData lightingData)
|
||||
{
|
||||
float2 screenUV = lightingData.screenUV;
|
||||
float2 grabUV = screenUV;
|
||||
|
||||
half3 worldViewDir = normalize(lightingData.worldViewDir);
|
||||
half worldViewDirY = abs(worldViewDir.y);
|
||||
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
float depth = GetOrthoEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, screenUV));
|
||||
#else
|
||||
float depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, screenUV), _ZBufferParams);
|
||||
#endif
|
||||
depth = depth - vertexOutput.screenPos.z;
|
||||
|
||||
half2 deltaUV = lightingData.worldNormal.xz * _WaterDistortScale * saturate(depth) * worldViewDirY / vertexOutput.screenPos.z;
|
||||
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
float newDepth = GetOrthoEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, screenUV + deltaUV));
|
||||
#else
|
||||
float newDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, screenUV + deltaUV), _ZBufferParams);
|
||||
#endif
|
||||
newDepth = newDepth - vertexOutput.screenPos.z;
|
||||
|
||||
half signDepth = saturate(newDepth * 10);
|
||||
grabUV = grabUV + deltaUV * signDepth;
|
||||
|
||||
depth = lerp(depth, newDepth, signDepth);
|
||||
|
||||
half viewMultiplier = (worldViewDirY + _WaterMuddyScale) * _WaterDepthOffset * _WaterDepthOffset;
|
||||
depth *= viewMultiplier;
|
||||
|
||||
half alpha = saturate(1 - depth);
|
||||
alpha = saturate(1.02 - pow(alpha, (dot(lightingData.worldNormal.xyz, worldViewDir) * 5 + 6)));
|
||||
|
||||
half4 refraction = SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, grabUV);
|
||||
refraction.rgb = lerp(refraction.rgb, refraction.rgb * _WaterMuddyColor * _WaterMuddyScale, alpha);
|
||||
refraction.a = alpha;
|
||||
|
||||
return refraction;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fd257daea5dd4d4e9099a02f23df58b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef BADDOG_WATER_ORTHO
|
||||
#define BADDOG_WATER_ORTHO
|
||||
|
||||
inline float GetOrthoEyeDepth(float rawDepth)
|
||||
{
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
#if UNITY_REVERSED_Z == 1
|
||||
rawDepth = 1.0f - rawDepth;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return lerp(_ProjectionParams.y, _ProjectionParams.z, rawDepth);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bc9c6313a3c40341a7840e748152130
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
158
Assets/Artwork/MeiGongZiYuan/Model/Water/Shaders/BGWaterSSR.hlsl
Normal file
158
Assets/Artwork/MeiGongZiYuan/Model/Water/Shaders/BGWaterSSR.hlsl
Normal file
@@ -0,0 +1,158 @@
|
||||
#ifndef BADDOG_WATER_SSR
|
||||
#define BADDOG_WATER_SSR
|
||||
|
||||
float UVJitter(in float2 uv)
|
||||
{
|
||||
return frac((52.9829189 * frac(dot(uv, float2(0.06711056, 0.00583715)))));
|
||||
}
|
||||
|
||||
void SSRRayConvert(float3 worldPos, out float4 clipPos, out float3 screenPos)
|
||||
{
|
||||
clipPos = TransformWorldToHClip(worldPos);
|
||||
float k = ((1.0) / (clipPos.w));
|
||||
|
||||
screenPos.xy = ComputeScreenPos(clipPos).xy * k;
|
||||
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
screenPos.z = GetOrthoEyeDepth(clipPos.z);
|
||||
clipPos.w = screenPos.z;
|
||||
#else
|
||||
screenPos.z = k;
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_SINGLE_PASS_STEREO)
|
||||
screenPos.xy = UnityStereoTransformScreenSpaceTex(screenPos.xy);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 SSRRayMarch(BGWaterVertexOutput vertexOutput, BGLightingData lightingData)
|
||||
{
|
||||
float4 startClipPos;
|
||||
float3 startScreenPos;
|
||||
|
||||
SSRRayConvert(lightingData.worldPos, startClipPos, startScreenPos);
|
||||
|
||||
float4 endClipPos;
|
||||
float3 endScreenPos;
|
||||
|
||||
SSRRayConvert(lightingData.worldPos + lightingData.R, endClipPos, endScreenPos);
|
||||
|
||||
if (((endClipPos.w) < (startClipPos.w)))
|
||||
{
|
||||
return float3(0, 0, 0);
|
||||
}
|
||||
|
||||
float3 screenDir = endScreenPos - startScreenPos;
|
||||
|
||||
float screenDirX = abs(screenDir.x);
|
||||
float screenDirY = abs(screenDir.y);
|
||||
|
||||
float dirMultiplier = lerp( 1 / (_ScreenParams.y * screenDirY), 1 / (_ScreenParams.x * screenDirX), screenDirX > screenDirY ) * _SSRSampleStep;
|
||||
|
||||
screenDir *= dirMultiplier;
|
||||
|
||||
half lastRayDepth = startClipPos.w;
|
||||
|
||||
half sampleCount = 1 + UVJitter(vertexOutput.pos) * 0.1;
|
||||
|
||||
float3 lastScreenMarchUVZ = startScreenPos;
|
||||
float lastDeltaDepth = 0;
|
||||
|
||||
#if defined (SHADER_API_OPENGL) || defined (SHADER_API_D3D11) || defined (SHADER_API_D3D12)
|
||||
[unroll(64)]
|
||||
#else
|
||||
UNITY_LOOP
|
||||
#endif
|
||||
for(int i = 0; i < _SSRMaxSampleCount; i++)
|
||||
{
|
||||
float3 screenMarchUVZ = startScreenPos + screenDir * sampleCount;
|
||||
|
||||
if((screenMarchUVZ.x <= 0) || (screenMarchUVZ.x >= 1) || (screenMarchUVZ.y <= 0) || (screenMarchUVZ.y >= 1))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
float sceneDepth = GetOrthoEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, screenMarchUVZ.xy));
|
||||
#else
|
||||
float sceneDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, screenMarchUVZ.xy), _ZBufferParams);
|
||||
#endif
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
half rayDepth = screenMarchUVZ.z;
|
||||
#else
|
||||
half rayDepth = 1.0 / screenMarchUVZ.z;
|
||||
#endif
|
||||
half deltaDepth = rayDepth - sceneDepth;
|
||||
|
||||
if((deltaDepth > 0) && (sceneDepth > startClipPos.w) && (deltaDepth < (abs(rayDepth - lastRayDepth) * 2)))
|
||||
{
|
||||
float samplePercent = saturate(lastDeltaDepth / (lastDeltaDepth - deltaDepth));
|
||||
samplePercent = lerp(samplePercent, 1, rayDepth >= _ProjectionParams.z);
|
||||
float3 hitScreenUVZ = lerp(lastScreenMarchUVZ, screenMarchUVZ, samplePercent);
|
||||
return float3(hitScreenUVZ.xy, 1);
|
||||
}
|
||||
|
||||
lastRayDepth = rayDepth;
|
||||
sampleCount += 1;
|
||||
|
||||
lastScreenMarchUVZ = screenMarchUVZ;
|
||||
lastDeltaDepth = deltaDepth;
|
||||
}
|
||||
|
||||
float4 farClipPos;
|
||||
float3 farScreenPos;
|
||||
|
||||
SSRRayConvert(lightingData.worldPos + lightingData.R * 100000, farClipPos, farScreenPos);
|
||||
|
||||
if((farScreenPos.x > 0) && (farScreenPos.x < 1) && (farScreenPos.y > 0) && (farScreenPos.y < 1))
|
||||
{
|
||||
#if defined(_BGWATER_ORTHO_ON)
|
||||
float farDepth = GetOrthoEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, farScreenPos.xy));
|
||||
#else
|
||||
float farDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, farScreenPos.xy), _ZBufferParams);
|
||||
#endif
|
||||
|
||||
if(farDepth > startClipPos.w)
|
||||
{
|
||||
return float3(farScreenPos.xy, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return float3(0, 0, 0);
|
||||
}
|
||||
|
||||
float3 GetSSRUVZ(BGWaterVertexOutput vertexOutput, BGLightingData lightingData)
|
||||
{
|
||||
#if defined(UNITY_SINGLE_PASS_STEREO)
|
||||
half ssrWeight = 1;
|
||||
|
||||
half NoV = lightingData.NoV * 2;
|
||||
ssrWeight *= (1 - NoV * NoV);
|
||||
#else
|
||||
float screenUV = lightingData.screenUV * 2 - 1;
|
||||
screenUV *= screenUV;
|
||||
|
||||
half ssrWeight = saturate(1 - dot(screenUV, screenUV));
|
||||
|
||||
half NoV = lightingData.NoV * 2.5;
|
||||
ssrWeight *= (1 - NoV * NoV);
|
||||
#endif
|
||||
|
||||
if (ssrWeight > 0.005)
|
||||
{
|
||||
float3 uvz = SSRRayMarch(vertexOutput, lightingData);
|
||||
uvz.z *= ssrWeight;
|
||||
return uvz;
|
||||
}
|
||||
|
||||
return float3(0, 0, 0);
|
||||
}
|
||||
|
||||
float3 GetSSRUVZOrtho(BGWaterVertexOutput vertexOutput, BGLightingData lightingData)
|
||||
{
|
||||
float3 uvz = SSRRayMarch(vertexOutput, lightingData);
|
||||
return uvz;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0426b0a130788f849bf700b6735531aa
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef BADDOG_WATER_STRUCT
|
||||
#define BADDOG_WATER_STRUCT
|
||||
|
||||
struct BGWaterVertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent: TANGENT;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct BGWaterVertexOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
|
||||
float3 mainWaveUV : TEXCOORD0;
|
||||
float4 secondWaveUV : TEXCOORD1;
|
||||
|
||||
float4 worldNormalDir : TEXCOORD2;
|
||||
float4 worldTangentDir : TEXCOORD3;
|
||||
float4 worldBitangentDir : TEXCOORD4;
|
||||
|
||||
float4 screenPos : TEXCOORD5;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct BGLightingData
|
||||
{
|
||||
float3 worldPos;
|
||||
float3 worldNormal;
|
||||
float3 worldLightDir;
|
||||
float3 worldViewDir;
|
||||
|
||||
half NoL;
|
||||
half NoV;
|
||||
half NoH;
|
||||
half LoH;
|
||||
|
||||
half3 R;
|
||||
|
||||
half3 diffuseColor;
|
||||
half3 specularColor;
|
||||
half3 lightColor;
|
||||
|
||||
float2 screenUV;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f69fde22446968408fb0bb98a80c482
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Artwork/MeiGongZiYuan/Model/Water/Textures.meta
Normal file
8
Assets/Artwork/MeiGongZiYuan/Model/Water/Textures.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9dd3ae0e34ba1d449bce2c062b98146
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Artwork/MeiGongZiYuan/Model/Water/Textures/Normal1.png
Normal file
BIN
Assets/Artwork/MeiGongZiYuan/Model/Water/Textures/Normal1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 402 KiB |
@@ -0,0 +1,112 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3886b9ead27a5cf43a9df9c03c98f1b6
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
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
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
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: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Artwork/MeiGongZiYuan/Model/Water/Textures/Normal2.png
Normal file
BIN
Assets/Artwork/MeiGongZiYuan/Model/Water/Textures/Normal2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 133 KiB |
@@ -0,0 +1,112 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4457dafb0271e844095acf636990e620
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
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
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
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: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user