OpenGL 3+ RenderSystem

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 214

Re: OpenGL 3+ RenderSystem

Post by scrawl »

I tried the workaround. It seems to fix it.

Code: Select all

GL_VERSION = 4.3.0 NVIDIA 310.14
And yeah, I definitely have updated drivers since then.

Ident
Gremlin
Posts: 155
Joined: Thu Sep 17, 2009 8:43 pm
Location: Austria
x 9
Contact:

Re: OpenGL 3+ RenderSystem

Post by Ident »

I would like to use this RenderSystem for a research project. For this we would need the Tesselation shaders of OpenGL 4.X+. I saw there was some talk in here about them already and i saw they are part of the 1.9 roadmap and also the source code seems to contain some fragments of tesselation shader support. I wanted to ask how far the tesselation shader progress is right now and to what extent they are functional?

The use-case would be to tesselate objects depending on proximity to the camera, similar to how it would be done for bump mapping tesselation.

Edit: fixed a sentence
Last edited by Ident on Mon Apr 15, 2013 7:36 pm, edited 1 time in total.

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

There is some work on supporting them, but I have not yet had a successful test.

User avatar
holocronweaver
Google Summer of Code Student
Google Summer of Code Student
Posts: 273
Joined: Mon Oct 29, 2012 8:52 pm
Location: Princeton, NJ
x 47

Re: OpenGL 3+ RenderSystem

Post by holocronweaver »

masterfalcon wrote:There is some work on supporting them, but I have not yet had a successful test.
Do you mean you have not tested tessellation, or that all your tests have not succeeded?

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

The tests have not been successful. Furthermore, I don't have a system that has decent GL debugging tools and supports GL 4. So it's slow going.

If anyone wants to help, it would be greatly appreciated.

User avatar
holocronweaver
Google Summer of Code Student
Google Summer of Code Student
Posts: 273
Joined: Mon Oct 29, 2012 8:52 pm
Location: Princeton, NJ
x 47

Re: OpenGL 3+ RenderSystem

Post by holocronweaver »

masterfalcon wrote:If anyone wants to help, it would be greatly appreciated.
*raises hand in the air so quickly his arm nearly comes out of socket* Meeeeeeeee!

I have an AMD Radeon 6950 (currently OpenGL 4.2 capable) and am fairly well acquainted with OpenGL 4 tessellation shaders. I am currently finishing up work on a paging system for the Ogre Volume component, but I cannot work on that during my lunch breaks so possibly tessellation shaders in OpenGL can fill the void. I need tessellation shaders for my personal Ogre project, so I have a personal stake in ensuring their successful impelmentation. That and I love new shiny things.

So what can I do to help?

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

Well, my understanding and experience with tessellation shaders is confined to trying to get this work. Very much a beginner. I get how it works, just have very little experience with them.

User avatar
holocronweaver
Google Summer of Code Student
Google Summer of Code Student
Posts: 273
Joined: Mon Oct 29, 2012 8:52 pm
Location: Princeton, NJ
x 47

Re: OpenGL 3+ RenderSystem

Post by holocronweaver »

Do you have particular test systems that need debugging or additional work? I have never debugged tessellation shaders using software debuggers, so that would be new to me. Up to now I always fix things the old fashion way by visualizing the tessellation grid and tweaking the shader until everything works.

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

So far I have only tried the tessellation sample. I'm not even sure if the shaders I wrote are correct.

Ident
Gremlin
Posts: 155
Joined: Thu Sep 17, 2009 8:43 pm
Location: Austria
x 9
Contact:

Re: OpenGL 3+ RenderSystem

Post by Ident »

Once there is a working simple test-case I can also step in to help,test and find bugs and debug, because from then on I will be able to use this in my project.

User avatar
bvanevery
Goblin
Posts: 218
Joined: Wed Feb 28, 2007 4:54 am
Location: Asheville, NC
x 7

Re: OpenGL 3+ RenderSystem

Post by bvanevery »

I can test whether it screws anything up on a 3d card that doesn't have tessellation.

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

