//internal abstract void PushShaderParameters(HDCamera hdCamera, CommandBuffer cmd); public virtual void PushShaderParameters(HDCamera hdCamera, CommandBuffer cmd) { cmd.SetGlobalInt(HDShaderIDs._FogEnabled, 1); cmd.SetGlobalFloat(HDShaderIDs._MaxFogDistance, maxFogDistance.value); // Fog Color cmd.SetGlobalFloat(m_ColorModeParam, (float)colorMode.value); cmd.SetGlobalColor(m_FogColorParam, new Color(color.value.r, color.value.g, color.value.b, 0.0f)); cmd.SetGlobalVector(m_MipFogParam, new Vector4(mipFogNear.value, mipFogFar.value, mipFogMaxMip.value, 0.0f)); DensityVolumeArtistParameters param = new DensityVolumeArtistParameters(albedo.value, meanFreePath.value, anisotropy.value); DensityVolumeEngineData data = param.ConvertToEngineData(); cmd.SetGlobalVector(HDShaderIDs._HeightFogBaseScattering, data.scattering); cmd.SetGlobalFloat(HDShaderIDs._HeightFogBaseExtinction, data.extinction); float crBaseHeight = baseHeight.value; if (ShaderConfig.s_CameraRelativeRendering != 0) { crBaseHeight -= hdCamera.camera.transform.position.y; } float layerDepth = Mathf.Max(0.01f, maximumHeight.value - baseHeight.value); float H = ScaleHeightFromLayerDepth(layerDepth); cmd.SetGlobalVector(HDShaderIDs._HeightFogExponents, new Vector2(1.0f / H, H)); cmd.SetGlobalFloat(HDShaderIDs._HeightFogBaseHeight, crBaseHeight); bool enableVolumetrics = enableVolumetricFog.value && hdCamera.frameSettings.IsEnabled(FrameSettingsField.Volumetrics); cmd.SetGlobalFloat(HDShaderIDs._GlobalFogAnisotropy, anisotropy.value); cmd.SetGlobalInt(HDShaderIDs._EnableVolumetricFog, enableVolumetrics ? 1 : 0); }
void UpdateShaderVariablesGlobalCBFogParameters(ref ShaderVariablesGlobal cb, HDCamera hdCamera) { bool enableVolumetrics = enableVolumetricFog.value && hdCamera.frameSettings.IsEnabled(FrameSettingsField.Volumetrics); cb._FogEnabled = 1; cb._PBRFogEnabled = IsPBRFogEnabled(hdCamera) ? 1 : 0; cb._EnableVolumetricFog = enableVolumetrics ? 1 : 0; cb._MaxFogDistance = maxFogDistance.value; Color fogColor = (colorMode.value == FogColorMode.ConstantColor) ? color.value : tint.value; cb._FogColorMode = (float)colorMode.value; cb._FogColor = new Color(fogColor.r, fogColor.g, fogColor.b, 0.0f); cb._MipFogParameters = new Vector4(mipFogNear.value, mipFogFar.value, mipFogMaxMip.value, 0.0f); DensityVolumeArtistParameters param = new DensityVolumeArtistParameters(albedo.value, meanFreePath.value, anisotropy.value); DensityVolumeEngineData data = param.ConvertToEngineData(); cb._HeightFogBaseScattering = data.scattering; cb._HeightFogBaseExtinction = data.extinction; float crBaseHeight = baseHeight.value; if (ShaderConfig.s_CameraRelativeRendering != 0) { crBaseHeight -= hdCamera.camera.transform.position.y; } float layerDepth = Mathf.Max(0.01f, maximumHeight.value - baseHeight.value); float H = ScaleHeightFromLayerDepth(layerDepth); cb._HeightFogExponents = new Vector2(1.0f / H, H); cb._HeightFogBaseHeight = crBaseHeight; cb._GlobalFogAnisotropy = anisotropy.value; }