Exemplo n.º 1
0
        public static Texture2D GeneratePerlinNoiseGPU(Vector3 position, GraphicsDevice device, SpriteBatch sp)
        {
            device.SetRenderTarget(cloudsRenderTarget);
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
            sp.Begin(SpriteSortMode.Deferred, null, null, null, null, PerlinEffect);

            PerlinEffect.Parameters["TextureSampler+permTexture"].SetValue(permTexture);
            //PerlinEffect.Parameters["Overcast"].SetValue(1.1f);
            PerlinEffect.Parameters["xCoord"].SetValue(new Vector2(position.X, position.Z));
            foreach (var pass in PerlinEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, fullScreenVertices, 0, 4, IndexData, 0, 2);
            }
            sp.End();

            device.SetRenderTarget(null);

            return(cloudsRenderTarget.CloneRenderTarget(device));
        }