I tried a little work recently. It didn't seem to help but may be in the right direction. I'm attaching the diff just in case it helps anyone.
Attachments
tess.diff.zip
(1.83 KiB) Downloaded 150 times

User avatar
holocronweaver
Google Summer of Code Student
Google Summer of Code Student
Posts: 273
Joined: Mon Oct 29, 2012 8:52 pm
Location: Princeton, NJ
x 47

Re: OpenGL 3+ RenderSystem

Post by holocronweaver »

@masterfalcon: Do you think finishing up the OpenGL 3+ render system and creating samples would make a good GSoC project?

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

Possibly. I'm afraid that there wouldn't be enough but we could probably come up with a good sized list of things to implement.

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

Another update to my tessellation work. It's rendering something at least, if you move the mouse around you'll see it. I suspect that there is something wrong with how I translated the shaders. Would anyone be able to verify?
Attachments
tess.diff.zip
(2.01 KiB) Downloaded 167 times

User avatar
holocronweaver
Google Summer of Code Student
Google Summer of Code Student
Posts: 273
Joined: Mon Oct 29, 2012 8:52 pm
Location: Princeton, NJ
x 47

Re: OpenGL 3+ RenderSystem

Post by holocronweaver »

masterfalcon wrote:Another update to my tessellation work. It's rendering something at least, if you move the mouse around you'll see it. I suspect that there is something wrong with how I translated the shaders. Would anyone be able to verify?
I will check this out when I get home today.

BTW, besides the samples, are there any visual tests for OpenGL 3+?

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: OpenGL 3+ RenderSystem

Post by Klaim »

masterfalcon wrote:Another update to my tessellation work. It's rendering something at least, if you move the mouse around you'll see it. I suspect that there is something wrong with how I translated the shaders. Would anyone be able to verify?
Sorry I will not be able to test until at least thursday.

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

@holocronweaver Nothing specific, just the normal tests. I have them partially running but they crash part way through. I know why, just haven't gotten to fixing it yet.

@Klaim No problem. Take your time.

dermont
Bugbear
Posts: 808
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: OpenGL 3+ RenderSystem

Post by dermont »

Not sure if I should be posting this in Help (if so sorry).

I'm trying to create a simple example using OpenGL3+ from looking at the Sdk Samples.

From trial and error and with the ShaderGeneratorTechniqueResolverListener where it appears that the Ogre::RTShader creates shaders for material's (with DEFAULT_SCHEME_NAME) techniques I can display a mesh on the screen.

The problem I encounter is creating a manual video texture to play a gstreamer video.

With OpenGL everything works fine where I use a shader to swap the gstreamer data red and blue components.

With OpenGL3+ it just doesn't work and I'm not sure how to do this, whether it is a problem in my version 150 shaders or I'm not understanding something basic (most likely). I've disabled the ShaderGeneratorTechniqueResolverListener for testing this. Any help or pointers would be greatly appreciated, failing that I guess I'll have to test with a native GL demo.

The video texture:

Code: Select all

// Create new texture with updated dimensions.
    mVideoTexture = Ogre::TextureManager::getSingleton().createManual(
                    mName + "_Texture",
                    ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                    TEX_TYPE_2D,
                    mVideoWidth, mVideoHeight,
                    0,PF_X8R8G8B8,
                    //0, PF_B8G8R8A8,
                    //0, PF_R8G8B8A8, //THIS ONE
                    //0,PF_A8R8G8B8,
                    TU_DYNAMIC_WRITE_ONLY);

    //mVideoMaterial->getTechnique(0)->setSchemeName("ShaderScheme");
    mVideoMaterial->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
    mVideoMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(
                    mVideoTexture->getName());

The shaders, for OpenGL these were used to swap the red and blue components.

