Sign in to follow this  

Postprocess shader not working properly

Recommended Posts

Ok, so what I'm trying to do is do fake lighting in a 2d game by making 2 textures, one with the normal screen information, and the second one a black and white texture where the "lights" are located. I'm having trouble getting the second texture set properly. I'm generating the second texture by rendering the white only sprites to a backbuffer, then saving the result of that to a texture. I know it's being generated properly, because when I use a function to save the texture to a file during the game, the save is what I'm expecting to see. I'm using the flatredball engine, and it handles setting the first texture as the rendered screen for me, I just need to figure out how to set the second texture. When I try to just output the second color in the shader, all I get is a completely blank screen. What am I doing wrong? The texture gets updated every frame. This is getting pretty frustrating [img][/img].

The Shader Code:
[code]// Shader Variable
float colorIntensity;

texture backTexture;

// Texture Sampler
//sampler2D inputSampler : register(s0);

sampler2D inputSampler;

sampler2D backSampler : register(s1) = sampler_state
texture = <backTexture>;

// Pixel Shader
float4 SaturateShader(float2 texCoord1 : TEXCOORD0) : COLOR
// Get the pixel's color
float4 color1 = tex2D(inputSampler, texCoord1);
float4 color2 = tex2D(backSampler, texCoord1);

// Return the saturated color
//color3 = color2 + .1f;
//color3 = color;
return color2;

// Technique
technique SetSaturation
pass Pass0
pixelShader = compile ps_2_0 SaturateShader();

The code that sets the second texture:
[code]namespace Light.Entities
class PostProcessEffect : PostProcessingEffectBase
private Texture2D backTexture;
private float intensity;

public PostProcessEffect(String shader, Texture2D newBackTexture)
: base(shader)
backTexture = newBackTexture;

public override void InitializeEffect()

mEnabled = true;

public void setIntensity(float intensityValue)
intensity = intensityValue;

public void updateTexture(Texture2D newBackTexture)

protected override void SetEffectParameters(FlatRedBall.Camera camera)

Edit: Never mind, I solved my problem through sheer luck.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this