i need a real time Perlin Noise generation for a 2d game i am implementing. The CPU noise runs fine, but needs ~1 sec for half my screen size (1920 x 1080). I can scale it up about 4 times without too many artifacts but still that is a little slow assuming, that my cpu is pretty fast. So i want to implement it on the GPU. THe problem is i have no experience with HLSL and there are not too many tutorials on it out there... I have tried to implement this (i pretty much copied it all) and added this:
void SpriteVertexShader(inout float4 color : COLOR0,
inout float2 texCoord : TEXCOORD0,
inout float4 position : SV_Position)
{
position = mul(position, MatrixTransform);
}
technique Technique1
{
pass Pass1
{
// TODO: set renderstates here.
VertexShader = compile vs_3_0 SpriteVertexShader();
PixelShader = compile ps_3_0 PixelShaderFunction();
}
}
at the end. I Call it like this:
Matrix projection = Matrix.CreateOrthographicOffCenter(0,
GraphicsDevice.Viewport.Width,
GraphicsDevice.Viewport.Height, 0, 0, 1);
Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
perlin.Parameters["MatrixTransform"].SetValue(halfPixelOffset * projection);
perlin.CurrentTechnique = perlin.Techniques["Technique1"];
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
perlin.CurrentTechnique.Passes[0].Apply();
spriteBatch.Draw(new Texture2D(GraphicsDevice,1000,1000),
new Rectangle(0, 0, 500, 500), Color.White);
spriteBatch.End();
and i finally get a black texture. What am i doing wrong? I don't understand the vertex shader part... But here they say i have to change it so that i won't get the error: "that is too complex for the target shader model"...