Code: Select all

    String customVideoMatVp_GLSL =
        "#version 150 \n"
        "in vec2 uv0;\n"
        "in vec4 vertex;\n"
        "out vec2 oUv0;\n"
        "uniform mat4 worldViewProj;\n"
        "void main()\n"
        "{\n"
            " gl_Position = worldViewProj * vertex;\n"
            " oUv0.xy = uv0.xy;\n"
        "}\n";

    String customVideoMatFp_GLSL =
        "#version 150 \n"
        "in vec2 oUv0;\n"
        "out vec4 fragColour;\n"
        "uniform sampler2D diffuseMap;\n"
        "void main()\n"
        "{\n"
           " fragColour = vec4(texture(diffuseMap, oUv0.xy).zyx,1.0);\n"
        "}\n";

        String customVideoMatVp_GLSL_120 =
            " #version 120 \n"
            " varying vec2 UV;\n"
            " uniform mat4 worldViewProj;\n"
            " void main()\n"
            " {\n"
                " gl_Position = worldViewProj * gl_Vertex;\n"
                " UV = gl_MultiTexCoord0.xy;"
            " }\n";
        String customVideoMatFp_GLSL_120 =
            " varying vec2 UV;\n"
            " uniform sampler2D diffuseMap;\n"
            " void main()\n"
            "{\n"
                " gl_FragColor = vec4(texture2D(diffuseMap, UV).zyx,1.0);\n"
            "}\n";

    bool useCG = false;
    bool useGLSL120 = false;
   bool useGLSL150 = true;

    String mLanguage;
    if (useCG)
        mLanguage = "cg";
    else
        mLanguage = "glsl";

    HighLevelGpuProgramPtr vp = HighLevelGpuProgramManager::getSingleton()
                .createProgram("VideoVp",
                        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                        mLanguage, GPT_VERTEX_PROGRAM);
    HighLevelGpuProgramPtr fp = HighLevelGpuProgramManager::getSingleton()
            .createProgram("VideoFp",
            ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                mLanguage, GPT_FRAGMENT_PROGRAM);


    if (vp->getLanguage()=="cg") {
        vp->setSource(customVideoMatVp_CG);
        vp->setParameter("profiles", "vs_1_1 arbvp1");
        vp->setParameter("entry_point", "VideoVp");
    }
    else {
        if (useGLSL120) {
            vp->setParameter("syntax", "glsl");
            vp->setSource(customVideoMatVp_GLSL_120);
        }
        else
        {
            vp->setParameter("syntax", "glsl150");
            vp->setSource(customVideoMatVp_GLSL);
        }
    }

    if (fp->getLanguage()=="cg") {
        fp->setSource(customVideoMatFp_CG);
        fp->setParameter("profiles", "ps_1_1 arbfp1");
        fp->setParameter("entry_point", "VideoFp");
    }
    else
    {
        if (useGLSL120) {
            fp->setParameter("syntax", "glsl");
            fp->setSource(customVideoMatFp_GLSL_120);
        }
        else
        {
            fp->setParameter("syntax", "glsl150");
            fp->setSource(customVideoMatFp_GLSL);
        }
    }

    vp->load();
    fp->load();

    p->setVertexProgram("VideoVp");
    p->setFragmentProgram("VideoFp");

    p->getVertexProgramParameters()->setNamedAutoConstant(
                "worldViewProj", 
                GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);

    if (!useCG)
        p->getFragmentProgramParameters()->setNamedConstant(
                "diffuseMap", 
                0);
Updating the texture data where memory/size is the GStreamer memory/size of data.

Code: Select all


//guint8* memory, gsize size

HardwarePixelBufferSharedPtr pixelBuffer = mVideoTexture->getBuffer();
void* textureData = pixelBuffer->lock(HardwareBuffer::HBL_DISCARD);
memcpy(textureData, &memory[0], (int)size);
pixelBuffer->unlock();

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

Is it crashing or are you just not getting the output you expect? You could try turning on GL error checks in OgreGL3PlusPrerequisites.h and see if that reveals part of the problem. Otherwise I can try to take a look later using your sample.

dermont
Bugbear
Posts: 808
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: OpenGL 3+ RenderSystem

Post by dermont »

