对精灵的多重效果
我已经使用像素着色器文件实现了效果和过渡。当我分别应用效果和过渡时,它工作正常,但如果我同时应用两者,它就不起作用。如何将多个着色器应用于精灵。下面是我正在做的代码。
_effect = Effect.FromFile(_parentRVRenderer.Device, path, null, ShaderFlags.None, null);
_effect1 = Effect.FromFile(_parentRVRenderer.Device, path1, null, ShaderFlags.None, null);
_effect.Technique = "TransformTexture";
_effect1.Technique = "TransformTexture";
_effect1.Begin(0);
_effect1.BeginPass(0);
_effect.Begin(0);
_effect.BeginPass(0);
sprint.Begin()
Sprite.Draw();
....
I have implement the effect and Transition using pixel shader files. When i apply effect and transition separately it working fine, but if i am applying both simultaneously it is not working. How can apply multiple shader to a sprite. Below is code what i am doing.
_effect = Effect.FromFile(_parentRVRenderer.Device, path, null, ShaderFlags.None, null);
_effect1 = Effect.FromFile(_parentRVRenderer.Device, path1, null, ShaderFlags.None, null);
_effect.Technique = "TransformTexture";
_effect1.Technique = "TransformTexture";
_effect1.Begin(0);
_effect1.BeginPass(0);
_effect.Begin(0);
_effect.BeginPass(0);
sprint.Begin()
Sprite.Draw();
....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将两个像素着色器函数放在同一个着色器中,并使用双通道技术,在每个通道中应用不同的像素着色器。
您仍然必须使用两个渲染目标将输出从第一个通道弹回到另一个通道,如上所述,但使用两通道方法比将渲染目标发送到另一种着色器技术更好。
伪代码:
Put your two pixel shader functions in the same shader, and use a two-pass technique that applies a different pixel shader in each pass.
You still have to use two render targets to bounce the output from the first pass to the other as stated above, but it's better to use the two-pass approach than sending the render target to another shader technique.
Pseudocode:
我不确定是否可以同时应用 2 个着色器。但我要做的是使用第一个着色器将精灵绘制到渲染目标,然后使用第二个着色器将生成的图像绘制到屏幕上。
显然,如果您可以将这些效果组合到单个着色器中,那将是理想的选择,但这并不总是可能的。这可能不是最好的解决方案,但它应该可以解决问题。
I'm unsure as to if you can apply 2 shaders simultaneously. But what i would do, is draw the sprite to a render target using the first shader, and then draw the resulting image to the screen using the second shader.
Obviously it would be ideal if you could combine the effects into a single shader but thats not always possible. This might not be the best solution, but it should do the trick.