[1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
emc
Silver Sponsor
Silver Sponsor
Posts: 41
Joined: Mon Mar 20, 2006 12:43 pm
Location: Athens/Greece
Contact:

[1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by emc »

I have a problem with integrated texture shadow mapping after upgrading to RenderSystemGL3+.

This is running under RenderSystemGL, works as expected:
https://www.youtube.com/watch?v=wsZ3yZ3DWYo

Now under RenderSystemGL3+ with NVidia GPU:
https://www.youtube.com/watch?v=CvvijOARbrI

looks like the shadow texture is updated correctly when the program starts but the pose of the shadow camera is not updated when the light is moving.

Under RenderSystemGL3+ with AMD GPU:
https://www.youtube.com/watch?v=TJZ7HWOquVw

looks like the shadow texture is updated from the user's perspective instead of the light's.

any ideas?

thank you

Edit: No errors in ogre.log. I'm using the default shadow camera setup.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by paroj »

this could be a problem with the RTSS. Can you try to add the line
"mEnableFixedPipeline = false;"
at
https://github.com/OGRECave/ogre/blob/v ... m.cpp#L164

and see whether the Problem also occurs with RenderSystemGL.
User avatar
emc
Silver Sponsor
Silver Sponsor
Posts: 41
Joined: Mon Mar 20, 2006 12:43 pm
Location: Athens/Greece
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by emc »

paroj wrote:this could be a problem with the RTSS. Can you try to add the line
"mEnableFixedPipeline = false;"
at
https://github.com/OGRECave/ogre/blob/v ... m.cpp#L164

and see whether the Problem also occurs with RenderSystemGL.
Thank you for the suggestion. I added the line and recompiled the Ogre libraries. The RenderSystemGL shadows are still correct.
Please note that I'm not using the RTSS component.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by paroj »

emc wrote: Please note that I'm not using the RTSS component.
could you provide a minimal reproducer test with your shaders and your materials?

If the RTSS is disabled, then the difference must be in the GLSL shader or how the parameters are passed.
Are you by chance reading some fixed function state in the shader? (things starting with gl_) This would be still available in GL legacy but not with GL3+. Also are you forcing a specific GLSL version via "#version XXX"?
User avatar
emc
Silver Sponsor
Silver Sponsor
Posts: 41
Joined: Mon Mar 20, 2006 12:43 pm
Location: Athens/Greece
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by emc »

paroj wrote:
emc wrote: Please note that I'm not using the RTSS component.
could you provide a minimal reproducer test with your shaders and your materials?

If the RTSS is disabled, then the difference must be in the GLSL shader or how the parameters are passed.
Are you by chance reading some fixed function state in the shader? (things starting with gl_) This would be still available in GL legacy but not with GL3+. Also are you forcing a specific GLSL version via "#version XXX"?
I created a minimal test using my shaders and materials. I modified the "Lighting sample" and as you can see in the video it works fine:
https://youtu.be/cM0e6e5aDDo

I'm not reading fixed function state variables but I'm forcing a specific GLSL version via "#version330".

Back to my application now. I forgot to mention that the application supports multiple RenderWindows. On startup it creates a dummy RenderWindow and uses it to initialize Ogre. No viewports are created, and it is kept hidden during the lifetime of the application. During runtime, when the user loads a Scene a new RenderWindow is created and added to a notebook style widget.

This design works great with the legacy OpenGL rendersystem. With OpenGL3+ it seems to mess up the RenderWindow rendering in general, not just the shadows. For example when I load a new scene I see this:

Image

Looks like the camera matrix used for rendering is no longer the correct one.

One final remark. I modified my application, I removed the dummy window. Ogre now is initialized after the first RenderWindow is created (when the user loads a scene). Everything works perfectly (shadows etc):

Image

..until the user loads another scene and a new RenderWindow is created:

Image

Both RenderWindows are messed up.

Seems like GL3+ does not like creating RenderWindows after Ogre initialization.
Any insight is really appreciated. Meanwhile I'm trying to reproduce the problem on the modified sample so I can give you some code to look at.

Thank you
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by paroj »

do you re-use the GL context or create a new one for each window?

this works on linux at least:
https://github.com/OGRECave/ogre/blob/m ... #L349-L352
User avatar
emc
Silver Sponsor
Silver Sponsor
Posts: 41
Joined: Mon Mar 20, 2006 12:43 pm
Location: Athens/Greece
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by emc »

paroj wrote:do you re-use the GL context or create a new one for each window?

this works on linux at least:
https://github.com/OGRECave/ogre/blob/m ... #L349-L352
I create a new one for each window. Using currentGLContext = true raises an exception:

Code: Select all

18:20:33: GL3PlusRenderSystem::_createRenderWindow "eb80778d-5285-4cbb-a8c2-9ea3d6e3efdb", 800x600 windowed  miscParams: FSAA=4 FSAAQuality=0 currentGLContext=true externalWindowHandle=657516 
18:20:33: RenderingAPIException: wglMakeCurrent in Win32Window::create at E:\Devel\Dependencies\src\Ogre\v1.10.8p\ogre-1.10.8p\RenderSystems\GLSupport\src\win32\OgreWin32Window.cpp (line 497)
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by paroj »

ah.. you open a can of worms there.. OGRE tries to share resources with the main context if you create a new one. However some resources are strictly per context. Most notably FBOs and VAOs. This is not properly considered in the codebase. E.g. Ogre tries to cache renderbuffers here:
https://github.com/OGRECave/ogre/blob/m ... e.cpp#L506

There were some fixes for this in GLES2:
https://github.com/OGRECave/ogre/commit ... 7e2e000da7

Things probably worked in GL, as we do not use VAOs there - not sure why FBOs did work.

Anyway your best bet is to fix "currentGLContext=true" on Windows.
User avatar
emc
Silver Sponsor
Silver Sponsor
Posts: 41
Joined: Mon Mar 20, 2006 12:43 pm
Location: Athens/Greece
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by emc »

paroj wrote:ah.. you open a can of worms there.. OGRE tries to share resources with the main context if you create a new one. However some resources are strictly per context. Most notably FBOs and VAOs. This is not properly considered in the codebase. E.g. Ogre tries to cache renderbuffers here:
https://github.com/OGRECave/ogre/blob/m ... e.cpp#L506

There were some fixes for this in GLES2:
https://github.com/OGRECave/ogre/commit ... 7e2e000da7

Things probably worked in GL, as we do not use VAOs there - not sure why FBOs did work.

Anyway your best bet is to fix "currentGLContext=true" on Windows.
This is really helpful. I'll try to make it work in this direction.
Thank you so much for you time
User avatar
emc
Silver Sponsor
Silver Sponsor
Posts: 41
Joined: Mon Mar 20, 2006 12:43 pm
Location: Athens/Greece
Contact:

Re: [1.10.8, GL3Plus, Win10, AMD/NVidia] integrated texture shadows update issue

Post by emc »

Victory!

Image

The exception was raised because I was setting the "FSAA" option for the new RenderWindow.

Thanks again :)
Post Reply