食人魔材料脚本;如何为一项技术提供多个 lod_indexes?

发布于 2024-08-16 17:25:33 字数 1779 浏览 5 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

同展鸳鸯锦 2024-08-23 17:25:33

您对不同 LOD 值使用不同技术的方法确实是正确的。包含材质 LOD 使用情况的完整示例文件如下所示。

注意:您当然可以更改 LOD 策略以满足您的需求。所有有效的策略值及其行为都在 Ogre 手册中进行了解释。

material testLOD
{
lod_strategy screen_ratio_pixel_count
lod_values 0.8 0.6 0.4 0.2

technique red10
{
    pass red
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 1 0 0 1
    }
}

technique green20
{
    lod_index 1
    pass green
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 0 1 0 1
    }
}

technique cyan100
{
    lod_index 2
    pass cyan
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 0 0.945098 0.980392 1
    }
}

technique blue200
{
    lod_index 3
    pass blue
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 0 0 1 1
    }
}

technique yellow1000
{
    lod_index 4
    pass yellow
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 1 1 0 1
    }
}
}

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.

material testLOD
{
lod_strategy screen_ratio_pixel_count
lod_values 0.8 0.6 0.4 0.2

technique red10
{
    pass red
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 1 0 0 1
    }
}

technique green20
{
    lod_index 1
    pass green
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 0 1 0 1
    }
}

technique cyan100
{
    lod_index 2
    pass cyan
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 0 0.945098 0.980392 1
    }
}

technique blue200
{
    lod_index 3
    pass blue
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 0 0 1 1
    }
}

technique yellow1000
{
    lod_index 4
    pass yellow
    {
        ambient 0.698039 0.698039 0.698039 1
        diffuse 0.698039 0.698039 0.698039 1
        specular 0.898039 0.898039 0.898039 1 20
        emissive 1 1 0 1
    }
}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文