From 3c0c106051fcb55cef434bff030b5051e011694f Mon Sep 17 00:00:00 2001 From: Areloch Date: Fri, 11 Sep 2020 02:28:15 -0500 Subject: [PATCH] Reorgs the editing of postFX so the editor settings edits the default config, and Scene > edit postFX to edit scene Changes the saving of postfx from saving via the editor to instead save on level save Reorganizes the core postfx folder to subfolders for better organization, as well as moving the shaders to group with the respective postFX Changes the postfx editor so it only edits postFXs that are actively enabled in the scene, and only saves out similarly. Adjusts the level download logic to pass asset id for both data compactness compared to the full level filename, as well as easier lookup reference for associated files like the postFX preset file or decal files from the asset def. Updated the PostFXAsset template to provide an up-to-date starting point/template. --- Engine/source/T3D/Scene.cpp | 17 + Engine/source/T3D/Scene.h | 4 + Engine/source/T3D/assets/LevelAsset.cpp | 16 +- .../scripts/client/levelDownload.cs | 41 +- .../scripts/server/levelDownload.cs | 10 +- .../clientServer/scripts/server/levelLoad.cs | 2 +- .../datablocks/defaultDatablocks.cs | 2 +- .../CameraMotionBlurPostFX.asset.taml | 8 + .../CameraMotionBlurPostFX.cs | 124 ++++++ .../CameraMotionBlurPostFXP.glsl} | 6 +- .../CameraMotionBlurPostFXP.hlsl} | 6 +- .../CausticsPostFX.asset.taml} | 4 +- .../CausticsPostFX.cs} | 4 +- .../scripts/Caustics/CausticsPostFXP.glsl} | 4 +- .../scripts/Caustics/CausticsPostFXP.hlsl} | 4 +- .../ChromaticAberrationPostFX.asset.taml | 8 + .../ChromaticAberrationPostFX.cs | 156 +++++++ .../ChromaticAberrationPostFXP.glsl | 13 + .../ChromaticAberrationPostFXP.hlsl | 35 ++ .../scripts/DepthOfField}/DOF_CalcCoC_P.glsl | 4 +- .../scripts/DepthOfField}/DOF_CalcCoC_P.hlsl | 2 +- .../scripts/DepthOfField}/DOF_CalcCoC_V.glsl | 6 +- .../scripts/DepthOfField}/DOF_CalcCoC_V.hlsl | 4 +- .../DepthOfField}/DOF_DownSample_P.glsl | 2 +- .../DepthOfField}/DOF_DownSample_P.hlsl | 4 +- .../DepthOfField}/DOF_DownSample_V.glsl | 4 +- .../DepthOfField}/DOF_DownSample_V.hlsl | 4 +- .../scripts/DepthOfField}/DOF_Final_P.glsl | 4 +- .../scripts/DepthOfField}/DOF_Final_P.hlsl | 4 +- .../scripts/DepthOfField}/DOF_Final_V.glsl | 6 +- .../scripts/DepthOfField}/DOF_Final_V.hlsl | 4 +- .../scripts/DepthOfField}/DOF_Gausian_P.glsl | 2 +- .../scripts/DepthOfField}/DOF_Gausian_P.hlsl | 2 +- .../scripts/DepthOfField}/DOF_Gausian_V.glsl | 4 +- .../scripts/DepthOfField}/DOF_Gausian_V.hlsl | 4 +- .../DepthOfField}/DOF_Passthrough_V.glsl | 6 +- .../DepthOfField}/DOF_Passthrough_V.hlsl | 4 +- .../DepthOfField}/DOF_SmallBlur_P.glsl | 2 +- .../DepthOfField}/DOF_SmallBlur_P.hlsl | 2 +- .../DepthOfField}/DOF_SmallBlur_V.glsl | 4 +- .../DepthOfField}/DOF_SmallBlur_V.hlsl | 4 +- .../DepthOfFieldPostFX.asset.taml | 6 + .../DepthOfFieldPostFX.cs} | 235 +++++------ .../scripts/EdgeDetect}/dbgEdgeDisplayP.glsl | 2 +- .../scripts/EdgeDetect}/dbgEdgeDisplayP.hlsl | 2 +- .../scripts/EdgeDetect}/edgeAAP.glsl | 4 +- .../scripts/EdgeDetect}/edgeAAP.hlsl | 2 +- .../EdgeDetect/edgeAAPostFX.asset.taml | 6 + .../{edgeAA.cs => EdgeDetect/edgeAAPostFX.cs} | 16 +- .../scripts/EdgeDetect}/edgeAAV.glsl | 6 +- .../scripts/EdgeDetect}/edgeAAV.hlsl | 4 +- .../scripts/EdgeDetect}/edgeDetectP.glsl | 2 +- .../scripts/EdgeDetect}/edgeDetectP.hlsl | 4 +- .../scripts/{ => FXAA}/FXAAPostFX.asset.taml | 0 .../postFX/scripts/{ => FXAA}/FXAAPostFX.cs | 8 +- .../fxaa => postFX/scripts/FXAA}/Fxaa3_11.h | 0 .../gl => postFX/scripts/FXAA}/fxaaP.glsl | 4 +- .../fxaa => postFX/scripts/FXAA}/fxaaP.hlsl | 2 +- .../gl => postFX/scripts/FXAA}/fxaaV.glsl | 4 +- .../fxaa => postFX/scripts/FXAA}/fxaaV.hlsl | 4 +- .../gl => postFX/scripts/Flash}/flashP.glsl | 0 .../scripts/Flash}/flashP.hlsl | 0 .../scripts/Flash/flashPostFX.asset.taml | 6 + .../{flash.cs => Flash/flashPostFX.cs} | 4 +- .../gl => postFX/scripts/Fog}/fogP.glsl | 4 +- .../postFX => postFX/scripts/Fog}/fogP.hlsl | 6 +- .../scripts/{ => Fog}/fogPostFX.asset.taml | 0 .../postFX/scripts/{ => Fog}/fogPostFX.cs | 4 +- .../scripts/Gamma/GammaPostFX.asset.taml | 8 + .../postFX/scripts/{ => Gamma}/GammaPostFX.cs | 65 ++- .../gl => postFX/scripts/Gamma}/gammaP.glsl | 10 +- .../scripts/Gamma}/gammaP.hlsl | 10 +- .../scripts/{ => Glow}/GlowPostFX.asset.taml | 0 .../postFX/scripts/{ => Glow}/GlowPostFX.cs | 24 +- .../scripts/Glow}/VolFogGlowP.glsl | 0 .../scripts/Glow}/VolFogGlowP.hlsl | 0 .../gl => postFX/scripts/Glow}/glowBlurP.glsl | 0 .../scripts/Glow}/glowBlurP.hlsl | 0 .../gl => postFX/scripts/Glow}/glowBlurV.glsl | 0 .../scripts/Glow}/glowBlurV.hlsl | 0 .../scripts/{ => HDR}/HDRPostFX.asset.taml | 0 .../postFX/scripts/{ => HDR}/HDRPostFX.cs | 216 +++++----- .../scripts/HDR}/bloomGaussBlurHP.glsl | 4 +- .../scripts/HDR}/bloomGaussBlurHP.hlsl | 45 +- .../scripts/HDR}/bloomGaussBlurVP.glsl | 4 +- .../scripts/HDR}/bloomGaussBlurVP.hlsl | 43 +- .../scripts/HDR}/brightPassFilterP.glsl | 6 +- .../scripts/HDR}/brightPassFilterP.hlsl | 4 +- .../scripts/HDR}/calculateAdaptedLumP.glsl | 4 +- .../scripts/HDR}/calculateAdaptedLumP.hlsl | 2 +- .../scripts/HDR}/downScale4x4P.glsl | 4 +- .../scripts/HDR}/downScale4x4P.hlsl | 4 +- .../scripts/HDR}/downScale4x4V.glsl | 4 +- .../scripts/HDR}/downScale4x4V.hlsl | 4 +- .../scripts/HDR}/finalPassCombineP.glsl | 59 ++- .../scripts/HDR}/finalPassCombineP.hlsl | 51 ++- .../scripts/HDR}/luminanceVisP.glsl | 6 +- .../scripts/HDR}/luminanceVisP.hlsl | 4 +- .../scripts/HDR}/sampleLumInitialP.glsl | 6 +- .../scripts/HDR}/sampleLumInitialP.hlsl | 4 +- .../scripts/HDR}/sampleLumIterativeP.glsl | 4 +- .../scripts/HDR}/sampleLumIterativeP.hlsl | 2 +- .../postFX/scripts/LUTColorGrading/Eerie.png | Bin 0 -> 2904 bytes .../LUTColorGradePostFX.asset.taml | 8 + .../LUTColorGrading/LUTColorGradePostFX.cs | 145 +++++++ .../LUTColorGrading/LUTColorGradePostFXP.glsl | 35 ++ .../LUTColorGradePostFXP.hlsl} | 42 +- .../scripts/LUTColorGrading/Misty_Blue.png | Bin 0 -> 2878 bytes .../scripts/LUTColorGrading/Warm_Day.png | Bin 0 -> 2872 bytes .../LUTColorGrading/perfect_Gradient.png | Bin 0 -> 2843 bytes .../scripts/LightRays}/lightRayOccludeP.glsl | 0 .../scripts/LightRays}/lightRayOccludeP.hlsl | 4 +- .../scripts/LightRays}/lightRayP.glsl | 4 +- .../scripts/LightRays}/lightRayP.hlsl | 2 +- .../{ => LightRays}/lightRays.asset.taml | 0 .../postFX/scripts/LightRays/lightRays.cs | 152 +++++++ .../postFX/scripts/MLAA/MLAAPostFX.asset.taml | 6 + .../scripts/{MLAA.cs => MLAA/MLAAPostFX.cs} | 24 +- .../MLAA}/blendWeightCalculationP.glsl | 2 +- .../MLAA}/blendWeightCalculationP.hlsl | 0 .../scripts/MLAA}/edgeDetectionP.glsl | 2 +- .../scripts/MLAA}/edgeDetectionP.hlsl | 0 .../gl => postFX/scripts/MLAA}/functions.glsl | 0 .../scripts/MLAA}/functions.hlsl | 0 .../scripts/MLAA}/neighborhoodBlendingP.glsl | 2 +- .../scripts/MLAA}/neighborhoodBlendingP.hlsl | 0 .../gl => postFX/scripts/MLAA}/offsetV.glsl | 2 +- .../mlaa => postFX/scripts/MLAA}/offsetV.hlsl | 0 .../gl => postFX/scripts/MLAA}/passthruV.glsl | 2 +- .../scripts/MLAA}/passthruV.hlsl | 0 .../game/core/postFX/scripts/MotionBlurFx.cs | 71 ---- .../reflectionProbeArrayPostFX.asset.taml | 0 .../reflectionProbeArrayPostFX.cs | 0 .../scripts/{ => SSAO}/SSAOPostFx.asset.taml | 0 .../core/postFX/scripts/SSAO/SSAOPostFx.cs | 368 +++++++++++++++++ .../scripts/SSAO}/SSAO_Blur_P.glsl | 2 +- .../scripts/SSAO}/SSAO_Blur_P.hlsl | 4 +- .../scripts/SSAO}/SSAO_Blur_V.glsl | 4 +- .../scripts/SSAO}/SSAO_Blur_V.hlsl | 4 +- .../gl => postFX/scripts/SSAO}/SSAO_P.glsl | 4 +- .../ssao => postFX/scripts/SSAO}/SSAO_P.hlsl | 4 +- .../scripts/SSAO}/SSAO_PowerTable_P.glsl | 2 +- .../scripts/SSAO}/SSAO_PowerTable_P.hlsl | 2 +- .../scripts/SSAO}/SSAO_PowerTable_V.glsl | 6 +- .../scripts/SSAO}/SSAO_PowerTable_V.hlsl | 4 +- .../game/core/postFX/scripts/SSAOPostFx.cs | 384 ------------------ .../scripts/Sharpen/SharpenPostFX.asset.taml | 8 + .../postFX/scripts/Sharpen/SharpenPostFX.cs | 145 +++++++ .../scripts/Sharpen/SharpenPostFXP.glsl} | 43 +- .../scripts/Sharpen/SharpenPostFXP.hlsl | 24 ++ .../TurbulencePostFX.asset.taml | 0 .../{ => Turbulence}/TurbulencePostFX.cs | 4 +- .../scripts/Turbulence}/turbulenceP.glsl | 4 +- .../scripts/Turbulence}/turbulenceP.hlsl | 2 +- .../underWaterFogPostFX.asset.taml | 0 .../underWaterFogPostFX.cs | 4 +- .../UnderwaterFog}/underwaterFogP.glsl | 6 +- .../UnderwaterFog}/underwaterFogP.hlsl | 6 +- .../scripts/VR}/barrelDistortionChromaP.glsl | 4 +- .../scripts/VR}/barrelDistortionChromaP.hlsl | 4 +- .../scripts/VR}/barrelDistortionP.glsl | 4 +- .../scripts/VR}/barrelDistortionP.hlsl | 4 +- .../scripts/VR}/monoToStereoP.glsl | 4 +- .../scripts/VR}/monoToStereoP.hlsl | 4 +- .../VR/ovrBarrelDistortionPostFX.asset.taml | 6 + .../ovrBarrelDistortionPostFX.cs} | 6 +- .../Vignette/VignettePostFX.asset.taml | 6 + .../postFX/scripts/Vignette/VignettePostFX.cs | 133 ++++++ .../scripts/Vignette/VignettePostFXP.glsl} | 5 +- .../scripts/Vignette/VignettePostFXP.hlsl} | 5 +- .../game/core/postFX/scripts/chromaticLens.cs | 77 ---- .../game/core/postFX/scripts/lightRays.cs | 154 ------- .../game/core/postFX/scripts/postFxManager.cs | 17 +- .../game/core/postFX/scripts/vignette.cs | 97 ----- .../core/rendering/scripts/graphicsOptions.cs | 2 +- .../scripts/assetTypes/cubemap.cs | 5 +- .../assetBrowser/scripts/assetTypes/level.cs | 4 +- .../assetBrowser/scripts/assetTypes/postFX.cs | 19 +- .../scripts/assetTypes/stateMachine.cs | 6 +- .../templateFiles/postFXFile.cs.template | 41 +- .../templateFiles/postFXFileP.glsl.template | 8 +- .../templateFiles/postFXFileP.hlsl.template | 8 +- .../game/tools/gui/editorSettingsWindow.ed.cs | 9 + .../BaseGame/game/tools/gui/postFxEditor.cs | 101 ++++- .../BaseGame/game/tools/gui/postFxEditor.gui | 261 ++++++++---- .../worldEditor/scripts/menuHandlers.ed.cs | 11 +- 186 files changed, 2534 insertions(+), 1486 deletions(-) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.asset.taml create mode 100644 Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl/motionBlurP.glsl => postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.glsl} (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/motionBlurP.hlsl => postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.hlsl} (94%) rename Templates/BaseGame/game/core/postFX/scripts/{vignettePostFX.asset.taml => Caustics/CausticsPostFX.asset.taml} (53%) rename Templates/BaseGame/game/core/postFX/scripts/{caustics.cs => Caustics/CausticsPostFX.cs} (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/caustics/gl/causticsP.glsl => postFX/scripts/Caustics/CausticsPostFXP.glsl} (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/caustics/causticsP.hlsl => postFX/scripts/Caustics/CausticsPostFXP.hlsl} (96%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.asset.taml create mode 100644 Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs create mode 100644 Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.glsl create mode 100644 Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.hlsl rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_CalcCoC_P.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_CalcCoC_P.hlsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_CalcCoC_V.glsl (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_CalcCoC_V.hlsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_DownSample_P.glsl (99%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_DownSample_P.hlsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_DownSample_V.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_DownSample_V.hlsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_Final_P.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_Final_P.hlsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_Final_V.glsl (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_Final_V.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_Gausian_P.glsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_Gausian_P.hlsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_Gausian_V.glsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_Gausian_V.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_Passthrough_V.glsl (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_Passthrough_V.hlsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_SmallBlur_P.glsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_SmallBlur_P.hlsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof/gl => postFX/scripts/DepthOfField}/DOF_SmallBlur_V.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/dof => postFX/scripts/DepthOfField}/DOF_SmallBlur_V.hlsl (95%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.asset.taml rename Templates/BaseGame/game/core/postFX/scripts/{dof.cs => DepthOfField/DepthOfFieldPostFX.cs} (71%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa/gl => postFX/scripts/EdgeDetect}/dbgEdgeDisplayP.glsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa => postFX/scripts/EdgeDetect}/dbgEdgeDisplayP.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa/gl => postFX/scripts/EdgeDetect}/edgeAAP.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa => postFX/scripts/EdgeDetect}/edgeAAP.hlsl (97%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.asset.taml rename Templates/BaseGame/game/core/postFX/scripts/{edgeAA.cs => EdgeDetect/edgeAAPostFX.cs} (82%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa/gl => postFX/scripts/EdgeDetect}/edgeAAV.glsl (91%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa => postFX/scripts/EdgeDetect}/edgeAAV.hlsl (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa/gl => postFX/scripts/EdgeDetect}/edgeDetectP.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/edgeaa => postFX/scripts/EdgeDetect}/edgeDetectP.hlsl (96%) rename Templates/BaseGame/game/core/postFX/scripts/{ => FXAA}/FXAAPostFX.asset.taml (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => FXAA}/FXAAPostFX.cs (86%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/fxaa => postFX/scripts/FXAA}/Fxaa3_11.h (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/fxaa/gl => postFX/scripts/FXAA}/fxaaP.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/fxaa => postFX/scripts/FXAA}/fxaaP.hlsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/fxaa/gl => postFX/scripts/FXAA}/fxaaV.glsl (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/fxaa => postFX/scripts/FXAA}/fxaaV.hlsl (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/Flash}/flashP.glsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/Flash}/flashP.hlsl (100%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.asset.taml rename Templates/BaseGame/game/core/postFX/scripts/{flash.cs => Flash/flashPostFX.cs} (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/Fog}/fogP.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/Fog}/fogP.hlsl (92%) rename Templates/BaseGame/game/core/postFX/scripts/{ => Fog}/fogPostFX.asset.taml (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => Fog}/fogPostFX.cs (94%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.asset.taml rename Templates/BaseGame/game/core/postFX/scripts/{ => Gamma}/GammaPostFX.cs (63%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/Gamma}/gammaP.glsl (84%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/Gamma}/gammaP.hlsl (84%) rename Templates/BaseGame/game/core/postFX/scripts/{ => Glow}/GlowPostFX.asset.taml (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => Glow}/GlowPostFX.cs (83%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/Glow}/VolFogGlowP.glsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/Glow}/VolFogGlowP.hlsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/Glow}/glowBlurP.glsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/Glow}/glowBlurP.hlsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/Glow}/glowBlurV.glsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/Glow}/glowBlurV.hlsl (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => HDR}/HDRPostFX.asset.taml (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => HDR}/HDRPostFX.cs (63%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/bloomGaussBlurHP.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/bloomGaussBlurHP.hlsl (70%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/bloomGaussBlurVP.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/bloomGaussBlurVP.hlsl (72%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/brightPassFilterP.glsl (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/brightPassFilterP.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/calculateAdaptedLumP.glsl (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/calculateAdaptedLumP.hlsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/downScale4x4P.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/downScale4x4P.hlsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/downScale4x4V.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/downScale4x4V.hlsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/finalPassCombineP.glsl (76%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/finalPassCombineP.hlsl (77%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/luminanceVisP.glsl (91%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/luminanceVisP.hlsl (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/sampleLumInitialP.glsl (92%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/sampleLumInitialP.hlsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr/gl => postFX/scripts/HDR}/sampleLumIterativeP.glsl (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/hdr => postFX/scripts/HDR}/sampleLumIterativeP.hlsl (97%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Eerie.png create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.asset.taml create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.glsl rename Templates/BaseGame/game/core/{rendering/shaders/postFX/chromaticLens.hlsl => postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.hlsl} (55%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Misty_Blue.png create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Warm_Day.png create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/perfect_Gradient.png rename Templates/BaseGame/game/core/{rendering/shaders/postFX/lightRay/gl => postFX/scripts/LightRays}/lightRayOccludeP.glsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/lightRay => postFX/scripts/LightRays}/lightRayOccludeP.hlsl (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/lightRay/gl => postFX/scripts/LightRays}/lightRayP.glsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/lightRay => postFX/scripts/LightRays}/lightRayP.hlsl (98%) rename Templates/BaseGame/game/core/postFX/scripts/{ => LightRays}/lightRays.asset.taml (100%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/LightRays/lightRays.cs create mode 100644 Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.asset.taml rename Templates/BaseGame/game/core/postFX/scripts/{MLAA.cs => MLAA/MLAAPostFX.cs} (83%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa/gl => postFX/scripts/MLAA}/blendWeightCalculationP.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa => postFX/scripts/MLAA}/blendWeightCalculationP.hlsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa/gl => postFX/scripts/MLAA}/edgeDetectionP.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa => postFX/scripts/MLAA}/edgeDetectionP.hlsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa/gl => postFX/scripts/MLAA}/functions.glsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa => postFX/scripts/MLAA}/functions.hlsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa/gl => postFX/scripts/MLAA}/neighborhoodBlendingP.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa => postFX/scripts/MLAA}/neighborhoodBlendingP.hlsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa/gl => postFX/scripts/MLAA}/offsetV.glsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa => postFX/scripts/MLAA}/offsetV.hlsl (100%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa/gl => postFX/scripts/MLAA}/passthruV.glsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/mlaa => postFX/scripts/MLAA}/passthruV.hlsl (100%) delete mode 100644 Templates/BaseGame/game/core/postFX/scripts/MotionBlurFx.cs rename Templates/BaseGame/game/core/postFX/scripts/{ => ReflectionProbes}/reflectionProbeArrayPostFX.asset.taml (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => ReflectionProbes}/reflectionProbeArrayPostFX.cs (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => SSAO}/SSAOPostFx.asset.taml (100%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAOPostFx.cs rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao/gl => postFX/scripts/SSAO}/SSAO_Blur_P.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao => postFX/scripts/SSAO}/SSAO_Blur_P.hlsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao/gl => postFX/scripts/SSAO}/SSAO_Blur_V.glsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao => postFX/scripts/SSAO}/SSAO_Blur_V.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao/gl => postFX/scripts/SSAO}/SSAO_P.glsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao => postFX/scripts/SSAO}/SSAO_P.hlsl (98%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao/gl => postFX/scripts/SSAO}/SSAO_PowerTable_P.glsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao => postFX/scripts/SSAO}/SSAO_PowerTable_P.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao/gl => postFX/scripts/SSAO}/SSAO_PowerTable_V.glsl (91%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/ssao => postFX/scripts/SSAO}/SSAO_PowerTable_V.hlsl (94%) delete mode 100644 Templates/BaseGame/game/core/postFX/scripts/SSAOPostFx.cs create mode 100644 Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.asset.taml create mode 100644 Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl/chromaticLens.glsl => postFX/scripts/Sharpen/SharpenPostFXP.glsl} (55%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFXP.hlsl rename Templates/BaseGame/game/core/postFX/scripts/{ => Turbulence}/TurbulencePostFX.asset.taml (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => Turbulence}/TurbulencePostFX.cs (93%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/Turbulence}/turbulenceP.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/Turbulence}/turbulenceP.hlsl (97%) rename Templates/BaseGame/game/core/postFX/scripts/{ => UnderwaterFog}/underWaterFogPostFX.asset.taml (100%) rename Templates/BaseGame/game/core/postFX/scripts/{ => UnderwaterFog}/underWaterFogPostFX.cs (94%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/gl => postFX/scripts/UnderwaterFog}/underwaterFogP.glsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX => postFX/scripts/UnderwaterFog}/underwaterFogP.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/oculusvr/gl => postFX/scripts/VR}/barrelDistortionChromaP.glsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/oculusvr => postFX/scripts/VR}/barrelDistortionChromaP.hlsl (97%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/oculusvr/gl => postFX/scripts/VR}/barrelDistortionP.glsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/oculusvr => postFX/scripts/VR}/barrelDistortionP.hlsl (96%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/oculusvr/gl => postFX/scripts/VR}/monoToStereoP.glsl (95%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/oculusvr => postFX/scripts/VR}/monoToStereoP.hlsl (95%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.asset.taml rename Templates/BaseGame/game/core/postFX/scripts/{ovrBarrelDistortion.cs => VR/ovrBarrelDistortionPostFX.cs} (95%) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.asset.taml create mode 100644 Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs rename Templates/BaseGame/game/core/{rendering/shaders/postFX/vignette/gl/VignetteP.glsl => postFX/scripts/Vignette/VignettePostFXP.glsl} (91%) rename Templates/BaseGame/game/core/{rendering/shaders/postFX/vignette/VignetteP.hlsl => postFX/scripts/Vignette/VignettePostFXP.hlsl} (91%) delete mode 100644 Templates/BaseGame/game/core/postFX/scripts/chromaticLens.cs delete mode 100644 Templates/BaseGame/game/core/postFX/scripts/lightRays.cs delete mode 100644 Templates/BaseGame/game/core/postFX/scripts/vignette.cs diff --git a/Engine/source/T3D/Scene.cpp b/Engine/source/T3D/Scene.cpp index f762b160f..e756ceb4a 100644 --- a/Engine/source/T3D/Scene.cpp +++ b/Engine/source/T3D/Scene.cpp @@ -34,6 +34,11 @@ void Scene::initPersistFields() addGroup("Gameplay"); addField("gameModeName", TypeString, Offset(mGameModeName, Scene), "The name of the gamemode that this scene utilizes"); endGroup("Gameplay"); + + addGroup("PostFX"); + addProtectedField("EditPostEffects", TypeBool, Offset(mEditPostFX, Scene), + &Scene::_editPostEffects, &defaultProtectedGetFn, "Edit Scene's default Post Effects", AbstractClassRep::FieldFlags::FIELD_ComponentInspectors); + endGroup("PostFX"); } bool Scene::onAdd() @@ -88,6 +93,18 @@ void Scene::onPostAdd() Con::executef(this, "onPostAdd"); } +bool Scene::_editPostEffects(void* object, const char* index, const char* data) +{ + Scene* scene = static_cast(object); + +#ifdef TORQUE_TOOLS + if(Con::isFunction("editScenePostEffects")) + Con::executef("editScenePostEffects", scene); +#endif + + return false; +} + void Scene::addObject(SimObject* object) { //Child scene diff --git a/Engine/source/T3D/Scene.h b/Engine/source/T3D/Scene.h index ca2238be6..64eabd019 100644 --- a/Engine/source/T3D/Scene.h +++ b/Engine/source/T3D/Scene.h @@ -35,6 +35,8 @@ class Scene : public NetObject, public virtual ITickable bool mIsDirty; + bool mEditPostFX; + StringTableEntry mGameModeName; protected: @@ -48,6 +50,8 @@ public: static void initPersistFields(); + static bool _editPostEffects(void* object, const char* index, const char* data); + virtual bool onAdd(); virtual void onRemove(); virtual void onPostAdd(); diff --git a/Engine/source/T3D/assets/LevelAsset.cpp b/Engine/source/T3D/assets/LevelAsset.cpp index 770c94f53..de6f18caa 100644 --- a/Engine/source/T3D/assets/LevelAsset.cpp +++ b/Engine/source/T3D/assets/LevelAsset.cpp @@ -361,13 +361,27 @@ void LevelAsset::unloadDependencies() } } -DefineEngineMethod(LevelAsset, getLevelFile, const char*, (),, +DefineEngineMethod(LevelAsset, getLevelPath, const char*, (),, "Creates a new script asset using the targetFilePath.\n" "@return The bool result of calling exec") { return object->getLevelPath(); } +DefineEngineMethod(LevelAsset, getPostFXPresetPath, const char*, (), , + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->getPostFXPresetPath(); +} + +DefineEngineMethod(LevelAsset, getDecalsPath, const char*, (), , + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->getDecalsPath(); +} + DefineEngineMethod(LevelAsset, loadDependencies, void, (), , "Initiates the loading of asset dependencies for this level.") { diff --git a/Templates/BaseGame/game/core/clientServer/scripts/client/levelDownload.cs b/Templates/BaseGame/game/core/clientServer/scripts/client/levelDownload.cs index 9c7dbd434..1149424df 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/client/levelDownload.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/client/levelDownload.cs @@ -41,7 +41,7 @@ $pref::Client::EnableDatablockCache = true; $pref::Client::DatablockCacheFilename = "data/cache/client/datablock_cache_c.dbc"; -function clientCmdMissionStartPhase1_LoadCache(%seq, %missionName) +function clientCmdMissionStartPhase1_LoadCache(%seq, %levelAsset) { if ($pref::Client::EnableDatablockCache && $loadFromDatablockCache) { @@ -57,16 +57,16 @@ function clientCmdMissionStartPhase1_LoadCache(%seq, %missionName) echo("<<<< Loading Datablocks From Cache >>>>"); if (ServerConnection.loadDatablockCache_Begin()) { - schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %missionName); + schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %levelAsset); } } } -function updateLoadDatablockCacheProgress(%seq, %missionName) +function updateLoadDatablockCacheProgress(%seq, %levelAsset) { if (ServerConnection.loadDatablockCache_Continue()) { - $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %missionName); + $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %levelAsset); return; } @@ -80,14 +80,14 @@ function updateLoadDatablockCacheProgress(%seq, %missionName) } echo("<<<< Finished Loading Datablocks From Cache >>>>"); - clientCmdMissionStartPhase2(%seq,%missionName); + clientCmdMissionStartPhase2(%seq, %levelAsset); } -function updateLoadDatablockCacheProgress(%seq, %missionName) +function updateLoadDatablockCacheProgress(%seq, %levelAsset) { if (ServerConnection.loadDatablockCache_Continue()) { - $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %missionName); + $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %levelAsset); return; } @@ -101,21 +101,24 @@ function updateLoadDatablockCacheProgress(%seq, %missionName) } echo("<<<< Finished Loading Datablocks From Cache >>>>"); - clientCmdMissionStartPhase2(%seq,%missionName); + clientCmdMissionStartPhase2(%seq, %levelAsset); } -function clientCmdMissionStartPhase1(%seq, %missionName, %cache_crc) +function clientCmdMissionStartPhase1(%seq, %levelAsset, %cache_crc) { + %levelAssetDef = AssetDatabase.acquireAsset(%levelAsset); + // These need to come after the cls. - echo ("*** New Mission: " @ %missionName); + echo ("*** New Mission: " @ %levelAssetDef.levelName); echo ("*** Phase 1: Download Datablocks & Targets"); - $Client::MissionFile = %missionName; + $Client::LevelAsset = %levelAssetDef; + $Client::MissionFile = %levelAssetDef.getLevelPath(); $pref::ReflectionProbes::CurrentLevelPath = filePath($Client::MissionFile) @ "/" @ fileBase($Client::MissionFile) @ "/probes/"; //Prep the postFX stuff // Load the post effect presets for this mission. - %path = filePath( %missionName ) @ "/" @ fileBase( %missionName ) @ $PostFXManager::fileExtension; + %path = %levelAssetDef.getPostFXPresetPath(); if ( isScriptFile( %path ) ) { @@ -190,7 +193,7 @@ function onDataBlockObjectReceived(%index, %total) //---------------------------------------------------------------------------- // Phase 2 //---------------------------------------------------------------------------- -function clientCmdMissionStartPhase2(%seq,%missionName) +function clientCmdMissionStartPhase2(%seq, %levelAsset) { onPhaseComplete(); echo ("*** Phase 2: Download Ghost Objects"); @@ -215,19 +218,21 @@ function onGhostAlwaysObjectReceived() //---------------------------------------------------------------------------- // Phase 3 //---------------------------------------------------------------------------- -function clientCmdMissionStartPhase3(%seq,%missionName) +function clientCmdMissionStartPhase3(%seq, %levelAsset) { onPhaseComplete(); StartClientReplication(); - StartFoliageReplication(); + + %levelAssetDef = AssetDatabase.acquireAsset(%levelAsset); // Load the static mission decals. - if(isFile(%missionName @ ".decals")) - decalManagerLoad( %missionName @ ".decals" ); + if(isFile(%levelAssetDef.getDecalsPath())) + decalManagerLoad( %levelAssetDef.getDecalsPath() ); echo ("*** Phase 3: Mission Lighting"); $MSeq = %seq; - $Client::MissionFile = %missionName; + $Client::LevelAsset = %levelAssetDef; + $Client::MissionFile = %levelAssetDef.getLevelPath(); // Need to light the mission before we are ready. // The sceneLightingComplete function will complete the handshake diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs index 1b04f1439..3e9662721 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs @@ -68,9 +68,9 @@ function GameConnection::loadMission(%this) } else { - commandToClient(%this, 'MissionStartPhase1', $missionSequence, $Server::MissionFile, %cache_crc); + commandToClient(%this, 'MissionStartPhase1', $missionSequence, $Server::LevelAsset.getAssetId(), %cache_crc); - echo("*** Sending mission load to client: " @ $Server::MissionFile); + echo("*** Sending mission load to client: " @ $Server::LevelAsset.getAssetId()); } } @@ -100,7 +100,7 @@ function GameConnection::onBeginDatablockCacheLoad( %this, %missionSequence ) if (%this.currentPhase != 1) return; %this.currentPhase = 1.5; - commandToClient(%this, 'MissionStartPhase1_LoadCache', $missionSequence, $Server::MissionFile); + commandToClient(%this, 'MissionStartPhase1_LoadCache', $missionSequence, $Server::LevelAsset.getAssetId()); } function serverCmdMissionStartPhase1Ack(%client, %seq) @@ -129,7 +129,7 @@ function GameConnection::onDataBlocksDone( %this, %missionSequence ) %this.currentPhase = 1.5; // On to the next phase - commandToClient(%this, 'MissionStartPhase2', $missionSequence, $Server::MissionFile); + commandToClient(%this, 'MissionStartPhase2', $missionSequence, $Server::LevelAsset.getAssetId()); } //---------------------------------------------------------------------------- @@ -163,7 +163,7 @@ function GameConnection::onGhostAlwaysFailed(%client) function GameConnection::onGhostAlwaysObjectsReceived(%client) { // Ready for next phase. - commandToClient(%client, 'MissionStartPhase3', $missionSequence, $Server::MissionFile); + commandToClient(%client, 'MissionStartPhase3', $missionSequence, $Server::LevelAsset.getAssetId()); } //---------------------------------------------------------------------------- diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs index 340ea5fe5..64e2aa268 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs @@ -44,7 +44,7 @@ function loadMission( %levelAsset, %isFirstMission ) // increment the mission sequence (used for ghost sequencing) $missionSequence++; $missionRunning = false; - $Server::MissionFile = $Server::LevelAsset.getLevelFile(); + $Server::MissionFile = $Server::LevelAsset.getLevelPath(); $Server::LoadFailMsg = ""; $Server::LevelAsset.loadDependencies(); diff --git a/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs b/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs index 25192bf79..340cf368b 100644 --- a/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs +++ b/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs @@ -1,6 +1,6 @@ datablock ReflectorDesc( DefaultCubeDesc ) { - texSize = 256; + texSize = 64; nearDist = 0.1; farDist = 1000.0; objectTypeMask = 0xFFFFFFFF; diff --git a/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.asset.taml new file mode 100644 index 000000000..385e46e80 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.asset.taml @@ -0,0 +1,8 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs new file mode 100644 index 000000000..3dc2d8d63 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs @@ -0,0 +1,124 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +$PostFX::CameraMotionBlurPostFX::samples = 5; +$PostFX::CameraMotionBlurPostFX::velocityMultiplier = 3000; + +singleton ShaderData( CameraMotionBlurPostFX_Shader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "./CameraMotionBlurPostFXP.hlsl"; + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./CameraMotionBlurPostFXP.glsl"; + + samplerNames[0] = "$backBuffer"; + samplerNames[1] = "$deferredTex"; + + pixVersion = 3.0; +}; + +singleton GFXStateBlockData( CameraMotionBlurPostFX_StateBlock ) +{ + zDefined = true; + zEnable = false; + zWriteEnable = false; + + samplersDefined = true; + samplerStates[0] = SamplerClampLinear; +}; + + +function CameraMotionBlurPostFX::setShaderConsts( %this ) +{ + %this.setShaderConst( "$velocityMultiplier", $PostFX::CameraMotionBlurPostFX::velocityMultiplier ); + %this.setShaderConst( "$samples", $PostFX::CameraMotionBlurPostFX::samples ); +} + +function CameraMotionBlurPostFX::preProcess( %this ) +{ +} + +function CameraMotionBlurPostFX::onAdd(%this) +{ + //Register the postFX with the manager + PostFXManager.registerPostEffect(%this); +} + +function CameraMotionBlurPostFX::onEnabled( %this ) +{ + return true; +} + +function CameraMotionBlurPostFX::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 CameraMotionBlurPostFX::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("CameraMotionBlurPostFX - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::CameraMotionBlurPostFX::Enabled", "Enabled", "bool", "", $PostFX::CameraMotionBlurPostFX::Enabled, "", "toggleCameraMotionBlurPostFX"); + PostEffectEditorInspector.addField("$PostFX::CameraMotionBlurPostFX::velocityMultiplier", "Velocity Multiplier", "float", "", $PostFX::CameraMotionBlurPostFX::velocityMultiplier, ""); + PostEffectEditorInspector.addField("$PostFX::CameraMotionBlurPostFX::samples", "Sample Count", "float", "", $PostFX::CameraMotionBlurPostFX::samples, ""); + 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::toggleCameraMotionBlurPostFX(%this) +{ + if($PostFX::CameraMotionBlurPostFX::Enabled) + CameraMotionBlurPostFX.enable(); + else + CameraMotionBlurPostFX.disable(); +} + +function CameraMotionBlurPostFX::applyFromPreset(%this) +{ + if($PostFX::CameraMotionBlurPostFX::Enabled) + %this.enable(); + else + %this.disable(); +} + +function CameraMotionBlurPostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::CameraMotionBlurPostFX::Enabled"); + PostFXManager::savePresetSetting("$PostFX::CameraMotionBlurPostFX::velocityMultiplier"); + PostFXManager::savePresetSetting("$PostFX::CameraMotionBlurPostFX::samples"); +} + +//Our actual postFX +singleton PostEffect( CameraMotionBlurPostFX ) +{ + isEnabled = false; + renderTime = "PFXAfterDiffuse"; + + shader = CameraMotionBlurPostFX_Shader; + stateBlock = CameraMotionBlurPostFX_StateBlock; + texture[0] = "$backbuffer"; + texture[1] = "#deferred"; + target = "$backBuffer"; +}; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/motionBlurP.glsl b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.glsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/motionBlurP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.glsl index 9eff3382c..b2edeec2f 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/motionBlurP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.glsl @@ -20,10 +20,10 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../gl/hlslCompat.glsl" -#include "../../gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" #include "shadergen:/autogenConditioners.h" -#include "postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" #undef IN_uv0 #define _IN_uv0 uv0 diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/motionBlurP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.hlsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/motionBlurP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.hlsl index d9a64816f..19e7a75d2 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/motionBlurP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.hlsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./postFx.hlsl" -#include "../torque.hlsl" -#include "../shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" uniform float4x4 matPrevScreenToWorld; uniform float4x4 matWorldToScreen; diff --git a/Templates/BaseGame/game/core/postFX/scripts/vignettePostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.asset.taml similarity index 53% rename from Templates/BaseGame/game/core/postFX/scripts/vignettePostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.asset.taml index c2bd1c15e..b83af8891 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/vignettePostFX.asset.taml +++ b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.asset.taml @@ -1,6 +1,6 @@ diff --git a/Templates/BaseGame/game/core/postFX/scripts/caustics.cs b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs similarity index 93% rename from Templates/BaseGame/game/core/postFX/scripts/caustics.cs rename to Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs index 7dcea20a5..418daa330 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/caustics.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs @@ -36,10 +36,10 @@ singleton GFXStateBlockData( PFX_CausticsStateBlock : PFX_DefaultStateBlock ) singleton ShaderData( PFX_CausticsShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/causticsP.hlsl"; + DXPixelShaderFile = "./causticsP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/gl/causticsP.glsl"; + OGLPixelShaderFile = "./causticsP.glsl"; samplerNames[0] = "$deferredTex"; samplerNames[1] = "$causticsTex0"; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/gl/causticsP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.glsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/gl/causticsP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.glsl index 7bcf39173..48a42677b 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/gl/causticsP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.glsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" #include "shadergen:/autogenConditioners.h" uniform vec3 eyePosWorld; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/causticsP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/causticsP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.hlsl index 8c8abd480..345eec178 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/causticsP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" -#include "../../shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFx.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" uniform float accumTime; uniform float3 eyePosWorld; diff --git a/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.asset.taml new file mode 100644 index 000000000..5da78e350 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.asset.taml @@ -0,0 +1,8 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs new file mode 100644 index 000000000..c55bd4d8e --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs @@ -0,0 +1,156 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +/// The lens distortion coefficient. +$PostFX::EnableChromaticAberrationPostFX::DistCoefficient = -0.05; + +/// The cubic distortion value. +$PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor = -0.1; + +/// The amount and direction of the maxium shift for +/// the red, green, and blue channels. +$PostFX::EnableChromaticAberrationPostFX::ColorDistFactor = "0.005 -0.005 0.01"; + +singleton ShaderData( ChromaticAberrationPostFX_Shader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "./ChromaticAberrationPostFXP.hlsl"; + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./ChromaticAberrationPostFXP.glsl"; + + samplerNames[0] = "$inputTex"; + + pixVersion = 2.0; +}; + +singleton GFXStateBlockData( ChromaticAberrationPostFX_StateBlock ) +{ + samplersDefined = true; + samplerStates[0] = SamplerClampLinear; + samplerStates[1] = SamplerClampLinear; + samplerStates[2] = SamplerClampLinear; + samplerStates[3] = SamplerClampLinear; + + blendDefined = true; + blendDest = GFXBlendOne; + blendSrc = GFXBlendZero; + + zDefined = true; + zEnable = false; + zWriteEnable = false; + + cullDefined = true; + cullMode = GFXCullNone; +}; + + +function ChromaticAberrationPostFX::setShaderConsts( %this ) +{ + %this.setShaderConst( "$distCoeff", $PostFX::EnableChromaticAberrationPostFX::DistCoefficient ); + %this.setShaderConst( "$cubeDistort", $PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor ); + %this.setShaderConst( "$colorDistort", $PostFX::EnableChromaticAberrationPostFX::ColorDistFactor ); +} + +function ChromaticAberrationPostFX::preProcess( %this ) +{ +} + +function ChromaticAberrationPostFX::onAdd(%this) +{ + //Register the postFX with the manager + PostFXManager.registerPostEffect(%this); +} + +function ChromaticAberrationPostFX::onEnabled( %this ) +{ + return true; +} + +function ChromaticAberrationPostFX::onDisabled( %this ) +{ +} + +//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 ChromaticAberrationPostFX::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("ChromaticAberrationPostFX - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::EnableChromaticAberrationPostFX::Enabled", "Enabled", "bool", "", $PostFX::EnableChromaticAberrationPostFX::Enabled, "", "toggleChromaticAberrationPostFX"); + PostEffectEditorInspector.addField("$PostFX::EnableChromaticAberrationPostFX::DistCoefficient", "Dist Coefficient", "float", "", $PostFX::EnableChromaticAberrationPostFX::DistCoefficient, ""); + PostEffectEditorInspector.addField("$PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor", "Cube Distortion Factor", "float", "", $PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor, ""); + PostEffectEditorInspector.addField("$PostFX::EnableChromaticAberrationPostFX::ColorDistFactor", "Color Distortion Factor", "string", "", $PostFX::EnableChromaticAberrationPostFX::ColorDistFactor, ""); + PostEffectEditorInspector.endGroup(); +} + +function PostEffectEditorInspector::toggleChromaticAberrationPostFX(%this) +{ + if($PostFX::EnableChromaticAberrationPostFX::Enabled) + ChromaticAberrationPostFX.enable(); + else + ChromaticAberrationPostFX.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 ChromaticAberrationPostFX::applyFromPreset(%this) +{ + if($PostFX::EnableChromaticAberrationPostFX::Enabled) + %this.enable(); + else + %this.disable(); +} + +function ChromaticAberrationPostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::Enabled"); + PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::DistCoefficient"); + PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor"); + PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::ColorDistFactor"); +} + +//Our actual postFX +singleton PostEffect( ChromaticAberrationPostFX ) +{ + isEnabled = false; + allowReflectPass = false; + + // Resolve the HDR before we render any editor stuff + // and before we resolve the scene to the backbuffer. + renderTime = "PFXBeforeBin"; + renderBin = "EditorBin"; + renderPriority = 9999; + + // The bright pass generates a bloomed version of + // the scene for pixels which are brighter than a + // fixed threshold value. + // + // This is then used in the final HDR combine pass + // at the end of this post effect chain. + shader = ChromaticAberrationPostFX_Shader; + stateBlock = PFX_DefaultStateBlock; + texture[0] = "$backBuffer"; + target = "$backBuffer"; + targetFormat = "GFXFormatR16G16B16A16F"; + targetScale = "1 1"; +}; diff --git a/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.glsl b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.glsl new file mode 100644 index 000000000..810e99012 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.glsl @@ -0,0 +1,13 @@ +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "shadergen:/autogenConditioners.h" +#include "core/rendering/shaders/postFX/gl/postFX.glsl" + +uniform sampler2D inputTex; + +out vec4 OUT_col; + +void main() +{ + OUT_col = hdrEncode( vec4(1,1,1,1) ); +} diff --git a/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.hlsl new file mode 100644 index 000000000..281403e93 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.hlsl @@ -0,0 +1,35 @@ +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" + +TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); +uniform float distCoeff; +uniform float cubeDistort; +uniform float3 colorDistort; + +float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 +{ + float2 tex = IN.uv0; + + float f = 0; + float r2 = (tex.x - 0.5) * (tex.x - 0.5) + (tex.y - 0.5) * (tex.y - 0.5); + + // Only compute the cubic distortion if necessary. + if ( cubeDistort == 0.0 ) + f = 1 + r2 * distCoeff; + else + f = 1 + r2 * (distCoeff + cubeDistort * sqrt(r2)); + + // Distort each color channel seperately to get a chromatic distortion effect. + float3 outColor; + float3 distort = f.xxx + colorDistort; + + [unroll] + for ( int i=0; i < 3; i++ ) + { + float x = distort[i] * ( tex.x - 0.5 ) + 0.5; + float y = distort[i] * ( tex.y - 0.5 ) + 0.5; + outColor[i] = TORQUE_TEX2DLOD( inputTex, float4(x,y,0,0) )[i]; + } + + return float4( outColor.rgb, 1 ); +} diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.glsl index 33754006b..d8d6ad098 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.glsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" // These are set by the game engine. uniform sampler2D shrunkSampler; // Output of DofDownsample() diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.hlsl index 2f5835fc2..1a4c8d29c 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" // These are set by the game engine. TORQUE_UNIFORM_SAMPLER2D(shrunkSampler, 0); // Output of DofDownsample() diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.glsl similarity index 93% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.glsl index ab2d7ef62..12f14d752 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform vec4 rtParams0; uniform vec4 rtParams1; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.hlsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.hlsl index 8131e45cd..2b38b4f60 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform float4 rtParams0; uniform float4 rtParams1; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.glsl similarity index 99% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.glsl index f3c093f31..92c9660ea 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" // These are set by the game engine. diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.hlsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.hlsl index 907c3d122..ef64284cb 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../shaderModel.hlsl" -#include "../../shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/shaderModel.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" // These are set by the game engine. // The render target size is one-quarter the scene rendering size. diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.glsl index b8e840c9e..e45666172 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.glsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.hlsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.hlsl index 0b3ec01e2..288c2c751 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" struct Vert { diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.glsl index 96f775cfd..29725a698 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D colorSampler; // Original source image uniform sampler2D smallBlurSampler; // Output of SmallBlurPS() diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.hlsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.hlsl index 9a7cb3d5e..b1ee9539c 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../shaderModelAutoGen.hlsl" -#include "./../postFx.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(colorSampler,0); // Original source image TORQUE_UNIFORM_SAMPLER2D(smallBlurSampler,1); // Output of SmallBlurPS() diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.glsl similarity index 93% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.glsl index f8d5f62a6..1fc7dbdff 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform vec4 rtParams0; uniform vec4 rtParams1; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.hlsl index 86c93701a..2ffea84b6 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform float4 rtParams0; uniform float4 rtParams1; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.glsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.glsl index 61e7697af..b542948a0 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" in vec3 wsEyeRay; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.hlsl index f4d29f3e1..92950bf79 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.glsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.glsl index c77e23c53..9a7038605 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.glsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.hlsl index b2d4582e0..fabf78ab9 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform float4 rtParams0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Passthrough_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.glsl similarity index 93% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Passthrough_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.glsl index cce9df691..51e2bc691 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Passthrough_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform vec4 rtParams0; uniform vec4 rtParams1; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Passthrough_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.hlsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Passthrough_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.hlsl index 8131e45cd..2b38b4f60 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Passthrough_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform float4 rtParams0; uniform float4 rtParams1; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.glsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.glsl index ae94edd78..8f207aec5 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.glsl @@ -25,7 +25,7 @@ // The sample weights are 1/16 in the corners, 2/16 on the edges, // and 4/16 in the center. -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" uniform sampler2D colorSampler; // Output of DofNearCoc() diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.hlsl index 175525a91..23b973468 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.hlsl @@ -24,7 +24,7 @@ // colorMapSampler, which is the same size as the render target. // The sample weights are 1/16 in the corners, 2/16 on the edges, // and 4/16 in the center. -#include "../../shaderModel.hlsl" +#include "core/rendering/shaders/shaderModel.hlsl" TORQUE_UNIFORM_SAMPLER2D(colorSampler, 0); // Output of DofNearCoc() diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.glsl index 413abd352..1f6a65a32 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.glsl @@ -25,8 +25,8 @@ // The sample weights are 1/16 in the corners, 2/16 on the edges, // and 4/16 in the center. -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.hlsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.hlsl index 3edb1ec2a..e29120bb7 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.hlsl @@ -25,8 +25,8 @@ // The sample weights are 1/16 in the corners, 2/16 on the edges, // and 4/16 in the center. -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" struct Vert { diff --git a/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.asset.taml new file mode 100644 index 000000000..14251e94a --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/dof.cs b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs similarity index 71% rename from Templates/BaseGame/game/core/postFX/scripts/dof.cs rename to Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs index 914404e13..c55d39774 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/dof.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs @@ -1,32 +1,11 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- /* ================================================================================ - The DOFPostEffect API + The DepthOfFieldPostFX API ================================================================================ -DOFPostEffect::setFocalDist( %dist ) +DepthOfFieldPostFX::setFocalDist( %dist ) @summary This method is for manually controlling the focus distance. It will have no @@ -38,7 +17,7 @@ float distance in meters -------------------------------------------------------------------------------- -DOFPostEffect::setAutoFocus( %enabled ) +DepthOfFieldPostFX::setAutoFocus( %enabled ) @summary This method sets auto focus enabled or disabled. Makes use of the parameters set @@ -50,7 +29,7 @@ bool -------------------------------------------------------------------------------- -DOFPostEffect::setFocusParams( %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope ) +DepthOfFieldPostFX::setFocusParams( %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope ) Set the parameters that control how the near and far equations are calculated from the focal distance. If you are not using auto focus you will need to call @@ -101,19 +80,19 @@ NOTE: These are not real callbacks! Hook these up to your code where appropriate function onSniperZoom() { // Parameterize how you want DOF to look. - DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 ); + DepthOfFieldPostFX.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 ); // Turn on auto focus - DOFPostEffect.setAutoFocus( true ); + DepthOfFieldPostFX.setAutoFocus( true ); // Turn on the PostEffect - DOFPostEffect.enable(); + DepthOfFieldPostFX.enable(); } function onSniperUnzoom() { // Turn off the PostEffect - DOFPostEffect.disable(); + DepthOfFieldPostFX.disable(); } Example2: Manually control DOF with the mouse wheel. @@ -121,13 +100,13 @@ Example2: Manually control DOF with the mouse wheel. // Somewhere on startup... // Parameterize how you want DOF to look. -DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 ); +DepthOfFieldPostFX.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 ); // Turn off auto focus -DOFPostEffect.setAutoFocus( false ); +DepthOfFieldPostFX.setAutoFocus( false ); // Turn on the PostEffect -DOFPostEffect.enable(); +DepthOfFieldPostFX.enable(); NOTE: These are not real callbacks! Hook these up to your code where appropriate! @@ -136,19 +115,19 @@ function onMouseWheelUp() { // Since setFocalDist is really just a wrapper to assign to the focalDist // dynamic field we can shortcut and increment it directly. - DOFPostEffect.focalDist += 8; + DepthOfFieldPostFX.focalDist += 8; } function onMouseWheelDown() { - DOFPostEffect.focalDist -= 8; + DepthOfFieldPostFX.focalDist -= 8; } */ /// This method is for manually controlling the focal distance. It will have no /// effect if auto focus is currently enabled. Makes use of the parameters set by /// setFocusParams. -function DOFPostEffect::setFocalDist( %this, %dist ) +function DepthOfFieldPostFX::setFocalDist( %this, %dist ) { %this.focalDist = %dist; } @@ -156,7 +135,7 @@ function DOFPostEffect::setFocalDist( %this, %dist ) /// This method sets auto focus enabled or disabled. Makes use of the parameters set /// by setFocusParams. When auto focus is enabled it determine the focal depth /// by performing a raycast at the screen-center. -function DOFPostEffect::setAutoFocus( %this, %enabled ) +function DepthOfFieldPostFX::setAutoFocus( %this, %enabled ) { %this.autoFocusEnabled = %enabled; } @@ -164,7 +143,7 @@ function DOFPostEffect::setAutoFocus( %this, %enabled ) /// Set the parameters that control how the near and far equations are calculated /// from the focal distance. If you are not using auto focus you will need to call /// setFocusParams PRIOR to calling setFocalDist. -function DOFPostEffect::setFocusParams( %this, %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope ) +function DepthOfFieldPostFX::setFocusParams( %this, %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope ) { %this.nearBlurMax = %nearBlurMax; %this.farBlurMax = %farBlurMax; @@ -318,11 +297,11 @@ singleton GFXStateBlockData( PFX_DOFFinalStateBlock ) singleton ShaderData( PFX_DOFDownSampleShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_P.hlsl"; + DXVertexShaderFile = "./DOF_DownSample_V.hlsl"; + DXPixelShaderFile = "./DOF_DownSample_P.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_P.glsl"; + OGLVertexShaderFile = "./DOF_DownSample_V.glsl"; + OGLPixelShaderFile = "./DOF_DownSample_P.glsl"; samplerNames[0] = "$colorSampler"; samplerNames[1] = "$depthSampler"; @@ -332,11 +311,11 @@ singleton ShaderData( PFX_DOFDownSampleShader ) singleton ShaderData( PFX_DOFBlurYShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_P.hlsl"; + DXVertexShaderFile = "./DOF_Gausian_V.hlsl"; + DXPixelShaderFile = "./DOF_Gausian_P.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_P.glsl"; + OGLVertexShaderFile = "./DOF_Gausian_V.glsl"; + OGLPixelShaderFile = "./DOF_Gausian_P.glsl"; samplerNames[0] = "$diffuseMap"; @@ -351,11 +330,11 @@ singleton ShaderData( PFX_DOFBlurXShader : PFX_DOFBlurYShader ) singleton ShaderData( PFX_DOFCalcCoCShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_P.hlsl"; + DXVertexShaderFile = "./DOF_CalcCoC_V.hlsl"; + DXPixelShaderFile = "./DOF_CalcCoC_P.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_P.glsl"; + OGLVertexShaderFile = "./DOF_CalcCoC_V.glsl"; + OGLPixelShaderFile = "./DOF_CalcCoC_P.glsl"; samplerNames[0] = "$shrunkSampler"; samplerNames[1] = "$blurredSampler"; @@ -365,11 +344,11 @@ singleton ShaderData( PFX_DOFCalcCoCShader ) singleton ShaderData( PFX_DOFSmallBlurShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_P.hlsl"; + DXVertexShaderFile = "./DOF_SmallBlur_V.hlsl"; + DXPixelShaderFile = "./DOF_SmallBlur_P.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_P.glsl"; + OGLVertexShaderFile = "./DOF_SmallBlur_V.glsl"; + OGLPixelShaderFile = "./DOF_SmallBlur_P.glsl"; samplerNames[0] = "$colorSampler"; @@ -378,11 +357,11 @@ singleton ShaderData( PFX_DOFSmallBlurShader ) singleton ShaderData( PFX_DOFFinalShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_P.hlsl"; + DXVertexShaderFile = "./DOF_Final_V.hlsl"; + DXPixelShaderFile = "./DOF_Final_P.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_P.glsl"; + OGLVertexShaderFile = "./DOF_Final_V.glsl"; + OGLPixelShaderFile = "./DOF_Final_P.glsl"; samplerNames[0] = "$colorSampler"; samplerNames[1] = "$smallBlurSampler"; @@ -396,7 +375,7 @@ singleton ShaderData( PFX_DOFFinalShader ) // PostEffects //----------------------------------------------------------------------------- -function DOFPostEffect::onAdd( %this ) +function DepthOfFieldPostFX::onAdd( %this ) { // The weighted distribution of CoC value to the three blur textures // in the order small, medium, large. Most likely you will not need to @@ -417,14 +396,16 @@ function DOFPostEffect::onAdd( %this ) PostFXManager.registerPostEffect(%this); } -function DOFPostEffect::setLerpDist( %this, %d0, %d1, %d2 ) +function DepthOfFieldPostFX::setLerpDist( %this, %d0, %d1, %d2 ) { %this.lerpScale = -1.0 / %d0 SPC -1.0 / %d1 SPC -1.0 / %d2 SPC 1.0 / %d2; %this.lerpBias = 1.0 SPC ( 1.0 - %d2 ) / %d1 SPC 1.0 / %d2 SPC ( %d2 - 1.0 ) / %d2; } -singleton PostEffect( DOFPostEffect ) +singleton PostEffect( DepthOfFieldPostFX ) { + isEnabled = false; + renderTime = "PFXAfterBin"; renderBin = "GlowBin"; renderPriority = 0.1; @@ -436,75 +417,83 @@ singleton PostEffect( DOFPostEffect ) target = "#shrunk"; targetScale = "0.25 0.25"; - isEnabled = false; -}; - -singleton PostEffect( DOFBlurY ) -{ - shader = PFX_DOFBlurYShader; - stateBlock = PFX_DOFBlurStateBlock; - texture[0] = "#shrunk"; - target = "$outTex"; -}; - -DOFPostEffect.add( DOFBlurY ); - -singleton PostEffect( DOFBlurX ) -{ - shader = PFX_DOFBlurXShader; - stateBlock = PFX_DOFBlurStateBlock; - texture[0] = "$inTex"; - target = "#largeBlur"; -}; - -DOFPostEffect.add( DOFBlurX ); - -singleton PostEffect( DOFCalcCoC ) -{ - shader = PFX_DOFCalcCoCShader; - stateBlock = PFX_DOFCalcCoCStateBlock; - texture[0] = "#shrunk"; - texture[1] = "#largeBlur"; - target = "$outTex"; -}; - -DOFPostEffect.add( DOFCalcCoc ); - -singleton PostEffect( DOFSmallBlur ) -{ - shader = PFX_DOFSmallBlurShader; - stateBlock = PFX_DefaultDOFStateBlock; - texture[0] = "$inTex"; - target = "$outTex"; -}; - -DOFPostEffect.add( DOFSmallBlur ); + singleton PostEffect( DOFBlurY ) + { + shader = PFX_DOFBlurYShader; + stateBlock = PFX_DOFBlurStateBlock; + texture[0] = "#shrunk"; + target = "$outTex"; + }; -singleton PostEffect( DOFFinalPFX ) -{ - shader = PFX_DOFFinalShader; - stateBlock = PFX_DOFFinalStateBlock; - texture[0] = "$backBuffer"; - texture[1] = "$inTex"; - texture[2] = "#largeBlur"; - texture[3] = "#deferred"; - target = "$backBuffer"; + singleton PostEffect( DOFBlurX ) + { + shader = PFX_DOFBlurXShader; + stateBlock = PFX_DOFBlurStateBlock; + texture[0] = "$inTex"; + target = "#largeBlur"; + }; + + singleton PostEffect( DOFCalcCoC ) + { + shader = PFX_DOFCalcCoCShader; + stateBlock = PFX_DOFCalcCoCStateBlock; + texture[0] = "#shrunk"; + texture[1] = "#largeBlur"; + target = "$outTex"; + }; + + singleton PostEffect( DOFSmallBlur ) + { + shader = PFX_DOFSmallBlurShader; + stateBlock = PFX_DefaultDOFStateBlock; + texture[0] = "$inTex"; + target = "$outTex"; + }; + + singleton PostEffect( DOFFinalPFX ) + { + shader = PFX_DOFFinalShader; + stateBlock = PFX_DOFFinalStateBlock; + texture[0] = "$backBuffer"; + texture[1] = "$inTex"; + texture[2] = "#largeBlur"; + texture[3] = "#deferred"; + target = "$backBuffer"; + }; }; -DOFPostEffect.add( DOFFinalPFX ); - - //----------------------------------------------------------------------------- // Scripts //----------------------------------------------------------------------------- -function DOFPostEffect::populatePostFXSettings(%this) +function DepthOfFieldPostFX::populatePostFXSettings(%this) { - PostEffectEditorInspector.startGroup("Depth of Field"); - PostEffectEditorInspector.addField("isEnabled", "Enabled", "bool", "", DOFPostEffect.isEnabled, "", DOFPostEffect); + PostEffectEditorInspector.startGroup("Depth of Field - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::DepthOfFieldPostFX::Enabled", "Enabled", "bool", "", $PostFX::DepthOfFieldPostFX::Enabled, "", "toggleDepthOfFieldPostFX"); PostEffectEditorInspector.endGroup(); } -function DOFPostEffect::setShaderConsts( %this ) +function PostEffectEditorInspector::toggleDepthOfFieldPostFX(%this) +{ + if($PostFX::DepthOfFieldPostFX::Enabled) + DepthOfFieldPostFX.enable(); + else + DepthOfFieldPostFX.disable(); +} + +function DepthOfFieldPostFX::applyFromPreset(%this) +{ + if($PostFX::DepthOfFieldPostFX::Enabled) + DepthOfFieldPostFX.enable(); + else + DepthOfFieldPostFX.disable(); +} + +function DepthOfFieldPostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::DepthOfFieldPostFX::Enabled"); +} + +function DepthOfFieldPostFX::setShaderConsts( %this ) { if ( %this.autoFocusEnabled ) %this.autoFocus(); @@ -553,7 +542,7 @@ function DOFPostEffect::setShaderConsts( %this ) DOFFinalPFX.setShaderConst( "$dofLerpBias", %this.lerpBias ); } -function DOFPostEffect::autoFocus( %this ) +function DepthOfFieldPostFX::autoFocus( %this ) { if ( !isObject( ServerConnection ) || !isObject( ServerConnection.getCameraObject() ) ) @@ -593,9 +582,9 @@ function DOFPostEffect::autoFocus( %this ) function reloadDOF() { exec( "./dof.cs" ); - DOFPostEffect.reload(); - DOFPostEffect.disable(); - DOFPostEffect.enable(); + DepthOfFieldPostFX.reload(); + DepthOfFieldPostFX.disable(); + DepthOfFieldPostFX.enable(); } function dofMetricsCallback() diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.glsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.glsl index ccc3b8ba5..4799dd0c0 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" in vec2 uv0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/dbgEdgeDisplayP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/dbgEdgeDisplayP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.hlsl index fbd529031..383af0964 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/dbgEdgeDisplayP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(edgeBuffer); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAP.glsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.glsl index 5f2701b12..8eb178ec1 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D edgeBuffer; uniform sampler2D backBuffer; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.hlsl index f5a71687d..625a906bc 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(edgeBuffer,0); TORQUE_UNIFORM_SAMPLER2D(backBuffer, 1); diff --git a/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.asset.taml new file mode 100644 index 000000000..476c7358e --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/edgeAA.cs b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs similarity index 82% rename from Templates/BaseGame/game/core/postFX/scripts/edgeAA.cs rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs index c3b4263fa..3decba411 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/edgeAA.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs @@ -35,10 +35,10 @@ singleton GFXStateBlockData( PFX_DefaultEdgeAAStateBlock ) singleton ShaderData( PFX_EdgeAADetectShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeDetectP.hlsl"; + DXPixelShaderFile = "./edgeDetectP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeDetectP.glsl"; + OGLPixelShaderFile = "./edgeDetectP.glsl"; samplerNames[0] = "$deferredBuffer"; @@ -47,11 +47,11 @@ singleton ShaderData( PFX_EdgeAADetectShader ) singleton ShaderData( PFX_EdgeAAShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAP.hlsl"; + DXVertexShaderFile = "./edgeAAV.hlsl"; + DXPixelShaderFile = "./edgeAAP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAP.glsl"; + OGLVertexShaderFile = "./edgeAAV.glsl"; + OGLPixelShaderFile = "./edgeAAP.glsl"; samplerNames[0] = "$edgeBuffer"; samplerNames[1] = "$backBuffer"; @@ -62,10 +62,10 @@ singleton ShaderData( PFX_EdgeAAShader ) singleton ShaderData( PFX_EdgeAADebugShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/dbgEdgeDisplayP.hlsl"; + DXPixelShaderFile = "./dbgEdgeDisplayP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl"; + OGLPixelShaderFile = "./dbgEdgeDisplayP.glsl"; samplerNames[0] = "$edgeBuffer"; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAV.glsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.glsl similarity index 91% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAV.glsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.glsl index f886d9313..e60c7a0d9 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAV.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform vec4 rtParams0; uniform vec4 rtParams1; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAV.hlsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.hlsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAV.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.hlsl index 4718b40f5..21a7f47eb 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAV.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform float4 rtParams0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeDetectP.glsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeDetectP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.glsl index 02507eee8..acffd4a53 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeDetectP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" // GPU Gems 3, pg 443-444 diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeDetectP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeDetectP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.hlsl index c8bfb2153..ef59000f2 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeDetectP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" -#include "../../shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" TORQUE_UNIFORM_SAMPLER2D(deferredBuffer,0); diff --git a/Templates/BaseGame/game/core/postFX/scripts/FXAAPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/FXAAPostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/FXAAPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs similarity index 86% rename from Templates/BaseGame/game/core/postFX/scripts/FXAAPostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs index b24aef85f..be27a075e 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/FXAAPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs @@ -36,11 +36,11 @@ singleton GFXStateBlockData( FXAA_StateBlock : PFX_DefaultStateBlock ) singleton ShaderData( FXAA_ShaderData ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/fxaaV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/fxaaP.hlsl"; + DXVertexShaderFile = "./fxaaV.hlsl"; + DXPixelShaderFile = "./fxaaP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaP.glsl"; + OGLVertexShaderFile = "./fxaaV.glsl"; + OGLPixelShaderFile = "./fxaaP.glsl"; samplerNames[0] = "$colorTex"; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/Fxaa3_11.h b/Templates/BaseGame/game/core/postFX/scripts/FXAA/Fxaa3_11.h similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/Fxaa3_11.h rename to Templates/BaseGame/game/core/postFX/scripts/FXAA/Fxaa3_11.h diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaP.glsl b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.glsl index 19d76ef42..306855d63 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.glsl @@ -25,8 +25,8 @@ #define FXAA_QUALITY__PRESET 12 #define FXAA_GREEN_AS_LUMA 1 -#include "../Fxaa3_11.h" -#include "../../../gl/hlslCompat.glsl" +#include "Fxaa3_11.h" +#include "core/rendering/shaders/gl/hlslCompat.glsl" uniform sampler2D colorTex ; uniform vec2 oneOverTargetSize; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.hlsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.hlsl index dc99702c3..b8e08b8b7 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../shaderModel.hlsl" +#include "core/rendering/shaders/shaderModel.hlsl" #define FXAA_PC 1 #if TORQUE_SM == 40 diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaV.glsl b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.glsl similarity index 93% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaV.glsl rename to Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.glsl index 55d445d91..48f0d1aa0 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaV.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.glsl @@ -19,8 +19,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../../gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaV.hlsl b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.hlsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaV.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.hlsl index f2974c587..f1151d44e 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaV.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../../torque.hlsl" -#include "./../postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" struct VertToPix { diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/flashP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.glsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/flashP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.glsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/flashP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/flashP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.hlsl diff --git a/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.asset.taml new file mode 100644 index 000000000..46b6dda3c --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/flash.cs b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs similarity index 93% rename from Templates/BaseGame/game/core/postFX/scripts/flash.cs rename to Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs index 1c97c6411..8d26bb4fc 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/flash.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs @@ -23,10 +23,10 @@ singleton ShaderData( PFX_FlashShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/flashP.hlsl"; + DXPixelShaderFile = "./flashP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/flashP.glsl"; + OGLPixelShaderFile = "./flashP.glsl"; samplerNames[0] = "$backBuffer"; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/fogP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/fogP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.glsl index c2fe32fe4..86500107d 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/fogP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.glsl @@ -20,10 +20,10 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/torque.glsl" +#include "core/rendering/shaders/gl/torque.glsl" uniform sampler2D deferredTex ; uniform vec3 eyePosWorld; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/fogP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.hlsl similarity index 92% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/fogP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.hlsl index 894e68e79..9236d664c 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/fogP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.hlsl @@ -21,9 +21,9 @@ //----------------------------------------------------------------------------- -#include "./postFx.hlsl" -#include "./../torque.hlsl" -#include "./../shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0); uniform float3 eyePosWorld; diff --git a/Templates/BaseGame/game/core/postFX/scripts/fogPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/fogPostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/fogPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs similarity index 94% rename from Templates/BaseGame/game/core/postFX/scripts/fogPostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs index ed9dd9ce7..cb0365622 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/fogPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs @@ -27,10 +27,10 @@ singleton ShaderData( FogPassShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/fogP.hlsl"; + DXPixelShaderFile = "./fogP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/fogP.glsl"; + OGLPixelShaderFile = "./fogP.glsl"; samplerNames[0] = "$deferredTex"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.asset.taml new file mode 100644 index 000000000..dd64d32e2 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.asset.taml @@ -0,0 +1,8 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/GammaPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs similarity index 63% rename from Templates/BaseGame/game/core/postFX/scripts/GammaPostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs index 293d44714..11fe55ed7 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/GammaPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs @@ -23,10 +23,10 @@ singleton ShaderData( GammaShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gammaP.hlsl"; + DXPixelShaderFile = "./gammaP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/gammaP.glsl"; + OGLPixelShaderFile = "./gammaP.glsl"; samplerNames[0] = "$backBuffer"; samplerNames[1] = "$colorCorrectionTex"; @@ -54,14 +54,11 @@ singleton PostEffect( GammaPostFX ) stateBlock = GammaStateBlock; texture[0] = "$backBuffer"; - texture[1] = $HDRPostFX::colorCorrectionRamp; textureSRGB[1] = true; }; function GammaPostFX::preProcess( %this ) { - if ( %this.texture[1] !$= $HDRPostFX::colorCorrectionRamp ) - %this.setTexture( 1, $HDRPostFX::colorCorrectionRamp ); } function GammaPostFX::setShaderConsts( %this ) @@ -70,4 +67,60 @@ function GammaPostFX::setShaderConsts( %this ) %this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma ); %this.setShaderConst( "$Brightness", $pref::Video::Brightness ); %this.setShaderConst( "$Contrast", $pref::Video::Contrast ); -} \ No newline at end of file +} + +function GammaPostFX::onAdd(%this) +{ + //Register the postFX with the manager + PostFXManager.registerPostEffect(%this); +} + +function GammaPostFX::onEnabled( %this ) +{ + return true; +} + +function GammaPostFX::onDisabled( %this ) +{ +} + +//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 GammaPostFX::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("GammaPostFX - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::GammaPostFX::Enabled", "Enable", "bool", "", $PostFX::GammaPostFX::Enabled, "", "toggleGammaPostFX"); + PostEffectEditorInspector.endGroup(); +} + +function PostEffectEditorInspector::toggleGammaPostFX(%this) +{ + //If we're toggling between gamma then we're also toggling HDR the opposite way + if($PostFX::GammaPostFX::Enabled) + { + HDRPostFX.disable(); + } + else + { + HDRPostFX.enable(); + } +} + +function GammaPostFX::applyFromPreset(%this) +{ + if($PostFX::GammaPostFX::Enabled) + { + HDRPostFX.disable(); + } + else + { + HDRPostFX.enable(); + } +} + +function GammaPostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::GammaPostFX::Enabled"); +} + diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/gammaP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.glsl similarity index 84% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/gammaP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.glsl index 04533e494..40d5a2615 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/gammaP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.glsl @@ -20,12 +20,11 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../gl/hlslCompat.glsl" -#include "../../gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" #include "shadergen:/autogenConditioners.h" uniform sampler2D backBuffer; -uniform sampler1D colorCorrectionTex; uniform float OneOverGamma; uniform float Brightness; @@ -39,11 +38,6 @@ void main() { vec4 color = texture(backBuffer, uv0.xy); - // Apply the color correction. - color.r = texture( colorCorrectionTex, color.r ).r; - color.g = texture( colorCorrectionTex, color.g ).g; - color.b = texture( colorCorrectionTex, color.b ).b; - // Apply contrast color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gammaP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.hlsl similarity index 84% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gammaP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.hlsl index ea9df604d..973fa17f1 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/gammaP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.hlsl @@ -21,11 +21,10 @@ //----------------------------------------------------------------------------- #include "shadergen:/autogenConditioners.h" -#include "./postFx.hlsl" -#include "../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0); -TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 1); uniform float OneOverGamma; uniform float Brightness; @@ -35,11 +34,6 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 { float4 color = TORQUE_TEX2D(backBuffer, IN.uv0.xy); - // Apply the color correction. - color.r = TORQUE_TEX1D( colorCorrectionTex, color.r ).r; - color.g = TORQUE_TEX1D( colorCorrectionTex, color.g ).g; - color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b; - // Apply contrast color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f; diff --git a/Templates/BaseGame/game/core/postFX/scripts/GlowPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/GlowPostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/GlowPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs similarity index 83% rename from Templates/BaseGame/game/core/postFX/scripts/GlowPostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs index 41a23db82..2e977a208 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/GlowPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs @@ -23,11 +23,11 @@ singleton ShaderData( PFX_GlowBlurVertShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurP.hlsl"; + DXVertexShaderFile = "./glowBlurV.hlsl"; + DXPixelShaderFile = "./glowBlurP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurP.glsl"; + OGLVertexShaderFile = "./glowBlurV.glsl"; + OGLPixelShaderFile = "./glowBlurP.glsl"; defines = "BLUR_DIR=float2(0.0,1.0)"; @@ -109,11 +109,11 @@ singleton PostEffect( GlowPostFX ) singleton ShaderData( PFX_VolFogGlowBlurVertShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl"; + DXVertexShaderFile = "./glowBlurV.hlsl"; + DXPixelShaderFile = "./VolFogGlowP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl"; + OGLVertexShaderFile = "./glowBlurV.glsl"; + OGLPixelShaderFile = "./VolFogGlowP.glsl"; defines = "BLUR_DIR=float2(0.0,1.0)"; samplerNames[0] = "$diffuseMap"; @@ -121,11 +121,11 @@ singleton ShaderData( PFX_VolFogGlowBlurVertShader ) }; singleton ShaderData( PFX_VolFogGlowBlurHorzShader : PFX_VolFogGlowBlurVertShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl"; + DXVertexShaderFile = "./glowBlurV.hlsl"; + DXPixelShaderFile = "./VolFogGlowP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl"; + OGLVertexShaderFile = "./glowBlurV.glsl"; + OGLPixelShaderFile = "./VolFogGlowP.glsl"; defines = "BLUR_DIR=float2(1.0,0.0)"; }; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/VolFogGlowP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.glsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/VolFogGlowP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.glsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/VolFogGlowP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/VolFogGlowP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.hlsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/glowBlurP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.glsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/glowBlurP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.glsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/glowBlurP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/glowBlurP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.hlsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/glowBlurV.glsl b/Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.glsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/glowBlurV.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.glsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/glowBlurV.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/glowBlurV.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.hlsl diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs similarity index 63% rename from Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs index 01f8d1cc2..c6648d68e 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs @@ -22,63 +22,63 @@ /// Blends between the scene and the tone mapped scene. -$HDRPostFX::enableToneMapping = 0.5; +$PostFX::HDRPostFX::enableToneMapping = 0.5; /// The tone mapping middle grey or exposure value used /// to adjust the overall "balance" of the image. /// /// 0.18 is fairly common value. /// -$HDRPostFX::keyValue = 0.18; +$PostFX::HDRPostFX::keyValue = 0.18; /// The minimum luninace value to allow when tone mapping /// the scene. Is particularly useful if your scene very /// dark or has a black ambient color in places. -$HDRPostFX::minLuminace = 0.001; +$PostFX::HDRPostFX::minLuminace = 0.001; /// The lowest luminance value which is mapped to white. This /// is usually set to the highest visible luminance in your /// scene. By setting this to smaller values you get a contrast /// enhancement. -$HDRPostFX::whiteCutoff = 1.0; +$PostFX::HDRPostFX::whiteCutoff = 1.0; /// The rate of adaptation from the previous and new /// average scene luminance. -$HDRPostFX::adaptRate = 2.0; +$PostFX::HDRPostFX::adaptRate = 2.0; /// Blends between the scene and the blue shifted version /// of the scene for a cinematic desaturated night effect. -$HDRPostFX::enableBlueShift = 0.0; +$PostFX::HDRPostFX::enableBlueShift = 0.0; /// The blue shift color value. -$HDRPostFX::blueShiftColor = "1.05 0.97 1.27"; +$PostFX::HDRPostFX::blueShiftColor = "1.05 0.97 1.27"; /// Blends between the scene and the bloomed scene. -$HDRPostFX::enableBloom = 1.0; +$PostFX::HDRPostFX::enableBloom = 1.0; /// The threshold luminace value for pixels which are /// considered "bright" and need to be bloomed. -$HDRPostFX::brightPassThreshold = 1.0; +$PostFX::HDRPostFX::brightPassThreshold = 1.0; /// These are used in the gaussian blur of the /// bright pass for the bloom effect. -$HDRPostFX::gaussMultiplier = 0.3; -$HDRPostFX::gaussMean = 0.0; -$HDRPostFX::gaussStdDev = 0.8; +$PostFX::HDRPostFX::gaussMultiplier = 0.3; +$PostFX::HDRPostFX::gaussMean = 0.0; +$PostFX::HDRPostFX::gaussStdDev = 0.8; -/// The 1x255 color correction ramp texture used -/// by both the HDR shader and the GammaPostFx shader -/// for doing full screen color correction. -$HDRPostFX::colorCorrectionRamp = "core/postFX/images/null_color_ramp.png"; +// The tonemapping algo to use +$PostFX::HDRPostFX::tonemapMode = "Filmic"; + +$PostFX::HDRPostFX::enableAutoExposure = true; singleton ShaderData( HDR_BrightPassShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/brightPassFilterP.hlsl"; + DXPixelShaderFile = "./brightPassFilterP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/brightPassFilterP.glsl"; + OGLPixelShaderFile = "./brightPassFilterP.glsl"; samplerNames[0] = "$inputTex"; samplerNames[1] = "$luminanceTex"; @@ -88,10 +88,10 @@ singleton ShaderData( HDR_BrightPassShader ) singleton ShaderData( HDR_DownScale4x4Shader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/downScale4x4V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/downScale4x4P.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/downScale4x4V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/downScale4x4P.glsl"; + DXVertexShaderFile = "./downScale4x4V.hlsl"; + DXPixelShaderFile = "./downScale4x4P.hlsl"; + OGLVertexShaderFile = "./downScale4x4V.glsl"; + OGLPixelShaderFile = "./downScale4x4P.glsl"; samplerNames[0] = "$inputTex"; @@ -101,9 +101,9 @@ singleton ShaderData( HDR_DownScale4x4Shader ) singleton ShaderData( HDR_BloomGaussBlurHShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurHP.hlsl"; + DXPixelShaderFile = "./bloomGaussBlurHP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurHP.glsl"; + OGLPixelShaderFile = "./bloomGaussBlurHP.glsl"; samplerNames[0] = "$inputTex"; @@ -113,9 +113,9 @@ singleton ShaderData( HDR_BloomGaussBlurHShader ) singleton ShaderData( HDR_BloomGaussBlurVShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurVP.hlsl"; + DXPixelShaderFile = "./bloomGaussBlurVP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurVP.glsl"; + OGLPixelShaderFile = "./bloomGaussBlurVP.glsl"; samplerNames[0] = "$inputTex"; @@ -125,9 +125,9 @@ singleton ShaderData( HDR_BloomGaussBlurVShader ) singleton ShaderData( HDR_SampleLumShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/sampleLumInitialP.hlsl"; + DXPixelShaderFile = "./sampleLumInitialP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumInitialP.glsl"; + OGLPixelShaderFile = "./sampleLumInitialP.glsl"; samplerNames[0] = "$inputTex"; @@ -137,9 +137,9 @@ singleton ShaderData( HDR_SampleLumShader ) singleton ShaderData( HDR_DownSampleLumShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/sampleLumIterativeP.hlsl"; + DXPixelShaderFile = "./sampleLumIterativeP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumIterativeP.glsl"; + OGLPixelShaderFile = "./sampleLumIterativeP.glsl"; samplerNames[0] = "$inputTex"; @@ -149,9 +149,9 @@ singleton ShaderData( HDR_DownSampleLumShader ) singleton ShaderData( HDR_CalcAdaptedLumShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/calculateAdaptedLumP.hlsl"; + DXPixelShaderFile = "./calculateAdaptedLumP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/calculateAdaptedLumP.glsl"; + OGLPixelShaderFile = "./calculateAdaptedLumP.glsl"; samplerNames[0] = "$currLum"; samplerNames[1] = "$lastAdaptedLum"; @@ -162,9 +162,9 @@ singleton ShaderData( HDR_CalcAdaptedLumShader ) singleton ShaderData( HDR_CombineShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/finalPassCombineP.hlsl"; + DXPixelShaderFile = "./finalPassCombineP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/finalPassCombineP.glsl"; + OGLPixelShaderFile = "./finalPassCombineP.glsl"; samplerNames[0] = "$sceneTex"; samplerNames[1] = "$luminanceTex"; @@ -221,20 +221,20 @@ singleton GFXStateBlockData( HDRStateBlock ) function HDRPostFX::setShaderConsts( %this ) { - %this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold ); - %this.setShaderConst( "$g_fMiddleGray", $HDRPostFX::keyValue ); + %this.setShaderConst( "$brightPassThreshold", $PostFX::HDRPostFX::brightPassThreshold ); + %this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue ); %bloomH = %this-->bloomH; - %bloomH.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier ); - %bloomH.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean ); - %bloomH.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev ); + %bloomH.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier ); + %bloomH.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean ); + %bloomH.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev ); %bloomV = %this-->bloomV; - %bloomV.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier ); - %bloomV.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean ); - %bloomV.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev ); + %bloomV.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier ); + %bloomV.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean ); + %bloomV.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev ); - %minLuminace = $HDRPostFX::minLuminace; + %minLuminace = $PostFX::HDRPostFX::minLuminace; if ( %minLuminace <= 0.0 ) { // The min should never be pure zero else the @@ -243,22 +243,32 @@ function HDRPostFX::setShaderConsts( %this ) } %this-->adaptLum.setShaderConst( "$g_fMinLuminace", %minLuminace ); - %this-->finalLum.setShaderConst( "$adaptRate", $HDRPostFX::adaptRate ); + %this-->finalLum.setShaderConst( "$adaptRate", $PostFX::HDRPostFX::adaptRate ); %combinePass = %this-->combinePass; - %combinePass.setShaderConst( "$g_fEnableToneMapping", $HDRPostFX::enableToneMapping ); - %combinePass.setShaderConst( "$g_fMiddleGray", $HDRPostFX::keyValue ); - %combinePass.setShaderConst( "$g_fBloomScale", $HDRPostFX::enableBloom ); - %combinePass.setShaderConst( "$g_fEnableBlueShift", $HDRPostFX::enableBlueShift ); - %combinePass.setShaderConst( "$g_fBlueShiftColor", $HDRPostFX::blueShiftColor ); + %combinePass.setShaderConst( "$g_fEnableToneMapping", $PostFX::HDRPostFX::enableToneMapping ); + %combinePass.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue ); + %combinePass.setShaderConst( "$g_fBloomScale", $PostFX::HDRPostFX::enableBloom ); + %combinePass.setShaderConst( "$g_fEnableBlueShift", $PostFX::HDRPostFX::enableBlueShift ); + %combinePass.setShaderConst( "$g_fBlueShiftColor", $PostFX::HDRPostFX::blueShiftColor ); + + %combinePass.setShaderConst( "$g_fEnableAutoExposure", $PostFX::HDRPostFX::enableAutoExposure ); + + %tonemapMode = 1; + if($PostFX::HDRPostFX::tonemapMode $= "Filmic") + %tonemapMode = 1; + else if($PostFX::HDRPostFX::tonemapMode $= "ACES") + %tonemapMode = 2; + + %combinePass.setShaderConst( "$g_fTonemapMode", %tonemapMode ); %clampedGamma = mClamp( $pref::Video::Gamma, 2.0, 2.5); %combinePass.setShaderConst( "$g_fOneOverGamma", 1 / %clampedGamma ); %combinePass.setShaderConst( "$Brightness", $pref::Video::Brightness ); %combinePass.setShaderConst( "$Contrast", $pref::Video::Contrast ); - %whiteCutoff = ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff ) * - ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff ); + %whiteCutoff = ( $PostFX::HDRPostFX::whiteCutoff * $PostFX::HDRPostFX::whiteCutoff ) * + ( $PostFX::HDRPostFX::whiteCutoff * $PostFX::HDRPostFX::whiteCutoff ); %combinePass.setShaderConst( "$g_fWhiteCutoff", %whiteCutoff ); } @@ -266,8 +276,8 @@ function HDRPostFX::preProcess( %this ) { %combinePass = %this-->combinePass; - if ( %combinePass.texture[3] !$= $HDRPostFX::colorCorrectionRamp ) - %combinePass.setTexture( 3, $HDRPostFX::colorCorrectionRamp ); + if ( %combinePass.texture[3] !$= $PostFX::HDRPostFX::colorCorrectionRamp ) + %combinePass.setTexture( 3, $PostFX::HDRPostFX::colorCorrectionRamp ); } function HDRPostFX::onEnabled( %this ) @@ -301,12 +311,16 @@ function HDRPostFX::onEnabled( %this ) // hdr encoding takes effect in all the shaders and // that the offscreen surface is enabled. resetLightManager(); + + $PostFX::HDRPostFX::Enabled = true; return true; } function HDRPostFX::onDisabled( %this ) { + $PostFX::HDRPostFX::Enabled = false; + // Enable a special GammaCorrection PostFX when this is disabled. GammaPostFX.enable(); @@ -330,7 +344,7 @@ function HDRPostFX::onAdd( %this ) //HDR should really be on at all times //%this.enable(); - $HDRPostFX::enableToneMapping = 1; + $PostFX::HDRPostFX::enableToneMapping = 1; } //This is used to populate the PostFXEditor's settings so the post FX can be edited @@ -339,62 +353,64 @@ function HDRPostFX::onAdd( %this ) function HDRPostFX::populatePostFXSettings(%this) { PostEffectEditorInspector.startGroup("HDR - General"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::keyValue", "Key Value", "range", "", $HDRPostFX::keyValue, "0 1 10"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::minLuminace", "Minimum Luminance", "range", "", $HDRPostFX::minLuminace, "0 1 10"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::whiteCutoff", "White Cutoff", "range", "", $HDRPostFX::whiteCutoff, "0 1 10"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::adaptRate", "Brightness Adapt Rate", "range", "", $HDRPostFX::adaptRate, "0 1 10"); + PostEffectEditorInspector.addCallbackField("$PostFX::HDRPostFX::Enabled", "Enabled", "bool", "", $PostFX::HDRPostFX::Enabled, "", "toggleHDRPostFX"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::minLuminace", "Minimum Luminance", "range", "", $PostFX::HDRPostFX::minLuminace, "0 1 100"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::whiteCutoff", "White Cutoff", "range", "", $PostFX::HDRPostFX::whiteCutoff, "0 10 20"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::adaptRate", "Brightness Adapt Rate", "range", "", $PostFX::HDRPostFX::adaptRate, "0 1 10"); + PostEffectEditorInspector.endGroup(); + + PostEffectEditorInspector.startGroup("HDR - Tonemapping"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::tonemapMode", "Tonemapping Mode", "list", "", $PostFX::HDRPostFX::tonemapMode, "Filmic,ACES"); PostEffectEditorInspector.endGroup(); PostEffectEditorInspector.startGroup("HDR - Bloom"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::enableBloom", "Enable Bloom", "bool", "", $HDRPostFX::enableBloom, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::brightPassThreshold", "Bright Pass Threshold", "float", "", $HDRPostFX::brightPassThreshold, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::gaussMultiplier", "Blur Multiplier", "float", "", $HDRPostFX::gaussMultiplier, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::gaussMean", "Blur \"Mean\" Value", "float", "", $HDRPostFX::gaussMean, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::gaussStdDev", "Blur \"Std. Dev\" Value", "float", "", $HDRPostFX::gaussStdDev, ""); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBloom", "Enable Bloom", "bool", "", $PostFX::HDRPostFX::enableBloom, ""); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::brightPassThreshold", "Bright Pass Threshold", "float", "", $PostFX::HDRPostFX::brightPassThreshold, ""); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussMultiplier", "Blur Multiplier", "range", "", $PostFX::HDRPostFX::gaussMultiplier, "0 1 10"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussMean", "Blur Mean Value", "range", "", $PostFX::HDRPostFX::gaussMean, "0 1 10"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussStdDev", "Blur Std. Dev Value", "range", "", $PostFX::HDRPostFX::gaussStdDev, "0 1 10"); PostEffectEditorInspector.endGroup(); - PostEffectEditorInspector.startGroup("HDR - Effects"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::enableBlueShift", "Enable Blue Shift", "bool", "", $HDRPostFX::enableBlueShift, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::blueShiftColor", "Blue Shift Color", "colorF", "", $HDRPostFX::blueShiftColor, ""); + PostEffectEditorInspector.startGroup("HDR - Adaptation"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableAutoExposure", "Enable Auto Exposure", "bool", "", $PostFX::HDRPostFX::enableAutoExposure, ""); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::keyValue", "Key Value", "range", "", $PostFX::HDRPostFX::keyValue, "0 1 10"); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBlueShift", "Enable Blue Shift", "bool", "", $PostFX::HDRPostFX::enableBlueShift, ""); + PostEffectEditorInspector.addField("$PostFX::HDRPostFX::blueShiftColor", "Blue Shift Color", "colorF", "", $PostFX::HDRPostFX::blueShiftColor, ""); PostEffectEditorInspector.endGroup(); } -//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 HDRPostFX::applyFromPreset(%this) +function PostEffectEditorInspector::toggleHDRPostFX(%this) { - //HDRPostFX Settings - $HDRPostFX::adaptRate = $PostFXManager::Settings::HDR::adaptRate; - $HDRPostFX::blueShiftColor = $PostFXManager::Settings::HDR::blueShiftColor; - $HDRPostFX::brightPassThreshold = $PostFXManager::Settings::HDR::brightPassThreshold; - $HDRPostFX::enableBloom = $PostFXManager::Settings::HDR::enableBloom; - $HDRPostFX::enableBlueShift = $PostFXManager::Settings::HDR::enableBlueShift; - $HDRPostFX::enableToneMapping = $PostFXManager::Settings::HDR::enableToneMapping; - $HDRPostFX::gaussMean = $PostFXManager::Settings::HDR::gaussMean; - $HDRPostFX::gaussMultiplier = $PostFXManager::Settings::HDR::gaussMultiplier; - $HDRPostFX::gaussStdDev = $PostFXManager::Settings::HDR::gaussStdDev; - $HDRPostFX::keyValue = $PostFXManager::Settings::HDR::keyValue; - $HDRPostFX::minLuminace = $PostFXManager::Settings::HDR::minLuminace; - $HDRPostFX::whiteCutoff = $PostFXManager::Settings::HDR::whiteCutoff; - $HDRPostFX::colorCorrectionRamp = $PostFXManager::Settings::ColorCorrectionRamp; + if($PostFX::HDRPostFX::Enabled) + HDRPostFX.enable(); + else + HDRPostFX.disable(); } -function HDRPostFX::settingsApply(%this) +function HDRPostFX::applyFromPreset(%this) { - $PostFXManager::Settings::HDR::adaptRate = $HDRPostFX::adaptRate; - $PostFXManager::Settings::HDR::blueShiftColor = $HDRPostFX::blueShiftColor; - $PostFXManager::Settings::HDR::brightPassThreshold = $HDRPostFX::brightPassThreshold; - $PostFXManager::Settings::HDR::enableBloom = $HDRPostFX::enableBloom; - $PostFXManager::Settings::HDR::enableBlueShift = $HDRPostFX::enableBlueShift; - $PostFXManager::Settings::HDR::enableToneMapping = $HDRPostFX::enableToneMapping; - $PostFXManager::Settings::HDR::gaussMean = $HDRPostFX::gaussMean; - $PostFXManager::Settings::HDR::gaussMultiplier = $HDRPostFX::gaussMultiplier; - $PostFXManager::Settings::HDR::gaussStdDev = $HDRPostFX::gaussStdDev; - $PostFXManager::Settings::HDR::keyValue = $HDRPostFX::keyValue; - $PostFXManager::Settings::HDR::minLuminace = $HDRPostFX::minLuminace; - $PostFXManager::Settings::HDR::whiteCutoff = $HDRPostFX::whiteCutoff; - $PostFXManager::Settings::ColorCorrectionRamp = $HDRPostFX::colorCorrectionRamp; + if($PostFX::HDRPostFX::Enabled) + HDRPostFX.enable(); + else + HDRPostFX.disable(); +} + +function HDRPostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::Enabled"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::minLuminace"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::whiteCutoff"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::adaptRate"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::tonemapMode"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBloom"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::brightPassThreshold"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussMultiplier"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussMean"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussStdDev"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableAutoExposure"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::keyValue"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBlueShift"); + PostFXManager::savePresetSetting("$PostFX::HDRPostFX::blueShiftColor"); } singleton PostEffect( HDRPostFX ) @@ -537,7 +553,7 @@ singleton PostEffect( HDRPostFX ) texture[0] = "$backBuffer"; texture[1] = "#adaptedLum"; texture[2] = "#bloomFinal"; - texture[3] = $HDRPostFX::colorCorrectionRamp; + texture[3] = $PostFX::HDRPostFX::colorCorrectionRamp; target = "$backBuffer"; }; }; @@ -562,7 +578,7 @@ singleton GFXStateBlockData( LuminanceVisStateBlock : PFX_DefaultStateBlock ) function LuminanceVisPostFX::setShaderConsts( %this ) { - %this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold ); + %this.setShaderConst( "$brightPassThreshold", $PostFX::HDRPostFX::brightPassThreshold ); } singleton PostEffect( LuminanceVisPostFX ) diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurHP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurHP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.glsl index f3486dce2..48e654ddc 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurHP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D inputTex ; uniform vec2 oneOverTargetSize; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurHP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.hlsl similarity index 70% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurHP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.hlsl index 77f4b9915..48e490e7c 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurHP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); uniform float2 oneOverTargetSize; @@ -47,6 +47,46 @@ float computeGaussianValue( float x, float mean, float std_deviation ) return tmp * tmp2; } +float SCurve (float x) +{ + x = x * 2.0 - 1.0; + return -x * abs(x) * 0.5 + x + 0.5; +} + +float4 BlurH (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius) +{ + if (radius >= 1.0) + { + float4 A = float4(0.0,0.0,0.0,0.0); + float4 C = float4(0.0,0.0,0.0,0.0); + + float width = 1.0 / size.x; + + float divisor = 0.0; + float weight = 0.0; + + float radiusMultiplier = 1.0 / radius; + + // Hardcoded for radius 20 (normally we input the radius + // in there), needs to be literal here + + for (float x = -20.0; x <= 20.0; x++) + { + A = TORQUE_TEX2D(source, uv + float2(x * width, 0.0)); + + weight = SCurve(1.0 - (abs(x) * radiusMultiplier)); + + C += A * weight; + + divisor += weight; + } + + return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0); + } + + return TORQUE_TEX2D(source, uv); +} + float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 { float4 color = { 0.0f, 0.0f, 0.0f, 0.0f }; @@ -63,6 +103,9 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev ); color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( offset, 0.0f ) ) * weight ); } + + //float2 targetSize = 1/oneOverTargetSize; + //float4 color = BlurH(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0); return float4( color.rgb, 1.0f ); } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurVP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurVP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.glsl index 5a456bea5..04e45e1e3 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurVP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D inputTex ; uniform vec2 oneOverTargetSize; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurVP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.hlsl similarity index 72% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurVP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.hlsl index 8381f6a5d..bd8e16a16 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurVP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); uniform float2 oneOverTargetSize; @@ -46,6 +46,44 @@ float computeGaussianValue( float x, float mean, float std_deviation ) return tmp * tmp2; } +float SCurve (float x) +{ + x = x * 2.0 - 1.0; + return -x * abs(x) * 0.5 + x + 0.5; +} + +float4 BlurV (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius) +{ + if (radius >= 1.0) + { + float4 A = float4(0.0,0.0,0.0,0.0); + float4 C = float4(0.0,0.0,0.0,0.0); + + float height = 1.0 / size.y; + + float divisor = 0.0; + float weight = 0.0; + + float radiusMultiplier = 1.0 / radius; + + for (float y = -20.0; y <= 20.0; y++) + { + A = TORQUE_TEX2D(source, uv + float2(0.0, y * height)); + + weight = SCurve(1.0 - (abs(y) * radiusMultiplier)); + + C += A * weight; + + divisor += weight; + } + + return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0); + } + + return TORQUE_TEX2D(source, uv); +} + + float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 { float4 color = { 0.0f, 0.0f, 0.0f, 0.0f }; @@ -63,5 +101,8 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( 0.0f, offset ) ) * weight ); } + //float2 targetSize = 1/oneOverTargetSize; + //float4 color = BlurV(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0); + return float4( color.rgb, 1.0f ); } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/brightPassFilterP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.glsl similarity index 93% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/brightPassFilterP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.glsl index 222185a4c..04d9e97c9 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/brightPassFilterP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.glsl @@ -20,10 +20,10 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/torque.glsl" -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D inputTex ; uniform sampler2D luminanceTex ; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/brightPassFilterP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/brightPassFilterP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.hlsl index 9a8a93e97..c3f04db93 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/brightPassFilterP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/calculateAdaptedLumP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.glsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/calculateAdaptedLumP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.glsl index ea23a489d..669cc1ebb 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/calculateAdaptedLumP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D currLum; uniform sampler2D lastAdaptedLum; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/calculateAdaptedLumP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/calculateAdaptedLumP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.hlsl index 0f895070a..0a1be4d96 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/calculateAdaptedLumP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(currLum, 0); TORQUE_UNIFORM_SAMPLER2D(lastAdaptedLum, 1); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4P.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl index 131671760..8ff63a6b2 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #define IN_GLSL -#include "../../../shdrConsts.h" -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/shdrConsts.h" +#include ".core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" in vec4 texCoords[8]; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.hlsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.hlsl index 01998af0b..86fe46397 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.hlsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #define IN_HLSL -#include "../../shdrConsts.h" -#include "../postFx.hlsl" +#include "core/rendering/shaders/shdrConsts.h" +#include "core/rendering/shaders/postFX/postFx.hlsl" //----------------------------------------------------------------------------- // Data diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4V.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.glsl index 51f1da896..070aa29e4 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.glsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #define IN_GLSL -#include "../../../shdrConsts.h" -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/shdrConsts.h" +#include "core/rendering/shaders/gl/hlslCompat.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.hlsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.hlsl index c9a34b7f4..4bc25d94e 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.hlsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #define IN_HLSL -#include "../../shdrConsts.h" -#include "../postFx.hlsl" +#include "core/rendering/shaders/shdrConsts.h" +#include "core/rendering/shaders/postFX/postFx.hlsl" //----------------------------------------------------------------------------- // Constants //----------------------------------------------------------------------------- diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/finalPassCombineP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl similarity index 76% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/finalPassCombineP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl index 4a532345f..21956e036 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/finalPassCombineP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl @@ -20,15 +20,14 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/torque.glsl" -#include "../../../gl/hlslCompat.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" #include "shadergen:/autogenConditioners.h" uniform sampler2D sceneTex; uniform sampler2D luminanceTex; uniform sampler2D bloomTex; -uniform sampler1D colorCorrectionTex; uniform vec2 texSize0; uniform vec2 texSize2; @@ -37,6 +36,9 @@ uniform float g_fEnableToneMapping; uniform float g_fMiddleGray; uniform float g_fWhiteCutoff; +uniform float g_fEnableAutoExposure; +uniform float g_fTonemapMode; + uniform float g_fEnableBlueShift; uniform vec3 g_fBlueShiftColor; @@ -60,15 +62,38 @@ vec3 Uncharted2Tonemap(vec3 x) return ((x*(A*x + C*B) + D*E) / (x*(A*x + B) + D*F)) - E / F; } +float3 ACESFilm( float3 x ) +{ + const float a = 2.51; + const float b = 0.03; + const float c = 2.43; + const float d = 0.59; + const float e = 0.14; + return sat((x*(a*x+b))/(x*(c*x+d)+e)); +} + vec3 tonemap(vec3 c) { - const float W = 11.2; - float ExposureBias = 2.0f; - float ExposureAdjust = 1.5f; - c *= ExposureAdjust; - vec3 curr = Uncharted2Tonemap(ExposureBias*c); - vec3 whiteScale = 1.0f / Uncharted2Tonemap(vec3(W,W,W)); - return curr*whiteScale; + vec3 colorOut = c; + + if(g_fTonemapMode == 1.0) + { + const float W = 11.2; + float ExposureBias = 2.0f; + float ExposureAdjust = 1.5f; + c *= ExposureAdjust; + vec3 curr = Uncharted2Tonemap(ExposureBias*c); + vec3 whiteScale = 1.0f / Uncharted2Tonemap(vec3(W,W,W)); + + colorOut = curr*whiteScale; + } + } + else if(g_fTonemapMode == 2.0) + { + colorOut = ACESFilm(c); + } + + return colorOut; } void main() @@ -100,11 +125,6 @@ void main() // Add the bloom effect. _sample += g_fBloomScale * bloom; - // Apply the color correction. - _sample.r = texture( colorCorrectionTex, _sample.r ).r; - _sample.g = texture( colorCorrectionTex, _sample.g ).g; - _sample.b = texture( colorCorrectionTex, _sample.b ).b; - // Apply contrast _sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f; @@ -114,7 +134,12 @@ void main() //tonemapping - TODO fix up eye adaptation if ( g_fEnableToneMapping > 0.0f ) { - _sample.rgb = tonemap(_sample.rgb); + float adapation = 1; + + if ( g_fEnableAutoExposure > 0.0f ) + adapation = (g_fMiddleGray / (adaptedLum + 0.0001)) * hdrLuminance( _sample.rgb ); + + _sample.rgb = tonemap(_sample.rgb * adapation); } OUT_col = _sample; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/finalPassCombineP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl similarity index 77% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/finalPassCombineP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl index 43a71a4a0..24bca9779 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/finalPassCombineP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl @@ -20,14 +20,13 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../torque.hlsl" -#include "../postFx.hlsl" -#include "../../shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" TORQUE_UNIFORM_SAMPLER2D(sceneTex, 0); TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1); TORQUE_UNIFORM_SAMPLER2D(bloomTex, 2); -TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 3); uniform float2 texSize0; uniform float2 texSize2; @@ -37,6 +36,9 @@ uniform float g_fMiddleGray; uniform float g_fWhiteCutoff; uniform float g_fEnableBlueShift; +uniform float g_fEnableAutoExposure; +uniform float g_fTonemapMode; + uniform float3 g_fBlueShiftColor; uniform float g_fBloomScale; uniform float g_fOneOverGamma; @@ -55,14 +57,31 @@ float3 Uncharted2Tonemap(const float3 x) return ((x*(A*x + C*B) + D*E) / (x*(A*x + B) + D*F)) - E / F; } +float3 ACESFilm( float3 x ) +{ + const float a = 2.51; + const float b = 0.03; + const float c = 2.43; + const float d = 0.59; + const float e = 0.14; + return saturate((x*(a*x+b))/(x*(c*x+d)+e)); +} + float3 tonemap(float3 color) { - const float W = 11.2; - float ExposureBias = 2.0f; - //float ExposureAdjust = 1.5f; - //c *= ExposureAdjust; - color = Uncharted2Tonemap(ExposureBias*color); - color = color * (1.0f / Uncharted2Tonemap(W)); + if(g_fTonemapMode == 1.0) + { + const float W = 11.2; + float ExposureBias = 2.0f; + //float ExposureAdjust = 1.5f; + //c *= ExposureAdjust; + color = Uncharted2Tonemap(ExposureBias*color); + color = color * (1.0f / Uncharted2Tonemap(W)); + } + else if(g_fTonemapMode == 2.0) + { + color = ACESFilm(color); + } return color; } @@ -96,11 +115,6 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 // Add the bloom effect. sample += g_fBloomScale * bloom; - // Apply the color correction. - sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r; - sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g; - sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b; - // Apply contrast sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f; @@ -110,7 +124,12 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 //tonemapping - TODO fix up eye adaptation if ( g_fEnableToneMapping > 0.0f ) { - sample.rgb = tonemap(sample.rgb); + float adapation = 1; + + if( g_fEnableAutoExposure > 0.0f ) + adapation = (g_fMiddleGray / (adaptedLum + 0.0001)) * hdrLuminance( sample.rgb ); + + sample.rgb = tonemap(sample.rgb * adapation); } return sample; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/luminanceVisP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.glsl similarity index 91% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/luminanceVisP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.glsl index 3ced367c3..ada9a4f91 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/luminanceVisP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.glsl @@ -20,10 +20,10 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/torque.glsl" -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D inputTex; uniform float brightPassThreshold; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/luminanceVisP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.hlsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/luminanceVisP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.hlsl index 505d1b825..ef56bd4f9 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/luminanceVisP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/sampleLumInitialP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.glsl similarity index 92% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/sampleLumInitialP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.glsl index 18455d646..885617d8c 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/sampleLumInitialP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/torque.glsl" -#include "../../../gl/hlslCompat.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D inputTex; uniform vec2 texSize0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/sampleLumInitialP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.hlsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/sampleLumInitialP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.hlsl index 2e23ece1f..878660bcb 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/sampleLumInitialP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../torque.hlsl" -#include "../postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); uniform float2 texSize0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/sampleLumIterativeP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumIterativeP.glsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/sampleLumIterativeP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumIterativeP.glsl index 162141225..cf5875e63 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/sampleLumIterativeP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumIterativeP.glsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" uniform sampler2D inputTex; uniform vec2 oneOverTargetSize; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/sampleLumIterativeP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumIterativeP.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/sampleLumIterativeP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumIterativeP.hlsl index 46ed6fc70..479b4a122 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/sampleLumIterativeP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumIterativeP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); uniform float2 oneOverTargetSize; diff --git a/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Eerie.png b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Eerie.png new file mode 100644 index 0000000000000000000000000000000000000000..5a7855134c240c35852d5ec390fc7325d2bb327a GIT binary patch literal 2904 zcmV-e3#asnP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001kNkl3kF$(vBCUlHd1MosE5!nMQKy9MA%%|Ss5*qh(k@p5Ky?r z1(^!Ww*j3}C@<~9{{sLAi30!cfX=c20000 diff --git a/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs new file mode 100644 index 000000000..e3842b04a --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs @@ -0,0 +1,145 @@ +//----------------------------------------------------------------------------- +// 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( LUTColorGradePostFX_Shader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "./LUTColorGradePostFXP.hlsl"; + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./LUTColorGradePostFXP.glsl"; + + samplerNames[0] = "$inputTex"; + samplerNames[1] = "$colorCorrectionTex"; + + pixVersion = 3.0; +}; + +singleton GFXStateBlockData( LUTColorGradePostFX_StateBlock ) +{ + samplersDefined = true; + samplerStates[0] = SamplerClampLinear; + samplerStates[1] = SamplerClampLinear; + + blendDefined = true; + blendDest = GFXBlendOne; + blendSrc = GFXBlendZero; + + zDefined = true; + zEnable = false; + zWriteEnable = false; + + cullDefined = true; + cullMode = GFXCullNone; +}; + + +function LUTColorGradePostFX::setShaderConsts( %this ) +{ +} + +function LUTColorGradePostFX::preProcess( %this ) +{ + if($PostFX::LUTColorGradePostFX::LUTImage $= "") + $PostFX::LUTColorGradePostFX::LUTImage = "core/postFX/images/null_color_ramp.png"; + + if ( %this.texture[1] !$= $PostFX::LUTColorGradePostFX::LUTImage ) + %this.setTexture( 1, $PostFX::LUTColorGradePostFX::LUTImage ); +} + +function LUTColorGradePostFX::onAdd(%this) +{ + //Register the postFX with the manager + PostFXManager.registerPostEffect(%this); +} + +function LUTColorGradePostFX::onEnabled( %this ) +{ + return true; +} + +function LUTColorGradePostFX::onDisabled( %this ) +{ +} + +//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 LUTColorGradePostFX::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("LUTColorGradePostFX - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::LUTColorGradePostFX::Enabled", "Enable", "bool", "", $PostFX::LUTColorGradePostFX::Enabled, "", "toggleLUTColorGradePostFX"); + PostEffectEditorInspector.addField("$PostFX::LUTColorGradePostFX::LUTImage", "LUT Image", "image", "", $PostFX::LUTColorGradePostFX::LUTImage, ""); + PostEffectEditorInspector.endGroup(); +} + +function PostEffectEditorInspector::toggleLUTColorGradePostFX(%this) +{ + if($PostFX::LUTColorGradePostFX::Enabled) + LUTColorGradePostFX.enable(); + else + LUTColorGradePostFX.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 LUTColorGradePostFX::applyFromPreset(%this) +{ + //LUTColorGradePostFX Settings + if($PostFX::LUTColorGradePostFX::Enable) + %this.enable(); + else + %this.disable(); +} + +function LUTColorGradePostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::LUTColorGradePostFX::Enabled"); + PostFXManager::savePresetSetting("$PostFX::LUTColorGradePostFX::LUTImage"); +} + +//Our actual postFX +singleton PostEffect( LUTColorGradePostFX ) +{ + isEnabled = false; + allowReflectPass = false; + + // Resolve the HDR before we render any editor stuff + // and before we resolve the scene to the backbuffer. + renderTime = "PFXBeforeBin"; + renderBin = "EditorBin"; + renderPriority = 9999; + + // The bright pass generates a bloomed version of + // the scene for pixels which are brighter than a + // fixed threshold value. + // + // This is then used in the final HDR combine pass + // at the end of this post effect chain. + shader = LUTColorGradePostFX_Shader; + stateBlock = LUTColorGradePostFX_StateBlock; + texture[0] = "$backBuffer"; + texture[1] = $PostFX::LUTColorGradePostFX::LUTImage; + target = "$backBuffer"; + targetFormat = "GFXFormatR16G16B16A16F"; + targetScale = "1 1"; +}; diff --git a/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.glsl b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.glsl new file mode 100644 index 000000000..6611d718b --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.glsl @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "shadergen:/autogenConditioners.h" +#include "core/rendering/shaders/postFX/gl/postFX.glsl" + +uniform sampler2D inputTex; + +out vec4 OUT_col; + +void main() +{ + OUT_col = hdrEncode( vec4(1,1,1,1) ); +} diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/chromaticLens.hlsl b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.hlsl similarity index 55% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/chromaticLens.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.hlsl index 8fdca72b7..263eb7c76 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/chromaticLens.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFXP.hlsl @@ -20,41 +20,19 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -// Based on 'Cubic Lens Distortion HLSL Shader' by François Tarlier -// www.francois-tarlier.com/blog/index.php/2009/11/cubic-lens-distortion-shader - -#include "./postFx.hlsl" -#include "./../torque.hlsl" - -TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0); -uniform float distCoeff; -uniform float cubeDistort; -uniform float3 colorDistort; +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" +TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); +TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 1); float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 { - float2 tex = IN.uv0; + float3 color = TORQUE_TEX2D(inputTex, IN.uv0).rgb; - float f = 0; - float r2 = (tex.x - 0.5) * (tex.x - 0.5) + (tex.y - 0.5) * (tex.y - 0.5); + color.r = TORQUE_TEX1D( colorCorrectionTex, color.r ).r; + color.g = TORQUE_TEX1D( colorCorrectionTex, color.g ).g; + color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b; - // Only compute the cubic distortion if necessary. - if ( cubeDistort == 0.0 ) - f = 1 + r2 * distCoeff; - else - f = 1 + r2 * (distCoeff + cubeDistort * sqrt(r2)); - - // Distort each color channel seperately to get a chromatic distortion effect. - float3 outColor; - float3 distort = f.xxx + colorDistort; - - for ( int i=0; i < 3; i++ ) - { - float x = distort[i] * ( tex.x - 0.5 ) + 0.5; - float y = distort[i] * ( tex.y - 0.5 ) + 0.5; - outColor[i] = TORQUE_TEX2DLOD( backBuffer, float4(x,y,0,0) )[i]; - } - - return float4( outColor.rgb, 1 ); -} \ No newline at end of file + return float4(color,1); +} diff --git a/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Misty_Blue.png b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Misty_Blue.png new file mode 100644 index 0000000000000000000000000000000000000000..24aef5f0a7733b3285c7325dfc2cc079eba96390 GIT binary patch literal 2878 zcmV-E3&He>P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001KNkl+zD1Ki1S ziaSNd4*zgVvZ2B4R}v&2f;FoD<-#K;n%TCJ)IlxMAZcV c0RR630FCPc@F&dD5dZ)H07*qoM6N<$f{3(P82|tP literal 0 HcmV?d00001 diff --git a/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Warm_Day.png b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/Warm_Day.png new file mode 100644 index 0000000000000000000000000000000000000000..409cb5ca10ce4b6986a60f47d2ae0c2ad26afb13 GIT binary patch literal 2872 zcmV-83&-?{P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001ENklKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0000+Nklfinal; + %pfx.setShaderConst( "$numSamples", $PostFX::LightRayPostFX::numSamples ); + %pfx.setShaderConst( "$density", $PostFX::LightRayPostFX::density ); + %pfx.setShaderConst( "$weight", $PostFX::LightRayPostFX::weight ); + %pfx.setShaderConst( "$decay", $PostFX::LightRayPostFX::decay ); + %pfx.setShaderConst( "$exposure", $PostFX::LightRayPostFX::exposure ); +} + +function LightRayPostFX::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("LightRayPostFX - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::LightRayPostFX::Enabled", "Enabled", "bool", "", $PostFX::LightRayPostFX::Enabled, "", "toggleLightRayPostFX"); + PostEffectEditorInspector.addField("$PostFX::LightRayPostFX::brightScalar", "Brightness", "float", "", $PostFX::LightRayPostFX::brightScalar, ""); + PostEffectEditorInspector.addField("$PostFX::LightRayPostFX::numSamples", "Samples", "float", "", $PostFX::LightRayPostFX::numSamples, ""); + PostEffectEditorInspector.addField("$PostFX::LightRayPostFX::density", "Density", "float", "", $PostFX::LightRayPostFX::density, ""); + PostEffectEditorInspector.addField("$PostFX::LightRayPostFX::weight", "Weight", "float", "", $PostFX::LightRayPostFX::weight, ""); + PostEffectEditorInspector.addField("$PostFX::LightRayPostFX::decay", "Decay", "float", "", $PostFX::LightRayPostFX::decay, ""); + PostEffectEditorInspector.addField("$PostFX::LightRayPostFX::exposure", "Exposure", "float", "", $PostFX::LightRayPostFX::exposure, ""); + PostEffectEditorInspector.endGroup(); +} + +function PostEffectEditorInspector::toggleLightRayPostFX(%this) +{ + if($PostFX::LightRayPostFX::Enabled) + LightRayPostFX.enable(); + else + LightRayPostFX.disable(); +} + +function LightRayPostFX::applyFromPreset(%this) +{ + if($PostFX::LightRayPostFX::Enabled) + %this.enable(); + else + %this.disable(); +} + +function LightRayPostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::LightRayPostFX::Enabled"); + PostFXManager::savePresetSetting("$PostFX::LightRayPostFX::brightScalar"); + PostFXManager::savePresetSetting("$PostFX::LightRayPostFX::numSamples"); + PostFXManager::savePresetSetting("$PostFX::LightRayPostFX::density"); + PostFXManager::savePresetSetting("$PostFX::LightRayPostFX::weight"); + PostFXManager::savePresetSetting("$PostFX::LightRayPostFX::decay"); + PostFXManager::savePresetSetting("$PostFX::LightRayPostFX::exposure"); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.asset.taml new file mode 100644 index 000000000..badd16a0f --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/MLAA.cs b/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs similarity index 83% rename from Templates/BaseGame/game/core/postFX/scripts/MLAA.cs rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs index 491c98e4e..9e26954f3 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/MLAA.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs @@ -44,11 +44,11 @@ singleton GFXStateBlockData( MLAA_EdgeDetectStateBlock : PFX_DefaultStateBlock ) singleton ShaderData( MLAA_EdgeDetectionShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/edgeDetectionP.hlsl"; + DXVertexShaderFile = "./offsetV.hlsl"; + DXPixelShaderFile = "./edgeDetectionP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/edgeDetectionP.glsl"; + OGLVertexShaderFile = "./offsetV.glsl"; + OGLPixelShaderFile = "./edgeDetectionP.glsl"; samplerNames[0] = "$colorMapG"; samplerNames[1] = "$deferredMap"; @@ -73,11 +73,11 @@ singleton GFXStateBlockData( MLAA_BlendWeightCalculationStateBlock : PFX_Default singleton ShaderData( MLAA_BlendWeightCalculationShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/passthruV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/blendWeightCalculationP.hlsl"; + DXVertexShaderFile = "./passthruV.hlsl"; + DXPixelShaderFile = "./blendWeightCalculationP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/passthruV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/blendWeightCalculationP.glsl"; + OGLVertexShaderFile = "./passthruV.glsl"; + OGLPixelShaderFile = "./blendWeightCalculationP.glsl"; samplerNames[0] = "$edgesMap"; samplerNames[1] = "$edgesMapL"; @@ -103,11 +103,11 @@ singleton GFXStateBlockData( MLAA_NeighborhoodBlendingStateBlock : PFX_DefaultSt singleton ShaderData( MLAA_NeighborhoodBlendingShader ) { - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/neighborhoodBlendingP.hlsl"; + DXVertexShaderFile = "./offsetV.hlsl"; + DXPixelShaderFile = "./neighborhoodBlendingP.hlsl"; - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/neighborhoodBlendingP.glsl"; + OGLVertexShaderFile = "./offsetV.glsl"; + OGLPixelShaderFile = "./neighborhoodBlendingP.glsl"; samplerNames[0] = "$blendMap"; samplerNames[1] = "$colorMapL"; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/blendWeightCalculationP.glsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/blendWeightCalculationP.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/blendWeightCalculationP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/blendWeightCalculationP.glsl index af01ce6f9..6228cbf81 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/blendWeightCalculationP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/blendWeightCalculationP.glsl @@ -26,7 +26,7 @@ // // http://www.iryoku.com/mlaa/ -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" in vec2 texcoord; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/blendWeightCalculationP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/blendWeightCalculationP.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/blendWeightCalculationP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/blendWeightCalculationP.hlsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/edgeDetectionP.glsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/edgeDetectionP.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/edgeDetectionP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/edgeDetectionP.glsl index d964a28a4..914187a5f 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/edgeDetectionP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/edgeDetectionP.glsl @@ -26,7 +26,7 @@ // // http://www.iryoku.com/mlaa/ -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" uniform sampler2D colorMapG; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/edgeDetectionP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/edgeDetectionP.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/edgeDetectionP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/edgeDetectionP.hlsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/functions.glsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/functions.glsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/functions.glsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/functions.glsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/functions.hlsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/functions.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/functions.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/functions.hlsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/neighborhoodBlendingP.glsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/neighborhoodBlendingP.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/neighborhoodBlendingP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/neighborhoodBlendingP.glsl index eddbcc47c..408b5f972 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/neighborhoodBlendingP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/neighborhoodBlendingP.glsl @@ -26,7 +26,7 @@ // // http://www.iryoku.com/mlaa/ -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" in vec2 texcoord; in vec4 offset[2]; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/neighborhoodBlendingP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/neighborhoodBlendingP.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/neighborhoodBlendingP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/neighborhoodBlendingP.hlsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/offsetV.glsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/offsetV.glsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/offsetV.glsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/offsetV.glsl index 53d927c29..1fb29b880 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/offsetV.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/offsetV.glsl @@ -26,7 +26,7 @@ // // http://www.iryoku.com/mlaa/ -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/offsetV.hlsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/offsetV.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/offsetV.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/offsetV.hlsl diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/passthruV.glsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/passthruV.glsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/passthruV.glsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/passthruV.glsl index 1aa64112c..b695761a2 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/gl/passthruV.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/passthruV.glsl @@ -26,7 +26,7 @@ // // http://www.iryoku.com/mlaa/ -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/passthruV.hlsl b/Templates/BaseGame/game/core/postFX/scripts/MLAA/passthruV.hlsl similarity index 100% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/mlaa/passthruV.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/MLAA/passthruV.hlsl diff --git a/Templates/BaseGame/game/core/postFX/scripts/MotionBlurFx.cs b/Templates/BaseGame/game/core/postFX/scripts/MotionBlurFx.cs deleted file mode 100644 index 5e04a4200..000000000 --- a/Templates/BaseGame/game/core/postFX/scripts/MotionBlurFx.cs +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -$MotionBlurPostFX::samples = 15; -$MotionBlurPostFX::velocityMultiplier = 3000; - -singleton ShaderData( PFX_MotionBlurShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; //we use the bare-bones postFxV.hlsl - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/motionBlurP.hlsl"; //new pixel shader - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/motionBlurP.glsl"; - - samplerNames[0] = "$backBuffer"; - samplerNames[1] = "$deferredTex"; - - pixVersion = 3.0; -}; - -function MotionBlurFX::onAdd( %this ) -{ - PostFXManager.registerPostEffect(%this); -} - -singleton PostEffect(MotionBlurFX) -{ - isEnabled = false; - - renderTime = "PFXAfterDiffuse"; - - shader = PFX_MotionBlurShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "$backbuffer"; - texture[1] = "#deferred"; - target = "$backBuffer"; -}; - -function MotionBlurFX::populatePostFXSettings(%this) -{ - PostEffectEditorInspector.startGroup("General"); - PostEffectEditorInspector.addField("isEnabled", "Enabled", "bool", "", MotionBlurFX.isEnabled, "", MotionBlurFX); - PostEffectEditorInspector.addField("$MotionBlurPostFX::velocityMultiplier", "Velocity Multiplier", "float", "", $MotionBlurPostFX::velocityMultiplier, ""); - PostEffectEditorInspector.addField("$MotionBlurPostFX::samples", "Sample Count", "float", "", $MotionBlurPostFX::samples, ""); - PostEffectEditorInspector.endGroup(); -} - -function MotionBlurFX::setShaderConsts(%this) -{ - %this.setShaderConst( "$velocityMultiplier", $MotionBlurPostFX::velocityMultiplier ); - %this.setShaderConst( "$samples", $MotionBlurPostFX::samples ); -} diff --git a/Templates/BaseGame/game/core/postFX/scripts/reflectionProbeArrayPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/reflectionProbeArrayPostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/reflectionProbeArrayPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.cs similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/reflectionProbeArrayPostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.cs diff --git a/Templates/BaseGame/game/core/postFX/scripts/SSAOPostFx.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAOPostFx.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/SSAOPostFx.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAOPostFx.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAOPostFx.cs b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAOPostFx.cs new file mode 100644 index 000000000..99071264f --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAOPostFx.cs @@ -0,0 +1,368 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + + +/// +$PostFX::SSAOPostFX::overallStrength = 2.0; + +// TODO: Add small/large param docs. + +// The small radius SSAO settings. +$PostFX::SSAOPostFX::sRadius = 0.1; +$PostFX::SSAOPostFX::sStrength = 6.0; +$PostFX::SSAOPostFX::sDepthMin = 0.1; +$PostFX::SSAOPostFX::sDepthMax = 1.0; +$PostFX::SSAOPostFX::sDepthPow = 1.0; +$PostFX::SSAOPostFX::sNormalTol = 0.0; +$PostFX::SSAOPostFX::sNormalPow = 1.0; + +// The large radius SSAO settings. +$PostFX::SSAOPostFX::lRadius = 1.0; +$PostFX::SSAOPostFX::lStrength = 10.0; +$PostFX::SSAOPostFX::lDepthMin = 0.2; +$PostFX::SSAOPostFX::lDepthMax = 2.0; +$PostFX::SSAOPostFX::lDepthPow = 0.2; +$PostFX::SSAOPostFX::lNormalTol = -0.5; +$PostFX::SSAOPostFX::lNormalPow = 2.0; + +/// Valid values: 0, 1, 2 +$PostFX::SSAOPostFX::quality = 0; + +/// +$PostFX::SSAOPostFX::blurDepthTol = 0.001; + +/// +$PostFX::SSAOPostFX::blurNormalTol = 0.95; + +/// +$PostFX::SSAOPostFX::targetScale = "0.5 0.5"; + + +function SSAOPostFx::onAdd( %this ) +{ + %this.wasVis = "Uninitialized"; + %this.quality = "Uninitialized"; + + PostFXManager.registerPostEffect(%this); +} + +function SSAOPostFx::preProcess( %this ) +{ + if ( $PostFX::SSAOPostFX::quality !$= %this.quality ) + { + %this.quality = mClamp( mRound( $PostFX::SSAOPostFX::quality ), 0, 2 ); + + %this.setShaderMacro( "QUALITY", %this.quality ); + } + + %this.targetScale = $PostFX::SSAOPostFX::targetScale; +} + +function SSAOPostFx::setShaderConsts( %this ) +{ + %this.setShaderConst( "$overallStrength", $PostFX::SSAOPostFX::overallStrength ); + + // Abbreviate is s-small l-large. + + %this.setShaderConst( "$sRadius", $PostFX::SSAOPostFX::sRadius ); + %this.setShaderConst( "$sStrength", $PostFX::SSAOPostFX::sStrength ); + %this.setShaderConst( "$sDepthMin", $PostFX::SSAOPostFX::sDepthMin ); + %this.setShaderConst( "$sDepthMax", $PostFX::SSAOPostFX::sDepthMax ); + %this.setShaderConst( "$sDepthPow", $PostFX::SSAOPostFX::sDepthPow ); + %this.setShaderConst( "$sNormalTol", $PostFX::SSAOPostFX::sNormalTol ); + %this.setShaderConst( "$sNormalPow", $PostFX::SSAOPostFX::sNormalPow ); + + %this.setShaderConst( "$lRadius", $PostFX::SSAOPostFX::lRadius ); + %this.setShaderConst( "$lStrength", $PostFX::SSAOPostFX::lStrength ); + %this.setShaderConst( "$lDepthMin", $PostFX::SSAOPostFX::lDepthMin ); + %this.setShaderConst( "$lDepthMax", $PostFX::SSAOPostFX::lDepthMax ); + %this.setShaderConst( "$lDepthPow", $PostFX::SSAOPostFX::lDepthPow ); + %this.setShaderConst( "$lNormalTol", $PostFX::SSAOPostFX::lNormalTol ); + %this.setShaderConst( "$lNormalPow", $PostFX::SSAOPostFX::lNormalPow ); + + %blur = %this->blurY; + %blur.setShaderConst( "$blurDepthTol", $PostFX::SSAOPostFX::blurDepthTol ); + %blur.setShaderConst( "$blurNormalTol", $PostFX::SSAOPostFX::blurNormalTol ); + + %blur = %this->blurX; + %blur.setShaderConst( "$blurDepthTol", $PostFX::SSAOPostFX::blurDepthTol ); + %blur.setShaderConst( "$blurNormalTol", $PostFX::SSAOPostFX::blurNormalTol ); + + %blur = %this->blurY2; + %blur.setShaderConst( "$blurDepthTol", $PostFX::SSAOPostFX::blurDepthTol ); + %blur.setShaderConst( "$blurNormalTol", $PostFX::SSAOPostFX::blurNormalTol ); + + %blur = %this->blurX2; + %blur.setShaderConst( "$blurDepthTol", $PostFX::SSAOPostFX::blurDepthTol ); + %blur.setShaderConst( "$blurNormalTol", $PostFX::SSAOPostFX::blurNormalTol ); +} + +function SSAOPostFx::onEnabled( %this ) +{ + // This tells the AL shaders to reload and sample + // from our #ssaoMask texture target. + $AL::UseSSAOMask = true; + + return true; +} + +function SSAOPostFx::onDisabled( %this ) +{ + $AL::UseSSAOMask = false; +} + +function SSAOPostFx::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("SSAO - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::SSAOPostFx::Enabled", "Enabled", "bool", "", $PostFXManager::PostFX::Enable, "", "toggleSSAOPostFx"); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::quality", "Quality", "list", "0,1,2", $PostFX::SSAOPostFX::quality, "0,1,2"); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::overallStrength", "Overall Strength", "float", "", $PostFX::SSAOPostFX::overallStrength, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::blurDepthTol", "Blur (Softness)", "float", "", $PostFX::SSAOPostFX::blurDepthTol, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::blurNormalTol", "Blur (Normal Maps)", "float", "", $PostFX::SSAOPostFX::blurNormalTol, ""); + PostEffectEditorInspector.endGroup(); + + PostEffectEditorInspector.startGroup("SSAO - Near"); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::sRadius", "Radius", "float", "", $PostFX::SSAOPostFX::sRadius, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::sStrength", "Strength", "float", "", $PostFX::SSAOPostFX::sStrength, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::sDepthMin", "Depth Min", "float", "", $PostFX::SSAOPostFX::sDepthMin, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::sDepthMax", "Depth Max", "float", "", $PostFX::SSAOPostFX::sDepthMax, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::sNormalTol", "Normal Map Tolerance", "float", "", $PostFX::SSAOPostFX::sNormalTol, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::sNormalPow", "Normal Map Power", "float", "", $PostFX::SSAOPostFX::sNormalPow, ""); + PostEffectEditorInspector.endGroup(); + + PostEffectEditorInspector.startGroup("SSAO - Far"); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::lRadius", "Radius", "float", "", $PostFX::SSAOPostFX::lRadius, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::lStrength", "Strength", "float", "", $PostFX::SSAOPostFX::lStrength, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::lDepthMin", "Depth Min", "float", "", $PostFX::SSAOPostFX::lDepthMin, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::lDepthMax", "Depth Max", "float", "", $PostFX::SSAOPostFX::lDepthMax, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::lNormalTol", "Normal Map Tolerance", "float", "", $PostFX::SSAOPostFX::lNormalTol, ""); + PostEffectEditorInspector.addField("$PostFX::SSAOPostFx::lNormalPow", "Normal Map Power", "float", "", $PostFX::SSAOPostFX::lNormalPow, ""); + PostEffectEditorInspector.endGroup(); +} + +function PostEffectEditorInspector::toggleSSAOPostFx(%this) +{ + if($PostFX::SSAOPostFx::Enabled) + SSAOPostFx.enable(); + else + SSAOPostFx.disable(); +} + +function SSAOPostFx::applyFromPreset(%this) +{ + if($PostFXManager::PostFX::Enable) + %this.enable(); + else + %this.disable(); +} + +function SSAOPostFx::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::Enabled"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::quality"); + + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::sRadius"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::sStrength"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::sDepthMin"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::sDepthMax"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::sNormalTol"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::sNormalPow"); + + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::lRadius"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::lStrength"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::lDepthMin"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::lDepthMax"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::lNormalTol"); + PostFXManager::savePresetSetting("$PostFX::SSAOPostFx::lNormalPow"); +} + +//----------------------------------------------------------------------------- +// GFXStateBlockData / ShaderData +//----------------------------------------------------------------------------- + +singleton GFXStateBlockData( SSAOStateBlock : PFX_DefaultStateBlock ) +{ + samplersDefined = true; + samplerStates[0] = SamplerClampPoint; + samplerStates[1] = SamplerWrapLinear; + samplerStates[2] = SamplerClampPoint; +}; + +singleton GFXStateBlockData( SSAOBlurStateBlock : PFX_DefaultStateBlock ) +{ + samplersDefined = true; + samplerStates[0] = SamplerClampLinear; + samplerStates[1] = SamplerClampPoint; +}; + +singleton ShaderData( SSAOShader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "./SSAO_P.hlsl"; + + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./SSAO_P.glsl"; + + samplerNames[0] = "$deferredMap"; + samplerNames[1] = "$randNormalTex"; + samplerNames[2] = "$powTable"; + + pixVersion = 3.0; +}; + +singleton ShaderData( SSAOBlurYShader ) +{ + DXVertexShaderFile = "./SSAO_Blur_V.hlsl"; + DXPixelShaderFile = "./SSAO_Blur_P.hlsl"; + + OGLVertexShaderFile = "./SSAO_Blur_V.glsl"; + OGLPixelShaderFile = "./SSAO_Blur_P.glsl"; + + samplerNames[0] = "$occludeMap"; + samplerNames[1] = "$deferredMap"; + + pixVersion = 3.0; + + defines = "BLUR_DIR=float2(0.0,1.0)"; +}; + +singleton ShaderData( SSAOBlurXShader : SSAOBlurYShader ) +{ + defines = "BLUR_DIR=float2(1.0,0.0)"; +}; + +//----------------------------------------------------------------------------- +// PostEffects +//----------------------------------------------------------------------------- + +singleton PostEffect( SSAOPostFx ) +{ + allowReflectPass = false; + + renderTime = "PFXBeforeBin"; + renderBin = "ProbeBin"; + renderPriority = 10; + + shader = SSAOShader; + stateBlock = SSAOStateBlock; + + texture[0] = "#deferred"; + texture[1] = "core/postFX/images/noise.png"; + texture[2] = "#ssao_pow_table"; + + target = "$outTex"; + targetScale = "0.5 0.5"; + targetViewport = "PFXTargetViewport_NamedInTexture0"; + + singleton PostEffect() + { + internalName = "blurY"; + + shader = SSAOBlurYShader; + stateBlock = SSAOBlurStateBlock; + + texture[0] = "$inTex"; + texture[1] = "#deferred"; + + target = "$outTex"; + }; + + singleton PostEffect() + { + internalName = "blurX"; + + shader = SSAOBlurXShader; + stateBlock = SSAOBlurStateBlock; + + texture[0] = "$inTex"; + texture[1] = "#deferred"; + + target = "$outTex"; + }; + + singleton PostEffect() + { + internalName = "blurY2"; + + shader = SSAOBlurYShader; + stateBlock = SSAOBlurStateBlock; + + texture[0] = "$inTex"; + texture[1] = "#deferred"; + + target = "$outTex"; + }; + + singleton PostEffect() + { + internalName = "blurX2"; + + shader = SSAOBlurXShader; + stateBlock = SSAOBlurStateBlock; + + texture[0] = "$inTex"; + texture[1] = "#deferred"; + + // We write to a mask texture which is then + // read by the lighting shaders to mask ambient. + target = "#ssaoMask"; + }; +}; + + +/// Just here for debug visualization of the +/// SSAO mask texture used during lighting. +singleton PostEffect( SSAOVizPostFx ) +{ + allowReflectPass = false; + + shader = PFX_PassthruShader; + stateBlock = PFX_DefaultStateBlock; + + texture[0] = "#ssaoMask"; + + target = "$backbuffer"; +}; + +singleton ShaderData( SSAOPowTableShader ) +{ + DXVertexShaderFile = "./SSAO_PowerTable_V.hlsl"; + DXPixelShaderFile = "./SSAO_PowerTable_P.hlsl"; + + OGLVertexShaderFile = "./SSAO_PowerTable_V.glsl"; + OGLPixelShaderFile = "./SSAO_PowerTable_P.glsl"; + + pixVersion = 2.0; +}; + +singleton PostEffect( SSAOPowTablePostFx ) +{ + shader = SSAOPowTableShader; + stateBlock = PFX_DefaultStateBlock; + + renderTime = "PFXTexGenOnDemand"; + + target = "#ssao_pow_table"; + + targetFormat = "GFXFormatR16F"; + targetSize = "256 1"; +}; \ No newline at end of file diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_Blur_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_P.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_Blur_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_P.glsl index cae920af8..ed73276b1 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_Blur_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_P.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" in vec4 uv0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_Blur_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_P.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_Blur_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_P.hlsl index 5bdf9a77d..b652d8bdb 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_Blur_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_P.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../shaderModelAutoGen.hlsl" -#include "./../postFx.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(occludeMap, 0); TORQUE_UNIFORM_SAMPLER2D(deferredMap, 1); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_Blur_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_V.glsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_Blur_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_V.glsl index 45a52e890..ff3aa7d35 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_Blur_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_V.glsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- -#include "../../../gl/torque.glsl" -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" in vec4 vPosition; in vec2 vTexCoord0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_Blur_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_V.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_Blur_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_V.hlsl index 6ab278900..cd46daab2 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_Blur_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_Blur_V.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform float2 texSize0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_P.glsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_P.glsl index e4b17098a..57ac0a414 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_P.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" #define DOSMALL #define DOLARGE diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_P.hlsl similarity index 98% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_P.hlsl index ff31a4b8b..dc662c0e0 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_P.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../shaderModelAutoGen.hlsl" -#include "./../postFx.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" #define DOSMALL #define DOLARGE diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_PowerTable_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_P.glsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_PowerTable_P.glsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_P.glsl index 4f49479ba..37253dfbb 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_PowerTable_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_P.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" in vec2 uv0; #define IN_uv0 uv0 diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_PowerTable_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_P.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_PowerTable_P.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_P.hlsl index 696947d3e..d721f629f 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_PowerTable_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_P.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 { diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_PowerTable_V.glsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_V.glsl similarity index 91% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_PowerTable_V.glsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_V.glsl index 2b1d983d0..335078fee 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/gl/SSAO_PowerTable_V.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_V.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/torque.glsl" -#include "../../../gl/hlslCompat.glsl" -#include "../../gl/postFx.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" void main() { diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_PowerTable_V.hlsl b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_V.hlsl similarity index 94% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_PowerTable_V.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_V.hlsl index 76f67e711..26545e736 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/ssao/SSAO_PowerTable_V.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SSAO/SSAO_PowerTable_V.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./../postFx.hlsl" -#include "./../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform float4 rtParams0; diff --git a/Templates/BaseGame/game/core/postFX/scripts/SSAOPostFx.cs b/Templates/BaseGame/game/core/postFX/scripts/SSAOPostFx.cs deleted file mode 100644 index 2bf41c126..000000000 --- a/Templates/BaseGame/game/core/postFX/scripts/SSAOPostFx.cs +++ /dev/null @@ -1,384 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - - -/// -$SSAOPostFx::overallStrength = 2.0; - -// TODO: Add small/large param docs. - -// The small radius SSAO settings. -$SSAOPostFx::sRadius = 0.1; -$SSAOPostFx::sStrength = 6.0; -$SSAOPostFx::sDepthMin = 0.1; -$SSAOPostFx::sDepthMax = 1.0; -$SSAOPostFx::sDepthPow = 1.0; -$SSAOPostFx::sNormalTol = 0.0; -$SSAOPostFx::sNormalPow = 1.0; - -// The large radius SSAO settings. -$SSAOPostFx::lRadius = 1.0; -$SSAOPostFx::lStrength = 10.0; -$SSAOPostFx::lDepthMin = 0.2; -$SSAOPostFx::lDepthMax = 2.0; -$SSAOPostFx::lDepthPow = 0.2; -$SSAOPostFx::lNormalTol = -0.5; -$SSAOPostFx::lNormalPow = 2.0; - -/// Valid values: 0, 1, 2 -$SSAOPostFx::quality = 0; - -/// -$SSAOPostFx::blurDepthTol = 0.001; - -/// -$SSAOPostFx::blurNormalTol = 0.95; - -/// -$SSAOPostFx::targetScale = "0.5 0.5"; - - -function SSAOPostFx::onAdd( %this ) -{ - %this.wasVis = "Uninitialized"; - %this.quality = "Uninitialized"; - - PostFXManager.registerPostEffect(%this); -} - -function SSAOPostFx::preProcess( %this ) -{ - if ( $SSAOPostFx::quality !$= %this.quality ) - { - %this.quality = mClamp( mRound( $SSAOPostFx::quality ), 0, 2 ); - - %this.setShaderMacro( "QUALITY", %this.quality ); - } - - %this.targetScale = $SSAOPostFx::targetScale; -} - -function SSAOPostFx::setShaderConsts( %this ) -{ - %this.setShaderConst( "$overallStrength", $SSAOPostFx::overallStrength ); - - // Abbreviate is s-small l-large. - - %this.setShaderConst( "$sRadius", $SSAOPostFx::sRadius ); - %this.setShaderConst( "$sStrength", $SSAOPostFx::sStrength ); - %this.setShaderConst( "$sDepthMin", $SSAOPostFx::sDepthMin ); - %this.setShaderConst( "$sDepthMax", $SSAOPostFx::sDepthMax ); - %this.setShaderConst( "$sDepthPow", $SSAOPostFx::sDepthPow ); - %this.setShaderConst( "$sNormalTol", $SSAOPostFx::sNormalTol ); - %this.setShaderConst( "$sNormalPow", $SSAOPostFx::sNormalPow ); - - %this.setShaderConst( "$lRadius", $SSAOPostFx::lRadius ); - %this.setShaderConst( "$lStrength", $SSAOPostFx::lStrength ); - %this.setShaderConst( "$lDepthMin", $SSAOPostFx::lDepthMin ); - %this.setShaderConst( "$lDepthMax", $SSAOPostFx::lDepthMax ); - %this.setShaderConst( "$lDepthPow", $SSAOPostFx::lDepthPow ); - %this.setShaderConst( "$lNormalTol", $SSAOPostFx::lNormalTol ); - %this.setShaderConst( "$lNormalPow", $SSAOPostFx::lNormalPow ); - - %blur = %this->blurY; - %blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol ); - %blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol ); - - %blur = %this->blurX; - %blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol ); - %blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol ); - - %blur = %this->blurY2; - %blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol ); - %blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol ); - - %blur = %this->blurX2; - %blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol ); - %blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol ); -} - -function SSAOPostFx::onEnabled( %this ) -{ - // This tells the AL shaders to reload and sample - // from our #ssaoMask texture target. - $AL::UseSSAOMask = true; - - return true; -} - -function SSAOPostFx::onDisabled( %this ) -{ - $AL::UseSSAOMask = false; -} - -function SSAOPostFx::populatePostFXSettings(%this) -{ - PostEffectEditorInspector.startGroup("SSAO - General"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::EnabledSSAO", "Enabled", "bool", "Low,Medium,High", $PostFXManager::PostFX::EnableSSAO, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::quality", "Quality", "list", "Low,Medium,High", $SSAOPostFx::quality, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::overallStrength", "Overall Strength", "float", "", $SSAOPostFx::overallStrength, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::blurDepthTol", "Blur (Softness)", "float", "", $SSAOPostFx::blurDepthTol, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::blurNormalTol", "Blur (Normal Maps)", "float", "", $SSAOPostFx::blurNormalTol, ""); - PostEffectEditorInspector.endGroup(); - - PostEffectEditorInspector.startGroup("SSAO - Near"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::sRadius", "Radius", "list", "Low,Medium,High", $SSAOPostFx::sRadius, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::sStrength", "Strength", "float", "", $SSAOPostFx::sStrength, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::sDepthMin", "Depth Min", "float", "", $SSAOPostFx::sDepthMin, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::sDepthMax", "Depth Max", "float", "", $SSAOPostFx::sDepthMax, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::sNormalTol", "Normal Map Tolerance", "float", "", $SSAOPostFx::sNormalTol, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::sNormalPow", "Normal Map Power", "float", "", $SSAOPostFx::sNormalPow, ""); - PostEffectEditorInspector.endGroup(); - - PostEffectEditorInspector.startGroup("SSAO - Far"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::lRadius", "Radius", "list", "Low,Medium,High", $SSAOPostFx::lRadius, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::lStrength", "Strength", "float", "", $SSAOPostFx::lStrength, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::lDepthMin", "Depth Min", "float", "", $SSAOPostFx::lDepthMin, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::lDepthMax", "Depth Max", "float", "", $SSAOPostFx::lDepthMax, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::lNormalTol", "Normal Map Tolerance", "float", "", $SSAOPostFx::lNormalTol, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::SSAO::lNormalPow", "Normal Map Power", "float", "", $SSAOPostFx::lNormalPow, ""); - PostEffectEditorInspector.endGroup(); -} - -function SSAOPostFx::applyFromPreset(%this) -{ - //SSAO Settings - $PostFXManager::PostFX::EnableSSAO = $PostFXManager::Settings::EnabledSSAO; - $SSAOPostFx::blurDepthTol = $PostFXManager::Settings::SSAO::blurDepthTol; - $SSAOPostFx::blurNormalTol = $PostFXManager::Settings::SSAO::blurNormalTol; - $SSAOPostFx::lDepthMax = $PostFXManager::Settings::SSAO::lDepthMax; - $SSAOPostFx::lDepthMin = $PostFXManager::Settings::SSAO::lDepthMin; - $SSAOPostFx::lDepthPow = $PostFXManager::Settings::SSAO::lDepthPow; - $SSAOPostFx::lNormalPow = $PostFXManager::Settings::SSAO::lNormalPow; - $SSAOPostFx::lNormalTol = $PostFXManager::Settings::SSAO::lNormalTol; - $SSAOPostFx::lRadius = $PostFXManager::Settings::SSAO::lRadius; - $SSAOPostFx::lStrength = $PostFXManager::Settings::SSAO::lStrength; - $SSAOPostFx::overallStrength = $PostFXManager::Settings::SSAO::overallStrength; - $SSAOPostFx::quality = $PostFXManager::Settings::SSAO::quality; - $SSAOPostFx::sDepthMax = $PostFXManager::Settings::SSAO::sDepthMax; - $SSAOPostFx::sDepthMin = $PostFXManager::Settings::SSAO::sDepthMin; - $SSAOPostFx::sDepthPow = $PostFXManager::Settings::SSAO::sDepthPow; - $SSAOPostFx::sNormalPow = $PostFXManager::Settings::SSAO::sNormalPow; - $SSAOPostFx::sNormalTol = $PostFXManager::Settings::SSAO::sNormalTol; - $SSAOPostFx::sRadius = $PostFXManager::Settings::SSAO::sRadius; - $SSAOPostFx::sStrength = $PostFXManager::Settings::SSAO::sStrength; - - if($PostFXManager::PostFX::EnableSSAO) - %this.enable(); - else - %this.disable(); -} - -function SSAOPostFx::settingsApply(%this) -{ - $PostFXManager::Settings::EnabledSSAO = $PostFXManager::PostFX::EnableSSAO ; - - $PostFXManager::Settings::SSAO::blurDepthTol = $SSAOPostFx::blurDepthTol; - $PostFXManager::Settings::SSAO::blurNormalTol = $SSAOPostFx::blurNormalTol; - $PostFXManager::Settings::SSAO::lDepthMax = $SSAOPostFx::lDepthMax; - $PostFXManager::Settings::SSAO::lDepthMin = $SSAOPostFx::lDepthMin; - $PostFXManager::Settings::SSAO::lDepthPow = $SSAOPostFx::lDepthPow; - $PostFXManager::Settings::SSAO::lNormalPow = $SSAOPostFx::lNormalPow; - $PostFXManager::Settings::SSAO::lNormalTol = $SSAOPostFx::lNormalTol; - $PostFXManager::Settings::SSAO::lRadius = $SSAOPostFx::lRadius; - $PostFXManager::Settings::SSAO::lStrength = $SSAOPostFx::lStrength; - $PostFXManager::Settings::SSAO::overallStrength = $SSAOPostFx::overallStrength; - $PostFXManager::Settings::SSAO::quality = $SSAOPostFx::quality; - $PostFXManager::Settings::SSAO::sDepthMax = $SSAOPostFx::sDepthMax; - $PostFXManager::Settings::SSAO::sDepthMin = $SSAOPostFx::sDepthMin; - $PostFXManager::Settings::SSAO::sDepthPow = $SSAOPostFx::sDepthPow; - $PostFXManager::Settings::SSAO::sNormalPow = $SSAOPostFx::sNormalPow; - $PostFXManager::Settings::SSAO::sNormalTol = $SSAOPostFx::sNormalTol; - $PostFXManager::Settings::SSAO::sRadius = $SSAOPostFx::sRadius; - $PostFXManager::Settings::SSAO::sStrength = $SSAOPostFx::sStrength; -} -//----------------------------------------------------------------------------- -// GFXStateBlockData / ShaderData -//----------------------------------------------------------------------------- - -singleton GFXStateBlockData( SSAOStateBlock : PFX_DefaultStateBlock ) -{ - samplersDefined = true; - samplerStates[0] = SamplerClampPoint; - samplerStates[1] = SamplerWrapLinear; - samplerStates[2] = SamplerClampPoint; -}; - -singleton GFXStateBlockData( SSAOBlurStateBlock : PFX_DefaultStateBlock ) -{ - samplersDefined = true; - samplerStates[0] = SamplerClampLinear; - samplerStates[1] = SamplerClampPoint; -}; - -singleton ShaderData( SSAOShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_P.hlsl"; - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_P.glsl"; - - samplerNames[0] = "$deferredMap"; - samplerNames[1] = "$randNormalTex"; - samplerNames[2] = "$powTable"; - - pixVersion = 3.0; -}; - -singleton ShaderData( SSAOBlurYShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_Blur_V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_Blur_P.hlsl"; - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_Blur_V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_Blur_P.glsl"; - - samplerNames[0] = "$occludeMap"; - samplerNames[1] = "$deferredMap"; - - pixVersion = 3.0; - - defines = "BLUR_DIR=float2(0.0,1.0)"; -}; - -singleton ShaderData( SSAOBlurXShader : SSAOBlurYShader ) -{ - defines = "BLUR_DIR=float2(1.0,0.0)"; -}; - -//----------------------------------------------------------------------------- -// PostEffects -//----------------------------------------------------------------------------- - -singleton PostEffect( SSAOPostFx ) -{ - allowReflectPass = false; - - renderTime = "PFXBeforeBin"; - renderBin = "ProbeBin"; - renderPriority = 10; - - shader = SSAOShader; - stateBlock = SSAOStateBlock; - - texture[0] = "#deferred"; - texture[1] = "core/postFX/images/noise.png"; - texture[2] = "#ssao_pow_table"; - - target = "$outTex"; - targetScale = "0.5 0.5"; - targetViewport = "PFXTargetViewport_NamedInTexture0"; - - singleton PostEffect() - { - internalName = "blurY"; - - shader = SSAOBlurYShader; - stateBlock = SSAOBlurStateBlock; - - texture[0] = "$inTex"; - texture[1] = "#deferred"; - - target = "$outTex"; - }; - - singleton PostEffect() - { - internalName = "blurX"; - - shader = SSAOBlurXShader; - stateBlock = SSAOBlurStateBlock; - - texture[0] = "$inTex"; - texture[1] = "#deferred"; - - target = "$outTex"; - }; - - singleton PostEffect() - { - internalName = "blurY2"; - - shader = SSAOBlurYShader; - stateBlock = SSAOBlurStateBlock; - - texture[0] = "$inTex"; - texture[1] = "#deferred"; - - target = "$outTex"; - }; - - singleton PostEffect() - { - internalName = "blurX2"; - - shader = SSAOBlurXShader; - stateBlock = SSAOBlurStateBlock; - - texture[0] = "$inTex"; - texture[1] = "#deferred"; - - // We write to a mask texture which is then - // read by the lighting shaders to mask ambient. - target = "#ssaoMask"; - }; -}; - - -/// Just here for debug visualization of the -/// SSAO mask texture used during lighting. -singleton PostEffect( SSAOVizPostFx ) -{ - allowReflectPass = false; - - shader = PFX_PassthruShader; - stateBlock = PFX_DefaultStateBlock; - - texture[0] = "#ssaoMask"; - - target = "$backbuffer"; -}; - -singleton ShaderData( SSAOPowTableShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_PowerTable_V.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_PowerTable_P.hlsl"; - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_PowerTable_V.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_PowerTable_P.glsl"; - - pixVersion = 2.0; -}; - -singleton PostEffect( SSAOPowTablePostFx ) -{ - shader = SSAOPowTableShader; - stateBlock = PFX_DefaultStateBlock; - - renderTime = "PFXTexGenOnDemand"; - - target = "#ssao_pow_table"; - - targetFormat = "GFXFormatR16F"; - targetSize = "256 1"; -}; \ No newline at end of file diff --git a/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.asset.taml new file mode 100644 index 000000000..61d349a08 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.asset.taml @@ -0,0 +1,8 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs new file mode 100644 index 000000000..b8f72ea8f --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs @@ -0,0 +1,145 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +$PostFX::SharpenPostFX::sharpness = "1"; + +singleton ShaderData( SharpenPostFX_Shader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "./SharpenPostFXP.hlsl"; + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./SharpenPostFXP.glsl"; + + samplerNames[0] = "$inputTex"; + + pixVersion = 3.0; +}; + +singleton GFXStateBlockData( SharpenPostFX_StateBlock ) +{ + samplersDefined = true; + samplerStates[0] = SamplerClampLinear; + samplerStates[1] = SamplerClampLinear; + samplerStates[2] = SamplerClampLinear; + samplerStates[3] = SamplerClampLinear; + + blendDefined = true; + blendDest = GFXBlendOne; + blendSrc = GFXBlendZero; + + zDefined = true; + zEnable = false; + zWriteEnable = false; + + cullDefined = true; + cullMode = GFXCullNone; +}; + + +function SharpenPostFX::setShaderConsts( %this ) +{ + %this.setShaderConst( "$sharpness", $PostFX::SharpenPostFX::sharpness ); +} + +function SharpenPostFX::preProcess( %this ) +{ +} + +function SharpenPostFX::onAdd(%this) +{ + //Register the postFX with the manager + PostFXManager.registerPostEffect(%this); +} + +function SharpenPostFX::onEnabled( %this ) +{ + return true; +} + +function SharpenPostFX::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 SharpenPostFX::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("SharpenPostFX - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::SharpenPostFX::Enabled", "Enabled", "bool", "", $PostFX::SharpenPostFX::Enabled, "", "toggleSharpenPostFX"); + PostEffectEditorInspector.addField("$PostFX::SharpenPostFX::sharpness", "Sharpness", "range", "", $PostFX::SharpenPostFX::sharpness, "0 2 20"); + 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::toggleSharpenPostFX(%this) +{ + if($PostFX::SharpenPostFX::Enabled) + SharpenPostFX.enable(); + else + SharpenPostFX.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 SharpenPostFX::applyFromPreset(%this) +{ + if($PostFX::SharpenPostFX::Enabled) + %this.enable(); + else + %this.disable(); +} + +function SharpenPostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::SharpenPostFX::Enabled"); + PostFXManager::savePresetSetting("$PostFX::SharpenPostFX::sharpness"); +} + +//Our actual postFX +singleton PostEffect( SharpenPostFX ) +{ + isEnabled = false; + allowReflectPass = false; + + // Resolve the HDR before we render any editor stuff + // and before we resolve the scene to the backbuffer. + renderTime = "PFXBeforeBin"; + renderBin = "EditorBin"; + renderPriority = 9999; + + // The bright pass generates a bloomed version of + // the scene for pixels which are brighter than a + // fixed threshold value. + // + // This is then used in the final HDR combine pass + // at the end of this post effect chain. + shader = SharpenPostFX_Shader; + stateBlock = SharpenPostFX_StateBlock; + texture[0] = "$backBuffer"; + target = "$backBuffer"; + targetFormat = "GFXFormatR16G16B16A16F"; + targetScale = "1 1"; +}; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/chromaticLens.glsl b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFXP.glsl similarity index 55% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/chromaticLens.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFXP.glsl index e0aac53c7..35a2ff186 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/chromaticLens.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFXP.glsl @@ -20,43 +20,22 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -// Based on 'Cubic Lens Distortion HLSL Shader' by Fran�ois Tarlier -// www.francois-tarlier.com/blog/index.php/2009/11/cubic-lens-distortion-shader +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "shadergen:/autogenConditioners.h" +#include "core/rendering/shaders/postFX/gl/postFX.glsl" -#include "./postFx.glsl" -#include "../../gl/torque.glsl" -#include "../../gl/hlslCompat.glsl" +uniform sampler2D inputTex; -uniform sampler2D backBuffer; -uniform float distCoeff; -uniform float cubeDistort; -uniform vec3 colorDistort; +in vec4 modColor; out vec4 OUT_col; void main() { - vec2 tex = IN_uv0; - - float f = 0; - float r2 = (tex.x - 0.5) * (tex.x - 0.5) + (tex.y - 0.5) * (tex.y - 0.5); - - // Only compute the cubic distortion if necessary. - if ( cubeDistort == 0.0 ) - f = 1 + r2 * distCoeff; - else - f = 1 + r2 * (distCoeff + cubeDistort * sqrt(r2)); - - // Distort each color channel seperately to get a chromatic distortion effect. - vec3 outColor; - vec3 distort = vec3(f) + colorDistort; - - for ( int i=0; i < 3; i++ ) - { - float x = distort[i] * ( tex.x - 0.5 ) + 0.5; - float y = distort[i] * ( tex.y - 0.5 ) + 0.5; - outColor[i] = tex2Dlod( backBuffer, vec4(x,y,0,0) )[i]; - } - - OUT_col = vec4( outColor.rgb, 1 ); + vec4 color = texture(inputTex, IN_uv0); + + color *= modColor; + + OUT_col = hdrEncode( color ); } diff --git a/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFXP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFXP.hlsl new file mode 100644 index 000000000..7e8416dd3 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFXP.hlsl @@ -0,0 +1,24 @@ +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" + +TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); + +uniform float sharpness; +uniform float2 targetSize; + +float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 +{ + float2 step = 1.0 / targetSize.xy; + + float3 texA = TORQUE_TEX2D( inputTex, IN.uv0 + float2(-step.x, -step.y) * 1.5 ).rgb; + float3 texB = TORQUE_TEX2D( inputTex, IN.uv0 + float2( step.x, -step.y) * 1.5 ).rgb; + float3 texC = TORQUE_TEX2D( inputTex, IN.uv0 + float2(-step.x, step.y) * 1.5 ).rgb; + float3 texD = TORQUE_TEX2D( inputTex, IN.uv0 + float2( step.x, step.y) * 1.5 ).rgb; + + float3 around = 0.25 * (texA + texB + texC + texD); + float3 center = TORQUE_TEX2D( inputTex, IN.uv0 ).rgb; + + float3 col = center + (center - around) * sharpness; + + return hdrEncode( float4(col,1.0) ); +} diff --git a/Templates/BaseGame/game/core/postFX/scripts/TurbulencePostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/TurbulencePostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/TurbulencePostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs similarity index 93% rename from Templates/BaseGame/game/core/postFX/scripts/TurbulencePostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs index f9b0f0730..d6a5064e4 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/TurbulencePostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs @@ -33,10 +33,10 @@ singleton GFXStateBlockData( PFX_TurbulenceStateBlock : PFX_DefaultStateBlock) singleton ShaderData( PFX_TurbulenceShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/turbulenceP.hlsl"; + DXPixelShaderFile = "./turbulenceP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/turbulenceP.glsl"; + OGLPixelShaderFile = "./turbulenceP.glsl"; samplerNames[0] = "$inputTex"; pixVersion = 3.0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/turbulenceP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/turbulenceP.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/turbulenceP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Turbulence/turbulenceP.glsl index 9b97d971d..48399c967 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/turbulenceP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/turbulenceP.glsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../gl/hlslCompat.glsl" -#include "../../gl/torque.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" #include "shadergen:/autogenConditioners.h" uniform float accumTime; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/turbulenceP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/turbulenceP.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/turbulenceP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Turbulence/turbulenceP.hlsl index c8c572ae7..7a5baf29a 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/turbulenceP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/turbulenceP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" uniform float accumTime; uniform float2 projectionOffset; diff --git a/Templates/BaseGame/game/core/postFX/scripts/underWaterFogPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.asset.taml similarity index 100% rename from Templates/BaseGame/game/core/postFX/scripts/underWaterFogPostFX.asset.taml rename to Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.asset.taml diff --git a/Templates/BaseGame/game/core/postFX/scripts/underWaterFogPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs similarity index 94% rename from Templates/BaseGame/game/core/postFX/scripts/underWaterFogPostFX.cs rename to Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs index 739224a0b..03176b59f 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/underWaterFogPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs @@ -27,10 +27,10 @@ singleton ShaderData( UnderwaterFogPassShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/underwaterFogP.hlsl"; + DXPixelShaderFile = "./underwaterFogP.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/underwaterFogP.glsl"; + OGLPixelShaderFile = "./underwaterFogP.glsl"; samplerNames[0] = "$deferredTex"; samplerNames[1] = "$backbuffer"; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/underwaterFogP.glsl b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underwaterFogP.glsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/gl/underwaterFogP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underwaterFogP.glsl index ea9126566..0edc730b8 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/gl/underwaterFogP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underwaterFogP.glsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../gl/hlslCompat.glsl" -#include "../../gl/torque.glsl" -#include "postFx.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/torque.glsl" +#include "core/rendering/shaders/postFX/postFx.glsl" #include "shadergen:/autogenConditioners.h" //----------------------------------------------------------------------------- diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/underwaterFogP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underwaterFogP.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/underwaterFogP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underwaterFogP.hlsl index aab43c45c..366828b82 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/underwaterFogP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underwaterFogP.hlsl @@ -20,9 +20,9 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "./postFx.hlsl" -#include "../torque.hlsl" -#include "../shaderModelAutoGen.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" +#include "core/rendering/shaders/shaderModelAutoGen.hlsl" //----------------------------------------------------------------------------- // Defines //----------------------------------------------------------------------------- diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/barrelDistortionChromaP.glsl b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionChromaP.glsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/barrelDistortionChromaP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionChromaP.glsl index 6c8280d69..a67b3a022 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/barrelDistortionChromaP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionChromaP.glsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #include "shadergen:/autogenConditioners.h" -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform sampler2D backBuffer : register(S0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/barrelDistortionChromaP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionChromaP.hlsl similarity index 97% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/barrelDistortionChromaP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionChromaP.hlsl index 2ff414227..e21cdc572 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/barrelDistortionChromaP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionChromaP.hlsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #include "shadergen:/autogenConditioners.h" -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/barrelDistortionP.glsl b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionP.glsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/barrelDistortionP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionP.glsl index 336a3e217..d6751a801 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/barrelDistortionP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionP.glsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #include "shadergen:/autogenConditioners.h" -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform sampler2D backBuffer : register(S0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/barrelDistortionP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionP.hlsl similarity index 96% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/barrelDistortionP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionP.hlsl index c8f338f5c..7477a59ef 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/barrelDistortionP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/barrelDistortionP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/monoToStereoP.glsl b/Templates/BaseGame/game/core/postFX/scripts/VR/monoToStereoP.glsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/monoToStereoP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/VR/monoToStereoP.glsl index 326f423d9..b6b1aa228 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/gl/monoToStereoP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/monoToStereoP.glsl @@ -21,8 +21,8 @@ //----------------------------------------------------------------------------- #include "shadergen:/autogenConditioners.h" -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" uniform sampler2D backBuffer : register(S0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/monoToStereoP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/VR/monoToStereoP.hlsl similarity index 95% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/monoToStereoP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/VR/monoToStereoP.hlsl index 65cf62fe5..c84443c89 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/oculusvr/monoToStereoP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/monoToStereoP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" -#include "../../torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" +#include "core/rendering/shaders/torque.hlsl" TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0); diff --git a/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.asset.taml new file mode 100644 index 000000000..961da2df9 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/ovrBarrelDistortion.cs b/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs similarity index 95% rename from Templates/BaseGame/game/core/postFX/scripts/ovrBarrelDistortion.cs rename to Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs index 1ea280863..e413537ff 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/ovrBarrelDistortion.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs @@ -31,7 +31,7 @@ if(!isFunction(isOculusVRDeviceActive)) singleton ShaderData( OVRMonoToStereoShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/monoToStereoP.hlsl"; + DXPixelShaderFile = "./monoToStereoP.hlsl"; //OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.hlsl"; //OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/gl/monoToStereoP.glsl"; @@ -44,7 +44,7 @@ singleton ShaderData( OVRMonoToStereoShader ) singleton ShaderData( OVRBarrelDistortionShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/barrelDistortionP.hlsl"; + DXPixelShaderFile = "./barrelDistortionP.hlsl"; //OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; //OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/gl/barrelDistortionP.glsl"; @@ -57,7 +57,7 @@ singleton ShaderData( OVRBarrelDistortionShader ) singleton ShaderData( OVRBarrelDistortionChromaShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/barrelDistortionChromaP.hlsl"; + DXPixelShaderFile = "./barrelDistortionChromaP.hlsl"; pixVersion = 2.0; }; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.asset.taml b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.asset.taml new file mode 100644 index 000000000..f9a28676f --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs new file mode 100644 index 000000000..34699f918 --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs @@ -0,0 +1,133 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +$PostFX::VignettePostFX::VMax = 0.6; +$PostFX::VignettePostFX::VMin = 0.2; +$PostFX::VignettePostFX::Color = "0 0 0 1"; + +singleton ShaderData( VignettePostFX_Shader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "./VignettePostFXP.hlsl"; + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./VignettePostFXP.glsl"; + + samplerNames[0] = "$backBuffer"; + + pixVersion = 3.0; +}; + +singleton GFXStateBlockData( VignettePostFX_StateBlock ) +{ + zDefined = true; + zEnable = false; + zWriteEnable = false; + + samplersDefined = true; + samplerStates[0] = SamplerClampLinear; +}; + + +function VignettePostFX::setShaderConsts( %this ) +{ + %this.setShaderConst("$Vmax", $PostFX::VignettePostFX::VMax); + %this.setShaderConst("$Vmin", $PostFX::VignettePostFX::VMin); + %this.setShaderConst("$Color", $PostFX::VignettePostFX::Color); +} + +function VignettePostFX::preProcess( %this ) +{ +} + +function VignettePostFX::onAdd(%this) +{ + //Register the postFX with the manager + PostFXManager.registerPostEffect(%this); +} + +function VignettePostFX::onEnabled( %this ) +{ + return true; +} + +function VignettePostFX::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 VignettePostFX::populatePostFXSettings(%this) +{ + PostEffectEditorInspector.startGroup("VignettePostFX - General"); + PostEffectEditorInspector.addCallbackField("$PostFX::VignettePostFX::Enabled", "Enabled", "bool", "", $PostFX::VignettePostFX::Enabled, "", "toggleVignettePostFX"); + PostEffectEditorInspector.addField("$PostFX::VignettePostFX::VMin", "Min", "range", "", $PostFX::VignettePostFX::VMin, "0 1 10"); + PostEffectEditorInspector.addField("$PostFX::VignettePostFX::VMax", "Max", "range", "", $PostFX::VignettePostFX::VMax, "0 1 10"); + PostEffectEditorInspector.addField("$PostFX::VignettePostFX::Color", "Color", "colorF", "", $PostFX::VignettePostFX::Color, ""); + 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::toggleVignettePostFX(%this) +{ + if($PostFX::VignettePostFX::Enabled) + VignettePostFX.enable(); + else + VignettePostFX.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 VignettePostFX::applyFromPreset(%this) +{ + if($PostFX::VignettePostFX::Enabled) + %this.enable(); + else + %this.disable(); +} + +function VignettePostFX::savePresetSettings(%this) +{ + PostFXManager::savePresetSetting("$PostFX::VignettePostFX::Enabled"); + PostFXManager::savePresetSetting("$PostFX::VignettePostFX::VMin"); + PostFXManager::savePresetSetting("$PostFX::VignettePostFX::VMax"); + PostFXManager::savePresetSetting("$PostFX::VignettePostFX::Color"); +} + +//Our actual postFX +singleton PostEffect( VignettePostFX ) +{ + isEnabled = false; + + renderTime = "PFXBeforeBin"; + renderBin = "EditorBin"; + renderPriority = 9999; + + shader = VignettePostFX_Shader; + stateBlock = VignettePostFX_StateBlock; + texture[0] = "$backBuffer"; + renderPriority = 10; + target = "$backBuffer"; +}; diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/vignette/gl/VignetteP.glsl b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFXP.glsl similarity index 91% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/vignette/gl/VignetteP.glsl rename to Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFXP.glsl index 35de95c34..c210d131c 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/vignette/gl/VignetteP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFXP.glsl @@ -20,12 +20,13 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../../../gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" uniform sampler2D backBuffer; uniform float Vmax; uniform float Vmin; +uniform vec4 Color; in vec2 uv0; #define IN_uv0 uv0 @@ -36,6 +37,6 @@ void main() { vec4 base = texture(backBuffer, IN_uv0); float dist = distance(IN_uv0, vec2(0.5,0.5)); - base.rgb *= smoothstep(Vmax, Vmin, dist); + base.rgb = lerp(Color.rgb, base.rgb, smoothstep(Vmax, Vmin, dist)); OUT_col = base; } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/rendering/shaders/postFX/vignette/VignetteP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFXP.hlsl similarity index 91% rename from Templates/BaseGame/game/core/rendering/shaders/postFX/vignette/VignetteP.hlsl rename to Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFXP.hlsl index c518a2145..1603679d6 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/postFX/vignette/VignetteP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFXP.hlsl @@ -20,16 +20,17 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "../postFx.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0); uniform float Vmax; uniform float Vmin; +uniform float4 Color; float4 main(PFXVertToPix IN) : TORQUE_TARGET0 { float4 base = TORQUE_TEX2D(backBuffer, IN.uv0); float dist = distance(IN.uv0, float2(0.5,0.5)); - base.rgb *= smoothstep(Vmax, Vmin, dist); + base.rgb = lerp(Color.rgb, base.rgb, smoothstep(Vmax, Vmin, dist)); return base; } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/postFX/scripts/chromaticLens.cs b/Templates/BaseGame/game/core/postFX/scripts/chromaticLens.cs deleted file mode 100644 index 06b8d3988..000000000 --- a/Templates/BaseGame/game/core/postFX/scripts/chromaticLens.cs +++ /dev/null @@ -1,77 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -/// -$CAPostFx::enabled = false; - -/// The lens distortion coefficient. -$CAPostFx::distCoeffecient = -0.05; - -/// The cubic distortion value. -$CAPostFx::cubeDistortionFactor = -0.1; - -/// The amount and direction of the maxium shift for -/// the red, green, and blue channels. -$CAPostFx::colorDistortionFactor = "0.005 -0.005 0.01"; - - -singleton GFXStateBlockData( PFX_DefaultChromaticLensStateBlock ) -{ - zDefined = true; - zEnable = false; - zWriteEnable = false; - samplersDefined = true; - samplerStates[0] = SamplerClampPoint; -}; - -singleton ShaderData( PFX_ChromaticLensShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/chromaticLens.hlsl"; - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/chromaticLens.glsl"; - - samplerNames[0] = "$backBuffer"; - - pixVersion = 3.0; -}; - -singleton PostEffect( ChromaticLensPostFX ) -{ - renderTime = "PFXAfterDiffuse"; - renderPriority = 0.2; - isEnabled = false; - allowReflectPass = false; - - shader = PFX_ChromaticLensShader; - stateBlock = PFX_DefaultChromaticLensStateBlock; - texture[0] = "$backBuffer"; - target = "$backBuffer"; -}; - -function ChromaticLensPostFX::setShaderConsts( %this ) -{ - %this.setShaderConst( "$distCoeff", $CAPostFx::distCoeffecient ); - %this.setShaderConst( "$cubeDistort", $CAPostFx::cubeDistortionFactor ); - %this.setShaderConst( "$colorDistort", $CAPostFx::colorDistortionFactor ); -} diff --git a/Templates/BaseGame/game/core/postFX/scripts/lightRays.cs b/Templates/BaseGame/game/core/postFX/scripts/lightRays.cs deleted file mode 100644 index 8f414bfd0..000000000 --- a/Templates/BaseGame/game/core/postFX/scripts/lightRays.cs +++ /dev/null @@ -1,154 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - - -$LightRayPostFX::brightScalar = 0.75; -$LightRayPostFX::numSamples = 40; -$LightRayPostFX::density = 0.94; -$LightRayPostFX::weight = 5.65; -$LightRayPostFX::decay = 1.0; -$LightRayPostFX::exposure = 0.0005; -$LightRayPostFX::resolutionScale = 1.0; - -function LightRayPostFX::onAdd( %this ) -{ - PostFXManager.registerPostEffect(%this); -} - -singleton ShaderData( LightRayOccludeShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/lightRayOccludeP.hlsl"; - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/gl/lightRayOccludeP.glsl"; - - samplerNames[0] = "$backBuffer"; - samplerNames[1] = "$deferredTex"; - - pixVersion = 3.0; -}; - -singleton ShaderData( LightRayShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/lightRayP.hlsl"; - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/gl/lightRayP.glsl"; - - samplerNames[0] = "$frameSampler"; - samplerNames[1] = "$backBuffer"; - - pixVersion = 3.0; -}; - -singleton GFXStateBlockData( LightRayStateBlock : PFX_DefaultStateBlock ) -{ - samplersDefined = true; - samplerStates[0] = SamplerClampLinear; - samplerStates[1] = SamplerClampLinear; -}; - -singleton PostEffect( LightRayPostFX ) -{ - //isEnabled = false; - allowReflectPass = false; - - renderTime = "PFXBeforeBin"; - renderBin = "EditorBin"; - renderPriority = 10; - - shader = LightRayOccludeShader; - stateBlock = LightRayStateBlock; - texture[0] = "$backBuffer"; - texture[1] = "#deferred"; - target = "$outTex"; - targetFormat = "GFXFormatR16G16B16A16F"; - - new PostEffect() - { - shader = LightRayShader; - stateBlock = LightRayStateBlock; - internalName = "final"; - texture[0] = "$inTex"; - texture[1] = "$backBuffer"; - target = "$backBuffer"; - }; -}; - -function LightRayPostFX::preProcess( %this ) -{ - %this.targetScale = $LightRayPostFX::resolutionScale SPC $LightRayPostFX::resolutionScale; -} - -function LightRayPostFX::setShaderConsts( %this ) -{ - %this.setShaderConst( "$brightScalar", $LightRayPostFX::brightScalar ); - - %pfx = %this-->final; - %pfx.setShaderConst( "$numSamples", $LightRayPostFX::numSamples ); - %pfx.setShaderConst( "$density", $LightRayPostFX::density ); - %pfx.setShaderConst( "$weight", $LightRayPostFX::weight ); - %pfx.setShaderConst( "$decay", $LightRayPostFX::decay ); - %pfx.setShaderConst( "$exposure", $LightRayPostFX::exposure ); -} - -function LightRayPostFX::populatePostFXSettings(%this) -{ - PostEffectEditorInspector.startGroup("Light Ray"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::EnableLightRays", "Enabled", "bool", "", $PostFXManager::PostFX::EnableLightRays, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::LightRays::brightScalar", "Brightness", "float", "", $LightRayPostFX::brightScalar, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::LightRays::numSamples", "Samples", "float", "", $LightRayPostFX::numSamples, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::LightRays::density", "Density", "float", "", $LightRayPostFX::density, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::LightRays::weight", "Weight", "float", "", $LightRayPostFX::weight, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::LightRays::decay", "Decay", "float", "", $LightRayPostFX::decay, ""); - PostEffectEditorInspector.endGroup(); -} - -function LightRayPostFX::applyFromPreset(%this) -{ - //Light rays settings - $PostFXManager::PostFX::EnableLightRays = $PostFXManager::Settings::EnableLightRays; - $LightRayPostFX::brightScalar = $PostFXManager::Settings::LightRays::brightScalar; - - $LightRayPostFX::numSamples = $PostFXManager::Settings::LightRays::numSamples; - $LightRayPostFX::density = $PostFXManager::Settings::LightRays::density; - $LightRayPostFX::weight = $PostFXManager::Settings::LightRays::weight; - $LightRayPostFX::decay = $PostFXManager::Settings::LightRays::decay; - - if($PostFXManager::PostFX::EnableLightRays) - %this.enable(); - else - %this.disable(); -} - -function LightRayPostFX::settingsApply(%this) -{ - $PostFXManager::Settings::EnableLightRays = $PostFXManager::PostFX::EnableLightRays; - $PostFXManager::Settings::LightRays::brightScalar = $LightRayPostFX::brightScalar; - - $PostFXManager::Settings::LightRays::numSamples = $LightRayPostFX::numSamples; - $PostFXManager::Settings::LightRays::density = $LightRayPostFX::density; - $PostFXManager::Settings::LightRays::weight = $LightRayPostFX::weight; - $PostFXManager::Settings::LightRays::decay = $LightRayPostFX::decay; -} \ No newline at end of file diff --git a/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs b/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs index dadfafaaa..0ac91cbba 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs @@ -48,7 +48,7 @@ $PostFXManager::fileFilter = "Post Effect Presets|*.postfxpreset.cs"; // Enable / disable PostFX when loading presets or just apply the settings? $PostFXManager::forceEnableFromPresets = true; -$PostFXManager::defaultPreset = "./default.postfxpreset.cs"; +$PostFXManager::defaultPreset = "core/postFX/scripts/default.postfxpreset.cs"; $PostFXManager::currentPreset = ""; @@ -100,23 +100,30 @@ function PostFXManager::savePresetHandler( %filename ) %filename = makeRelativePath( %filename, getMainDotCsDir() ); if(strStr(%filename, ".") == -1) %filename = %filename @ $PostFXManager::fileExtension; + + $PostFXManager::currentPresetFile = %filename; + $PostFXManager::startedPresetFileSave = false; %count = PostFXManager.Count(); for(%i=0; %i < %count; %i++) { %postEffect = PostFXManager.getKey(%i); - if(isObject(%postEffect) && %postEffect.isMethod("settingsApply")) + if(isObject(%postEffect) && %postEffect.isMethod("savePresetSettings")) { - %postEffect.settingsApply(); + %postEffect.savePresetSettings(); } } - export("$PostFXManager::Settings::*", %filename, false); - postVerbose("% - PostFX Manager - Save complete. Preset saved at : " @ %filename); } +function PostFXManager::savePresetSetting(%setting) +{ + export(%setting, $PostFXManager::currentPresetFile, $PostFXManager::startedPresetFileSave); + $PostFXManager::startedPresetFileSave = true; +} + function PostFXManager::settingsApplyDefaultPreset(%this) { PostFXManager::loadPresetHandler($PostFXManager::defaultPreset); diff --git a/Templates/BaseGame/game/core/postFX/scripts/vignette.cs b/Templates/BaseGame/game/core/postFX/scripts/vignette.cs deleted file mode 100644 index 13704f908..000000000 --- a/Templates/BaseGame/game/core/postFX/scripts/vignette.cs +++ /dev/null @@ -1,97 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -$VignettePostEffect::VMax = 0.6; -$VignettePostEffect::VMin = 0.2; - -singleton ShaderData( VignetteShader ) -{ - DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/vignette/VignetteP.hlsl"; - - OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/vignette/gl/VignetteP.glsl"; - - samplerNames[0] = "$backBuffer"; - - pixVersion = 2.0; -}; - -function vignettePostFX::onAdd( %this ) -{ - PostFXManager.registerPostEffect(%this); -} - -singleton PostEffect( vignettePostFX ) -{ - isEnabled = false; - allowReflectPass = false; - renderTime = "PFXAfterBin"; - renderBin = "GlowBin"; - shader = VignetteShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "$backBuffer"; - renderPriority = 10; -}; - -function vignettePostFX::setShaderConsts(%this) -{ - %this.setShaderConst("$Vmax", $VignettePostEffect::VMax); - %this.setShaderConst("$Vmin", $VignettePostEffect::VMin); -} - -function vignettePostFX::populatePostFXSettings(%this) -{ - PostEffectEditorInspector.startGroup("General"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::EnableVignette", "Enabled", "bool", "", $PostFXManager::PostFX::EnableVignette, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::VignettePostEffect::VMin", "Vignette Min", "float", "", $VignettePostEffect::VMin, ""); - PostEffectEditorInspector.addField("$PostFXManager::Settings::VignettePostEffect::VMax", "Vignette Max", "float", "", $VignettePostEffect::VMax, ""); - PostEffectEditorInspector.endGroup(); -} - -function vignettePostFX::applyFromPreset(%this) -{ - //Light rays settings - $PostFXManager::PostFX::EnableLightRays = $PostFXManager::Settings::EnableLightRays; - $LightRayPostFX::brightScalar = $PostFXManager::Settings::LightRays::brightScalar; - - $LightRayPostFX::numSamples = $PostFXManager::Settings::LightRays::numSamples; - $LightRayPostFX::density = $PostFXManager::Settings::LightRays::density; - $LightRayPostFX::weight = $PostFXManager::Settings::LightRays::weight; - $LightRayPostFX::decay = $PostFXManager::Settings::LightRays::decay; - - if($PostFXManager::PostFX::EnableVignette) - %this.enable(); - else - %this.disable(); -} - -function vignettePostFX::settingsApply(%this) -{ - $PostFXManager::Settings::EnableLightRays = $PostFXManager::PostFX::EnableLightRays; - $PostFXManager::Settings::LightRays::brightScalar = $LightRayPostFX::brightScalar; - - $PostFXManager::Settings::LightRays::numSamples = $LightRayPostFX::numSamples; - $PostFXManager::Settings::LightRays::density = $LightRayPostFX::density; - $PostFXManager::Settings::LightRays::weight = $LightRayPostFX::weight; - $PostFXManager::Settings::LightRays::decay = $LightRayPostFX::decay; -} \ No newline at end of file diff --git a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.cs b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.cs index e786440ed..c833efe1d 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.cs +++ b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.cs @@ -689,7 +689,7 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem ) //force postFX updates PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO); PostFXManager.settingsEffectSetEnabled(HDRPostFX, $pref::PostFX::EnableHDR); - PostFXManager.settingsEffectSetEnabled(DOFPostEffect, $pref::PostFX::EnableDOF); + PostFXManager.settingsEffectSetEnabled(DepthOfFieldPostFX, $pref::PostFX::EnableDOF); PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays); PostFXManager.settingsEffectSetEnabled(VignettePostEffect, $pref::PostFX::EnableVignette); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.cs index 44f6e56c0..78076654b 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.cs @@ -7,9 +7,10 @@ function AssetBrowser::createCubemapAsset(%this) %modulePath = "data/" @ %moduleName; %assetName = AssetBrowser.newAssetSettings.assetName; + %assetPath = AssetBrowser.dirHandler.currentAddress @ "/"; - %tamlpath = %modulePath @ "/cubemaps/" @ %assetName @ ".asset.taml"; - %shapeFilePath = %modulePath @ "/cubemaps/" @ %assetName @ ".dae"; + %tamlpath = %assetPath @ %assetName @ ".asset.taml"; + %shapeFilePath = %assetPath @ %assetName @ ".dae"; %asset = new CubemapAsset() { diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.cs index 1e2e0e580..286793efd 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.cs @@ -134,7 +134,7 @@ function AssetBrowser::moveLevelAsset(%this, %assetDef, %destination) function AssetBrowser::buildLevelAssetPreview(%this, %assetDef, %previewData) { %previewData.assetName = %assetDef.assetName; - %previewData.assetPath = %assetDef.getlevelFile(); + %previewData.assetPath = %assetDef.getLevelPath(); %previewData.doubleClickCommand = "schedule( 1, 0, \"EditorOpenMission\", "@%assetDef@");"; %levelPreviewImage = %assetDesc.PreviewImage; @@ -149,5 +149,5 @@ function AssetBrowser::buildLevelAssetPreview(%this, %assetDef, %previewData) %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ "Asset Type: Level Asset\n" @ "Asset Definition ID: " @ %assetDef @ "\n" @ - "Level File path: " @ %assetDef.getLevelFile(); + "Level File path: " @ %assetDef.getLevelPath(); } \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/postFX.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/postFX.cs index c5cd13c37..030f7baea 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/postFX.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/postFX.cs @@ -1,14 +1,14 @@ function AssetBrowser::createPostEffectAsset(%this) { %moduleName = AssetBrowser.newAssetSettings.moduleName; - %modulePath = "data/" @ %moduleName; - %assetName = AssetBrowser.newAssetSettings.assetName; + %assetName = AssetBrowser.newAssetSettings.assetName; + %assetPath = AssetBrowser.dirHandler.currentAddress @ "/"; - %tamlpath = %modulePath @ "/postFXs/" @ %assetName @ ".asset.taml"; - %scriptPath = %modulePath @ "/postFXs/" @ %assetName @ ".cs"; - %hlslPath = %modulePath @ "/postFXs/" @ %assetName @ "P.hlsl"; - %glslPath = %modulePath @ "/postFXs/" @ %assetName @ "P.glsl"; + %tamlpath = %assetPath @ %assetName @ ".asset.taml"; + %scriptPath = %assetPath @ %assetName @ ".cs"; + %hlslPath = %assetPath @ %assetName @ "P.hlsl"; + %glslPath = %assetPath @ %assetName @ "P.glsl"; %asset = new PostEffectAsset() { @@ -24,13 +24,6 @@ function AssetBrowser::createPostEffectAsset(%this) %moduleDef = ModuleDatabase.findModule(%moduleName, 1); AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath); - AssetBrowser.loadFilters(); - - %treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName); - %smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "PostEffectAsset"); - - AssetBrowserFilterTree.onSelect(%smItem); - %file = new FileObject(); %templateFile = new FileObject(); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.cs index 58ffbfecb..5ba480239 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.cs @@ -2,6 +2,8 @@ function AssetBrowser::createStateMachineAsset(%this) { %assetName = AssetBrowser.newAssetSettings.assetName; %moduleName = AssetBrowser.selectedModule; + + %assetPath = AssetBrowser.dirHandler.currentAddress @ "/"; %assetQuery = new AssetQuery(); @@ -20,8 +22,8 @@ function AssetBrowser::createStateMachineAsset(%this) %assetQuery.delete(); - %tamlpath = "data/" @ %moduleName @ "/stateMachines/" @ %assetName @ ".asset.taml"; - %smFilePath = "data/" @ %moduleName @ "/stateMachines/" @ %assetName @ ".xml"; + %tamlpath = %assetPath @ %assetName @ ".asset.taml"; + %smFilePath = %assetPath @ %assetName @ ".xml"; %asset = new StateMachineAsset() { diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFile.cs.template b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFile.cs.template index dd43f4b05..14756fbe2 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFile.cs.template +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFile.cs.template @@ -20,12 +20,14 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- +$PostFX::@@::modColor = "1 1 1 1"; + singleton ShaderData( @@_Shader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; - DXPixelShaderFile = $Core:modulePath @ "@@P.hlsl"; + DXPixelShaderFile = "./@@P.hlsl"; OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = $Core:modulePath @ "@@P.glsl"; + OGLPixelShaderFile = "./@@P.glsl"; samplerNames[0] = "$inputTex"; @@ -55,6 +57,7 @@ singleton GFXStateBlockData( @@_StateBlock ) function @@::setShaderConsts( %this ) { + %this.setShaderConst( "$modColor", $PostFX::@@::modColor ); } function @@::preProcess( %this ) @@ -69,11 +72,14 @@ function @@::onAdd(%this) function @@::onEnabled( %this ) { + $PostFX::@@::Enabled = true; return true; } function @@::onDisabled( %this ) { + $PostFX::@@::Enabled = false; + return true; } //This is used to populate the PostFXEditor's settings so the post FX can be edited @@ -82,27 +88,36 @@ function @@::onDisabled( %this ) function @@::populatePostFXSettings(%this) { PostEffectEditorInspector.startGroup("@@ - General"); - PostEffectEditorInspector.addField("$PostFXManager::Settings::Enabled@@", "Enabled", "bool", "", $PostFXManager::PostFX::Enable@@, ""); + PostEffectEditorInspector.addCallbackField("$PostFX::@@::Enabled", "Enabled", "bool", "", $PostFX::@@::Enabled, "", "toggle@@"); + PostEffectEditorInspector.addField("$PostFX::@@::modColor", "Modifier Color", "colorI", "", $PostFX::@@::modColor, ""); PostEffectEditorInspector.endGroup(); } -//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 +//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::toggle@@(%this) +{ + if($PostFX::@@::Enabled) + @@.enable(); + else + @@.disable(); +} + +//This function is called when the post FX is loaded via a postFX preset file. It's used to do any special-case onload work +//At minimum, it ensures that if the preset indicates it should be enabled, it actually enables the postFX object itself function @@::applyFromPreset(%this) { - //@@ Settings - $PostFXManager::PostFX::Enable@@ = $PostFXManager::Settings::Enabled@@; - - if($PostFXManager::PostFX::Enable@@) + if($PostFX::@@::Enabled) %this.enable(); else %this.disable(); } -function @@::settingsApply(%this) +//This function writes out the postFX's settings to the edited preset file +function HDRPostFX::savePresetSettings(%this) { - $PostFXManager::Settings::Enabled@@ = $PostFXManager::PostFX::Enable@@; + PostFXManager::savePresetSetting("$PostFX::@@::Enabled"); + PostFXManager::savePresetSetting("$PostFX::@@::modColor"); } //Our actual postFX @@ -126,7 +141,7 @@ singleton PostEffect( @@ ) shader = @@_Shader; stateBlock = @@_StateBlock; texture[0] = "$backBuffer"; - target = "$outTex"; + target = "$backBuffer"; targetFormat = "GFXFormatR16G16B16A16F"; targetScale = "1 1"; }; \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.glsl.template b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.glsl.template index 6611d718b..35a2ff186 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.glsl.template +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.glsl.template @@ -27,9 +27,15 @@ uniform sampler2D inputTex; +in vec4 modColor; + out vec4 OUT_col; void main() { - OUT_col = hdrEncode( vec4(1,1,1,1) ); + vec4 color = texture(inputTex, IN_uv0); + + color *= modColor; + + OUT_col = hdrEncode( color ); } diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.hlsl.template b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.hlsl.template index 27b5838e8..71c87b98a 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.hlsl.template +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/postFXFileP.hlsl.template @@ -25,7 +25,13 @@ TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); +uniform float4 modColor; + float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 { - return hdrEncode( float4(1,1,1,1) ); + float4 color = TORQUE_TEX2D( inputTex, IN.uv0 ); + + color *= modColor; + + return hdrEncode( color ); } diff --git a/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.cs b/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.cs index e4429a4e6..a8ff8cbc6 100644 --- a/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.cs +++ b/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.cs @@ -33,6 +33,7 @@ function ESettingsWindow::startup( %this ) %this.addEditorSettingsPage("NavEditor", "Navigation Editor"); %this.addEditorSettingsPage("Theme", "Theme"); %this.addEditorSettingsPage("AssetEditing", "Asset Editing"); + %this.addEditorSettingsPage("PostFX", "Post Effects"); %this.addGameSettingsPage("GameGeneral", "General"); %this.addGameSettingsPage("Gameplay", "Gameplay"); @@ -430,6 +431,14 @@ function ESettingsWindow::getThemeSettings(%this) SettingsInspector.addSettingsField("Theme/tooltipDivColor", "Tooltip Divider Color", "ColorI", ""); SettingsInspector.endGroup(); } + +function ESettingsWindow::getPostFXSettings(%this) +{ + SettingsInspector.startGroup("Post Effects"); + SettingsInspector.addField("Edit Default PostFX", "Edit Default PostFX Config", "button", "Edit Default PostFX Config", "", "PostFXEditor.editDefaultPostFXSettings();"); + SettingsInspector.endGroup(); +} + // // COMMON GAME SETTINGS // diff --git a/Templates/BaseGame/game/tools/gui/postFxEditor.cs b/Templates/BaseGame/game/tools/gui/postFxEditor.cs index aa2710a00..774051642 100644 --- a/Templates/BaseGame/game/tools/gui/postFxEditor.cs +++ b/Templates/BaseGame/game/tools/gui/postFxEditor.cs @@ -5,9 +5,44 @@ function PostFXEditor::onDialogPush( %this ) %this.refresh(); - ESettingsWindowList.setSelectedById( 1 ); + PostEffectEditorList.setSelectedById( 1 ); } +function PostFXEditor::onDialogPop( %this ) +{ + //Always change the manager target back to the scene's just to be save when done editing + $PostFXManager::currentPreset = $Client::LevelAsset.getPostFXPresetPath(); + + PostFXManager.loadPresetHandler($PostFXManager::currentPreset); + + PostFXEditorWindow.text = "PostFX Editor"; +} + +function PostFXEditor::editScenePostFXSettings( %this ) +{ + $PostFXManager::currentPreset = $Client::LevelAsset.getPostFXPresetPath(); + Canvas.pushDialog(%this); + + PostFXEditorWindow.text = "PostFX Editor - " @ getScene(0).getName(); + + PostFXEditorActionButton.text = "Revert"; + PostFXEditorActionButton.command = "PostFXEditor.revert();"; +} + +function PostFXEditor::editDefaultPostFXSettings( %this ) +{ + $PostFXManager::currentPreset = $PostFXManager::defaultPreset; + PostFXManager.loadPresetHandler($PostFXManager::currentPreset); + + Canvas.pushDialog(%this); + + PostFXEditorWindow.text = "PostFX Editor - Default Config"; + + PostFXEditorActionButton.text = "Save"; + PostFXEditorActionButton.command = "PostFXManager::savePresetHandler($PostFXManager::defaultPreset);"; +} + + function PostFXEditor::refresh(%this) { PostEffectEditorList.clear(); @@ -17,7 +52,8 @@ function PostFXEditor::refresh(%this) { %postEffect = PostFXManager.getKey(%i); - PostEffectEditorList.addRow( %i, %postEffect.getName() ); + if(%postEffect.isEnabled) + PostEffectEditorList.addRow( %i, %postEffect.getName() ); } } @@ -37,7 +73,16 @@ function PostFXEditor::apply(%this) function PostFXEditor::revert(%this) { - PostFXManager::loadPresetHandler($PostFXManager::currentPreset); + %targetPreset = $PostFXManager::currentPreset; + if(%targetPreset $= "") + %targetPreset = $PostFXManager::defaultPreset; + + PostFXManager::loadPresetHandler(%targetPreset); + + %this.refresh(); + + PostEffectEditorInspector.clearFields(); + PostEffectEditorList.setSelectedRow(1); } function PostEffectEditorList::onSelect( %this, %id, %text ) @@ -50,4 +95,54 @@ function PostEffectEditorList::onSelect( %this, %id, %text ) { %postEffect.populatePostFXSettings(); } +} + +function PostFXEditor::addNewPostFXs(%this) +{ + %rowIndex = PostFXEditorNewPFXList.getSelectedRow(); + %postFXName = PostFXEditorNewPFXList.getRowText(%rowIndex); + + %postFXName.enable(); + + %this.refresh(); + + %rowIndex = PostEffectEditorList.findTextIndex(%postFXName); + PostEffectEditorList.setSelectedRow(%rowIndex); + + PostFXEditorNewPFXWindow.setHidden(true); +} + +function PostFXEditor::removePostFX(%this) +{ + %rowIndex = PostEffectEditorList.getSelectedRow(); + %postFXName = PostEffectEditorList.getRowText(%rowIndex); + + %postFXName.disable(); + + %this.refresh(); + + PostEffectEditorInspector.clearFields(); + PostEffectEditorList.setSelectedRow(1); +} + +function editScenePostEffects(%scene) +{ + if(EditorIsActive()) + PostFXEditor.editScenePostFXSettings(); +} + +function PostFXEditorNewPFXWindow::showDialog(%this) +{ + %this.setHidden(false); + + PostFXEditorNewPFXList.clear(); + + %count = PostFXManager.Count(); + for(%i=0; %i < %count; %i++) + { + %postEffect = PostFXManager.getKey(%i); + + if(!%postEffect.isEnabled) + PostFXEditorNewPFXList.addRow( %i, %postEffect.getName() ); + } } \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/gui/postFxEditor.gui b/Templates/BaseGame/game/tools/gui/postFxEditor.gui index 92cf6a09f..4db85cb0d 100644 --- a/Templates/BaseGame/game/tools/gui/postFxEditor.gui +++ b/Templates/BaseGame/game/tools/gui/postFxEditor.gui @@ -1,7 +1,7 @@ //--- OBJECT WRITE BEGIN --- %guiContent = new GuiControl(postFXEditor) { position = "0 0"; - extent = "1024 768"; + extent = "1920 1200"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; @@ -14,8 +14,8 @@ canSave = "1"; canSaveDynamicFields = "1"; - new GuiWindowCtrl(ppOptionsWindow) { - text = "PostFX Editor"; + new GuiWindowCtrl(PostFXEditorWindow) { + text = "PostFX Editor - EditorTemplateLevel"; resizeWidth = "1"; resizeHeight = "1"; canMove = "1"; @@ -31,7 +31,7 @@ anchorBottom = "0"; anchorLeft = "1"; anchorRight = "0"; - position = "197 65"; + position = "639 292"; extent = "642 615"; minExtent = "8 8"; horizSizing = "center"; @@ -95,6 +95,60 @@ canSave = "1"; canSaveDynamicFields = "0"; + new GuiBitmapButtonCtrl() { + bitmap = "tools/gui/images/iconAdd.png"; + bitmapMode = "Centered"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "145 4"; + extent = "16 16"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + command = "PostFXEditorNewPFXWindow.showDialog();"; + tooltipProfile = "GuiToolTipProfile"; + tooltip = "Add a new Import Config"; + hovertime = "1000"; + isContainer = "0"; + internalName = "newImportConfig"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl() { + bitmap = "tools/gui/images/iconDelete.png"; + bitmapMode = "Centered"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "163 4"; + extent = "16 16"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + command = "PostFXEditor.removePostFX();"; + tooltipProfile = "GuiToolTipProfile"; + tooltip = "Delets the currently selected import config"; + hovertime = "1000"; + isContainer = "0"; + internalName = "deleteImportConfig"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; new GuiScrollCtrl() { willFirstRespond = "1"; hScrollBar = "alwaysOff"; @@ -110,8 +164,8 @@ anchorBottom = "0"; anchorLeft = "1"; anchorRight = "0"; - position = "3 3"; - extent = "177 643"; + position = "3 24"; + extent = "177 538"; minExtent = "100 50"; horizSizing = "width"; vertSizing = "height"; @@ -226,85 +280,146 @@ }; }; }; - new GuiButtonCtrl(ppOptionsApply) { - text = "Apply"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "547 588"; - extent = "93 23"; - minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "top"; - profile = "ToolsGuiButtonProfile"; - visible = "1"; - active = "1"; - command = "PostFXEditor.apply();"; - tooltipProfile = "GuiToolTipProfile"; - tooltip = "Apply the settings and close this dialog"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(ppOptionsSavePreset) { - text = "Save Preset..."; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "349 588"; - extent = "93 23"; - minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "top"; - profile = "ToolsGuiButtonProfile"; - visible = "1"; - active = "1"; - command = "PostFXManager.savePresetFile();"; - tooltipProfile = "GuiToolTipProfile"; - tooltip = "Save the preset to a file to disk for later use (use postfx::applyPreset)"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(ppOptionsLoadPreset) { - text = "Load Preset..."; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "250 588"; - extent = "93 23"; - minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "top"; - profile = "ToolsGuiButtonProfile"; - visible = "1"; - active = "1"; - command = "PostFXManager.loadPresetFile();"; - tooltipProfile = "GuiToolTipProfile"; - tooltip = "Load a post FX preset file from disk"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(ppOptionsOk1) { + new GuiButtonCtrl(PostFXEditorActionButton) { text = "Revert"; groupNum = "-1"; buttonType = "PushButton"; useMouseEvents = "0"; - position = "448 588"; + position = "451 588"; extent = "93 23"; minExtent = "8 8"; - horizSizing = "right"; + horizSizing = "left"; vertSizing = "top"; profile = "ToolsGuiButtonProfile"; visible = "1"; active = "1"; command = "PostFXEditor.revert(); PostFXEditor.refresh();"; tooltipProfile = "GuiToolTipProfile"; - tooltip = "Revert any changes made since opening the dialog"; + tooltip = "Revert any changes made."; + hovertime = "1000"; + isContainer = "0"; + internalName=""; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiButtonCtrl() { + text = "Close"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "547 588"; + extent = "93 23"; + minExtent = "8 8"; + horizSizing = "left"; + vertSizing = "top"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + command = "Canvas.popDialog(postFXEditor);"; + tooltipProfile = "GuiToolTipProfile"; + tooltip = "Close the Post Effect Editor"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; + new GuiWindowCtrl(PostFXEditorNewPFXWindow) { + text = "Add New PostFX"; + resizeWidth = "1"; + resizeHeight = "1"; + canMove = "1"; + canClose = "1"; + canMinimize = "0"; + canMaximize = "0"; + canCollapse = "0"; + edgeSnap = "1"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "884 437"; + extent = "182 276"; + minExtent = "48 70"; + horizSizing = "center"; + vertSizing = "center"; + profile = "ToolsGuiWindowProfile"; + visible = "0"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + closeCommand = "PostFXEditorNewPFXWindow.setHidden(true);"; + hovertime = "1000"; + isContainer = "1"; + hidden = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiScrollCtrl() { + willFirstRespond = "1"; + hScrollBar = "alwaysOff"; + vScrollBar = "dynamic"; + lockHorizScroll = "0"; + lockVertScroll = "0"; + constantThumbHeight = "0"; + childMargin = "0 0"; + mouseWheelScrollSpeed = "-1"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "3 24"; + extent = "177 224"; + minExtent = "100 50"; + horizSizing = "width"; + vertSizing = "height"; + profile = "ToolsGuiScrollProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiTextListCtrl(PostFXEditorNewPFXList) { + columns = "0"; + fitParentWidth = "0"; + clipColumnText = "0"; + rowHeightPadding = "2"; + position = "1 1"; + extent = "174 221"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "height"; + profile = "ToolsGuiListBoxProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; + new GuiButtonCtrl() { + text = "Done"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "107 251"; + extent = "64 22"; + minExtent = "8 2"; + horizSizing = "left"; + vertSizing = "top"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + command = "PostFXEditor.addNewPostFXs();"; + tooltipProfile = "ToolsGuiToolTipProfile"; hovertime = "1000"; isContainer = "0"; canSave = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs index 10f2e57de..ac7086969 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs @@ -332,6 +332,9 @@ function EditorSaveMission() %obj.onSaveMission( $Server::MissionFile ); } + //Save out the PostFX config + PostFXManager::savePresetHandler( $Server::LevelAsset.getPostFXPresetPath() ); + EditorClearDirty(); EditorGui.saveAs = false; @@ -355,14 +358,14 @@ function EditorSaveMissionAs( %levelAsset ) return; } - %missionName = %levelAssetDef.getLevelFile(); + %missionName = %levelAssetDef.getLevelPath(); if( fileExt( %missionName ) !$= ".mis" ) %missionName = %missionName @ ".mis"; //Update to be our active $Server::MissionFile = %missionName; - %Server::LevelAsset = %levelAssetDef; + $Server::LevelAsset = %levelAssetDef; //Update the scene name to comply to the new level's name GetRootScene().name = %levelAssetDef.AssetName; @@ -490,7 +493,7 @@ function EditorOpenMission(%levelAsset) updateEditorRecentLevelsList(%levelAssetId); - %filename = %assetDef.getlevelFile(); + %filename = %assetDef.getLevelPath(); if(%filename $= "") { @@ -539,7 +542,7 @@ function EditorOpenMission(%levelAsset) function EditorOpenSceneAppend(%levelAsset) { //Load the asset's level file - exec(%levelAsset.getlevelFile()); + exec(%levelAsset.getLevelPath()); //We'll assume the scene name and assetname are the same for now %sceneName = %levelAsset.AssetName;