@tylrbd wrote:
Hello! I'm using a pixel shader to draw lights in my game, ported from XNA to Xbox/Windows 10 as a UWP. The .fx file builds through the MonoGame Content Pipeline, but returns all black when used. I apologize, my shader knowledge is minimal.
Shader code:
sampler s0; texture lightMask; sampler lightSampler = sampler_state { Texture = <lightMask>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0 { float4 color = tex2D(s0, coords); float4 lightColor = tex2D(lightSampler, coords); color *= 1 + lightColor * 3; return color; } technique Technique1 { pass Pass1 { PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction(); } }
And this is how I use it in game:
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); Game1.lightingEffect.Parameters["lightMask"].SetValue(Game1.lightsTarget); Game1.lightingEffect.CurrentTechnique.Passes[0].Apply(); spriteBatch.Draw(Game1.mainTarget, Vector2.Zero, Color.White); spriteBatch.End();
Thanks for any help!
Posts: 3
Participants: 2