浏览代码

[PlanarReflection] Discard pixels out of oblique frustrum wen samplign environment

/main
Frédéric Vauchelles 7 年前
当前提交
6f37bc42
共有 2 个文件被更改,包括 11 次插入5 次删除
  1. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  2. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemInternal.cs

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


if (cacheType == ENVCACHETYPE_TEXTURE2D)
{
float2 ndc = ComputeNormalizedDeviceCoordinates(_Env2DCapturePositionWS[index] + texCoord, _Env2DCaptureVP[index]);
weight = any(ndc < 0) || any(ndc > 1) ? 0 : 1;
return SAMPLE_TEXTURE2D_ARRAY_LOD(_Env2DTextures, s_trilinear_clamp_sampler, ndc, index, 0);
float4 color = SAMPLE_TEXTURE2D_ARRAY_LOD(_Env2DTextures, s_trilinear_clamp_sampler, ndc, index, 0);
// Discard pixels out of oblique projection
// We only check RGB because the texture may have BC6H compression
weight = any(ndc < 0) || any(ndc > 1) || all(color.rgb >= 1000) ? 0 : 1;
return color;
}
else if (cacheType == ENVCACHETYPE_CUBEMAP)
{

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemInternal.cs


using System;
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering.HDPipeline.Internal

// -FLT_MAX in hlsl
static readonly Color k_DiscardedColor = new Color(1000, 1000, 1000, 1000);
static Camera s_RenderCamera = null;
static HDAdditionalCameraData s_RenderCameraData;

camera.fieldOfView = fov;
camera.aspect = aspect;
camera.clearFlags = clearFlags;
camera.backgroundColor = backgroundColor;
// TODO: Find a cleaner way to discard pixel out of frustrum
camera.backgroundColor = k_DiscardedColor;
camera.projectionMatrix = projection;
camera.worldToCameraMatrix = worldToCamera;

正在加载...
取消
保存