예제 #1
0
        public void PushGlobalParams(HDCamera camera, CommandBuffer cmd)
        {
            if (preset == VolumetricLightingPreset.Off)
            {
                return;
            }

            HomogeneousFog globalFogComponent = HomogeneousFog.GetGlobalFogComponent();

            // TODO: may want to cache these results somewhere.
            VolumeProperties globalFogProperties = (globalFogComponent != null) ? globalFogComponent.volumeParameters.GetProperties()
                                                                            : VolumeProperties.GetNeutralVolumeProperties();

            cmd.SetGlobalVector(HDShaderIDs._GlobalFog_Scattering, globalFogProperties.scattering);
            cmd.SetGlobalFloat(HDShaderIDs._GlobalFog_Extinction, globalFogProperties.extinction);
            cmd.SetGlobalFloat(HDShaderIDs._GlobalFog_Asymmetry, globalFogComponent != null ? globalFogComponent.volumeParameters.asymmetry : 0);

            int     w = 0, h = 0, d = 0;
            Vector2 scale = ComputeVBufferResolutionAndScale(preset, (int)camera.screenSize.x, (int)camera.screenSize.y, ref w, ref h, ref d);

            VBuffer vBuffer = FindVBuffer(camera.GetViewID());

            Debug.Assert(vBuffer != null);

            cmd.SetGlobalVector(HDShaderIDs._VBufferResolution, new Vector4(w, h, 1.0f / w, 1.0f / h));
            cmd.SetGlobalVector(HDShaderIDs._VBufferScaleAndSliceCount, new Vector4(scale.x, scale.y, d, 1.0f / d));
            cmd.SetGlobalVector(HDShaderIDs._VBufferDepthEncodingParams, ComputeLogarithmicDepthEncodingParams(m_VBufferNearPlane, m_VBufferFarPlane, k_LogScale));
            cmd.SetGlobalVector(HDShaderIDs._VBufferDepthDecodingParams, ComputeLogarithmicDepthDecodingParams(m_VBufferNearPlane, m_VBufferFarPlane, k_LogScale));
            cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, vBuffer.GetLightingIntegralBuffer());
        }
예제 #2
0
        public VolumeProperties GetProperties()
        {
            VolumeProperties properties = new VolumeProperties();

            properties.scattering = GetScatteringCoefficient();
            properties.extinction = GetExtinctionCoefficient();

            return(properties);
        }
예제 #3
0
        public float   extinction; // [0, 1], prefer sRGB

        public static VolumeProperties GetNeutralVolumeProperties()
        {
            VolumeProperties properties = new VolumeProperties();

            properties.scattering = Vector3.zero;
            properties.extinction = 0;

            return(properties);
        }
        public void SetVolumetricLightingData(HDCamera camera, CommandBuffer cmd)
        {
            HomogeneousFog globalFogComponent = GetGlobalFogComponent();

            // TODO: may want to cache these results somewhere.
            VolumeProperties globalFogProperties = (globalFogComponent != null) ? globalFogComponent.volumeParameters.GetProperties()
                                                                            : VolumeProperties.GetNeutralVolumeProperties();

            cmd.SetGlobalVector(HDShaderIDs._GlobalFog_Scattering, globalFogProperties.scattering);
            cmd.SetGlobalFloat(HDShaderIDs._GlobalFog_Extinction, globalFogProperties.extinction);

            int     w = 0, h = 0, d = 0;
            Vector2 scale = ComputeVBufferResolutionAndScale(camera.screenSize.x, camera.screenSize.y, ref w, ref h, ref d);

            int viewId     = camera.camera.GetInstanceID();
            int viewOffset = ViewOffsetFromViewId(viewId);

            Debug.Assert(viewOffset >= 0 && viewOffset < 8);

            cmd.SetGlobalVector(HDShaderIDs._VBufferResolution, new Vector4(w, h, 1.0f / w, 1.0f / h));
            cmd.SetGlobalVector(HDShaderIDs._VBufferScaleAndSliceCount, new Vector4(scale.x, scale.y, d, 1.0f / d));
            cmd.SetGlobalVector(HDShaderIDs._VBufferDepthEncodingParams, ComputeLogarithmicDepthEncodingParams(m_VBufferNearPlane, m_VBufferFarPlane));
            cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, GetVBufferLightingIntegral(viewOffset));
        }