• GLSL传递数组


    static const char *microshaderFragSource = {
        "varying vec4 color;
    "
        "uniform bool test1=true;
    "
        "uniform float test2=15.0;
    "
        "uniform float gauss_num[10];
    "
        "void main(void)
    "
        "{
    "
        "        if(test1)
    "
        "    gl_FragColor = clamp( color, 0.0, 1.0 );
    "
        "        else
    "
        "    gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
    "
        "}
    "
    };
    // 数组类型的uniform,数组大小必须与.glsl中的数组大小保持一致
        osg::FloatArray* g_GaussNum = new osg::FloatArray(10);
        osg::Uniform* gauss_num = new osg::Uniform(osg::Uniform::FLOAT, "gauss_num", g_GaussNum->size());
        gauss_num->setArray(g_GaussNum);
    //如果是vec2类型的数组,使用FLOAT_VEC2,setElement循环设置每一个元素
    // 给uniform添加一个回调 osg::Uniform* OffsetUniform = new osg::Uniform("Offset", osg::Vec3(0.0f, 0.0f, 0.0f)); OffsetUniform->setUpdateCallback(new AnimateCallback()); ss->addUniform(OffsetUniform);
  • 相关阅读:
    luogu 2962 [USACO09NOV]灯Lights
    bzoj 1923
    bzoj 1013
    bzoj 3513
    bzoj 4259
    bzoj 4503
    CF 632E
    bzoj 3527
    bzoj 3160
    bzoj 2179
  • 原文地址:https://www.cnblogs.com/coolbear/p/10668853.html
Copyright © 2020-2023  润新知