|
|
|
|
|
|
public float occlusionBiasSkyRayleigh = 0.2f; |
|
|
|
public float occlusionBiasSkyMie = 0.4f; |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
// public bool forcePerPixel = true;
|
|
|
|
// public bool forcePerPixel = true;
|
|
|
|
|
|
|
|
|
|
|
|
// [HideInInspector] public Shader occlusionShaderOverride;
|
|
|
|
|
|
|
|
// Camera m_currentCamera;
|
|
|
|
|
|
|
Material m_atmosphericMaterial = null; |
|
|
|
// Material m_occlusionMaterial = null;
|
|
|
|
bool m_isAwake = false; |
|
|
|
|
|
|
|
|
|
|
|
public static AtmosphericParameters instance { get; private set; } |
|
|
|
|
|
|
|
void Awake() |
|
|
|
|
|
|
occlusionBiasSkyRayleigh = Mathf.Clamp01(occlusionBiasSkyRayleigh); |
|
|
|
occlusionBiasSkyMie = Mathf.Clamp01(occlusionBiasSkyMie); |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
skyDomeExposure = Mathf.Clamp(skyDomeExposure, 0f, 8f); |
|
|
|
|
|
|
|
if (instance == this) |
|
|
|
|
|
|
{ |
|
|
|
Debug.LogErrorFormat("Unexpected: AtmosphericParameters.instance already set (to: {0}). Still overriding with: {1}.", instance.name, name); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
instance = this; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Shader.SetGlobalFloat("_WorldScaleExponent", worldScaleExponent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Shader.SetGlobalFloat("_HeightSeaLevel", heightSeaLevel); |
|
|
|
Shader.SetGlobalFloat("_HeightDistanceRcp", 1f/heightDistance); |
|
|
|
Shader.SetGlobalVector("_HeightPlaneShift", heightPlaneShift); |
|
|
|
|
|
|
Shader.SetGlobalFloat("_MieExtinctionFactor", worldMieExtinctionFactor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Shader.SetGlobalVector("_MieColorM20", (Vector4)mieColorM20 * worldMieColorIntensity); |
|
|
|
Shader.SetGlobalVector("_MieColorO00", (Vector4)mieColorO00 * worldMieColorIntensity); |
|
|
|
Shader.SetGlobalVector("_MieColorP20", (Vector4)mieColorP20 * worldMieColorIntensity); |
|
|
|
|
|
|
var camRgt = m_currentCamera.transform.right; |
|
|
|
var camUp = m_currentCamera.transform.up; |
|
|
|
var camFwd = m_currentCamera.transform.forward; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var vpCenter = camFwd * m_currentCamera.farClipPlane; |
|
|
|
var vpRight = camRgt * dx * m_currentCamera.farClipPlane; |
|
|
|
var vpUp = camUp * dy * m_currentCamera.farClipPlane; |
|
|
|
|
|
|
var downscale = 1f / (float)(int)occlusionDownscale; |
|
|
|
var occWidth = Mathf.RoundToInt(srcRect.width * downscale); |
|
|
|
var occHeight = Mathf.RoundToInt(srcRect.height * downscale); |
|
|
|
var occlusionId = Shader.PropertyToID("_OcclusionTexture"); |
|
|
|
var occlusionId = Shader.PropertyToID("_OcclusionTexture"); |
|
|
|
null, |
|
|
|
null, |
|
|
|
occlusionId, |
|
|
|
m_occlusionMaterial, |
|
|
|
(int)occlusionSamples |
|
|
|
|
|
|
Shader.SetGlobalMatrix("_SkyDomeRotation", |
|
|
|
Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(skyDomeRotation.x, 0f, 0f), Vector3.one) |
|
|
|
* Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, skyDomeRotation.y - trackedYaw, 0f), Vector3.one) |
|
|
|
* Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1f, skyDomeVerticalFlip ? -1f : 1f, 1f)) |
|
|
|
* Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1f, skyDomeVerticalFlip ? -1f : 1f, 1f)) |
|
|
|
Shader.SetGlobalVector("_SunDirection", transform.forward); |
|
|
|
Shader.SetGlobalVector("_SunDirection", -transform.forward); |
|
|
|
Shader.SetGlobalFloat("_WorldMieDensity", -worldMieDensity / 100000f); |
|
|
|
Shader.SetGlobalFloat("_HeightMieDensity", -heightMieDensity / 100000f); |
|
|
|
|
|
|
|