diff --git a/Engine/source/gui/controls/guiTextListCtrl.cpp b/Engine/source/gui/controls/guiTextListCtrl.cpp index 4ac1e200e..9aa038814 100644 --- a/Engine/source/gui/controls/guiTextListCtrl.cpp +++ b/Engine/source/gui/controls/guiTextListCtrl.cpp @@ -125,6 +125,7 @@ GuiTextListCtrl::GuiTextListCtrl() mColumnOffsets.push_back(0); mFitParentWidth = true; mClipColumnText = false; + mRowHeightPadding = 2; } void GuiTextListCtrl::initPersistFields() @@ -132,6 +133,7 @@ void GuiTextListCtrl::initPersistFields() addField("columns", TypeS32Vector, Offset(mColumnOffsets, GuiTextListCtrl), "A vector of column offsets. The number of values determines the number of columns in the table.\n" ); addField("fitParentWidth", TypeBool, Offset(mFitParentWidth, GuiTextListCtrl), "If true, the width of this control will match the width of its parent.\n"); addField("clipColumnText", TypeBool, Offset(mClipColumnText, GuiTextListCtrl), "If true, text exceeding a column's given width will get clipped.\n" ); + addField("rowHeightPadding", TypeS32, Offset(mRowHeightPadding, GuiTextListCtrl), "Sets how much padding to add to the row heights on top of the font height"); Parent::initPersistFields(); } @@ -205,7 +207,7 @@ void GuiTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, else slen = dStrlen(text); - Point2I pos(offset.x + 4 + mColumnOffsets[index], offset.y); + Point2I pos(offset.x + 4 + mColumnOffsets[index], offset.y + mRowHeightPadding / 2); RectI saveClipRect; bool clipped = false; @@ -368,7 +370,7 @@ void GuiTextListCtrl::setSize(Point2I newSize) mCellSize.x = maxWidth + 8; } - mCellSize.y = mFont->getHeight() + 2; + mCellSize.y = mFont->getHeight() + mRowHeightPadding; } Point2I newExtent( newSize.x * mCellSize.x + mHeaderDim.x, newSize.y * mCellSize.y + mHeaderDim.y ); diff --git a/Engine/source/gui/controls/guiTextListCtrl.h b/Engine/source/gui/controls/guiTextListCtrl.h index b1a63461f..9948f8f27 100644 --- a/Engine/source/gui/controls/guiTextListCtrl.h +++ b/Engine/source/gui/controls/guiTextListCtrl.h @@ -56,6 +56,7 @@ class GuiTextListCtrl : public GuiArrayCtrl bool mFitParentWidth; bool mClipColumnText; + S32 mRowHeightPadding; U32 getRowWidth(Entry *row); bool cellSelected(Point2I cell); diff --git a/Engine/source/gui/editor/popupMenu.cpp b/Engine/source/gui/editor/popupMenu.cpp index 2c9765f09..4d3a2002b 100644 --- a/Engine/source/gui/editor/popupMenu.cpp +++ b/Engine/source/gui/editor/popupMenu.cpp @@ -296,6 +296,7 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */) mTextList = new GuiPopupMenuTextListCtrl(); mTextList->registerObject(); mTextList->setControlProfile(profile); + mTextList->mRowHeightPadding = 5; mTextList->mPopup = this; mTextList->mMenuBar = getMenuBarCtrl(); diff --git a/Engine/source/renderInstance/forcedMaterialMeshMgr.cpp b/Engine/source/renderInstance/forcedMaterialMeshMgr.cpp index 4fbe0ffbd..bf50a8ecd 100644 --- a/Engine/source/renderInstance/forcedMaterialMeshMgr.cpp +++ b/Engine/source/renderInstance/forcedMaterialMeshMgr.cpp @@ -126,9 +126,10 @@ const char* ForcedMaterialMeshMgr::_getOverrideMat( void *object, const char *da bool ForcedMaterialMeshMgr::_setOverrideMat( void *object, const char *index, const char *data ) { ForcedMaterialMeshMgr &mgr = *reinterpret_cast( object ); - BaseMatInstance* material; - Sim::findObject( data, material ); - mgr.setOverrideMaterial( material ); + Material* material; + Sim::findObject(data, material); + mgr.mOverrideMaterial = material; + return false; } diff --git a/Templates/BaseGame/game/data/ui/UI.cs b/Templates/BaseGame/game/data/ui/UI.cs index 8df07adaa..cbd2999a7 100644 --- a/Templates/BaseGame/game/data/ui/UI.cs +++ b/Templates/BaseGame/game/data/ui/UI.cs @@ -73,8 +73,10 @@ function UI::initClient(%this) //Load scripts exec("./scripts/optionsList.cs"); + exec("./scripts/displayMenu.cs"); exec("./scripts/graphicsMenu.cs"); exec("./scripts/controlsMenu.cs"); + exec("./scripts/audioMenu.cs"); exec("./scripts/messageBoxes.cs"); exec("./scripts/help.cs"); exec("./scripts/cursors.cs"); diff --git a/Templates/BaseGame/game/data/ui/guis/optionsMenu.cs b/Templates/BaseGame/game/data/ui/guis/optionsMenu.cs index 3bc12b532..98c3eda8d 100644 --- a/Templates/BaseGame/game/data/ui/guis/optionsMenu.cs +++ b/Templates/BaseGame/game/data/ui/guis/optionsMenu.cs @@ -70,6 +70,7 @@ function OptionsMenu::onWake(%this) text = "Keyboard and Mouse"; profile = GuiMenuButtonProfile; extent = %array.extent.x SPC "35"; + command="ControlsMenu::loadSettings();"; }; %controllerMenuBtn = new GuiButtonCtrl(){ @@ -104,14 +105,15 @@ function OptionsMenu::onWake(%this) text = "Gameplay"; profile = GuiMenuButtonProfile; extent = %array.extent.x SPC "35"; + command="GameplayMenu::loadSettings();"; }; %array.add(%keyboardMenuBtn); - %array.add(%controllerMenuBtn); + //%array.add(%controllerMenuBtn); %array.add(%displayMenuBtn); %array.add(%graphicsMenuBtn); %array.add(%audioMenuBtn); - %array.add(%gameplayMenuBtn); + //%array.add(%gameplayMenuBtn); //We programmatically set up our settings here so we can do some prepwork on the fields/controls //Presets @@ -143,6 +145,13 @@ function OptionsMenu::onWake(%this) OptionsMenu.addSettingOption(%array, "Water Reflections", "On", ShadowQualityList, $pref::Video::Resolution); OptionsMenu.addSettingOption(%array, "Anisotropic Filtering", "16x", ShadowQualityList, $pref::Video::Resolution);*/ + + if(!isObject(GraphicsSettingsCache)) + { + new ArrayObject(GraphicsSettingsCache){}; + } + + GraphicsSettingsCache.empty(); } function OptionsMenuOKButton::onClick(%this) @@ -438,228 +447,4 @@ function CameraMenuOKButton::onClick(%this) function CameraMenuDefaultsButton::onClick(%this) { -} -// ============================================================================= -// AUDIO MENU -// ============================================================================= -$AudioTestHandle = 0; -// Description to use for playing the volume test sound. This isn't -// played with the description of the channel that has its volume changed -// because we know nothing about the playback state of the channel. If it -// is paused or stopped, the test sound would not play then. -$AudioTestDescription = new SFXDescription() -{ - sourceGroup = AudioChannelMaster; -}; - -function AudioMenu::loadSettings(%this) -{ - // Audio - //OptAudioHardwareToggle.setStateOn($pref::SFX::useHardware); - //OptAudioHardwareToggle.setActive( true ); - - %this-->OptAudioVolumeMaster.setValue( $pref::SFX::masterVolume ); - %this-->OptAudioVolumeShell.setValue( $pref::SFX::channelVolume[ $GuiAudioType] ); - %this-->OptAudioVolumeSim.setValue( $pref::SFX::channelVolume[ $SimAudioType ] ); - %this-->OptAudioVolumeMusic.setValue( $pref::SFX::channelVolume[ $MusicAudioType ] ); - - AudioMenuSoundDriver.clear(); - %buffer = sfxGetAvailableDevices(); - %count = getRecordCount( %buffer ); - for(%i = 0; %i < %count; %i++) - { - %record = getRecord(%buffer, %i); - %provider = getField(%record, 0); - - if ( AudioMenuSoundDriver.findText( %provider ) == -1 ) - AudioMenuSoundDriver.add( %provider, %i ); - } - - AudioMenuSoundDriver.sort(); - - %selId = AudioMenuSoundDriver.findText($pref::SFX::provider); - if ( %selId == -1 ) - AudioMenuSoundDriver.setFirstSelected(); - else - AudioMenuSoundDriver.setSelected( %selId ); -} - -function AudioMenu::loadDevices(%this) -{ - if(!isObject(SoundDeviceGroup)) - { - new SimGroup( SoundDeviceGroup ); - } - else - { - SoundDeviceGroup.clear(); - } - - %buffer = sfxGetAvailableDevices(); - %count = getRecordCount( %buffer ); - for (%i = 0; %i < %count; %i++) - { - %record = getRecord(%buffer, %i); - %provider = getField(%record, 0); - %device = getField(%record, 1); - - if($pref::SFX::provider !$= %provider) - continue; - - %setting = new ArrayObject() - { - class = "OptionsMenuSettingLevel"; - caseSensitive = true; - - displayName = %device; - - key["$pref::SFX::Device"] = %device; - }; - - SoundDeviceGroup.add(%setting); - } -} - -function AudioMenu::apply(%this) -{ - sfxSetMasterVolume( $pref::SFX::masterVolume ); - - sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] ); - sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] ); - sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] ); - - if ( !sfxCreateDevice( $pref::SFX::provider, - $pref::SFX::device, - $pref::SFX::useHardware, - -1 ) ) - error( "Unable to create SFX device: " @ $pref::SFX::provider - SPC $pref::SFX::device - SPC $pref::SFX::useHardware ); - - if( !isObject( $AudioTestHandle ) ) - { - sfxPlay(menuButtonPressed); - } -} - -function AudioMenuOKButton::onClick(%this) -{ - //save the settings and then back out - AudioMenu.apply(); - OptionsMenu.backOut(); -} - -function AudioMenuDefaultsButton::onClick(%this) -{ - sfxInit(); - AudioMenu.loadSettings(); -} - -function OptAudioUpdateMasterVolume( %volume ) -{ - if( %volume == $pref::SFX::masterVolume ) - return; - - sfxSetMasterVolume( %volume ); - $pref::SFX::masterVolume = %volume; - - if( !isObject( $AudioTestHandle ) ) - $AudioTestHandle = sfxPlayOnce( AudioChannel, "data/ui/sounds/volumeTest.wav" ); -} - -function OptAudioUpdateChannelVolume( %description, %volume ) -{ - %channel = sfxGroupToOldChannel( %description.sourceGroup ); - - if( %volume == $pref::SFX::channelVolume[ %channel ] ) - return; - - sfxSetChannelVolume( %channel, %volume ); - $pref::SFX::channelVolume[ %channel ] = %volume; - - if( !isObject( $AudioTestHandle ) ) - { - $AudioTestDescription.volume = %volume; - $AudioTestHandle = sfxPlayOnce( $AudioTestDescription, "data/ui/sounds/volumeTest.wav" ); - } -} - -function AudioMenuSoundDriver::onSelect( %this, %id, %text ) -{ - // Skip empty provider selections. - if ( %text $= "" ) - return; - - $pref::SFX::provider = %text; - AudioMenuSoundDevice.clear(); - - %buffer = sfxGetAvailableDevices(); - %count = getRecordCount( %buffer ); - for(%i = 0; %i < %count; %i++) - { - %record = getRecord(%buffer, %i); - %provider = getField(%record, 0); - %device = getField(%record, 1); - - if (%provider !$= %text) - continue; - - if ( AudioMenuSoundDevice.findText( %device ) == -1 ) - AudioMenuSoundDevice.add( %device, %i ); - } - - // Find the previous selected device. - %selId = AudioMenuSoundDevice.findText($pref::SFX::device); - if ( %selId == -1 ) - AudioMenuSoundDevice.setFirstSelected(); - else - AudioMenuSoundDevice.setSelected( %selId ); -} - -function AudioMenuSoundDevice::onSelect( %this, %id, %text ) -{ - // Skip empty selections. - if ( %text $= "" ) - return; - - $pref::SFX::device = %text; - - if ( !sfxCreateDevice( $pref::SFX::provider, - $pref::SFX::device, - $pref::SFX::useHardware, - -1 ) ) - error( "Unable to create SFX device: " @ $pref::SFX::provider - SPC $pref::SFX::device - SPC $pref::SFX::useHardware ); -} - -//============================================================================== -// DISPLAY MENU -//============================================================================== -function DisplayMenu::loadSettings() -{ - OptionsSettingStack.clear(); - - OptionsMenu.addSettingOption(OptionsSettingStack, "Resolution", "1024 x 768", "", $pref::Video::Resolution); - OptionsMenu.addSettingOption(OptionsSettingStack, "Full Screen", "Off", "", $pref::Video::FullScreen); - OptionsMenu.addSettingOption(OptionsSettingStack, "Refresh Rate", "60", "", $pref::Video::RefreshRate); - OptionsMenu.addSettingOption(OptionsSettingStack, "VSync", "Off", "", $pref::Video::Vsync); - - OptionsMenu.addSliderOption(OptionsSettingStack, "Field of View", $pref::Video::FOV, "65 120", 55, 75); - - OptionsMenu.addSliderOption(OptionsSettingStack, "Brightness", $pref::Video::Brightness, "0 1", 10, 5); - OptionsMenu.addSliderOption(OptionsSettingStack, "Contrast", $pref::Video::Contrast, "0 1", 10, 5); -} - -//============================================================================== -// AUDIO MENU -//============================================================================== -function AudioMenu::loadSettings() -{ - OptionsSettingStack.clear(); - - OptionsMenu.addSliderOption(OptionsSettingStack, "Master Volume", $pref::Video::Brightness, "0 1", 10, 5); - OptionsMenu.addSliderOption(OptionsSettingStack, "Menu Volume", $pref::Video::Brightness, "0 1", 10, 5); - OptionsMenu.addSliderOption(OptionsSettingStack, "Effects Volume", $pref::Video::Brightness, "0 1", 10, 5); - OptionsMenu.addSliderOption(OptionsSettingStack, "Music Volume", $pref::Video::Brightness, "0 1", 10, 5); } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/ui/scripts/audioMenu.cs b/Templates/BaseGame/game/data/ui/scripts/audioMenu.cs new file mode 100644 index 000000000..d996745b8 --- /dev/null +++ b/Templates/BaseGame/game/data/ui/scripts/audioMenu.cs @@ -0,0 +1,200 @@ +// ============================================================================= +// AUDIO MENU +// ============================================================================= +$AudioTestHandle = 0; +// Description to use for playing the volume test sound. This isn't +// played with the description of the channel that has its volume changed +// because we know nothing about the playback state of the channel. If it +// is paused or stopped, the test sound would not play then. +$AudioTestDescription = new SFXDescription() +{ + sourceGroup = AudioChannelMaster; +}; + +function AudioMenu::loadSettings(%this) +{ + // Audio + //OptAudioHardwareToggle.setStateOn($pref::SFX::useHardware); + //OptAudioHardwareToggle.setActive( true ); + + /*%this-->OptAudioVolumeMaster.setValue( $pref::SFX::masterVolume ); + %this-->OptAudioVolumeShell.setValue( $pref::SFX::channelVolume[ $GuiAudioType] ); + %this-->OptAudioVolumeSim.setValue( $pref::SFX::channelVolume[ $SimAudioType ] ); + %this-->OptAudioVolumeMusic.setValue( $pref::SFX::channelVolume[ $MusicAudioType ] ); + + AudioMenuSoundDriver.clear(); + %buffer = sfxGetAvailableDevices(); + %count = getRecordCount( %buffer ); + for(%i = 0; %i < %count; %i++) + { + %record = getRecord(%buffer, %i); + %provider = getField(%record, 0); + + if ( AudioMenuSoundDriver.findText( %provider ) == -1 ) + AudioMenuSoundDriver.add( %provider, %i ); + } + + AudioMenuSoundDriver.sort(); + + %selId = AudioMenuSoundDriver.findText($pref::SFX::provider); + if ( %selId == -1 ) + AudioMenuSoundDriver.setFirstSelected(); + else + AudioMenuSoundDriver.setSelected( %selId );*/ + + OptionsSettingStack.clear(); + + OptionsMenu.addSliderOption(OptionsSettingStack, "Master Volume", $pref::Video::Brightness, "0 1", 10, 5); + OptionsMenu.addSliderOption(OptionsSettingStack, "Menu Volume", $pref::Video::Brightness, "0 1", 10, 5); + OptionsMenu.addSliderOption(OptionsSettingStack, "Effects Volume", $pref::Video::Brightness, "0 1", 10, 5); + OptionsMenu.addSliderOption(OptionsSettingStack, "Music Volume", $pref::Video::Brightness, "0 1", 10, 5); +} + +function AudioMenu::loadDevices(%this) +{ + if(!isObject(SoundDeviceGroup)) + { + new SimGroup( SoundDeviceGroup ); + } + else + { + SoundDeviceGroup.clear(); + } + + %buffer = sfxGetAvailableDevices(); + %count = getRecordCount( %buffer ); + for (%i = 0; %i < %count; %i++) + { + %record = getRecord(%buffer, %i); + %provider = getField(%record, 0); + %device = getField(%record, 1); + + if($pref::SFX::provider !$= %provider) + continue; + + %setting = new ArrayObject() + { + class = "OptionsMenuSettingLevel"; + caseSensitive = true; + + displayName = %device; + + key["$pref::SFX::Device"] = %device; + }; + + SoundDeviceGroup.add(%setting); + } +} + +function AudioMenu::apply(%this) +{ + sfxSetMasterVolume( $pref::SFX::masterVolume ); + + sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] ); + sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] ); + sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] ); + + if ( !sfxCreateDevice( $pref::SFX::provider, + $pref::SFX::device, + $pref::SFX::useHardware, + -1 ) ) + error( "Unable to create SFX device: " @ $pref::SFX::provider + SPC $pref::SFX::device + SPC $pref::SFX::useHardware ); + + if( !isObject( $AudioTestHandle ) ) + { + sfxPlay(menuButtonPressed); + } +} + +function AudioMenuOKButton::onClick(%this) +{ + //save the settings and then back out + AudioMenu.apply(); + OptionsMenu.backOut(); +} + +function AudioMenuDefaultsButton::onClick(%this) +{ + sfxInit(); + AudioMenu.loadSettings(); +} + +function OptAudioUpdateMasterVolume( %volume ) +{ + if( %volume == $pref::SFX::masterVolume ) + return; + + sfxSetMasterVolume( %volume ); + $pref::SFX::masterVolume = %volume; + + if( !isObject( $AudioTestHandle ) ) + $AudioTestHandle = sfxPlayOnce( AudioChannel, "data/ui/sounds/volumeTest.wav" ); +} + +function OptAudioUpdateChannelVolume( %description, %volume ) +{ + %channel = sfxGroupToOldChannel( %description.sourceGroup ); + + if( %volume == $pref::SFX::channelVolume[ %channel ] ) + return; + + sfxSetChannelVolume( %channel, %volume ); + $pref::SFX::channelVolume[ %channel ] = %volume; + + if( !isObject( $AudioTestHandle ) ) + { + $AudioTestDescription.volume = %volume; + $AudioTestHandle = sfxPlayOnce( $AudioTestDescription, "data/ui/sounds/volumeTest.wav" ); + } +} + +function AudioMenuSoundDriver::onSelect( %this, %id, %text ) +{ + // Skip empty provider selections. + if ( %text $= "" ) + return; + + $pref::SFX::provider = %text; + AudioMenuSoundDevice.clear(); + + %buffer = sfxGetAvailableDevices(); + %count = getRecordCount( %buffer ); + for(%i = 0; %i < %count; %i++) + { + %record = getRecord(%buffer, %i); + %provider = getField(%record, 0); + %device = getField(%record, 1); + + if (%provider !$= %text) + continue; + + if ( AudioMenuSoundDevice.findText( %device ) == -1 ) + AudioMenuSoundDevice.add( %device, %i ); + } + + // Find the previous selected device. + %selId = AudioMenuSoundDevice.findText($pref::SFX::device); + if ( %selId == -1 ) + AudioMenuSoundDevice.setFirstSelected(); + else + AudioMenuSoundDevice.setSelected( %selId ); +} + +function AudioMenuSoundDevice::onSelect( %this, %id, %text ) +{ + // Skip empty selections. + if ( %text $= "" ) + return; + + $pref::SFX::device = %text; + + if ( !sfxCreateDevice( $pref::SFX::provider, + $pref::SFX::device, + $pref::SFX::useHardware, + -1 ) ) + error( "Unable to create SFX device: " @ $pref::SFX::provider + SPC $pref::SFX::device + SPC $pref::SFX::useHardware ); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs b/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs index d6d7f5e73..7f4bce345 100644 --- a/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs +++ b/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs @@ -49,7 +49,7 @@ $RemapCmd[$RemapCount] = "toggleCamera"; $RemapGroup[$RemapCount] = "Miscellaneous"; $RemapCount++; -function ControlsMenu::onWake(%this) +function ControlsMenu::loadSettings(%this) { ControlSetList.clear(); ControlSetList.add( "Movement", "Movement" ); @@ -58,9 +58,9 @@ function ControlsMenu::onWake(%this) ControlSetList.setSelected( "Movement", false ); - ControlsMenuOptionsArray.clear(); - ControlsMenu.loadGroupKeybinds("Movement"); - ControlsMenuOptionsArray.refresh(); + OptionsSettingStack.clear(); + loadGroupKeybinds("Movement"); + //ControlsMenuOptionsArray.refresh(); } function ControlSetList::onSelect( %this, %id, %text ) @@ -68,13 +68,13 @@ function ControlSetList::onSelect( %this, %id, %text ) ControlsMenuOptionsArray.clear(); if(%text $= "Movement") - ControlsMenu.loadGroupKeybinds("Movement"); + loadGroupKeybinds("Movement"); else if(%text $= "Combat") - ControlsMenu.loadGroupKeybinds("Combat"); + loadGroupKeybinds("Combat"); else if(%text $= "Miscellaneous") - ControlsMenu.loadGroupKeybinds("Miscellaneous"); + loadGroupKeybinds("Miscellaneous"); - ControlsMenuOptionsArray.refresh(); + //ControlsMenuOptionsArray.refresh(); } function ControlsMenuOKButton::onClick(%this) @@ -94,7 +94,7 @@ function ControlsMenuDefaultsButton::onClick(%this) ControlsMenu.reload(); } -function ControlsMenu::loadGroupKeybinds(%this, %keybindGroup) +function loadGroupKeybinds(%keybindGroup) { %optionIndex = 0; for(%i=0; %i < $RemapCount; %i++) @@ -102,9 +102,9 @@ function ControlsMenu::loadGroupKeybinds(%this, %keybindGroup) //find and add all the keybinds for the particular group we're looking at if($RemapGroup[%i] $= %keybindGroup) { - %temp = %this.getKeybindString(%i); + %temp = getKeybindString(%i); - %option = %this.addKeybindOption(); + %option = addKeybindOption(); %option-->nameText.setText($RemapName[%i]); %option-->rebindButton.setText(%temp); %option-->rebindButton.keybindIndex = %i; @@ -114,18 +114,18 @@ function ControlsMenu::loadGroupKeybinds(%this, %keybindGroup) } } -function ControlsMenu::addKeybindOption(%this) +function addKeybindOption() { %tamlReader = new Taml(); %graphicsOption = %tamlReader.read("data/ui/guis/controlsMenuSetting.taml"); - ControlsMenuOptionsArray.add(%graphicsOption); + OptionsSettingStack.add(%graphicsOption); return %graphicsOption; } -function ControlsMenu::getKeybindString(%this, %index ) +function getKeybindString(%index ) { %name = $RemapName[%index]; %cmd = $RemapCmd[%index]; @@ -142,11 +142,11 @@ function ControlsMenu::getKeybindString(%this, %index ) %device = getField( %temp, %i + 0 ); %object = getField( %temp, %i + 1 ); - %displayName = %this.getMapDisplayName( %device, %object ); + %displayName = getMapDisplayName( %device, %object ); if(%displayName !$= "") { - %tmpMapString = %this.getMapDisplayName( %device, %object ); + %tmpMapString = getMapDisplayName( %device, %object ); if(%mapString $= "") { @@ -175,7 +175,7 @@ function ControlsMenu::redoMapping( %device, %action, %cmd, %oldIndex, %newIndex %remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) ); } -function ControlsMenu::getMapDisplayName( %this, %device, %action ) +function getMapDisplayName( %device, %action ) { if ( %device $= "keyboard" ) return( %action ); diff --git a/Templates/BaseGame/game/data/ui/scripts/displayMenu.cs b/Templates/BaseGame/game/data/ui/scripts/displayMenu.cs new file mode 100644 index 000000000..f8f59ae40 --- /dev/null +++ b/Templates/BaseGame/game/data/ui/scripts/displayMenu.cs @@ -0,0 +1,228 @@ +function DisplayMenu::loadSettings() +{ + OptionsMenu.currentMenu = "DisplayMenu"; + OptionsSettingStack.clear(); + + %APICount = getTokenCount(GraphicsDriverSetting::getList(),","); + if(%APICount > 1) + OptionsMenu.addSettingOption(OptionsSettingStack, "Diplay API", "", "GraphicsDriverSetting"); + + OptionsMenu.addSettingOption(OptionsSettingStack, "Screen Resolution", "", "ScreenResolutionSetting"); + OptionsMenu.addSettingOption(OptionsSettingStack, "Fullscreen", "", "FullscreenSetting"); + OptionsMenu.addSettingOption(OptionsSettingStack, "VSync", "", "VSyncSetting"); + + OptionsMenu.addSliderOption(OptionsSettingStack, "Field of View", $pref::Video::FOV, "65 120", 55, 75); + + OptionsMenu.addSliderOption(OptionsSettingStack, "Brightness", $pref::Video::Brightness, "0 1", 10, 5); + OptionsMenu.addSliderOption(OptionsSettingStack, "Contrast", $pref::Video::Contrast, "0 1", 10, 5); + + GraphicsSettingsCache.empty(); +} + +function DisplayMenu::apply(%this) +{ + //Loop through the settings cache and actually apply the values + %cachedSettingCount = GraphicsSettingsCache.count(); + + for(%i=0; %i < %cachedSettingCount; %i++) + { + %var = GraphicsSettingsCache.getKey(%i); + %val = GraphicsSettingsCache.getValue(%i); + + if(%var $= "$pref::Video::displayDevice") + { + MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." ); + } + + setVariable(%var, %val); + } + + //Update the display settings now + $pref::Video::Resolution = getWord( $pref::Video::Resolution, 0 ) SPC getWord( $pref::Video::Resolution, 2 ); + + /*if ( %newFullScreen $= "false" ) + { + // If we're in windowed mode switch the fullscreen check + // if the resolution is bigger than the desktop. + %deskRes = getDesktopResolution(); + %deskResX = getWord(%deskRes, $WORD::RES_X); + %deskResY = getWord(%deskRes, $WORD::RES_Y); + if ( getWord( %newRes, $WORD::RES_X ) > %deskResX || + getWord( %newRes, $WORD::RES_Y ) > %deskResY ) + { + $pref::Video::FullScreen = "true"; + GraphicsMenuFullScreen.setStateOn( true ); + } + }*/ + + // Build the final mode string. + %newMode = $pref::Video::Resolution SPC $pref::Video::FullScreen SPC 32 SPC $pref::Video::RefreshRate SPC $pref::Video::AA; + + // Change the video mode. + /*if ( %newMode !$= $pref::Video::mode || + %newVsync != $pref::Video::disableVerticalSync ) + { + if ( %testNeedApply ) + return true;*/ + + $pref::Video::mode = %newMode; + //$pref::Video::disableVerticalSync = %newVsync; + configureCanvas(); + //} + + echo("Exporting client prefs"); + %prefPath = getPrefpath(); + export("$pref::*", %prefPath @ "/clientPrefs.cs", false); +} +// +function GraphicsDriverSetting::set(%setting) +{ + switch$(%setting) + { + case "D3D11": + GraphicsMenu::set("$pref::Video::displayDevice", "D3D11"); + case "OpenGL": + GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL"); + default: + GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL"); + } +} + +function GraphicsDriverSetting::get() +{ + if($pref::Video::displayDevice == "D3D11") + return "D3D11"; + else if($pref::Video::displayDevice == "OpenGL") + return "OpenGL"; + else + return "Unknown"; +} + +function GraphicsDriverSetting::getList() +{ + %returnsList = ""; + %buffer = getDisplayDeviceList(); + %deviceCount = getFieldCount( %buffer ); + + %count = 0; + for(%i = 0; %i < %deviceCount; %i++) + { + %deviceDesc = getField(%buffer, %i); + + if(%deviceDesc $= "GFX Null Device") + continue; + + if(%count != 0) + %returnsList = %returnsList @ "," @ %deviceDesc; + else + %returnsList = %deviceDesc; + + %count++; + } + + return %returnsList; +} + +// +function ScreenResolutionSetting::set(%setting) +{ + GraphicsMenu::set("$pref::Video::Resolution", %setting); +} + +function ScreenResolutionSetting::get() +{ + return _makePrettyResString( $pref::Video::Resolution ); +} + +function ScreenResolutionSetting::getList() +{ + %returnsList = ""; + + %resCount = Canvas.getModeCount(); + for (%i = 0; %i < %resCount; %i++) + { + %testResString = Canvas.getMode( %i ); + %testRes = _makePrettyResString( %testResString ); + + //sanitize + %found = false; + %retCount = getTokenCount(%returnsList, ","); + for (%x = 0; %x < %retCount; %x++) + { + %existingEntry = getToken(%returnsList, ",", %x); + if(%existingEntry $= %testRes) + { + %found = true; + break; + } + } + + if(%found) + continue; + + if(%i != 0) + %returnsList = %returnsList @ "," @ %testRes; + else + %returnsList = %testRes; + } + + return %returnsList; +} + +// +function FullscreenSetting::set(%setting) +{ + switch$(%setting) + { + case "On": + GraphicsMenu::set("$pref::Video::FullScreen", "1"); + case "Off": + GraphicsMenu::set("$pref::Video::FullScreen", "0"); + default: + GraphicsMenu::set("$pref::Video::FullScreen", "0"); + } +} + +function FullscreenSetting::get() +{ + if($pref::Video::FullScreen == 1) + return "On"; + else if($pref::Video::FullScreen == 0) + return "Off"; + else + return "Custom"; +} + +function FullscreenSetting::getList() +{ + return "Off,On"; +} + +// +function VSyncSetting::set(%setting) +{ + switch$(%setting) + { + case "On": + GraphicsMenu::set("$pref::Video::disableVerticalSync", "0"); + case "Off": + GraphicsMenu::set("$pref::Video::disableVerticalSync", "1"); + default: + GraphicsMenu::set("$pref::Video::disableVerticalSync", "1"); + } +} + +function VSyncSetting::get() +{ + if($pref::Video::disableVerticalSync == 0) + return "On"; + else if($pref::Video::disableVerticalSync == 1) + return "Off"; + else + return "Custom"; +} + +function VSyncSetting::getList() +{ + return "Off,On"; +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/ui/scripts/graphicsMenu.cs b/Templates/BaseGame/game/data/ui/scripts/graphicsMenu.cs index 7f11dec21..d652d4d59 100644 --- a/Templates/BaseGame/game/data/ui/scripts/graphicsMenu.cs +++ b/Templates/BaseGame/game/data/ui/scripts/graphicsMenu.cs @@ -293,7 +293,7 @@ function GraphicsMenu::Autodetect_Apply(%this, %shaderVer, %intel, %videoMem ) return "Graphics quality settings have been auto detected."; } -function _makePrettyResString( %resString ) +function _makePrettyResString( %resString, %giveAspectRation ) { %width = getWord( %resString, $WORD::RES_X ); %height = getWord( %resString, $WORD::RES_Y ); @@ -312,7 +312,7 @@ function _makePrettyResString( %resString ) } %outRes = %width @ " x " @ %height; - if ( %aspect !$= "" ) + if ( %giveAspectRation && %aspect !$= "" ) %outRes = %outRes @ " (" @ %aspect @ ")"; return %outRes; @@ -320,38 +320,20 @@ function _makePrettyResString( %resString ) function GraphicsMenu::apply(%this) { - %newAdapter = GraphicsMenuDriver.getText(); - %numAdapters = GFXInit::getAdapterCount(); - %newDevice = $pref::Video::displayDevice; - - for( %i = 0; %i < %numAdapters; %i ++ ) - { - if( GFXInit::getAdapterName( %i ) $= %newAdapter ) - { - %newDevice = GFXInit::getAdapterType( %i ); - break; - } - } - - // Change the device. - if ( %newDevice !$= $pref::Video::displayDevice ) - { - if ( %testNeedApply ) - return true; - - $pref::Video::displayDevice = %newDevice; - if( %newAdapter !$= getDisplayDeviceInformation() ) - MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." ); - } - //Loop through the settings cache and actually apply the values %cachedSettingCount = GraphicsSettingsCache.count(); + %canvasUpdate = false; for(%i=0; %i < %cachedSettingCount; %i++) { %var = GraphicsSettingsCache.getKey(%i); %val = GraphicsSettingsCache.getValue(%i); + if(%var $= "$pref::Video::AA") + { + %canvasUpdate = true; + } + setVariable(%var, %val); } @@ -368,41 +350,10 @@ function GraphicsMenu::apply(%this) PostFXManager.settingsEffectSetEnabled("DOF", $pref::PostFX::EnableDOF); PostFXManager.settingsEffectSetEnabled("LightRays", $pref::PostFX::EnableLightRays); PostFXManager.settingsEffectSetEnabled("Vignette", $pref::PostFX::EnableVignette); - - //Update the display settings now - $pref::Video::Resolution = getWords( Canvas.getMode( GraphicsMenuResolution.getSelected() ), $WORD::RES_X, $WORD::RES_Y ); - %newBpp = 32; // ... its not 1997 anymore. - $pref::Video::FullScreen = GraphicsMenuFullScreen.isStateOn() ? "true" : "false"; - $pref::Video::RefreshRate = GraphicsMenuRefreshRate.getSelected(); - $pref::Video::disableVerticalSync = !GraphicsMenuVSync.isStateOn(); - - if ( %newFullScreen $= "false" ) - { - // If we're in windowed mode switch the fullscreen check - // if the resolution is bigger than the desktop. - %deskRes = getDesktopResolution(); - %deskResX = getWord(%deskRes, $WORD::RES_X); - %deskResY = getWord(%deskRes, $WORD::RES_Y); - if ( getWord( %newRes, $WORD::RES_X ) > %deskResX || - getWord( %newRes, $WORD::RES_Y ) > %deskResY ) - { - $pref::Video::FullScreen = "true"; - GraphicsMenuFullScreen.setStateOn( true ); - } - } - // Build the final mode string. - %newMode = $pref::Video::Resolution SPC $pref::Video::FullScreen SPC %newBpp SPC $pref::Video::RefreshRate SPC $pref::Video::AA; - - // Change the video mode. - if ( %newMode !$= $pref::Video::mode || - %newVsync != $pref::Video::disableVerticalSync ) + if ( %canvasUpdate ) { - if ( %testNeedApply ) - return true; - - $pref::Video::mode = %newMode; - $pref::Video::disableVerticalSync = %newVsync; + // Change the video mode. configureCanvas(); } @@ -436,11 +387,6 @@ function GraphicsMenu::loadSettings() OptionsMenu.addSettingOption(OptionsSettingStack, "Anti Aliasing", "", "AASetting"); OptionsMenu.addSettingOption(OptionsSettingStack, "Anisotropic Filtering", "", "AnisotropicFilteringSetting"); - if(!isObject(GraphicsSettingsCache)) - { - new ArrayObject(GraphicsSettingsCache){}; - } - GraphicsSettingsCache.empty(); } diff --git a/Templates/BaseGame/game/tools/settings.xml b/Templates/BaseGame/game/tools/settings.xml index edd7c47e4..372e22b2c 100644 --- a/Templates/BaseGame/game/tools/settings.xml +++ b/Templates/BaseGame/game/tools/settings.xml @@ -1,179 +1,5 @@ - - 240 240 240 255 - 100 98 96 255 - 96 94 92 255 - 50 49 48 255 - 59 58 57 255 - 50 49 48 255 - 234 232 230 255 - 32 31 30 255 - 236 234 232 255 - 59 58 57 255 - 43 43 43 255 - 178 175 172 255 - 50 49 48 255 - 17 16 15 255 - 72 70 68 255 - 72 70 68 255 - 255 255 255 255 - 37 36 35 255 - - - 100 - 0 - 15 - 0.8 - 0.8 - 1 - 0 - - 0 - 255 255 255 20 - 500 - 0 - 0 - 10 10 10 - - - - 40 - 50 - 6 - 0 - 1 - AssetWork_Debug.exe - screenCenter - WorldEditorInspectorPlugin - - 255 255 255 100 - 102 102 102 100 - 0 - 1 - 51 51 51 100 - - - http://www.garagegames.com/products/torque-3d/documentation/user - http://www.garagegames.com/products/torque-3d/forums - ../../../Documentation/Official Documentation.html - ../../../Documentation/Torque 3D - Script Manual.chm - - - 100 100 100 255 - 0 255 0 255 - 0 0 255 255 - 255 255 0 255 - 255 255 0 255 - 255 0 0 255 - 255 255 255 255 - - - 255 255 255 255 - 180 180 180 255 - 48 48 48 255 - 215 215 215 255 - 50 50 50 255 - - - 20 - 255 - 0 - 1 - 8 - - - 1 - 1 - 1 - 1 - 1 - - - 0 - 0 - 1 - 0 - 1 - 100 - 2 - - - tools/worldEditor/images/LockedHandle - tools/worldEditor/images/SelectHandle - tools/worldEditor/images/DefaultHandle - - - - tools/gui - 1024 768 - - 1 - 1 - - - ../../../Documentation/Official Documentation.html - ../../../Documentation/Torque 3D - Script Manual.chm - http://www.garagegames.com/products/torque-3d/documentation/user - - - 1 - 1 - 1 - 1 - 1 - 2 - 0 - 8 - - - 0 - - - 0 - 0 - 0 - - - Categorized - - - - lowerHeight - - 0 - 1 - 100 - 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 - 1 - 50 - 0.1 - 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 - 10 - 90 - - - 40 40 - 40 40 - ellipse - 1 - 1 - - - - 0 0 1 - 10 - 255 255 255 255 - 0 255 0 255 - 5 - 255 0 0 255 - - - Grid_512_Orange - - - AIPlayer - data/FPSGameplay/levels @@ -185,4 +11,178 @@ + + 50 + screenCenter + AssetWork_Debug.exe + 0 + 1 + 40 + 6 + WorldEditorInspectorPlugin + + 0 + 1 + 8 + 20 + 255 + + + 0 + 2 + 100 + 1 + 0 + 0 + 1 + + + http://www.garagegames.com/products/torque-3d/documentation/user + http://www.garagegames.com/products/torque-3d/forums + ../../../Documentation/Torque 3D - Script Manual.chm + ../../../Documentation/Official Documentation.html + + + 255 255 0 255 + 0 255 0 255 + 255 0 0 255 + 255 255 255 255 + 255 255 0 255 + 0 0 255 255 + 100 100 100 255 + + + tools/worldEditor/images/LockedHandle + tools/worldEditor/images/SelectHandle + tools/worldEditor/images/DefaultHandle + + + 102 102 102 100 + 0 + 1 + 51 51 51 100 + 255 255 255 100 + + + 1 + 1 + 1 + 1 + 1 + + + 180 180 180 255 + 48 48 48 255 + 255 255 255 255 + 215 215 215 255 + 50 50 50 255 + + + + 1024 768 + tools/gui + + 2 + 8 + 0 + 1 + 1 + 1 + 1 + 1 + + + Categorized + + + http://www.garagegames.com/products/torque-3d/documentation/user + ../../../Documentation/Official Documentation.html + ../../../Documentation/Torque 3D - Script Manual.chm + + + 1 + 1 + + + 0 + 0 + 0 + + + 0 + + + + 32 31 30 255 + 59 58 57 255 + 50 49 48 255 + 17 16 15 255 + 240 240 240 255 + 59 58 57 255 + 50 49 48 255 + 178 175 172 255 + 43 43 43 255 + 37 36 35 255 + 100 98 96 255 + 50 49 48 255 + 255 255 255 255 + 72 70 68 255 + 234 232 230 255 + 72 70 68 255 + 236 234 232 255 + 96 94 92 255 + + + lowerHeight + + 1 + 1 + 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 + 90 + 10 + 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 + 0.1 + 50 + 100 + 0 + + + 40 40 + 1 + 40 40 + 1 + ellipse + + + + 0 + 0.8 + 100 + 0.8 + 0 + 1 + 15 + + 0 + 10 10 10 + 500 + 0 + 255 255 255 20 + 0 + + + + 255 0 0 255 + 5 + 10 + 255 255 255 255 + 0 255 0 255 + 0 0 1 + + + AIPlayer + + + Grid_512_Orange + diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/lightViz.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/lightViz.cs index 5a13b1117..2edfa2898 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/lightViz.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/lightViz.cs @@ -425,4 +425,22 @@ function toggleLightFrustumViz() function disableLightFrustumViz() { $Light::renderLightFrustums = false; +} + +//Lighting Viz +singleton Material( Viz_DetailLightingMat ) +{ + diffuseColor[0] = "0.5 0.5 0.5 1"; + + preload = true; +}; + +function toggleDetailLightingViz() +{ + if(!isObject(lightBizBin)) + DiffuseRenderPassManager.addManager( new lightVisualizerBin(lightBizBin) { renderOrder = 1.5; processAddOrder = 1.5; } ); + + lightBizBin.material = Viz_DetailLightingMat; + + //Then set the lighting bin flags for various modes here } \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/miscViz.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/miscViz.cs index 754c0bd6c..3bb990019 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/miscViz.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/miscViz.cs @@ -302,4 +302,42 @@ function Viz_ColorBlindnessPFX::onEnabled( %this ) disableSurfacePropertiesViz(); return true; +} + + +// +//Material Complexity Viz +new ShaderData( Viz_MaterialComplexity ) +{ + DXVertexShaderFile = "./shaders/Viz_materialComplexityV.hlsl"; + DXPixelShaderFile = "./shaders/Viz_materialComplexityP.hlsl"; + + OGLVertexShaderFile = "./shaders/basicRibbonShaderV.glsl"; + OGLPixelShaderFile = "./shaders/basicRibbonShaderP.glsl"; + + //samplerNames[0] = "$ribTex"; + + pixVersion = 2.0; +}; + +singleton CustomMaterial( Viz_MaterialComplexityMat ) +{ + shader = Viz_MaterialComplexity; + version = 2.0; + + emissive[0] = true; + + doubleSided = true; + translucent = true; + + preload = true; +}; + +function toggleMatComplexityViz() +{ + if(!isObject(MatComplexityVizBin)) + DiffuseRenderPassManager.addManager( new MaterailComplexityVisualizerBin(MatComplexityVizBin) { renderOrder = 1.55; processAddOrder = 1.55; } ); + + MatComplexityVizBin.material = Viz_MaterialComplexityMat; + MatComplexityVizBin.maxComplexity = 10; } \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_LightProperties.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_LightProperties.hlsl new file mode 100644 index 000000000..b489519a7 --- /dev/null +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_LightProperties.hlsl @@ -0,0 +1,84 @@ +//----------------------------------------------------------------------------- +// 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/postFX/postFx.hlsl" +#include "../../../../core/rendering/shaders/shaderModel.hlsl" +#include "../../../../core/rendering/shaders/shaderModelAutoGen.hlsl" +#include "../../../../core/rendering/shaders/lighting.hlsl" + +TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0); +TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 1); +TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 2); +TORQUE_UNIFORM_SAMPLER2D(ssaoMaskTex, 3); +TORQUE_UNIFORM_SAMPLER2D(backbufferTex, 4); +TORQUE_UNIFORM_SAMPLER2D(glowBuffer, 5); + +uniform float mode; +uniform float3 eyePosWorld; +uniform float4x4 cameraToWorld; + +float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 +{ + //unpack normal and linear depth + float4 normDepth = TORQUE_DEFERRED_UNCONDITION(deferredBuffer, IN.uv0.xy); + + //create surface + Surface surface = createSurface(normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer), + IN.uv0.xy, eyePosWorld, IN.wsEyeRay, cameraToWorld); + + [branch] + if(mode == 0) + return float4(surface.baseColor.rgb,1); + else if(mode == 1) + return float4(surface.N.rgb,1); + else if(mode == 2) + return float4(surface.ao.rrr,1); + else if(mode == 3) + return float4(surface.roughness.rrr,1); + else if(mode == 4) + return float4(surface.metalness.rrr,1); + else if(mode == 5) + return float4(surface.depth.rrr,1); + else if(mode == 6) //Diffuse Color + return float4(surface.albedo.rgb,1); + else if(mode == 7) //Specular Color + { + float3 specularColor = surface.baseColor.rgb * surface.ao; + return float4(specularColor.rgb,1); + } + else if(mode == 8) //Mat Flags + return float4(surface.matFlag.rrr,1); + else if(mode == 9) + return float4(surface.P.xyz,1); + else if(mode == 10) + return float4(surface.R.xyz,1); + else if(mode == 11) + return float4(surface.F.rgb,1); + else if(mode == 12) + float4(TORQUE_TEX2D( ssaoMaskTex, IN.uv0 ).rgb, 1.0); + else if(mode == 13) + float4(TORQUE_TEX2D( backbufferTex, IN.uv0 ).rgb, 1.0); + else if(mode == 14) + float4(TORQUE_TEX2D( glowBuffer, IN.uv0 ).rgb, 1.0); + + return float4(0,0,0,1); +} diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_materialComplexityP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_materialComplexityP.hlsl new file mode 100644 index 000000000..b387340f9 --- /dev/null +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_materialComplexityP.hlsl @@ -0,0 +1,52 @@ +//----------------------------------------------------------------------------- +// 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/lighting.hlsl" +#include "../../../../core/rendering/shaders/torque.hlsl" + +struct ConnectData +{ + float4 hpos : SV_Position; + float2 out_texCoord : TEXCOORD0; + float3 outWsPosition : TEXCOORD1; +}; + +uniform float materialComplexity; +uniform float minComplexity; +uniform float maxComplexity; + + +float4 main( ConnectData IN ) : TORQUE_TARGET0 +{ + float complexity = (materialComplexity-minComplexity)/(maxComplexity-minComplexity); + + float3 green = float3(0,1,0); + float3 yellow = float3(1,1,0); + float3 red = float3(1,0,0); + + float a = complexity * 2; + float3 finalColor = lerp (green, yellow, a); + a -= 1; + finalColor = lerp (finalColor, red, a); + + return float4(finalColor, 1.0); +} diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_materialComplexityV.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_materialComplexityV.hlsl new file mode 100644 index 000000000..ded10e84f --- /dev/null +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shaders/Viz_materialComplexityV.hlsl @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- +// Dependencies: +#include "../../../../core/rendering/shaders/lighting.hlsl" +#include "../../../../core/rendering/shaders/torque.hlsl" + + +struct VertData +{ + float3 position : POSITION; + float3 normal : NORMAL; + float3 binormal : BINORMAL; + float3 tangent : TANGENT; + float2 uv0 : TEXCOORD0; +}; + + +struct ConnectData +{ + float4 hpos : SV_Position; + float2 out_texCoord : TEXCOORD0; + float3 outWsPosition : TEXCOORD1; +}; + + +//----------------------------------------------------------------------------- +// Main +//----------------------------------------------------------------------------- +ConnectData main( VertData IN, + uniform float4x4 modelview : register(C0), + uniform float4x4 worldToObj : register(C4), + uniform float4x4 objTrans : register(C8) +) +{ + ConnectData OUT; + + // Vert Position + OUT.hpos = mul(modelview, float4(IN.position.xyz,1)); + + // Base Texture + OUT.out_texCoord = (float2)IN.uv0; + + // Deferred RT Lighting + OUT.outWsPosition = mul( objTrans, float4( IN.position.xyz, 1 ) ).xyz; + + return OUT; +} diff --git a/Tools/CMake/torque3d.cmake b/Tools/CMake/torque3d.cmake index 4eccdc79a..f46febb1c 100644 --- a/Tools/CMake/torque3d.cmake +++ b/Tools/CMake/torque3d.cmake @@ -33,7 +33,7 @@ if(UNIX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -Wno-return-type-c-linkage -Wno-unused-local-typedef ${TORQUE_ADDITIONAL_LINKER_FLAGS}") else() # default compiler flags - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$$ORIGIN'") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -no-pie ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$$ORIGIN'") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$$ORIGIN'") endif() @@ -313,6 +313,7 @@ addPath("${srcDir}/materials") addPath("${srcDir}/lighting") addPath("${srcDir}/lighting/common") addPath("${srcDir}/renderInstance") +addPath("${srcDir}/renderInstance/debug") addPath("${srcDir}/scene") addPath("${srcDir}/scene/culling") addPath("${srcDir}/scene/zones")