refactor(srp): move rendering data ownership into universal package
This commit is contained in:
@@ -29,12 +29,6 @@ namespace XCEngine.Rendering
|
||||
}
|
||||
|
||||
private readonly ulong m_nativeHandle;
|
||||
private CameraData m_cameraData;
|
||||
private LightingData m_lightingData;
|
||||
private ShadowData m_shadowData;
|
||||
private EnvironmentData m_environmentData;
|
||||
private FinalColorData m_finalColorData;
|
||||
private StageColorData m_stageColorData;
|
||||
|
||||
internal ScriptableRenderContext(ulong nativeHandle)
|
||||
{
|
||||
@@ -45,26 +39,8 @@ namespace XCEngine.Rendering
|
||||
(CameraFrameStage)InternalCalls.Rendering_ScriptableRenderContext_GetStage(
|
||||
m_nativeHandle);
|
||||
|
||||
internal CameraData cameraData =>
|
||||
m_cameraData ?? (m_cameraData = ResolveCameraData());
|
||||
|
||||
internal LightingData lightingData =>
|
||||
m_lightingData ?? (m_lightingData = ResolveLightingData());
|
||||
|
||||
internal ShadowData shadowData =>
|
||||
m_shadowData ?? (m_shadowData = ResolveShadowData());
|
||||
|
||||
internal EnvironmentData environmentData =>
|
||||
m_environmentData ??
|
||||
(m_environmentData = ResolveEnvironmentData());
|
||||
|
||||
internal FinalColorData finalColorData =>
|
||||
m_finalColorData ??
|
||||
(m_finalColorData = ResolveFinalColorData());
|
||||
|
||||
internal StageColorData stageColorData =>
|
||||
m_stageColorData ??
|
||||
(m_stageColorData = ResolveStageColorData());
|
||||
internal ulong nativeHandle =>
|
||||
m_nativeHandle;
|
||||
|
||||
public bool RecordScene()
|
||||
{
|
||||
@@ -189,251 +165,6 @@ namespace XCEngine.Rendering
|
||||
ref vectorPayload);
|
||||
}
|
||||
|
||||
private CameraData ResolveCameraData()
|
||||
{
|
||||
Matrix4x4 view;
|
||||
Matrix4x4 projection;
|
||||
Matrix4x4 viewProjection;
|
||||
Vector3 worldPosition;
|
||||
Vector3 worldRight;
|
||||
Vector3 worldUp;
|
||||
Vector3 worldForward;
|
||||
Color clearColor;
|
||||
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraView(
|
||||
m_nativeHandle,
|
||||
out view);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraProjection(
|
||||
m_nativeHandle,
|
||||
out projection);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraViewProjection(
|
||||
m_nativeHandle,
|
||||
out viewProjection);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraWorldPosition(
|
||||
m_nativeHandle,
|
||||
out worldPosition);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraWorldRight(
|
||||
m_nativeHandle,
|
||||
out worldRight);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraWorldUp(
|
||||
m_nativeHandle,
|
||||
out worldUp);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraWorldForward(
|
||||
m_nativeHandle,
|
||||
out worldForward);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraClearColor(
|
||||
m_nativeHandle,
|
||||
out clearColor);
|
||||
|
||||
return new CameraData(
|
||||
view,
|
||||
projection,
|
||||
viewProjection,
|
||||
worldPosition,
|
||||
worldRight,
|
||||
worldUp,
|
||||
worldForward,
|
||||
clearColor,
|
||||
(RenderClearFlags)InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraClearFlags(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraPerspectiveProjection(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraVerticalFovRadians(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraOrthographicSize(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraAspectRatio(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraNearClipPlane(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraFarClipPlane(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraViewportWidth(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetCameraViewportHeight(
|
||||
m_nativeHandle));
|
||||
}
|
||||
|
||||
private LightingData ResolveLightingData()
|
||||
{
|
||||
Vector3 mainDirectionalLightDirection;
|
||||
Color mainDirectionalLightColor;
|
||||
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalLightDirection(
|
||||
m_nativeHandle,
|
||||
out mainDirectionalLightDirection);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalLightColor(
|
||||
m_nativeHandle,
|
||||
out mainDirectionalLightColor);
|
||||
|
||||
return new LightingData(
|
||||
new DirectionalLightData(
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalLightEnabled(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalLightCastsShadows(
|
||||
m_nativeHandle),
|
||||
mainDirectionalLightDirection,
|
||||
mainDirectionalLightColor,
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalLightIntensity(
|
||||
m_nativeHandle)),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetHasMainDirectionalShadow(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetAdditionalLightCount(
|
||||
m_nativeHandle));
|
||||
}
|
||||
|
||||
private EnvironmentData ResolveEnvironmentData()
|
||||
{
|
||||
Color skyboxTopColor;
|
||||
Color skyboxHorizonColor;
|
||||
Color skyboxBottomColor;
|
||||
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetEnvironmentSkyboxTopColor(
|
||||
m_nativeHandle,
|
||||
out skyboxTopColor);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetEnvironmentSkyboxHorizonColor(
|
||||
m_nativeHandle,
|
||||
out skyboxHorizonColor);
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetEnvironmentSkyboxBottomColor(
|
||||
m_nativeHandle,
|
||||
out skyboxBottomColor);
|
||||
|
||||
return new EnvironmentData(
|
||||
(RenderEnvironmentMode)InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetEnvironmentMode(
|
||||
m_nativeHandle),
|
||||
skyboxTopColor,
|
||||
skyboxHorizonColor,
|
||||
skyboxBottomColor);
|
||||
}
|
||||
|
||||
private ShadowData ResolveShadowData()
|
||||
{
|
||||
Matrix4x4 viewProjection;
|
||||
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowViewProjection(
|
||||
m_nativeHandle,
|
||||
out viewProjection);
|
||||
|
||||
return new ShadowData(
|
||||
new DirectionalShadowData(
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowEnabled(
|
||||
m_nativeHandle),
|
||||
viewProjection,
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowOrthographicHalfExtent(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowNearClipPlane(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowFarClipPlane(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowMapWidth(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowMapHeight(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowWorldTexelSize(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowReceiverDepthBias(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowNormalBiasScale(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowStrength(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowDepthBiasFactor(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetMainDirectionalShadowDepthBiasUnits(
|
||||
m_nativeHandle)));
|
||||
}
|
||||
|
||||
private FinalColorData ResolveFinalColorData()
|
||||
{
|
||||
Vector4 finalColorScale;
|
||||
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetFinalColorScale(
|
||||
m_nativeHandle,
|
||||
out finalColorScale);
|
||||
|
||||
FinalColorSettings settings =
|
||||
FinalColorSettings.CreateDefault();
|
||||
settings.outputTransferMode =
|
||||
(FinalColorOutputTransferMode)InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetFinalColorOutputTransferMode(
|
||||
m_nativeHandle);
|
||||
settings.exposureMode =
|
||||
(FinalColorExposureMode)InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetFinalColorExposureMode(
|
||||
m_nativeHandle);
|
||||
settings.exposureValue =
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetFinalColorExposureValue(
|
||||
m_nativeHandle);
|
||||
settings.toneMappingMode =
|
||||
(FinalColorToneMappingMode)InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetFinalColorToneMappingMode(
|
||||
m_nativeHandle);
|
||||
settings.finalColorScale =
|
||||
finalColorScale;
|
||||
|
||||
return new FinalColorData(
|
||||
settings,
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetFinalColorHasPipelineDefaults(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetFinalColorHasCameraOverrides(
|
||||
m_nativeHandle));
|
||||
}
|
||||
|
||||
private StageColorData ResolveStageColorData()
|
||||
{
|
||||
return new StageColorData(
|
||||
(CameraFrameColorSource)InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetStageColorSource(
|
||||
m_nativeHandle),
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_GetStageUsesGraphManagedOutputColor(
|
||||
m_nativeHandle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user