@Toemsel wrote:
I am new to shader programming and I am trying to get my shader to display something. However, the result of the vertex nor pixel shader is visible.
#if OPENGL #define SV_POSITION POSITION #define VS_SHADERMODEL vs_3_0 #define PS_SHADERMODEL ps_3_0 #else #define VS_SHADERMODEL vs_4_0_level_9_1 #define PS_SHADERMODEL ps_4_0_level_9_1 #endif float4x4 xViewProjection; float4 g_fTime; struct PixelShaderOutput { float4 Color: COLOR0; }; struct VertexShaderOutput { float4 Position : SV_POSITION; float2 TexCoord : TEXCOORD0; float4 Color: COLOR0; }; VertexShaderOutput VertexShaderLogic(float4 position : SV_POSITION, float4 color : COLOR0, float2 texCoord : TEXCOORD0) { VertexShaderOutput output = (VertexShaderOutput)0; output.Position = mul(position, xViewProjection); output.TexCoord = texCoord; output.Color = color; output.Position.x = g_fTime; return output; } PixelShaderOutput PixelShaderFunction(VertexShaderOutput input) : COLOR0 { PixelShaderOutput output = (PixelShaderOutput)0; output.Color = input.Color; output.Color = 0.1; return output; } technique SpriteDrawing { pass P0 { VertexShader = compile VS_SHADERMODEL VertexShaderLogic(); PixelShader = compile PS_SHADERMODEL PixelShaderFunction(); } };`
And the calling code
WindShader.Parameters["xViewProjection"].SetValue(Program.GetComponent<CameraComponent>().ViewMatrix); WindShader.Parameters["g_fTime"].SetValue((float)Math.Sin(gameTime.ToFloat()) * 2.5f); WindShader.CurrentTechnique.Passes[0].Apply(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, transformMatrix: Program.GetComponent<CameraComponent>().ViewMatrix); spriteBatch.Draw(Tree, new Vector2(512, 200), Color.White); spriteBatch.End();
The drawn texture2d doesn't appear to lack any color (alpha) nor does it move along the X axis. Actually I think just nothing happens at all. Am I missing something?
Thanks in advance
Posts: 2
Participants: 2