Ogre 1.8.2 to Ogre 14.3 issues

Problems building or running the engine, queries about how to use features etc.
AlphaSND
Gnoblar
Posts: 11
Joined: Sun Oct 06, 2002 11:19 pm
Location: France
x 2

Ogre 1.8.2 to Ogre 14.3 issues

Post by AlphaSND »

Ogre Version: 14.3
Operating System: Windows
Render System: OpenGL

Hello,

We have finally migrated from OGRE 1.8.2 to 14.3 and we got most the code working as expected, minus 2 things:

  • The shadow rendering seems much slower in 14.3 than it was in 1.8.2 (additive and modulative mode). Is there something expected or may be there is a flag to speed up like in the 1.8.2 may be with some quality drawback ?

  • We have a GLSL shader which should takes the closest light of an object, it was working in 1.8.2 but in 14.3 it now takes always the first light. Is something changed in light management for shaders ? Here is the shader code

vertex:

Code: Select all

#version 130

uniform mat4 P25;//+25
uniform vec4 P80;//+80
uniform vec4 P46;//+46 0
uniform vec4 P43;//+43 0
uniform vec4 P32;//+32

varying vec3 oviewdir;
varying vec3 olightdir;
varying vec3 onormal;
varying vec4 ovcolor;
varying float olightatt;
varying float ofogf;

void main()
{
oviewdir=normalize(P80.xyz-gl_Vertex.xyz);
olightdir=normalize(P46.xyz-gl_Vertex.xyz);
gl_Position=P25*gl_Vertex;
onormal=gl_Normal;
float Dist=distance(P46,gl_Vertex);
olightatt=1/(P43.y+P43.z*Dist+P43.w*Dist*Dist);
ovcolor=gl_Color;
ofogf=P32.z>0?min(abs(gl_Position.z)*P32.w,1):0;
}

fragment:

Code: Select all


#version 130

uniform vec4 P71;//+71 0
uniform vec4 P72;//+72 0
uniform vec4 P69;//+69 0
uniform float P37;//+37
uniform vec4 P31;//+31

varying vec3 oviewdir;
varying vec3 olightdir;
varying vec3 onormal;
varying vec4 ovcolor;
varying float olightatt;
varying float ofogf;

void main()
{
vec3 normal=normalize(onormal);if(gl_FrontFacing==false)normal*=-1;
vec3 viewdir=normalize(oviewdir);
vec3 lightdir=normalize(olightdir);
float dif=max(dot(lightdir,normal),0)*olightatt;
float spe=pow(max(dot(normalize(lightdir+viewdir),normal),0),P37);
vec4 color=(P69+P71*dif)+P72*spe;
gl_FragColor=mix(color,P31,ofogf);
}

Thanks !

rpgplayerrobin
Orc Shaman
Posts: 715
Joined: Wed Mar 18, 2009 3:03 am
x 396

Re: Ogre 1.8.2 to Ogre 14.3 issues

Post by rpgplayerrobin »

I think that paroj will be able to answer this question the best, but I also think you need to give a bit more information.

  1. Regarding the shadows, what kind shadows are you using? You mention additive and modulative but not exactly what kind of shadows it is.
    It can be any number of different shadows, such as stencil, simple texture shadows and advanced texture shadows such as depth shadows.

  2. Do you have objects that are using fixed function (meaning not using a shader)? In that case the new version of Ogre might use RTSS on them automatically, which might explain some slowdown. This could also affect the shadows, since a shadowcaster and receiver material that is fixed function will most likely always be faster than using a real shadow technique through a shader (such as depth texture shadows, which RTSS might use automatically).

  3. Regarding the light, is that light casting shadows? In that case the light should always be first in the list (which makes it much easier to handle in the shader because of shadow textures).
    Also, how does the shader material look to actually supply the light to the shader?

AlphaSND
Gnoblar
Posts: 11
Joined: Sun Oct 06, 2002 11:19 pm
Location: France
x 2

Re: Ogre 1.8.2 to Ogre 14.3 issues

Post by AlphaSND »

