Fading PostFX
by Andrew Edmonds · in Torque 3D Professional · 03/05/2010 (1:01 am) · 6 replies
Hi all,
Does anyone have any pointers on the best way to fade in and out a Post Effect? Ideally I'd like a way to control the 'strength' of the post effect via script.
Thanks.
Does anyone have any pointers on the best way to fade in and out a Post Effect? Ideally I'd like a way to control the 'strength' of the post effect via script.
Thanks.
About the author
Formed in 2005, EiKON Games is an indie games development project based in the UK working on the tactical first person shooter "Epoch: Incursion". See the Join Us or Contact Us pages at http://www.eikon-games.com/
#2
I'll have a play with your suggestion and see what I can come up with.
03/05/2010 (2:45 am)
Thanks Ivan - that's a great start. I'm new to shader programming - in fact I'm learning by taking your shaders apart (from the shader pack) and modifying them to see what results they give.I'll have a play with your suggestion and see what I can come up with.
#3
03/05/2010 (3:55 am)
Just complementing what Ivan said: setShaderConsts() is called every frame before rendering the post effect, so you can easily use it to change the values of shader constants over time.
#4
03/05/2010 (5:02 am)
Perfect - thanks both! That's solved that one.
#5
I have just posted a resource about this:
www.torquepowered.com/community/resources/view/19429
03/05/2010 (10:37 am)
@Eikon GamesI have just posted a resource about this:
www.torquepowered.com/community/resources/view/19429
#6
Downside is that without a code modification, you can only fade to black and not to another color.
//BTW: I modified GuiFadeinBitmapCtrl to have a new "fadeColor" property that allows to specify a fade-from and fade-to color other than the default black. Change will be included in b2.
03/09/2010 (9:40 pm)
BTW, another method that doesn't rely on a PostFX is to place a GuiFadeinBitmapCtrl with an empty "bitmap" property over your GameTSCtrl and set it up such that it only does a fade-out. This will progressively cover the underlying rendered scene until it finally goes to full black.Downside is that without a code modification, you can only fade to black and not to another color.
//BTW: I modified GuiFadeinBitmapCtrl to have a new "fadeColor" property that allows to specify a fade-from and fade-to color other than the default black. Change will be included in b2.
Torque Owner Ivan Mandzhukov
Liman3D
The postFx system is searching for a method called setShaderConsts()
If this method presents,then it is executed and your shader constants are added to constant's buffer.
For example:
function YourPostFX::setShaderConsts( %this ) { %this.setShaderConst( "$transition", evaluateTransition() ); }where evaluateTransition() have to return a value in [0-1] range.
Then transition used in a shader:
now you can lerp the final color based on its value.
When the color fade out,you can turn off the fullscreen shader.