浏览代码

Merge pull request #1618 from Unity-Technologies/lw/vr-postfx-fix

Fixes issue #1595. [DON'T MERGE YET. This PR depends on another PostFX PR]
/main
GitHub 6 年前
当前提交
0783dfdf
共有 3 个文件被更改,包括 29 次插入29 次删除
  1. 1
      com.unity.render-pipelines.lightweight/CHANGELOG.md
  2. 29
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
  3. 28
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs

1
com.unity.render-pipelines.lightweight/CHANGELOG.md


- Updated the UI for the Lighweight pipeline asset.
### Fixed
- Post-processing now works with VR on PC.
- PS4 compiler error
- Fixed VR multiview rendering by forcing MSAA to be off. There's a current issue in engine that breaks MSAA and Texture2DArray.
- Fixed UnityPerDraw CB layout

29
com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs


}
}
public static void RenderPostProcess(CommandBuffer cmd, PostProcessRenderContext context, ref CameraData cameraData, RenderTextureFormat colorFormat, RenderTargetIdentifier source, RenderTargetIdentifier dest, bool opaqueOnly)
{
context.Reset();
context.camera = cameraData.camera;
context.source = source;
context.sourceFormat = colorFormat;
context.destination = dest;
context.command = cmd;
context.flip = cameraData.camera.targetTexture == null;
if (opaqueOnly)
cameraData.postProcessLayer.RenderOpaqueOnly(context);
else
cameraData.postProcessLayer.Render(context);
}
void SetSupportedRenderingFeatures()
{
#if UNITY_EDITOR

cameraData.postProcessLayer = camera.GetComponent<PostProcessLayer>();
cameraData.postProcessEnabled = cameraData.postProcessLayer != null && cameraData.postProcessLayer.isActiveAndEnabled;
// PostProcess for VR is not working atm. Disable it for now.
cameraData.postProcessEnabled &= !cameraData.isStereoEnabled;
Rect cameraRect = camera.rect;
cameraData.isDefaultViewport = (!(Math.Abs(cameraRect.x) > 0.0f || Math.Abs(cameraRect.y) > 0.0f ||

float cameraWidth = (float)cameraData.camera.pixelWidth * cameraData.renderScale;
float cameraHeight = (float)cameraData.camera.pixelWidth * cameraData.renderScale;
Shader.SetGlobalVector(PerCameraBuffer._ScaledScreenParams, new Vector4(cameraWidth, cameraHeight, 1.0f + 1.0f / cameraWidth, 1.0f + 1.0f / cameraHeight));
}
bool IsStereoEnabled(Camera camera)
{
#if !UNITY_SWITCH
bool isSceneViewCamera = camera.cameraType == CameraType.SceneView;
return XRSettings.isDeviceActive && !isSceneViewCamera && (camera.stereoTargetEye == StereoTargetEyeMask.Both);
#else
return false;
#endif
}
}
}

28
com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs


using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.XR;
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{

public static bool IsSupportedCookieType(LightType lightType)
{
return lightType == LightType.Directional || lightType == LightType.Spot;
}
public static bool IsStereoEnabled(Camera camera)
{
#if !UNITY_SWITCH
bool isSceneViewCamera = camera.cameraType == CameraType.SceneView;
return XRSettings.isDeviceActive && !isSceneViewCamera && (camera.stereoTargetEye == StereoTargetEyeMask.Both);
#else
return false;
#endif
}
public static void RenderPostProcess(CommandBuffer cmd, PostProcessRenderContext context, ref CameraData cameraData, RenderTextureFormat colorFormat, RenderTargetIdentifier source, RenderTargetIdentifier dest, bool opaqueOnly)
{
Camera camera = cameraData.camera;
context.Reset();
context.camera = camera;
context.source = source;
context.sourceFormat = colorFormat;
context.destination = dest;
context.command = cmd;
context.flip = !IsStereoEnabled(camera) && camera.targetTexture == null;
if (opaqueOnly)
cameraData.postProcessLayer.RenderOpaqueOnly(context);
else
cameraData.postProcessLayer.Render(context);
}
}
}
正在加载...
取消
保存