masterfalcon wrote:Is it crashing or are you just not getting the output you expect?
No it just outputs something unrelated to whatever the video is.
http://img818.imageshack.us/img818/4985/gstreamer.png
masterfalcon wrote:You could try turning on GL error checks in OgreGL3PlusPrerequisites.h and see if that reveals part of the problem.
Yeah I'll try that and running through apitrace.
masterfalcon wrote:Otherwise I can try to take a look later using your sample.
No need, you have enough on your plate. I was just hoping that I had was doing something so dumb due to me misunderstanding the differences between GL and GL3+ that it would be blatantly obvious.

I'll try implementing one of the demos that has a manual texture and work from there.

dermont
Bugbear
Posts: 808
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: OpenGL 3+ RenderSystem

Post by dermont »

dermont wrote:
masterfalcon wrote:
masterfalcon wrote:You could try turning on GL error checks in OgreGL3PlusPrerequisites.h and see if that reveals part of the problem.
Yeah I'll try that and running through apitrace.
To debug this:

a) I disabled the Vertex/FragmentProgram creation. The video played OK with the shaders generated via ShaderGeneratorTechniqueResolverListener.

However I need a straightforward way to update the shader code, e.g. swap red and blue components.

b) I wrote out the material from the MaterialSerializer, and obtained a copy of the vertex/fragment shaders ShaderGeneratorTechniqueResolverListener. I combined these into material/shader files and everything works fine using these media. The ShaderGeneratorTechniqueResolverListener was never invoked.

c) I returned to creating the programs in code noticed that there was an additional technique, so I removed the technique(1) and it segfaulted in ShaderGeneratorTechniqueResolverListener. There appears to be no difference in my code and that of (b). I set technique(0) setSchemeName to Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME and it worked fine.

I understand that the problem is probably with my understanding of scheme usage and that I probably need to update shader listener to handle my particular case (i.e. no GL2 shaders etc).

Thanks for all your advice anyway.

Syniurge
Halfling
Posts: 40
Joined: Thu Aug 30, 2012 1:43 pm
Location: France
x 3

Re: OpenGL 3+ RenderSystem

Post by Syniurge »

On Mesa's current R600 driver the plugin fails to load with:

Code: Select all

symbol lookup error: /home/syniurge/Projets/Dependencies/ogre_build/lib/RenderSystem_GL3Plus.so.1.9.0: undefined symbol: glXCreateContextAttribsARB
Is this because it's calling glXCreateContextAttribsARB directly instead of using glXGetProcAddressARB?

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OpenGL 3+ RenderSystem

Post by masterfalcon »

Probably. Perhaps we need to add a function pointer and get the address.

dermont
Bugbear
Posts: 808
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: OpenGL 3+ RenderSystem

Post by dermont »

When running the animation demos from SampleBrowser OepnGL3 they are all software skinning. The following message is displayed:

Code: Select all

Error attaching FFPLib_Common_VS shader object to GLSL Program Object
Program binary could not be loaded. Binary is not compatible with current driver/hardware combination.
In SampleContext.h it appears to be adding resources for RTShaderLib/GLSL and RTShaderLib/GLSL150. Shouldn't it be one or the other?

Code: Select all

https://bitbucket.org/sinbad/ogre/raw/2ad4bd4336205e6964152141bcf15e105d215fea/Samples/Common/include/SampleContext.h

else if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsl"))
            {
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/RTShaderLib/GLSL", type, sec);
                if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsl150"))
                {
                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/RTShaderLib/GLSL150", type, sec);
                }
            }
For the Skeletal Animation demo I removed the Software blending technique for jaiqua, updated SampleContext.h to load only RTShaderLib/GLSL or RTShaderLib/GLSL150. I get the following error:

Code: Select all

GLSL compile log: Ogre/HardwareSkinningTwoWeightsShadowCasterGLSL
0(43) : error C7533: global variable gl_TexCoord is deprecated after version 120
GLSL compile log: Ogre/HardwareSkinningTwoWeightsShadowCasterGLSL
https://bitbucket.org/sinbad/ogre/src/2 ... sl?at=v1-9

Indeed the deprecated function is in the gl_TexCoord GLSL150 programs. Does this mean that not all shaders have been updated or am I doing something wrong here.

Post Reply