Hi,
Sorry in advance for my bad english level
I am trying to make a wave effect with shader.
It works fine only with a full screen quad renderer (position == cameraPosition)
I want to make this effect with a smaller quad without resize a final renderer target. (position != cameraposition)
Actually, I have a rendertarget 2D for my tile mapping layer and a second rendertarget 2D for my render light.
I combine the two rendertarget in a shader (colorMap + lightMap).
With this method :
FinalRender.CurrentTechnique = FinalRender.Techniques["Light_Color_Wave"]; FinalRender.Parameters["ColorMap"].SetValue(rendertarget_Layer); FinalRender.Parameters["LightMap"].SetValue(rendertarget_Light); FinalRender.Parameters["WorldViewProjection"].SetValue(camera3D.WorldViewProjection); FinalRender.Parameters["Timer"].SetValue(totalTime); FinalRender.CurrentTechnique.Passes[0].Apply();
QuadRenderer quadFullScreen = new QuadRenderer(game.GraphicsDevice); quadFullScreen.RenderQuad(game.GraphicsDevice, Vector2.One *-1, Vector2.One);
Now I want to pass with a other shader (waveFX) :
game.GraphicsDevice.SetRenderTarget(rendertarget_Layer_2);
game.GraphicsDevice.Clear(Color.TransparentBlack);
FinalRender.CurrentTechnique = FinalRender.Techniques["Light_Color"];
FinalRender.Parameters["ColorMap"].SetValue(rendertarget_Layer);
FinalRender.Parameters["LightMap"].SetValue(rendertarget_Light);
FinalRender.Parameters["WorldViewProjection"].SetValue(camera3D.WorldViewProjection);
FinalRender.CurrentTechnique.Passes[0].Apply();
QuadRenderer quadFullScreen = new QuadRenderer(game.GraphicsDevice);
quadFullScreen.RenderQuad(game.GraphicsDevice, Vector2.One *-1, Vector2.One);
game.GraphicsDevice.SetRenderTarget(null);
game.GraphicsDevice.Clear(Color.Transparent);
// WAVE EFFECT PASS
waveFX.CurrentTechnique = waveFX.Techniques["Wave"];
waveFX.Parameters["WorldViewProjection"].SetValue(camera3D.WorldViewProjection);
waveFX.Parameters["Timer"].SetValue(totalTime);
waveFX.Parameters["ColorMap"].SetValue(rendertarget_Layer_2);
waveFX.CurrentTechnique.Passes[0].Apply();
QuadRender quadRenderTest =
new QuadRender(new Vector3(0, 0, camera3D.Position.Z), Vector3.Forward, Vector3.Up);
Vector2 v1 = new Vector2(0, 2120);
Vector2 v2 = new Vector2(920, 3200);
quadRenderTest.RenderQuad(game.GraphicsDevice, v1, v2);
Now my texture is resized
I think I need to calculate a texture position, but a better way may exist? Is it possible to make this inside a shader?
Thx in advance