obtaining the tint color from a sprite batch, within a HLSL shader

淺唱寂寞╮ 提交于 2019-12-24 10:54:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!