[2.1] How to apply fog to billboards?

Problems building or running the engine, queries about how to use features etc.
Post Reply
ArbitraryValue
Gnoblar
Posts: 14
Joined: Tue Mar 22, 2011 10:06 pm

[2.1] How to apply fog to billboards?

Post by ArbitraryValue »

Ogre Version: 2.1:
Operating System: Windows 10
Render System: OpenGL

I have implemented fog exactly as described in this post: viewtopic.php?t=83081#p518819

It works for my V2 hlms-pbs meshes, but not for my V1 hlms-unlit billboards. Adding "hlmsUnlit->setListener(mySomeClass);" does not appear to do anything. Switching the billboards to use the same pbs datablock as my meshes causes these runtime errors:

Code: Select all

Shader Compiler:error(high) 0: SHADER_ID_COMPILE error has been generated. GLSL compile failed for shader 4, "": ERROR: 0:238: 'finalColour' : undeclared identifier 
ERROR: 0:239: 'mix' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:239: 'mix' : function is not known 
ERROR: 0:238: 'assign' :  cannot convert from 'const highp float' to '3-component vector of highp float'
Presumably this indicates that in CustomPost_piece_ps.glsl the following line is failing for the billboard. (Unsurprising, since viewtopic.php?t=84897 says to use unlit materials for billboards.)

Code: Select all

outColour.xyz   = mix(finalColour, fogColor, fogFactor );
Any suggestions?
gabbsson
Halfling
Posts: 65
Joined: Wed Aug 08, 2018 9:03 am
x 13

Re: [2.1] How to apply fog to billboards?

Post by gabbsson »

Just to be sure; have you added the CustomPost_piece_ps.gls (and the CustomPass buffer and so on) l to the Unlit folder as well?
I'm not familiar with that forum post or what you've added specifically. But assuming you are not using any PBS exclusive features it should work as far as I know. I might be wrong and you should double check that there are @insert for the pieces you create in the the custom pieces.
ArbitraryValue
Gnoblar
Posts: 14
Joined: Tue Mar 22, 2011 10:06 pm

Re: [2.1] How to apply fog to billboards?

Post by ArbitraryValue »

You guessed correctly, I was missing those files from the Unlit folder. (Sorry, silly mistake on my part.)

EDIT: I got it working! In addition to copying those files, I had to change:

Code: Select all

outColour.xyz   = mix(finalColour, fogColor, fogFactor );
in CustomPost_piece_ps.glsl (the custom fog code file) to

Code: Select all

outColour.xyz   = mix(outColour.xyz, fogColor, fogFactor );
because Unlit doesn't define "finalColour".

I also had to change

Code: Select all

// START UNIFORM DECLARATION
@property( has_planar_reflections )
	@insertpiece( PassDecl )
@end
in PixelShader_ps.glsl (which is a part of Ogre) to

Code: Select all

// START UNIFORM DECLARATION
@property( has_planar_reflections || !hlms_shadowcaster )
	@insertpiece( PassDecl )
@end
because otherwise Unlit would not define passBuf.

I am not experienced with glsl - did these changes have unintended consequences I don't know about?
Post Reply