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.
This commit is contained in:
Areloch 2020-09-11 02:28:15 -05:00
parent 82f7db3d48
commit 3c0c106051
186 changed files with 2534 additions and 1486 deletions

View file

@ -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()
{

View file

@ -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();
}

View file

@ -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();

View file

@ -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()
{

View file

@ -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";
};

View file

@ -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 );
}

View file

@ -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 );
}

View file

@ -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
//

View file

@ -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() );
}
}

View file

@ -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";

View file

@ -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;