[转]Passing an RTT to a shader
http://www.ogre3d.org/tikiwiki/Intermediate+Tutorial+7
As RTTs are often used with shaders, you have to know how to pass the RenderTexture to one. Fortunately, this is really simple.
The most simple case is one where you never change the texture for the shader during runtime. If it remains constant, you just have to tell your material script the name of the texture you create during runtime, in our case "RttTex". So your texture_unit in the material should look like this:
texture_unit { texture RttTex }
If you need to change the texture the shader should use during runtime, just add the two following lines:
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("Sepia"); material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("OtherRttTex");
With the first line we get a pointer to the material (in this case here a sepia shader material) where we change the texture name in the second line to the desired one.
Now, as you have set the correct texture name in your material script with one of these two methods, you can access the texture in your cg shader with the following line:
uniform sampler2D SceneSampler : register(s0)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构