[SOLVED]simple pass through vertex shader

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
paul424
Gnome
Posts: 330
Joined: Thu May 24, 2012 7:16 pm
x 16

[SOLVED]simple pass through vertex shader

Post by paul424 »

Ogre Version: : 1 12 13:
Operating System: :Linux Tumbleweed:
Render System: :OpenGL3+:

Hello, hello, I try to manually tinker toy with shaders. Manually means I do createMaterial on the fly and then pinpoint the vertex and fragment programs, without the need of material scripts ( I would need that later ) . I almost managed to write my first pass-through vertex program, well almost :

I do :

Code: Select all

       myOutliner = Ogre::MaterialManager::getSingletonPtr()->create("myOutliner", "Graphics");
        Ogre::HighLevelGpuProgramManager& mgr =  Ogre::HighLevelGpuProgramManager::getSingleton();
 
    Ogre::HighLevelGpuProgramPtr vertex_program = mgr.createProgram("enlarge", "Graphics","glsl" ,Ogre::GpuProgramType::GPT_VERTEX_PROGRAM);

    Ogre::GpuProgramParametersSharedPtr vertexParams = vertex_program->createParameters();
    vertexParams->setNamedAutoConstant("worldViewProj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);

    vertex_program->setSourceFile("enlarge.vert");

Code: Select all

#version 330 core
#extension GL_ARB_explicit_uniform_location : enable
#extension GL_ARB_shading_language_include : enable

layout (location = 0) in vec4 position;
uniform    mat4 worldViewProj;


void main(void)
{
  gl_Position =worldViewProj * position;
}

I get:

Code: Select all

Program 'enlarge' is not supported: Failed to preprocess shader enlarge
(20:31:15) (ODApplication) [NORMAL] InvalidParametersException: Named constants have not been initialised, perhaps a compile error in _findNamedConstantDefinition at /home/tom/Downloads/ogre-1.12.13/OgreMain/src/OgreGpuProgramParams.cpp (line 1675)

What I do wrong here ? For sure something wrong with the way I feed the namedAutoConstant parameteres but why it is so ?

Last edited by paul424 on Mon Jun 10, 2024 7:57 pm, edited 1 time in total.
User avatar
paul424
Gnome
Posts: 330
Joined: Thu May 24, 2012 7:16 pm
x 16

Re: simple pass through vertex shader

Post by paul424 »

oki the full program should be :

Code: Select all

        myOutliner = Ogre::MaterialManager::getSingletonPtr()->create("myOutliner", "Graphics");
        Ogre::HighLevelGpuProgramManager& mgr =  Ogre::HighLevelGpuProgramManager::getSingleton();
 
    Ogre::HighLevelGpuProgramPtr vertex_program = mgr.createProgram("enlarge", "Graphics","glsl" ,Ogre::GpuProgramType::GPT_VERTEX_PROGRAM);

    // Ogre::GpuProgramParametersSharedPtr vertexParams = vertex_program->getVertexProgramParameters()->setNamedAutoConstant("worldViewProj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);

    vertex_program->setSourceFile("enlarge.vert");

     myOutliner->getTechnique(0)->getPass(0)->setVertexProgram("enlarge","Graphics");
     myOutliner->getTechnique(0)->getPass(0)->getVertexProgramParameters()->setNamedAutoConstant("worldViewProj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
Post Reply