Hello rpgplayerrobin, thanks for the reply !

  1. About shadow, it's SHADOWTYPE_STENCIL_MODULATIVE and SHADOWTYPE_STENCIL_ADDITIVE
  2. I guess we have some mixing as we have basically ported the old code to the new one without doing much rework.
  3. About the light shadow, you are right, if I disable the shadow casting on the lights it works. In 1.8.2 it also worked with shadow casting enabled, or I miss something ?
rpgplayerrobin
Orc Shaman
Posts: 715
Joined: Wed Mar 18, 2009 3:03 am
x 396

Re: Ogre 1.8.2 to Ogre 14.3 issues

Post by rpgplayerrobin »

I am still unsure if you are using RTSS automatically or not, since it may be that the new version of Ogre is automatically creating shaders for you that has the same appearance as the old fixed-function ones, but that they may be slower for some reason (maybe they are adding texture shadows or something like that, impossible to know right now).
If I were you, I would check if RTSS is being used or not, since that may be a big part of this issue.

About shadow, it's SHADOWTYPE_STENCIL_MODULATIVE and SHADOWTYPE_STENCIL_ADDITIVE

Then I guess it is using fixed-function, since stencil shadows are never really used anymore.
I am unsure why the performance for stencil shadows would have changed between the versions, as last time I used stencil shadows were in 2008 or something like that.

About the light shadow, you are right, if I disable the shadow casting on the lights it works. In 1.8.2 it also worked with shadow casting enabled, or I miss something ?

I would suspect that 1.8.2 did not have that change yet in the code, but that change is actually good since it handles texture shadows much better in shaders (but since you are not using texture shadows, that change makes no difference for you of course).
Can you explain your scenario regarding this in more detail?
Because a normal setup is like this:

  • A directional light which casts shadows (this is the first one in the list always)
  • Multiple spot/point lights which do not cast shadows

In that scenario I don't see how the shader can get the wrong light, unless you also want the secondary lights as well (which you can easily implement in your shader).

rpgplayerrobin
Orc Shaman
Posts: 715
Joined: Wed Mar 18, 2009 3:03 am
x 396

Re: Ogre 1.8.2 to Ogre 14.3 issues

Post by rpgplayerrobin »

You can also try these settings a bit, since they may have changed their default values between the two Ogre versions:
mSceneMgr->setShadowUseInfiniteFarPlane(false);
mSceneMgr->setShadowFarDistance(x);
mSceneMgr->setShadowUseLightClipPlanes(x);
mSceneMgr->setShadowCasterRenderBackFaces(x);

AlphaSND
Gnoblar
Posts: 11
Joined: Sun Oct 06, 2002 11:19 pm
Location: France
x 2

Re: Ogre 1.8.2 to Ogre 14.3 issues

Post by AlphaSND »

Thanks again for the tips, I will check if it makes a difference. About the shadows, which mode is the most commonly used now ?

rpgplayerrobin
Orc Shaman
Posts: 715
Joined: Wed Mar 18, 2009 3:03 am
x 396

Re: Ogre 1.8.2 to Ogre 14.3 issues

Post by rpgplayerrobin »

Almost always depth texture shadows.
And it also depends on how your environment looks, because if it is a big outdoor scene you might also want adaptations of it such as PSSM shadows.

But either way, if you change to use texture shadows you also have to handle it in your shaders, and fixed function materials will not work with depth texture shadows at all.
To enable that, you would have to look into RTSS to generate shaders for you specifically for that, and that also requires your own written shaders to be completely removed or remade so that they work with RTSS as well.
Here are some info about RTSS (but there is more in the new samples I think as well): https://ogrecave.github.io/ogre/api/14/rtss.html

Or, you can just stick with stencil shadows, since doing that above might take a lot of work for an older project.

paroj
OGRE Team Member
OGRE Team Member
Posts: 2135
Joined: Sun Mar 30, 2014 2:51 pm
x 1145

Re: Ogre 1.8.2 to Ogre 14.3 issues

Post by paroj »

stencil shadows did not get much attention as it is not a popular choice any more.

Any commit in the last 13 years could be the culprit for your performance issues. If you can identify the faulty commit, I could look into that.

You can use git bisect to find it like:

Code: Select all

git bisect start
git bisect bad HEAD
git bisect good v1-8-1

this will take 12 tries to find the faulty commit.