Jump to content
  • Advertisement
Sign in to follow this  
EvilNando

Spritebatch brightness?

This topic is 3675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!