Last active
July 20, 2017 09:22
-
-
Save zsoi/1dd7fd1d2192654feacf850f23086e83 to your computer and use it in GitHub Desktop.
Unity3D Behaviours for changing LodBias and ShadowCasting for individual cameras. Add scripts to chosen cameras and modify the LodBias / ShadowCasting method as you require. Serves well to have e.g. reflection cameras draw with less quality.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Game.Camera | |
{ | |
using UnityEngine; | |
/// <summary> | |
/// Applies a custom LOD bias factor to rendering when attached to a camera | |
/// </summary> | |
[RequireComponent(typeof(Camera))] | |
class CustomLodBias : MonoBehaviour | |
{ | |
public float LodBiasFactor = 1F; | |
float originalLodBias = 0F; | |
private void OnPreCull() | |
{ | |
originalLodBias = QualitySettings.lodBias; | |
QualitySettings.lodBias = originalLodBias * LodBiasFactor; | |
} | |
private void OnPostRender() | |
{ | |
QualitySettings.lodBias = originalLodBias; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Game.Camera | |
{ | |
using UnityEngine; | |
/// <summary> | |
/// Applies a custom shadow casting scheme to rendering when attached to a camera | |
/// </summary> | |
[RequireComponent(typeof(Camera))] | |
class CustomShadowCasting : MonoBehaviour | |
{ | |
public ShadowQuality OverriddenShadowQuality = ShadowQuality.All; | |
ShadowQuality originalShadowQuality = ShadowQuality.All; | |
private void OnPreCull() | |
{ | |
originalShadowQuality = QualitySettings.shadows; | |
QualitySettings.shadows = OverriddenShadowQuality; | |
} | |
private void OnPostRender() | |
{ | |
QualitySettings.shadows = originalShadowQuality; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment