添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Render System: :OpenGL ES 2.0:
Hi, I am doing an Android port of my project using Ogre 1.12.11. I have added RTSS to the scene manager in order to get material scripts to compile under GL ES. In one particular mesh that use material with alpha channel, the script failed to compile with the following error:

Code: Select all

E/OGRE: Program 'ccd77c2b4d566d088768d7ba9ee68733_FS' is not supported: 'ccd77c2b4d566d088768d7ba9ee68733_FS' ERROR: 17:20: 'switch' : Illegal use of reserved word
    ERROR: 17:20: 'switch' : syntax error
E/OGRE: Error: RTSS - creating GpuPrograms for pass 0 of 'Plant/OakA' failed
A/libc: /buildbot/src/android/ndk-release-r21/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:72: abort_message: assertion "terminating with uncaught exception of type Ogre::RuntimeAssertionException: RuntimeAssertionException: gpu program could not be created in createGpuPrograms at ogre-1.12.11/Components/RTShaderSystem/src/OgreShaderProgramManager.cpp (line 259)" failed
    Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 6278 (pperstudio.gtd3), pid 6248 (pperstudio.gtd3)
On debugging the Ogre::RTShader::ProgramManager, I found that the generated script 'ccd77c2b4d566d088768d7ba9ee68733_FS':

Code: Select all

#version 100
precision highp float;
precision highp int;
//-----------------------------------------------------------------------------
// Program Type: Fragment shader
// Language: glsles
// Created by Ogre RT Shader Generator. All rights reserved.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//                         PROGRAM DEPENDENCIES
//-----------------------------------------------------------------------------
#include <OgreUnifiedShader.h>
#include "SGXLib_PerPixelLighting.glsl"
#include "FFPLib_Common.glsl"
#include "FFPLib_Texturing.glsl"
#include "FFPLib_AlphaTest.glsl"
compiled using the language 'glsles' include an alpha test GLSL script that has an Alpha_Func using the 'switch' keyword:

Code: Select all

bool Alpha_Func(in int func, in float alphaRef, in float alphaValue)
    bool result = true;
    switch (func)
        case 0:// - CMPF_ALWAYS_FAIL,
            result = false;
        break;
        case 1: //- CMPF_ALWAYS_PASS,
            result = true;
        break;
        case 2: //- CMPF_LESS,
            result = alphaValue < alphaRef;
        break;
        case 3: //- CMPF_LESS_EQUAL,
            result = alphaValue <= alphaRef;
        break;
        case 4: //- CMPF_EQUAL,
            result = alphaValue == alphaRef;
        break;
        case 5: //- CMPF_NOT_EQUAL,
            result = alphaValue != alphaRef;
        break;
        case 6: //- CMPF_GREATER_EQUAL,
            result = alphaValue >= alphaRef;
        break;
        case 7: //- CMPF_GREATER
            result = alphaValue > alphaRef;
        break;
    return result;
I workaround the problem by using the if-else if statements:

Code: Select all

    if (func == 0) // - CMPF_ALWAYS_FAIL,
        result = false;
    else if (func == 1) //- CMPF_ALWAYS_PASS,
        result = true;
    else if (func == 2) //- CMPF_LESS,
        result = alphaValue < alphaRef;
    else if (func == 3) //- CMPF_LESS_EQUAL,
        result = alphaValue <= alphaRef;
    else if (func == 4) //- CMPF_EQUAL,
        result = alphaValue == alphaRef;
    else if (func == 5) //- CMPF_NOT_EQUAL,
        result = alphaValue != alphaRef;
    else if (func == 6) //- CMPF_GREATER_EQUAL,
        result = alphaValue >= alphaRef;
    else if (func == 7) //- CMPF_GREATER
        result = alphaValue > alphaRef;
This problem doesn't exist when using the Open GL render system where the RTShader is not required to be added to the scene manager.