|
@@ -0,0 +1,153 @@
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
|
+// Copyright (c) 2012 GarageGames, LLC
|
|
|
|
+//
|
|
|
|
+// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
+// of this software and associated documentation files (the "Software"), to
|
|
|
|
+// deal in the Software without restriction, including without limitation the
|
|
|
|
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
+// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
+// furnished to do so, subject to the following conditions:
|
|
|
|
+//
|
|
|
|
+// The above copyright notice and this permission notice shall be included in
|
|
|
|
+// all copies or substantial portions of the Software.
|
|
|
|
+//
|
|
|
|
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
+// IN THE SOFTWARE.
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
|
+
|
|
|
|
+singleton ShaderData( PFX_Bloom_Shader )
|
|
|
|
+{
|
|
|
|
+ DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
|
|
|
+ DXPixelShaderFile = "./bloomP.hlsl";
|
|
|
|
+
|
|
|
|
+ samplerNames[0] = "$inputTex";
|
|
|
|
+
|
|
|
|
+ pixVersion = 3.0;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+singleton ShaderData( PFX_BloomDownSample_Shader )
|
|
|
|
+{
|
|
|
|
+ DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
|
|
|
+ DXPixelShaderFile = "./downSampleP.hlsl";
|
|
|
|
+
|
|
|
|
+ samplerNames[0] = "$inputTex";
|
|
|
|
+
|
|
|
|
+ pixVersion = 3.0;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+singleton GFXStateBlockData( BloomPostFX_SampleStateBlock : PFX_DefaultStateBlock )
|
|
|
|
+{
|
|
|
|
+ samplersDefined = true;
|
|
|
|
+ samplerStates[0] = SamplerClampLinear;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+function BloomPostFX::setShaderConsts( %this )
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function BloomPostFX::preProcess( %this )
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function BloomPostFX::onAdd(%this)
|
|
|
|
+{
|
|
|
|
+ //Register the postFX with the manager
|
|
|
|
+ PostFXManager.registerPostEffect(%this);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function BloomPostFX::onEnabled( %this )
|
|
|
|
+{
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function BloomPostFX::onDisabled( %this )
|
|
|
|
+{
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//This is used to populate the PostFXEditor's settings so the post FX can be edited
|
|
|
|
+//This is automatically polled for any postFX that has been registered(in our onAdd) and the settings
|
|
|
|
+//are thus exposed for editing
|
|
|
|
+function BloomPostFX::populatePostFXSettings(%this)
|
|
|
|
+{
|
|
|
|
+ PostEffectEditorInspector.startGroup("BloomPostFX - General");
|
|
|
|
+ PostEffectEditorInspector.addCallbackField("$PostFX::BloomPostFX::Enabled", "Enabled", "bool", "", $PostFX::BloomPostFX::Enabled, "", "toggleBloomPostFX");
|
|
|
|
+ PostEffectEditorInspector.endGroup();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//This is called back from our callbackField defined in populatePostFXSettings to
|
|
|
|
+//Allow us to easily toggle the postFX and have it respond immediately
|
|
|
|
+function PostEffectEditorInspector::toggleBloomPostFX(%this)
|
|
|
|
+{
|
|
|
|
+ if($PostFX::BloomPostFX::Enabled)
|
|
|
|
+ BloomPostFX.enable();
|
|
|
|
+ else
|
|
|
|
+ BloomPostFX.disable();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//This function pair(applyFromPreset and settingsApply) are done the way they are, with the separated variables
|
|
|
|
+//so that we can effectively store the 'settings' away from the live variables that the postFX's actually utilize
|
|
|
|
+//when rendering. This allows us to modify things but still leave room for reverting or temporarily applying them
|
|
|
|
+function BloomPostFX::applyFromPreset(%this)
|
|
|
|
+{
|
|
|
|
+ if($PostFX::BloomPostFX::Enabled)
|
|
|
|
+ %this.enable();
|
|
|
|
+ else
|
|
|
|
+ %this.disable();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function BloomPostFX::savePresetSettings(%this)
|
|
|
|
+{
|
|
|
|
+ PostFXManager::savePresetSetting("$PostFX::BloomPostFX::Enabled");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//Our actual postFX
|
|
|
|
+singleton PostEffect( BloomPostFX )
|
|
|
|
+{
|
|
|
|
+ enabled = false;
|
|
|
|
+ allowReflectPass = false;
|
|
|
|
+
|
|
|
|
+ renderTime = "PFXAfterBin";
|
|
|
|
+ renderBin = "EditorBin";
|
|
|
|
+ renderPriority = 9999;
|
|
|
|
+
|
|
|
|
+ shader = PFX_Bloom_Shader;
|
|
|
|
+ stateBlock = BloomPostFX_SampleStateBlock;
|
|
|
|
+ texture[0] = "$backBuffer";
|
|
|
|
+ target = "$outTex";
|
|
|
|
+ targetFormat = "GFXFormatR16G16B16A16F";
|
|
|
|
+
|
|
|
|
+ new PostEffect()
|
|
|
|
+ {
|
|
|
|
+ allowReflectPass = false;
|
|
|
|
+ shader = PFX_BloomDownSample_Shader;
|
|
|
|
+ stateBlock = BloomPostFX_SampleStateBlock;
|
|
|
|
+ texture[0] = "$inTex";
|
|
|
|
+ target = "#bloom0";
|
|
|
|
+ targetScale = "0.5 0.5";
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ new PostEffect()
|
|
|
|
+ {
|
|
|
|
+ allowReflectPass = false;
|
|
|
|
+ shader = PFX_BloomDownSample_Shader;
|
|
|
|
+ stateBlock = BloomPostFX_SampleStateBlock;
|
|
|
|
+ texture[0] = "#bloom0";
|
|
|
|
+ target = "#bloom1";
|
|
|
|
+ targetScale = "0.25 0.25";
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ new PostEffect()
|
|
|
|
+ {
|
|
|
|
+ allowReflectPass = false;
|
|
|
|
+ shader = PFX_PassthruShader;
|
|
|
|
+ stateBlock = BloomPostFX_SampleStateBlock;
|
|
|
|
+ texture[0] = "#bloom1";
|
|
|
|
+ target = "$backBuffer";
|
|
|
|
+ };
|
|
|
|
+};
|