[2.1] HlmsLowLevel material lighting, how?

Problems building or running the engine, queries about how to use features etc.
Post Reply
aberg
Gnoblar
Posts: 2
Joined: Fri Sep 24, 2010 12:37 pm

[2.1] HlmsLowLevel material lighting, how?

Post by aberg » Sun Dec 16, 2018 12:08 am

Ogre Version: 2.1
Operating System: any i think
Render System: opengl3+/dx11

Hi, we are starting to use 2.1 but would still like to keep support for our old 1.9 shaders for backward compatibility for a while.
We are currently testing with V1_FAST and Forward3DPlus.
PBS materials render fine and old materials also render, now using HlmsLowLevel, but they do not get any lighting.

As far as I can see, AutoParamDataSource::setCurrentLightList does not get called anymore and our Ogre 1.9 shaders need that i guess.

What is the current way to get lighting into HlmsLowLevel materials?

Also, as far as I can see, SceneManager::buildLightListThread02 and MovableObject::buildLightList does not get called anymore, in any mode (dead code?). Isn't that still needed to generate light lists for the low level materials?

The proper way may be to make a hlms specialization for the old materials but we were hoping for a quick fix with HlmsLowLevel.

/Cheers
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3940
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 170
Contact:

Re: [2.1] HlmsLowLevel material lighting, how?

Post by dark_sylinc » Mon Dec 17, 2018 6:10 am

Hi!

Because this is a very rarely requested feature, and it was consuming a lot of performance at all times despite not being used, you will see that inside SceneManager::buildLightList at the end there is some bit of code that is never executed due to a sneaky return:

Code: Select all

    if( mForwardPlusSystem )
        return; //Don't do this on non-forward passes.
    return; // -----> HERE THIS RETURN

    mRequestType = BUILD_LIGHT_LIST02;
#if OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN
    _updateWorkerThread( NULL );
#else
    mWorkerThreadsBarrier->sync(); //Fire threads
    mWorkerThreadsBarrier->sync(); //Wait them to complete
#endif
The code got "disabled" like that because nobody took 5 minutes on how to properly switch this at runtime. BUILD_LIGHT_LIST02/buildLightListThread02 is basically what makes lighting works on low level materials; as it creates a list of lights per MovableObject based on distance to them; which is what Ogre 1.x does.

If all goes well, just getting rid of that return may cause the lighting you're expecting to appear.

Cheers
Matias
0 x

aberg
Gnoblar
Posts: 2
Joined: Fri Sep 24, 2010 12:37 pm

Re: [2.1] HlmsLowLevel material lighting, how?

Post by aberg » Tue Dec 18, 2018 8:49 pm

Thanks a lot for a for a quick and good answer.

Yes, I saw the return(s) and this confirmed my thoughts nicely.

I did a quick change with a run-time option to turn on the legacy light list
generation and also use it in HlmsLowLevel. Seems to work.

I made a pull request with the change but I guess a nicer way to support legacy
code would be to move it out of the core and use callbacks or something.

https://github.com/OGRECave/ogre/pull/1008
0 x

Post Reply