食人魔材料脚本;如何为一项技术提供多个 lod_indexes?
我有一个 Ogre 材质脚本,它定义了 4 种渲染技术。 1 个使用 GLSL 着色器,然后其他 3 个仅使用不同分辨率的纹理。
如果显卡支持,我想无条件使用 GLSL 着色器,否则其他 3 个纹理取决于相机距离。
目前我的剧本是;
material foo
{
lod_distances 1600 2000
technique shaders
{
lod_index 0
lod_index 1
lod_index 2
//various passes here
}
technique high_res {
lod_index 0
//various passes here
}
technique medium_res {
lod_index 1
//various passes here
}
technique low_res {
lod_index 2
//various passes here
}
额外信息
Ogre手册说;
索引增加表示详细程度较低
您可以(并且经常会)将多种技术分配给同一个 LOD 索引,这意味着 OGRE 将选择“同一 LOD 索引列出的技术中的最佳技术”。
OGRE 通过首先列出哪个来确定哪个是“最佳”。
目前,在支持我正在使用的 GLSL 版本的计算机上,脚本的行为如下:
- 相机> 2000 : 着色器技术
- Camera >1600 <= 2000 : Medium // 这里选择我的“纹理”技术而不是着色器
- Camera <= 1600 : High //
如果我将着色器技术中的 lod 顺序更改为
{
lod_index 2
lod_index 1
lod_index 0
}
Only the使用最新的 lod_index。
如果我将其更改为
lod_index 0 1 2
它会对我大喊
Compiler error: fewer parameters expected in foo.material(#): lod_index only supports 1 argument
那么我如何指定一种技术来拥有 3 个 lod_indexes?
重复作品;
technique shaders
{
lod_index 0
//Shader passes here
}
technique shaders1
{
lod_index 1
//DUPLICATE of shader passses in lod 0
}
technique shaders2
{
lod_index 2
//DUPLICATE of shader passses in lod 0
}
……但是很丑。
I have an Ogre material script that defines 4 rendering techniques. 1 using GLSL shaders, then 3 others that just use textures of different resolutions.
I want to use the GLSL shader unconditionally if the graphics card supports it, and the other 3 textures depending on camera distance otherwise.
At the moment my script is;
material foo
{
lod_distances 1600 2000
technique shaders
{
lod_index 0
lod_index 1
lod_index 2
//various passes here
}
technique high_res {
lod_index 0
//various passes here
}
technique medium_res {
lod_index 1
//various passes here
}
technique low_res {
lod_index 2
//various passes here
}
Extra information
The Ogre manual says;
Increasing indexes denote lower levels of detail
You can (and often will) assign more than one technique to the same LOD index, what this means is that OGRE will pick 'the best technique of the ones listed at the same LOD index.
OGRE determines which one is 'best' by which one is listed first.
Currently, on a machine supporting the GLSL version I am using, the script behaves as follows;
- Camera > 2000 : Shader technique
- Camera >1600 <= 2000 : Medium // Here it is chosing my "texture" technique instead of the shader
- Camera <= 1600 : High //
If I change the lod order in shader technique to
{
lod_index 2
lod_index 1
lod_index 0
}
Only the latest lod_index is used.
If I change it to
lod_index 0 1 2
It shouts at me
Compiler error: fewer parameters expected in foo.material(#): lod_index only supports 1 argument
So how do I specify a technique to have 3 lod_indexes?
Duplication works;
technique shaders
{
lod_index 0
//Shader passes here
}
technique shaders1
{
lod_index 1
//DUPLICATE of shader passses in lod 0
}
technique shaders2
{
lod_index 2
//DUPLICATE of shader passses in lod 0
}
...but it's ugly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您对不同 LOD 值使用不同技术的方法确实是正确的。包含材质 LOD 使用情况的完整示例文件如下所示。
注意:您当然可以更改 LOD 策略以满足您的需求。所有有效的策略值及其行为都在 Ogre 手册中进行了解释。
Your approach with different techniques for the different LOD values is indeed the correct one. A complete example file with material LOD usage, would look like this.
Note: You can of course change LOD strategy to fit your needs. All valid strategy values and their behavior are explained in the Ogre manual.