preprocessor_defines not working with GLSL shader

Problems building or running the engine, queries about how to use features etc.
Post Reply
Conoktra
Gnoblar
Posts: 20
Joined: Thu Feb 14, 2013 2:45 pm

preprocessor_defines not working with GLSL shader

Post by Conoktra »

Hello,

I define some preprocessor options for a GLSL shader using preprocessor_defines like so:

Code: Select all

vertex_program UnitShader_WithBones_VS glsl
{
	preprocessor_defines ENABLE_BONES,NUM_BONES=4
}
But sometimes when I run my program those #defines aren't properly passed to the shader, but sometimes they are. It is very strange. How do I get Ogre to reliably set #defines for GLSL shaders?

Thanks, I really appreciate any and all help!
swuth
Bronze Sponsor
Bronze Sponsor
Posts: 53
Joined: Wed Mar 25, 2015 10:01 pm

Re: preprocessor_defines not working with GLSL shader

Post by swuth »

I am having the exact same problem. Can someone please explain how to properly set and check preprocessor defines in GLSL?

Thanks in advance

Swuth
hyyou
Gremlin
Posts: 173
Joined: Wed Feb 03, 2016 2:24 am
x 17
Contact:

Re: preprocessor_defines not working with GLSL shader

Post by hyyou »

A half year ago, in Ogre 1.9, I had this problem.
After a few days, I still could not solve it.

Now, I am using Ogre 2.1.

The new custom HLMS provide a far better flexibility than the old preprocessor_defines or anything I could ever imagine.

I really love to manipulate #ifdef in glsl ;
  • HLMS is just fit to my need - it also provides more than that.
    HLMS is one of the best designs I have ever seen.
If I could talk to myself in that days, I will recommend myself to stop trying to solve this problem.
I should move toward Ogre 2.1 instead.

Hey myself, did you hear me?
You should not hesitate to adopt HLMS-religion!
Custom HLMS (not just PBS or unlit) is very addictive.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: preprocessor_defines not working with GLSL shader

Post by frostbyte »

well, you've moved to ogre2.1, did'nt you?
i think your past-self have finally heard you (-:
just be careful not to collapse space-time...

btw: HLMS port also exist in ogre1.10 with PBS pipeline( thx wolfmanfx )

edit:
swuth: i don't think( but not sure ) its possible to get the GLSL preprocessor output- that was mentioned by dark_sylinc as one of HLMS advantages
Conoktra: if you think its a bug then open a jira ticket/bug submission...ogre 1.10 is still under active development...
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: preprocessor_defines not working with GLSL shader

Post by dark_sylinc »

I'm running into a similar problem and discovered the reason behind this issue.

GLSL is first parsed by Ogre, including the macro preprocessor. Apparently this was because of an era where GLSL drivers were really bad (i.e. refusing to compile perfectly valid GLSL code), so someone wrote a parser we could rely on. Unfortunately this parser is still needed due to the poor quality of Android GLES drivers out there in the wild.

This preprocessor supports most directives, but I found out it does not support #elif. I just added support for elif but only to GL3+ RenderSystem. There could be other limitations or bugs in the preprocessor.
That's very much likely why some macros appear to be working while others are not.
Post Reply