问题
How do I obtain the color tint from a sprite batch from within the HLSL shader? I'm working with xna.
Also, what is the theory behind this? I would think that the tint color would just change the actual texture color before passing it to HLSL, but that does not seem to be the case.
回答1:
You can look at the source code for the default SpriteBatch shader here. Look at SpriteEffect.fx
for details.
Specifically the tint colour is passed in COLOR0
to the vertex shader, which is then passed directly to the pixel shader. In the pixel shader it gets multiplied by the texture sample for that pixel.
Modifying the texture data directly would be tremendously slow.
来源:https://stackoverflow.com/questions/11897015/obtaining-the-tint-color-from-a-sprite-batch-within-a-hlsl-shader