Exemplo n.º 1
0
        public override void OnInitialize(DeviceContextHolder holder)
        {
            base.OnInitialize(holder);

            _effect = holder.GetEffect <EffectPpSsaoAlt>();

            var samplesKernel = new Vector4[EffectPpSsao.SampleCount];
            var random        = new Random(0);

            for (var i = 0; i < samplesKernel.Length; i++)
            {
                samplesKernel[i].X = (float)(random.NextDouble() * 2d - 1d);
                samplesKernel[i].Z = (float)(random.NextDouble() * 2d - 1d);
                samplesKernel[i].Y = (float)random.NextDouble();
                samplesKernel[i].Normalize();

                var scale = (float)i / samplesKernel.Length;
                scale             = (scale * scale).Lerp(0.1f, 1f);
                samplesKernel[i] *= scale;
            }

            _effect.FxSamplesKernel.Set(samplesKernel);
        }
Exemplo n.º 2
0
        public override void OnInitialize(DeviceContextHolder holder)
        {
            base.OnInitialize(holder);

            _effect = holder.GetEffect <EffectPpSsaoAlt>();
            _effect.FxNoiseMap.SetResource(holder.GetRandomTexture(4, 4));

            var samplesKernel = new Vector4[EffectPpSsao.SampleCount];

            for (var i = 0; i < samplesKernel.Length; i++)
            {
                samplesKernel[i].X = MathUtils.Random(-1f, 1f);
                samplesKernel[i].Z = MathUtils.Random(-1f, 1f);
                samplesKernel[i].Y = MathUtils.Random(0f, 1f);
                samplesKernel[i].Normalize();

                var scale = (float)i / samplesKernel.Length;
                scale             = MathUtils.Lerp(0.1f, 1f, scale * scale);
                samplesKernel[i] *= scale;
            }

            _effect.FxSamplesKernel.Set(samplesKernel);
        }