English 中文(简体)
Ogre material scripts; how do I give a technique multiple lod_indexes?
原标题:

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.

问题回答

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
    }
}
}




相关问题
OpenGL 3D Selection

I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it ...

Why and when should you use hoops 3d graphics? [closed]

My company needs 3D visualization for our commercial applications (CAD, mesh manipulation, computational geometry). We are tired of true vision 3D (tv3d), which we ve been using for years (poor ...

Prerequisite for learning directx

I am from .net C# background and I want to learn DirectX. I have knowledge of C++ but I am fairly new to graphic world. I am little confused about how to start learning directx, should I start ...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Determine VRAM size on windows

I need to determine roughly how much VRAM a system s graphics card has. I know all the reasons why I shouldn t but I do. It doesn t need to be perfect (some cards lie etc.) but I need a ballpark. On ...

Mask white color out of PNG image on iPhone

I know that there are already 2 relevant posts on that, but it s not clear... So the case is this...: I have a UIImage which consists of a png file requested from a url on the net. Is it possible to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签