浏览代码

RenderScale -> TargetScale; added groundwork for ViewportScale

/main
Nerites 7 年前
当前提交
71589903
共有 5 个文件被更改,包括 88 次插入18 次删除
  1. 50
      com.unity.render-pipelines.lightweight/LWRP/Data/LightweightPipelineAsset.cs
  2. 40
      com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightPipelineAssetEditor.cs
  3. 4
      com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs
  4. 10
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
  5. 2
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs

50
com.unity.render-pipelines.lightweight/LWRP/Data/LightweightPipelineAsset.cs


[SerializeField] Downsampling m_OpaqueDownsampling = Downsampling._2xBilinear;
[SerializeField] bool m_SupportsHDR = false;
[SerializeField] MSAAQuality m_MSAA = MSAAQuality._4x;
[SerializeField] float m_RenderScale = 1.0f;
[SerializeField] float m_TargetScale = 1.0f;
[SerializeField] float m_ViewportScale = 1.0f;
[SerializeField] bool m_SupportsDynamicBatching = true;
[SerializeField] bool m_DirectionalShadowsSupported = true;

[SerializeField] bool m_KeepSoftShadowVariants = true;
[SerializeField] LightweightPipelineResources m_ResourcesAsset;
[SerializeField] bool m_XREnabled = false;
// Deprecated
[SerializeField] ShadowType m_ShadowType = ShadowType.HARD_SHADOWS;

set { m_MSAA = (MSAAQuality)value; }
}
public float renderScale
public float TargetScale
{
get // FIXME race conditions?
{
//if (m_XREnabled)
// m_TargetScale = UnityEngine.XR.XRSettings.eyeTextureResolutionScale;
return m_TargetScale;
}
set
{
if (m_XREnabled)
UnityEngine.XR.XRSettings.eyeTextureResolutionScale = value;
m_TargetScale = value;
}
}
public float ViewportScale
{
get // FIXME race conditions?
{
//if (m_XREnabled)
// m_ViewportScale = UnityEngine.XR.XRSettings.renderViewportScale;
return m_ViewportScale;
}
set
{
if (m_XREnabled)
UnityEngine.XR.XRSettings.renderViewportScale = value;
m_ViewportScale = value;
}
}
public bool XREnabled
get { return m_RenderScale; }
set { m_RenderScale = value; }
get
{
return m_XREnabled;
}
set
{
UnityEngine.XR.XRSettings.enabled = value;
m_XREnabled = value;
}
}
public bool supportsDynamicBatching

40
com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightPipelineAssetEditor.cs


public static GUIContent localShadowLabel = new GUIContent("Local Shadows");
public static GUIContent capabilitiesLabel = new GUIContent("Capabilities");
public static GUIContent renderScaleLabel = new GUIContent("Render Scale", "Scales the camera render target allowing the game to render at a resolution different than native resolution. UI is always rendered at native resolution. When in VR mode, VR scaling configuration is used instead.");
public static GUIContent TargetScaleLabel = new GUIContent("Target Scale", "Scales the camera render target allowing the game to render at a resolution different than native resolution. UI is always rendered at native resolution. When in VR mode, analogous to XRSettings.eyeTextureResolutionScale.");
public static GUIContent ViewportScaleLabel = new GUIContent("Viewport Scale", "Scales the camera render viewport without resizing camera render target. When in VR mode, analogous to XRSettings.renderViewportScale.");
public static GUIContent maxPixelLightsLabel = new GUIContent("Pixel Lights",
"Controls the amount of pixel lights that run in fragment light loop. Lights are sorted and culled per-object.");

public static string[] shadowCascadeOptions = {"No Cascades", "Two Cascades", "Four Cascades"};
public static string[] opaqueDownsamplingOptions = {"None", "2x (Bilinear)", "4x (Box)", "4x (Bilinear)"};
public static GUIContent xrSettingsLabel = new GUIContent("XR Settings");
public static GUIContent xrEnabled = EditorGUIUtility.TrTextContent("XR Enabled");
}
public static class StrippingStyles

AnimBool m_ShowSoftParticles = new AnimBool();
AnimBool m_ShowOpaqueTextureScale = new AnimBool();
AnimBool m_ShowXREnabled = new AnimBool();
float k_MinRenderScale = 0.1f;
float k_MaxRenderScale = 4.0f;
SerializedProperty m_RenderScale;
float k_MinTargetScale = 0.1f;
float k_MaxTargetScale = 4.0f;
float k_MinViewportScale = 0.1f;
float k_MaxViewportScale = 1.0f;
SerializedProperty m_TargetScale;
SerializedProperty m_ViewportScale;
SerializedProperty m_MaxPixelLights;
SerializedProperty m_SupportsVertexLightProp;
SerializedProperty m_RequireDepthTextureProp;

SerializedProperty m_CustomShaderVariantStripSettingsProp;
SerializedProperty m_XREnabledProp;
DrawXRSettings();
serializedObject.ApplyModifiedProperties();
}

m_RenderScale = serializedObject.FindProperty("m_RenderScale");
m_TargetScale = serializedObject.FindProperty("m_TargetScale");
m_ViewportScale = serializedObject.FindProperty("m_ViewportScale");
m_MaxPixelLights = serializedObject.FindProperty("m_MaxPixelLights");
m_SupportsVertexLightProp = serializedObject.FindProperty("m_SupportsVertexLight");
m_RequireDepthTextureProp = serializedObject.FindProperty("m_RequireDepthTexture");

