浏览代码

Fixed distortion scale

/main
Thomas 6 年前
当前提交
f49d867e
共有 2 个文件被更改,包括 3 次插入4 次删除
  1. 2
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  2. 5
      com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/ApplyDistorsion.compute

2
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


using (new ProfilingSample(cmd, "ApplyDistortion", CustomSamplerId.ApplyDistortion.GetSampler()))
{
var size = new Vector4(hdCamera.screenSize.x, hdCamera.screenSize.y);
var size = new Vector4(hdCamera.actualWidth, hdCamera.actualHeight, 1f / hdCamera.actualWidth, 1f / hdCamera.actualHeight);
uint x, y, z;
m_applyDistortionCS.GetKernelThreadGroupSizes(m_applyDistortionKernel, out x, out y, out z);
cmd.SetComputeTextureParam(m_applyDistortionCS, m_applyDistortionKernel, HDShaderIDs._DistortionTexture, m_DistortionBuffer);

5
com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/ApplyDistorsion.compute


#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "HDRP/Material/Builtin/BuiltinData.hlsl"
#include "HDRP/ShaderVariables.hlsl"
TEXTURE2D(_ColorPyramidTexture);
RW_TEXTURE2D(float4, _Destination);
SamplerState sampler_ColorPyramidTexture;

float4 _ColorPyramidScale;
CBUFFER_END
#pragma kernel KMain

return;
// Get source pixel for distortion
float2 distordedUV = float2(dispatchThreadId + int2(distortion * _FetchBias)) * _Size.zw;
float2 distordedUV = float2(dispatchThreadId + int2(distortion * _FetchBias)) * _Size.zw * _ScreenToTargetScale.xy;
float mip = (_ColorPyramidScale.z - 1) * clamp(distortionBlur, 0.0, 1.0);
float4 sampled = SAMPLE_TEXTURE2D_LOD(_ColorPyramidTexture, sampler_ColorPyramidTexture, distordedUV, mip);
正在加载...
取消
保存