Show
Ignore:
Timestamp:
06/21/05 17:13:42 (10 years ago)
Author:
robert
Message:

Combined uniforms.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgparametric/osgparametric.cpp

    r4346 r4347  
    1515#include <osgProducer/Viewer> 
    1616 
    17 char vertexShaderSource[] =  
    18     "uniform vec2  xCoeff; \n" 
    19     "uniform vec2  yCoeff; \n" 
    20     "//uniform sampler2D baseTexture; \n" 
     17char vertexShaderSource_simple[] =  
     18    "uniform vec4 coeff; \n" 
    2119    "\n" 
    2220    "void main(void) \n" 
     
    2422    "\n" 
    2523    "    gl_TexCoord[0] = gl_Vertex; \n" 
    26     "    gl_Vertex.z = gl_Vertex.x*xCoeff[0] + gl_Vertex.x*gl_Vertex.x* xCoeff[1] + \n" 
    27     "                  gl_Vertex.y*yCoeff[1] + gl_Vertex.y*gl_Vertex.y* yCoeff[1]; \n" 
    28     "    //gl_Vertex.z = texture2D( vertexTexture, gl_TexCoord[0].xy).r; \n" 
     24    "    gl_Vertex.z = gl_Vertex.x*coeff[0] + gl_Vertex.x*gl_Vertex.x* coeff[1] + \n" 
     25    "                  gl_Vertex.y*coeff[2] + gl_Vertex.y*gl_Vertex.y* coeff[3]; \n" 
    2926    "    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" 
    3027    "}\n"; 
     
    4542        const osg::FrameStamp* fs = nv->getFrameStamp(); 
    4643        float value = sinf(fs->getReferenceTime()); 
    47         uniform->set(osg::Vec2(value,-value)); 
     44        uniform->set(osg::Vec4(value,-value,-value,value)); 
    4845    } 
    4946}; 
     
    10198    stateset->setAttribute(program); 
    10299 
    103     osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource); 
     100    osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource_simple); 
    104101    program->addShader(vertex_shader); 
    105102     
     
    109106 
    110107 
    111     osg::Uniform* xCoeff = new osg::Uniform("xCoeff",osg::Vec2(1.0,-1.0f)); 
     108    osg::Uniform* xCoeff = new osg::Uniform("coeff",osg::Vec4(1.0,-1.0f,-1.0f,1.0f)); 
    112109    xCoeff->setUpdateCallback(new UniformVarying); 
    113110    stateset->addUniform(xCoeff); 
    114111 
    115     osg::Uniform* yCoeff = new osg::Uniform("yCoeff",osg::Vec2(-1.0f,1.0f)); 
    116     stateset->addUniform(yCoeff); 
    117      
    118112     
    119113    osg::Texture2D* texture = new osg::Texture2D(osgDB::readImageFile("lz.rgb"));