Spritebatch brightness?
Is there a way to increase a sprite brightness using spritebatch.draw()?
Im guessing I have to mess with the Color parameter but Im already using Color.White for that purpose.
Is there a way to increase brightness beyond this value?
Thanks
Since the Color class only accepts colours values between 0 and 1 you'll need to find another way of dong this.
I'd suggest using a pixel shader - http://msdn.microsoft.com/en-us/library/bb313868.aspx which will allow you to multiply the sprite by a colour that has more than 1 in each component (you'll want to leave alpha is-is though).
I'd suggest using a pixel shader - http://msdn.microsoft.com/en-us/library/bb313868.aspx which will allow you to multiply the sprite by a colour that has more than 1 in each component (you'll want to leave alpha is-is though).
Oh my god -_-
Ive never worked with shaders before, guess its time to grab the bull by the horns
Ive never worked with shaders before, guess its time to grab the bull by the horns
question is it possible to pass values to shader functions?
I dont want all of my objects(sprites) to be affected by the brightness shader
so maybe I was thinking that in those cases I can pass 0 , null or whatever
in fact I wonder if its possible to pass directly the brightness value so each object can store its own value and then pass it to the shader effect
Im a little bit in the dark in this shader subject so I have no idea how I have to do to structure a .fx file , from the samples Ive seen it seems that does not have a start point , just a bunch of functions
I dont want all of my objects(sprites) to be affected by the brightness shader
so maybe I was thinking that in those cases I can pass 0 , null or whatever
in fact I wonder if its possible to pass directly the brightness value so each object can store its own value and then pass it to the shader effect
Im a little bit in the dark in this shader subject so I have no idea how I have to do to structure a .fx file , from the samples Ive seen it seems that does not have a start point , just a bunch of functions
Yes it is possible. You can pass the params you want: Matrix, texture, color, float, etc
And try to not use if statements into the shader. Mathematical solution is often the best. So in your case, I would pass the brightness value as a float and multiply it, avoiding using if statements :)
And try to not use if statements into the shader. Mathematical solution is often the best. So in your case, I would pass the brightness value as a float and multiply it, avoiding using if statements :)
Oh ok
one more thing do you know of a good site to use as a reference for coding shader files?
I've tried googling but no luck there
one more thing do you know of a good site to use as a reference for coding shader files?
I've tried googling but no luck there
I think in the XNA documentation there are "How to" about that.
I did it pretty quickly the last time and I never used HLSL before.
Basically, for your case, you do not need the vertex shader. You can delete it.
And simply add a parameter in the pixel shader function: float inBrightness
and use that into your shader.
float4 color = tex2D(texture, texcoord);
color.rgb *= inBrightness;
return color;
I did it pretty quickly the last time and I never used HLSL before.
Basically, for your case, you do not need the vertex shader. You can delete it.
And simply add a parameter in the pixel shader function: float inBrightness
and use that into your shader.
float4 color = tex2D(texture, texcoord);
color.rgb *= inBrightness;
return color;
If you don't want to go the shader route (though it's a good thing to learn), you can modify the state the sprite system is using. Change it to use a MODULATE2X colorop. In this setting, 128 is "white", and 255 is twice as bright.
I think ID3DXSprite sets up the states when you "begin", so you can modify it right after that.
I think ID3DXSprite sets up the states when you "begin", so you can modify it right after that.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement