Felipe Lira
5 年前
当前提交
d47cf909
共有 8 个文件被更改,包括 252 次插入 和 5 次删除
-
2Assets/Data/UniversalRP/CustomBoatDemoRenderer.asset
-
18Assets/Rendering/BoatRenderer.cs
-
1Assets/Rendering/BoatRendererData.cs
-
11Assets/Rendering/MainRenderPass.cs
-
113Packages/com.verasl.water-system/CausticsModified.mat
-
8Packages/com.verasl.water-system/CausticsModified.mat.meta
-
95Packages/com.verasl.water-system/Shaders/CausticsModified.shader
-
9Packages/com.verasl.water-system/Shaders/CausticsModified.shader.meta
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &-3341692864896818629 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 11 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
version: 1 |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: CausticsModified |
|||
m_Shader: {fileID: 4800000, guid: a7e6cd2d14dfc49d188a4707edf9a870, type: 3} |
|||
m_ShaderKeywords: |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- Texture2DArray_29EA5301: |
|||
m_Texture: {fileID: 18700000, guid: 2bf4e75081aab4b5f88bfb7069f598ac, type: 2} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- Texture2D_A294F6AA: |
|||
m_Texture: {fileID: 2800000, guid: f395b7d64f44848c6a3cba1f1173fe90, type: 3} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _BaseMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _CameraDepthTexture: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _CausticMap: |
|||
m_Texture: {fileID: 2800000, guid: f395b7d64f44848c6a3cba1f1173fe90, 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} |
|||
- _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} |
|||
- _SpecGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- Vector1_CD857B77: 0.47 |
|||
- Vector1_DC11883E: 0.5 |
|||
- Vector1_E85F4D08: -0.15 |
|||
- Vector1_EA2AE021: 0.4 |
|||
- Vector1_F3303B3C: 0.5 |
|||
- _AlphaClip: 0 |
|||
- _Blend: 0 |
|||
- _BlendDistance: 2 |
|||
- _BumpScale: 1 |
|||
- _Cull: 2 |
|||
- _Cutoff: 0.5 |
|||
- _DstBlend: 0 |
|||
- _EnvironmentReflections: 1 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _QueueOffset: 0 |
|||
- _ReceiveShadows: 1 |
|||
- _Size: 0.25 |
|||
- _Smoothness: 0.5 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 1 |
|||
- _SrcBlend: 1 |
|||
- _Surface: 0 |
|||
- _WaterLevel: -0.625 |
|||
- _WorkflowMode: 1 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _BaseColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} |
|||
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: f09f40ad472134250a9e0ad60dd212f0 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 2100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Hidden/BoatAttack/CausticsModified" |
|||
{ |
|||
Properties |
|||
{ |
|||
//Vector1_F3303B3C("Speed", Float) = 0.5 |
|||
_Size("Size", Float) = 0.5 |
|||
[NoScaleOffset]_CausticMap("Caustics", 2D) = "white" {} |
|||
_WaterLevel("WaterLevel", Float) = -0.25 |
|||
_BlendDistance("BlendDistance", Float) = 0.1 |
|||
//Vector1_CD857B77("CausticsRGB Split", Float) = 2 |
|||
} |
|||
SubShader |
|||
{ |
|||
// No culling or depth |
|||
Cull Off |
|||
ZWrite Off |
|||
ZTest Always |
|||
|
|||
Pass |
|||
{ |
|||
Blend DstColor Zero, One Zero |
|||
HLSLPROGRAM |
|||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
struct Attributes |
|||
{ |
|||
float4 positionOS : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
float4 positionOS : SV_POSITION; |
|||
}; |
|||
|
|||
TEXTURE2D(_CameraDepthTexture); SAMPLER(sampler_CameraDepthTexture); |
|||
TEXTURE2D(_CausticMap); SAMPLER(sampler_CausticMap); |
|||
|
|||
half _Size; |
|||
half _WaterLevel; |
|||
half _BlendDistance; |
|||
|
|||
float3 ReconstructWorldPos(half2 screenPos, float depth) |
|||
{ |
|||
// World Pos reconstriction |
|||
float4 raw = mul(UNITY_MATRIX_I_VP, float4(screenPos * 2 - 1, depth, 1)); |
|||
float3 worldPos = raw.rgb / raw.a; |
|||
return worldPos; |
|||
} |
|||
|
|||
// Can be done per-vertex |
|||
float2 CausticUVs(float2 rawUV, float2 offset) |
|||
{ |
|||
//anim |
|||
float2 uv = rawUV * _Size + float2(_Time.y, _Time.x) * 0.1; |
|||
return uv + offset * 0.25; |
|||
} |
|||
|
|||
Varyings vert (Attributes input) |
|||
{ |
|||
Varyings output; |
|||
output.positionOS = float4(input.positionOS.xyz, 1.0); |
|||
output.uv = float2(input.uv.x, 1.0 - input.uv.y); |
|||
return output; |
|||
} |
|||
|
|||
sampler2D _MainTex; |
|||
|
|||
real4 frag (Varyings input) : SV_Target |
|||
{ |
|||
real depth = SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, sampler_CameraDepthTexture, input.uv); |
|||
|
|||
float3 worldPos = ReconstructWorldPos(input.uv, depth); |
|||
float waveOffset = SAMPLE_TEXTURE2D(_CausticMap, sampler_CausticMap, worldPos.xz * 0.025 + _Time.x * 0.25).w - 0.5; |
|||
|
|||
float2 causticUV = CausticUVs(worldPos.xz, waveOffset); |
|||
|
|||
float3 caustics = SAMPLE_TEXTURE2D(_CausticMap, sampler_CausticMap, causticUV).bbb; |
|||
|
|||
half upperMask = saturate(-worldPos.y + _WaterLevel); |
|||
half lowerMask = saturate((worldPos.y - _WaterLevel) / _BlendDistance + _BlendDistance); |
|||
|
|||
caustics *= min(upperMask, lowerMask) * 1.5; |
|||
|
|||
//return half4(waveOffset.xx, 0, 1); |
|||
return half4(caustics + 1, 1); |
|||
} |
|||
ENDHLSL |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a7e6cd2d14dfc49d188a4707edf9a870 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue