Пример #1
0
        public DensityVolumeEngineData ConvertToEngineData()
        {
            DensityVolumeEngineData data = new DensityVolumeEngineData();

            data.extinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(meanFreePath);
            data.scattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(data.extinction, (Vector3)(Vector4)albedo);

            data.textureIndex  = textureIndex;
            data.textureScroll = volumeScrollingAmount;
            data.textureTiling = textureTiling;

            // Clamp to avoid NaNs.
            Vector3 positiveFade = this.positiveFade;
            Vector3 negativeFade = this.negativeFade;

            data.rcpPosFade.x = Mathf.Min(1.0f / positiveFade.x, float.MaxValue);
            data.rcpPosFade.y = Mathf.Min(1.0f / positiveFade.y, float.MaxValue);
            data.rcpPosFade.z = Mathf.Min(1.0f / positiveFade.z, float.MaxValue);

            data.rcpNegFade.y = Mathf.Min(1.0f / negativeFade.y, float.MaxValue);
            data.rcpNegFade.x = Mathf.Min(1.0f / negativeFade.x, float.MaxValue);
            data.rcpNegFade.z = Mathf.Min(1.0f / negativeFade.z, float.MaxValue);

            data.invertFade = invertFade ? 1 : 0;

            return(data);
        }
        // Override the volume blending function.
        public override void Override(VolumeComponent state, float interpFactor)
        {
            VolumetricFog other = state as VolumetricFog;

            float   thisExtinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(meanFreePath);
            Vector3 thisScattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(thisExtinction, (Vector3)(Vector4)albedo.value);

            float   otherExtinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(other.meanFreePath);
            Vector3 otherScattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(otherExtinction, (Vector3)(Vector4)other.albedo.value);

            float   blendExtinction = Mathf.Lerp(otherExtinction, thisExtinction, interpFactor);
            Vector3 blendScattering = Vector3.Lerp(otherScattering, thisScattering, interpFactor);
            float   blendAsymmetry  = Mathf.Lerp(other.asymmetry, asymmetry, interpFactor);

            float blendMeanFreePath = VolumeRenderingUtils.MeanFreePathFromExtinction(blendExtinction);
            Color blendAlbedo       = (Color)(Vector4)VolumeRenderingUtils.AlbedoFromMeanFreePathAndScattering(blendMeanFreePath, blendScattering);

            blendAlbedo.a = 1.0f;

            if (meanFreePath.overrideState)
            {
                other.meanFreePath.value = blendMeanFreePath;
            }

            if (albedo.overrideState)
            {
                other.albedo.value = blendAlbedo;
            }

            if (asymmetry.overrideState)
            {
                other.asymmetry.value = blendAsymmetry;
            }
        }
        public DensityVolumeEngineData ConvertToEngineData()
        {
            DensityVolumeEngineData data = new DensityVolumeEngineData();

            data.extinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(meanFreePath);
            data.scattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(data.extinction, (Vector3)(Vector4)albedo);

            data.textureIndex  = textureIndex;
            data.textureScroll = volumeScrollingAmount;
            data.textureTiling = textureTiling;

            // Note that we do not clamp here. Infinities work in the expected way in the shader.
            // This also allows us to avoid artifacts caused by numerical issues.
            data.rcpPosFade.x = 1.0f / positiveFade.x;
            data.rcpPosFade.y = 1.0f / positiveFade.y;
            data.rcpPosFade.z = 1.0f / positiveFade.z;

            data.rcpNegFade.y = 1.0f / negativeFade.y;
            data.rcpNegFade.x = 1.0f / negativeFade.x;
            data.rcpNegFade.z = 1.0f / negativeFade.z;

            data.invertFade = invertFade ? 1 : 0;

            return(data);
        }
Пример #4
0
        public DensityVolumeData GetData()
        {
            DensityVolumeData data = new DensityVolumeData();

            data.extinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(meanFreePath);
            data.scattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(data.extinction, (Vector3)(Vector4)albedo);

            return(data);
        }
        public DensityVolumeData GetData()
        {
            DensityVolumeData data = new DensityVolumeData();

            data.extinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(meanFreePath);
            data.scattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(data.extinction, (Vector3)(Vector4)albedo);

            data.textureIndex  = textureIndex;
            data.textureScroll = volumeScrollingAmount;
            data.textureTiling = textureTiling;

            return(data);
        }
Пример #6
0
        public DensityVolumeEngineData GetData()
        {
            DensityVolumeEngineData data = new DensityVolumeEngineData();

            data.extinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(meanFreePath);
            data.scattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(data.extinction, (Vector3)(Vector4)albedo);

            data.textureIndex  = textureIndex;
            data.textureScroll = volumeScrollingAmount;
            data.textureTiling = textureTiling;

            // Avoid numerical problems by clamping extreme values.
            data.rcpPosFade.x = Mathf.Clamp(1.0f / positiveFade.x, 0.00001526f, 65536.0f);
            data.rcpNegFade.x = Mathf.Clamp(1.0f / negativeFade.x, 0.00001526f, 65536.0f);
            data.rcpPosFade.y = Mathf.Clamp(1.0f / positiveFade.y, 0.00001526f, 65536.0f);
            data.rcpNegFade.y = Mathf.Clamp(1.0f / negativeFade.y, 0.00001526f, 65536.0f);
            data.rcpPosFade.z = Mathf.Clamp(1.0f / positiveFade.z, 0.00001526f, 65536.0f);
            data.rcpNegFade.z = Mathf.Clamp(1.0f / negativeFade.z, 0.00001526f, 65536.0f);

            return(data);
        }