Skip to content

Commit

Permalink
fix for all cases
Browse files Browse the repository at this point in the history
Signed-off-by: Alptuğ Cırıt <[email protected]>
  • Loading branch information
mozhoku committed Sep 19, 2024
1 parent f4992d7 commit a536616
Showing 1 changed file with 70 additions and 53 deletions.
123 changes: 70 additions & 53 deletions Assets/AWSIM/Scripts/UI/GraphicsSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
Expand Down Expand Up @@ -141,27 +140,33 @@ private void GraphicsLowQuality()
// update camera parameters
foreach (var cam in _cameraObjectsList)
{
cam.TryGetComponent<UniversalAdditionalCameraData>(out var cameraData);
cam.TryGetComponent<Volume>(out var cameraVolume);
var cameraVolumeProfile = cameraVolume.profile;
if (cam)
{
cam.TryGetComponent<UniversalAdditionalCameraData>(out var cameraData);
cam.TryGetComponent<Volume>(out var cameraVolume);
var cameraVolumeProfile = cameraVolume.profile;

cameraData.antialiasing = AntialiasingMode.None;
cameraData.renderPostProcessing = false;
cameraData.renderShadows = false;
cameraData.allowHDROutput = false;
cameraData.antialiasing = AntialiasingMode.None;
cameraData.renderPostProcessing = false;
cameraData.renderShadows = false;
cameraData.allowHDROutput = false;

if (cameraVolumeProfile.TryGet(out Bloom bloom))
{
bloom.active = false;
}
if (cameraVolumeProfile.TryGet(out Bloom bloom))
{
bloom.active = false;
}

if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping))
{
tonemapping.active = false;
if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping))
{
tonemapping.active = false;
}
}
}

_sunSource.shadows = LightShadows.Hard;
if (_sunSource)
{
_sunSource.shadows = LightShadows.Hard;
}
}

private void GraphicsMediumQuality()
Expand All @@ -173,29 +178,35 @@ private void GraphicsMediumQuality()
// update camera and volume parameters
foreach (var cam in _cameraObjectsList)
{
cam.TryGetComponent<UniversalAdditionalCameraData>(out var cameraData);
cam.TryGetComponent<Volume>(out var cameraVolume);
var cameraVolumeProfile = cameraVolume.profile;
if (cam)
{
cam.TryGetComponent<UniversalAdditionalCameraData>(out var cameraData);
cam.TryGetComponent<Volume>(out var cameraVolume);
var cameraVolumeProfile = cameraVolume.profile;

cameraData.antialiasing = AntialiasingMode.FastApproximateAntialiasing;
cameraData.antialiasingQuality = AntialiasingQuality.Medium;
cameraData.renderPostProcessing = true;
cameraData.renderShadows = true;
cameraData.allowHDROutput = false;
cameraData.antialiasing = AntialiasingMode.FastApproximateAntialiasing;
cameraData.antialiasingQuality = AntialiasingQuality.Medium;
cameraData.renderPostProcessing = true;
cameraData.renderShadows = true;
cameraData.allowHDROutput = false;

if (cameraVolumeProfile.TryGet(out Bloom bloom))
{
bloom.active = false;
bloom.intensity.value = 0.25f;
}
if (cameraVolumeProfile.TryGet(out Bloom bloom))
{
bloom.active = false;
bloom.intensity.value = 0.25f;
}

if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping))
{
tonemapping.active = false;
if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping))
{
tonemapping.active = false;
}
}
}

_sunSource.shadows = LightShadows.Hard;
if (_sunSource)
{
_sunSource.shadows = LightShadows.Hard;
}
}

private void GraphicsHighQuality()
Expand All @@ -207,32 +218,38 @@ private void GraphicsHighQuality()
// update camera parameters
foreach (var cam in _cameraObjectsList)
{
cam.TryGetComponent<UniversalAdditionalCameraData>(out var cameraData);
cam.TryGetComponent<Volume>(out var cameraVolume);
var cameraVolumeProfile = cameraVolume.profile;
if (cam)
{
cam.TryGetComponent<UniversalAdditionalCameraData>(out var cameraData);
cam.TryGetComponent<Volume>(out var cameraVolume);
var cameraVolumeProfile = cameraVolume.profile;

cameraData.antialiasing = AntialiasingMode.SubpixelMorphologicalAntiAliasing;
cameraData.antialiasingQuality = AntialiasingQuality.High;
cameraData.renderPostProcessing = true;
cameraData.renderShadows = true;
cameraData.allowHDROutput = true;
cameraData.antialiasing = AntialiasingMode.SubpixelMorphologicalAntiAliasing;
cameraData.antialiasingQuality = AntialiasingQuality.High;
cameraData.renderPostProcessing = true;
cameraData.renderShadows = true;
cameraData.allowHDROutput = true;

if (cameraVolumeProfile.TryGet(out Bloom bloom))
{
bloom.active = true;
bloom.intensity.value = 0.5f;
bloom.highQualityFiltering.overrideState = false;
bloom.highQualityFiltering.value = false;
}
if (cameraVolumeProfile.TryGet(out Bloom bloom))
{
bloom.active = true;
bloom.intensity.value = 0.5f;
bloom.highQualityFiltering.overrideState = false;
bloom.highQualityFiltering.value = false;
}

if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping))
{
tonemapping.active = true;
tonemapping.mode.value = TonemappingMode.ACES;
if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping))
{
tonemapping.active = true;
tonemapping.mode.value = TonemappingMode.ACES;
}
}
}

_sunSource.shadows = LightShadows.Soft;
if (_sunSource)
{
_sunSource.shadows = LightShadows.Soft;
}
}

private void GraphicsUltraQuality()
Expand Down

0 comments on commit a536616

Please sign in to comment.