armory3d / armory

3D Engine with Blender Integration
https://armory3d.org
zlib License
3.06k stars 316 forks source link

Deferred shader doesn't compile if _EnvCol is defined but _Brdf isn't #2690

Open MoritzBrueckner opened 1 year ago

MoritzBrueckner commented 1 year ago

https://github.com/armory3d/armory/commit/c0a07a70f448756a5fde8cab48ac0b572738feee introduced a small issue: If _EnvCol is defined but _Brdf isn't, envBRDF does not exist in the following line: https://github.com/armory3d/armory/blob/c0a07a70f448756a5fde8cab48ac0b572738feee/Shaders/deferred_light/deferred_light.frag.glsl#L269-L271

ERROR: [...]\build_test\compiled\Shaders\deferred_light.frag.glsl:270: 'envBRDF' : undeclared identifier
ERROR: [...]\compiled\Shaders\deferred_light.frag.glsl:270: '' : missing #endif
ERROR: [...]\compiled\Shaders\deferred_light.frag.glsl:270: '' : compilation terminated

Compilation would of course work again if the #ifdef would be extended by _Brdf, but this looks like it defeats the purpose of _EnvCol, which I presume to be rather complementary to _Brdf. _EnvCol gets defined for example when the world uses no nodes or no output node exists in a node tree, and _Brdf only exists when there is a proper world shader and radiance is enabled.

Example file brdf_issue.zip

The same could potentially happen a few lines above in the #ifdef _Rad block, but I think at the moment _Brdf is always defined if _Rad is defined so it works.

@LVutner maybe you know how to properly fix this? Should we define _Brdf also if _EnvCol is defined?

LVutner commented 1 year ago

I'll try to fix the issue soon. Thanks for reporting it!