m_HDR = serializedObject.FindProperty("m_SupportsHDR");
m_MSAA = serializedObject.FindProperty("m_MSAA");
m_SupportsDynamicBatching = serializedObject.FindProperty("m_SupportsDynamicBatching");
m_XREnabledProp = serializedObject.FindProperty("m_XREnabled");
m_DirectionalShadowsSupportedProp = serializedObject.FindProperty("m_DirectionalShadowsSupported");
m_ShadowDistanceProp = serializedObject.FindProperty("m_ShadowDistance");

m_ShowSoftParticles.value = m_RequireSoftParticlesProp.boolValue;
m_ShowOpaqueTextureScale.valueChanged.AddListener(Repaint);
m_ShowOpaqueTextureScale.value = m_RequireOpaqueTextureProp.boolValue;
m_ShowXREnabled.valueChanged.AddListener(Repaint);
m_ShowXREnabled.value = m_XREnabledProp.boolValue;
}
void OnDisable()

{
m_ShowSoftParticles.target = m_RequireDepthTextureProp.boolValue;
m_ShowOpaqueTextureScale.target = m_RequireOpaqueTextureProp.boolValue;
m_ShowXREnabled.target = UnityEngine.XR.XRSettings.enabled;
}
void DrawGeneralSettings()

m_RenderScale.floatValue = EditorGUILayout.Slider(Styles.renderScaleLabel, m_RenderScale.floatValue, k_MinRenderScale, k_MaxRenderScale);
m_TargetScale.floatValue = EditorGUILayout.Slider(Styles.TargetScaleLabel, m_TargetScale.floatValue, k_MinTargetScale, k_MaxTargetScale);
m_ViewportScale.floatValue = EditorGUILayout.Slider(Styles.ViewportScaleLabel, m_ViewportScale.floatValue, k_MinViewportScale, k_MaxViewportScale);
m_MaxPixelLights.intValue = EditorGUILayout.IntSlider(Styles.maxPixelLightsLabel, m_MaxPixelLights.intValue, 0, k_MaxSupportedPixelLights);
EditorGUILayout.Space();

EditorGUILayout.Space();
EditorGUILayout.Space();
}
void DrawXRSettings()
{
EditorGUILayout.LabelField(Styles.xrSettingsLabel, EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_XREnabledProp, Styles.xrEnabled);
EditorGUI.BeginDisabledGroup(m_ShowXREnabled.value);
EditorGUI.indentLevel++;
EditorGUI.indentLevel--;
EditorGUI.EndDisabledGroup();
}
}
}

4
com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs


{
Camera camera = cameraData.camera;
RenderTextureDescriptor desc;
float renderScale = cameraData.renderScale;
float renderScale = cameraData.targetScale;
#if !UNITY_SWITCH
if (cameraData.isStereoEnabled)

if (cameraData.isOffscreenRender)
return false;
bool isScaledRender = !Mathf.Approximately(cameraData.renderScale, 1.0f);
bool isScaledRender = !Mathf.Approximately(cameraData.targetScale, 1.0f);
bool isTargetTexture2DArray = baseDescriptor.dimension == TextureDimension.Tex2DArray;
return requiresCameraDepth || cameraData.isSceneViewCamera || isScaledRender || cameraData.isHdrEnabled ||
cameraData.postProcessEnabled || cameraData.requiresOpaqueTexture || isTargetTexture2DArray || !cameraData.isDefaultViewport;

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


void InitializeCameraData(Camera camera, out CameraData cameraData)
{
const float kRenderScaleThreshold = 0.05f;
const float kTargetScaleThreshold = 0.05f;
cameraData.camera = camera;
bool msaaEnabled = camera.allowMSAA && pipelineAsset.msaaSampleCount > 1;

// Discard variations lesser than kRenderScaleThreshold.
// Scale is only enabled for gameview
cameraData.renderScale = (Mathf.Abs(1.0f - pipelineAsset.renderScale) < kRenderScaleThreshold) ? 1.0f : pipelineAsset.renderScale;
cameraData.renderScale = (camera.cameraType == CameraType.Game) ? cameraData.renderScale : 1.0f;
cameraData.targetScale = (Mathf.Abs(1.0f - pipelineAsset.TargetScale) < kTargetScaleThreshold) ? 1.0f : pipelineAsset.TargetScale;
cameraData.targetScale = (camera.cameraType == CameraType.Game) ? cameraData.targetScale : 1.0f;
cameraData.requiresDepthTexture = pipelineAsset.supportsCameraDepthTexture || cameraData.isSceneViewCamera;
cameraData.requiresSoftParticles = pipelineAsset.supportsSoftParticles;

void SetupPerCameraShaderConstants(CameraData cameraData)
{
float cameraWidth = (float)cameraData.camera.pixelWidth * cameraData.renderScale;
float cameraHeight = (float)cameraData.camera.pixelWidth * cameraData.renderScale;
float cameraWidth = (float)cameraData.camera.pixelWidth * cameraData.targetScale;
float cameraHeight = (float)cameraData.camera.pixelWidth * cameraData.targetScale;
Shader.SetGlobalVector(PerCameraBuffer._ScaledScreenParams, new Vector4(cameraWidth, cameraHeight, 1.0f + 1.0f / cameraWidth, 1.0f + 1.0f / cameraHeight));
}

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


public struct CameraData
{
public Camera camera;
public float renderScale;
public float targetScale;
public int msaaSamples;
public bool isSceneViewCamera;
public bool isDefaultViewport;

正在加载...
取消
保存