浏览代码

* Fixed XR single pass instanced mode and multiview mode.

/main
thomas-zeng 5 年前
当前提交
fe02dad1
共有 4 个文件被更改,包括 15 次插入9 次删除
  1. 4
      Packages/com.verasl.water-system/Scripts/Rendering/WaterSystemFeature.cs
  2. 8
      Packages/com.verasl.water-system/Shaders/WaterCommon.hlsl
  3. 6
      Packages/com.verasl.water-system/Shaders/WaterFXShader.shader
  4. 6
      Packages/com.verasl.water-system/Shaders/WaterInput.hlsl

4
Packages/com.verasl.water-system/Scripts/Rendering/WaterSystemFeature.cs


cameraTextureDescriptor.colorFormat = RenderTextureFormat.Default;
// get a temp RT for rendering into
cmd.GetTemporaryRT(m_WaterFX.id, cameraTextureDescriptor, FilterMode.Bilinear);
ConfigureTarget(m_WaterFX.Identifier());
ConfigureTarget(new RenderTargetIdentifier(m_WaterFX.Identifier(), 0, CubemapFace.Unknown, -1));
// clear the screen with a specific color for the packed data
ConfigureClear(ClearFlag.Color, m_ClearColor);
}

8
Packages/com.verasl.water-system/Shaders/WaterCommon.hlsl


float2 AdjustedDepth(half2 uvs, half4 additionalData)
{
float rawD = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_ScreenTextures_linear_clamp, uvs);
float rawD = SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_ScreenTextures_linear_clamp, uvs).r;
float d = LinearEyeDepth(rawD, _ZBufferParams);
return float2(d * additionalData.x - additionalData.y, (rawD * -_ProjectionParams.x) + (1-UNITY_REVERSED_Z));
}

half3 Refraction(half2 distortion, half depth, real depthMulti)
{
half3 output = SAMPLE_TEXTURE2D_LOD(_CameraOpaqueTexture, sampler_CameraOpaqueTexture_linear_clamp, distortion, depth * 0.25).rgb;
half3 output = SAMPLE_TEXTURE2D_X_LOD(_CameraOpaqueTexture, sampler_CameraOpaqueTexture_linear_clamp, distortion, depth * 0.25).rgb;
output *= Absorption((depth) * depthMulti);
return output;
}

#endif
// Dynamic displacement
half4 waterFX = SAMPLE_TEXTURE2D_LOD(_WaterFXMap, sampler_ScreenTextures_linear_clamp, screenUV.xy, 0);
half4 waterFX = SAMPLE_TEXTURE2D_X_LOD(_WaterFXMap, sampler_ScreenTextures_linear_clamp, screenUV.xy, 0);
input.posWS.y += waterFX.w * 2 - 1;
// After waves

UNITY_SETUP_INSTANCE_ID(IN);
half3 screenUV = IN.shadowCoord.xyz / IN.shadowCoord.w;//screen UVs
half4 waterFX = SAMPLE_TEXTURE2D(_WaterFXMap, sampler_ScreenTextures_linear_clamp, IN.preWaveSP.xy);
half4 waterFX = SAMPLE_TEXTURE2D_X(_WaterFXMap, sampler_ScreenTextures_linear_clamp, IN.preWaveSP.xy);
// Depth
float3 depth = WaterDepth(IN.posWS, IN.additionalData, screenUV.xy);// TODO - hardcoded shore depth UVs

6
Packages/com.verasl.water-system/Shaders/WaterFXShader.shader


float4 tangentOS : TANGENT;
half4 color : COLOR;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings

half4 bitangent : TEXCOORD3; // xyz: binormal, w: viewDir.z
half4 color : TEXCOORD4;
float4 vertex : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;

Varyings output = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexPosition = GetVertexPositionInputs(input.positionOS.xyz);
VertexNormalInputs vertexTBN = GetVertexNormalInputs(input.normalOS, input.tangentOS);

6
Packages/com.verasl.water-system/Shaders/WaterInput.hlsl


TEXTURECUBE(_CubemapTexture);
SAMPLER(sampler_CubemapTexture);
#endif
TEXTURE2D(_WaterFXMap);
TEXTURE2D(_CameraDepthTexture);
TEXTURE2D(_CameraOpaqueTexture); SAMPLER(sampler_CameraOpaqueTexture_linear_clamp);
TEXTURE2D_X(_WaterFXMap);
TEXTURE2D_X(_CameraDepthTexture);
TEXTURE2D_X(_CameraOpaqueTexture); SAMPLER(sampler_CameraOpaqueTexture_linear_clamp);
TEXTURE2D(_WaterDepthMap); SAMPLER(sampler_WaterDepthMap_linear_clamp);

正在加载...
取消
保存