From 3ec347b2bbdcde7f69419794d0a33916e19b9f1a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 9 Dec 2025 18:46:00 -0600 Subject: [PATCH 01/21] followup to https://github.com/TorqueGameEngines/Torque3D/pull/1601 --- Engine/source/T3D/assets/assetMacroHelpers.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Engine/source/T3D/assets/assetMacroHelpers.h b/Engine/source/T3D/assets/assetMacroHelpers.h index ce4bb37d9..983e6f22a 100644 --- a/Engine/source/T3D/assets/assetMacroHelpers.h +++ b/Engine/source/T3D/assets/assetMacroHelpers.h @@ -140,7 +140,7 @@ DefineEngineMethod(className, set##name, void, (const char* assetName), , assetT #define PACKDATA_ASSET(name)\ if (stream->writeFlag(m##name##Asset.notNull()))\ {\ - stream->writeString(m##name##Asset.getAssetId());\ + AssetDatabase.packDataAsset(stream, m##name##Asset.getAssetId());\ }\ else if(stream->writeFlag(m##name##Name != StringTable->EmptyString()))\ {\ @@ -151,7 +151,7 @@ DefineEngineMethod(className, set##name, void, (const char* assetName), , assetT #define UNPACKDATA_ASSET(name)\ if (stream->readFlag())\ {\ - m##name##AssetId = stream->readSTString();\ + m##name##AssetId = AssetDatabase.unpackDataAsset(stream);\ _set##name(m##name##AssetId);\ }\ else if (stream->readFlag())\ @@ -168,8 +168,7 @@ DefineEngineMethod(className, set##name, void, (const char* assetName), , assetT #define PACK_ASSET(netconn, name)\ if (stream->writeFlag(m##name##Asset.notNull()))\ {\ - NetStringHandle assetIdStr = m##name##Asset.getAssetId();\ - netconn->packNetStringHandleU(stream, assetIdStr);\ + AssetDatabase.packDataAsset(stream, m##name##Asset.getAssetId());\ }\ else if (stream->writeFlag(m##name##Name != StringTable->EmptyString()))\ {\ @@ -181,7 +180,7 @@ DefineEngineMethod(className, set##name, void, (const char* assetName), , assetT #define UNPACK_ASSET(netconn, name)\ if (stream->readFlag())\ {\ - m##name##AssetId = StringTable->insert(netconn->unpackNetStringHandleU(stream).getString());\ + m##name##AssetId = AssetDatabase.unpackDataAsset(stream);\ _set##name(m##name##AssetId);\ }\ else if (stream->readFlag())\ From 34a8e5ef529a52f410e44d7d341ebebae20894c9 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Wed, 10 Dec 2025 03:25:52 +0000 Subject: [PATCH 02/21] follow up to asset data management --- Engine/source/T3D/assets/SoundAsset.cpp | 35 +++++++++---- .../T3D/gameBase/gameConnectionEvents.cpp | 12 +---- Engine/source/assets/assetManager.cpp | 50 +++++++++++++------ 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.cpp b/Engine/source/T3D/assets/SoundAsset.cpp index af834b2c2..f4882c50f 100644 --- a/Engine/source/T3D/assets/SoundAsset.cpp +++ b/Engine/source/T3D/assets/SoundAsset.cpp @@ -149,7 +149,7 @@ SoundAsset::SoundAsset() mSubtitleString = StringTable->EmptyString(); mLoadedState = AssetErrCode::NotLoaded; - mPreload = false; + mPreload = true; // SFX description inits // reverb is useless here, reverb is inacted on listener. mProfileDesc.mPitch = 1; @@ -164,10 +164,17 @@ SoundAsset::SoundAsset() mProfileDesc.mConeOutsideAngle = 360; mProfileDesc.mConeOutsideVolume = 1; mProfileDesc.mRolloffFactor = -1.0f; + mProfileDesc.mFadeInTime = 0.0f; + mProfileDesc.mFadeOutTime = 0.0f; + mProfileDesc.mFadeLoops = false; mProfileDesc.mScatterDistance = Point3F(0.f, 0.f, 0.f); + mProfileDesc.mStreamPacketSize = 8; + mProfileDesc.mStreamReadAhead = 3; mProfileDesc.mPriority = 1.0f; mProfileDesc.mSourceGroup = NULL; mProfileDesc.mFadeInEase = EaseF(); + mProfileDesc.mReverb = SFXSoundReverbProperties(); + dMemset(mProfileDesc.mParameters, 0, sizeof(mProfileDesc.mParameters)); mIsPlaylist = false; mPlaylist.mNumSlotsToPlay = SFXPlayList::SFXPlaylistSettings::NUM_SLOTS; @@ -182,6 +189,15 @@ SoundAsset::SoundAsset() SoundAsset::~SoundAsset() { + + for (U32 i = 0; i < SFXPlayList::NUM_SLOTS; i++) + { + if(mSFXProfile[i].isProperlyAdded() && !mSFXProfile[i].isDeleted()) + mSFXProfile[i].unregisterObject(); + } + + if (mPlaylist.isProperlyAdded() && !mPlaylist.isDeleted()) + mPlaylist.unregisterObject(); } //----------------------------------------------------------------------------- @@ -353,6 +369,7 @@ void SoundAsset::onAssetRefresh(void) mSoundPath[i] = getOwned() ? expandAssetFilePath(mSoundFile[i]) : mSoundPath[i]; } + } U32 SoundAsset::load() @@ -372,6 +389,8 @@ U32 SoundAsset::load() numSlots++; } + if (mProfileDesc.mSourceGroup == NULL) + mProfileDesc.mSourceGroup = dynamic_cast(Sim::findObject("AudioChannelMaster")); if (numSlots > 1) { @@ -391,16 +410,14 @@ U32 SoundAsset::load() return mLoadedState; } else - {// = new SFXProfile(mProfileDesc, mSoundFile, mPreload); - if (mProfileDesc.mSourceGroup == NULL) - mProfileDesc.mSourceGroup = dynamic_cast(Sim::findObject("AudioChannelMaster")); + { SFXProfile* trackProfile = new SFXProfile(); trackProfile->setDescription(&mProfileDesc); trackProfile->setSoundFileName(mSoundPath[i]); trackProfile->setPreload(mPreload); - trackProfile->getBuffer(); mSFXProfile[i] = *trackProfile; + mSFXProfile[i].registerObject(String::ToString("%s_profile_track%d", getAssetName()).c_str()); mPlaylist.mSlots.mTrack[i] = trackProfile; @@ -409,6 +426,7 @@ U32 SoundAsset::load() } mPlaylist.setDescription(&mProfileDesc); + mPlaylist.registerObject(String::ToString("%s_playlist", getAssetName()).c_str()); } else { @@ -424,15 +442,12 @@ U32 SoundAsset::load() return mLoadedState; } else - {// = new SFXProfile(mProfileDesc, mSoundFile, mPreload); - if (mProfileDesc.mSourceGroup == NULL) - mProfileDesc.mSourceGroup = dynamic_cast(Sim::findObject("AudioChannelMaster")); + { mSFXProfile[0].setDescription(&mProfileDesc); mSFXProfile[0].setSoundFileName(mSoundPath[0]); mSFXProfile[0].setPreload(mPreload); - //give it a nudge to preload if required - mSFXProfile[0].getBuffer(); + mSFXProfile[0].registerObject(String::ToString("%s_profile", getAssetName()).c_str()); } } diff --git a/Engine/source/T3D/gameBase/gameConnectionEvents.cpp b/Engine/source/T3D/gameBase/gameConnectionEvents.cpp index 4b173902f..dbdab1c83 100644 --- a/Engine/source/T3D/gameBase/gameConnectionEvents.cpp +++ b/Engine/source/T3D/gameBase/gameConnectionEvents.cpp @@ -311,8 +311,7 @@ SimSoundAssetEvent::SimSoundAssetEvent(StringTableEntry assetId, const MatrixF* void SimSoundAssetEvent::pack(NetConnection* con, BitStream* stream) { - NetStringHandle assetIdStr = mAsset->getAssetId(); - con->packNetStringHandleU(stream, assetIdStr); + AssetDatabase.packUpdateAsset(con, 0, stream, mAsset.getAssetId()); SFXDescription* ad = mAsset->getSfxDescription(); if (stream->writeFlag(sentTransform)) @@ -348,14 +347,7 @@ void SimSoundAssetEvent::write(NetConnection* con, BitStream* stream) void SimSoundAssetEvent::unpack(NetConnection* con, BitStream* stream) { - StringTableEntry temp = StringTable->insert(con->unpackNetStringHandleU(stream).getString()); - if (AssetDatabase.isDeclaredAsset(temp)) - { - AssetPtr tempSoundAsset; - tempSoundAsset = temp; - - mAsset = temp; - } + mAsset = AssetDatabase.unpackUpdateAsset(con, stream); sentTransform = stream->readFlag(); if (sentTransform) { diff --git a/Engine/source/assets/assetManager.cpp b/Engine/source/assets/assetManager.cpp index 9f1f603ee..45ddb0c38 100644 --- a/Engine/source/assets/assetManager.cpp +++ b/Engine/source/assets/assetManager.cpp @@ -326,6 +326,17 @@ bool AssetManager::addDeclaredAsset( ModuleDefinition* pModuleDefinition, const //----------------------------------------------------------------------------- +static U32 HashAssetId(const char* str) +{ + U32 hash = 2166136261u; + while (*str) + { + hash ^= (U8)*str++; + hash *= 16777619u; + } + return hash; +} + StringTableEntry AssetManager::addPrivateAsset( AssetBase* pAssetBase ) { // Debug Profiling. @@ -377,6 +388,22 @@ StringTableEntry AssetManager::addPrivateAsset( AssetBase* pAssetBase ) // Set ownership by asset manager. pAssetDefinition->mpAssetBase->setOwned( this, pAssetDefinition ); + U32 netId = HashAssetId(pAssetDefinition->mAssetName); + + // Collision detection + typeNetIdToAssetMap::iterator netIterator = mNetIdToAsset.find(netId); + if (netIterator != mNetIdToAsset.end()) + { + Con::warnf( + "AssetManager: Hash collision for '%s' and '%s'", + pAssetDefinition->mAssetName, + mNetIdToAsset.find(netId)->value + ); + } + + mNetIdToAsset.insert(netId, pAssetDefinition->mAssetId); + mAssetToNetId.insert(pAssetDefinition->mAssetId, netId); + // Store in declared assets. mDeclaredAssets.insert( pAssetDefinition->mAssetId, pAssetDefinition ); @@ -475,6 +502,14 @@ bool AssetManager::removeDeclaredAsset( const char* pAssetId ) // Remove from declared assets. mDeclaredAssets.erase( declaredAssetItr ); + typeAssetToNetIdMap::iterator netId = mAssetToNetId.find(pAssetId); + typeNetIdToAssetMap::iterator netChar = mNetIdToAsset.find(netId->value); + if (netId != mAssetToNetId.end() && netChar != mNetIdToAsset.end()) + { + mNetIdToAsset.erase(netChar); + mAssetToNetId.erase(netId); + } + // Info. if ( mEchoInfo ) { @@ -2691,17 +2726,6 @@ const char* AssetManager::getAssetLooseFile(const char* pAssetId, const S32& ind //----------------------------------------------------------------------------- -static U32 HashAssetId(const char* str) -{ - U32 hash = 2166136261u; - while (*str) - { - hash ^= (U8)*str++; - hash *= 16777619u; - } - return hash; -} - bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension, const bool recurse, ModuleDefinition* pModuleDefinition ) { // Debug Profiling. @@ -2829,13 +2853,11 @@ bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension typeNetIdToAssetMap::iterator netIterator = mNetIdToAsset.find(netId); if (netIterator != mNetIdToAsset.end()) { - Con::errorf( + Con::warnf( "AssetManager: Hash collision for '%s' and '%s'", assetIdBuffer, mNetIdToAsset.find(netId)->value ); - - AssertFatal(false, "Asset hash collision detected."); } mNetIdToAsset.insert(netId, foundAssetDefinition.mAssetId); From a716107dd2b252bc03c1963b85145dc70a908f50 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Wed, 10 Dec 2025 04:50:58 +0000 Subject: [PATCH 03/21] Assimp Import Axis Build a matrix to fix the assimp import to be zup yforward --- Engine/source/ts/assimp/assimpAppNode.cpp | 6 +- Engine/source/ts/assimp/assimpShapeLoader.cpp | 76 ++++++++++++++++++- Engine/source/ts/collada/colladaUtils.h | 1 + 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Engine/source/ts/assimp/assimpAppNode.cpp b/Engine/source/ts/assimp/assimpAppNode.cpp index b39ca2fd7..15cec1e9b 100644 --- a/Engine/source/ts/assimp/assimpAppNode.cpp +++ b/Engine/source/ts/assimp/assimpAppNode.cpp @@ -84,7 +84,11 @@ MatrixF AssimpAppNode::getTransform(F32 time) // no parent (ie. root level) => scale by global shape mLastTransform.identity(); mLastTransform.scale(ColladaUtils::getOptions().unit * ColladaUtils::getOptions().formatScaleFactor); - ColladaUtils::convertTransform(mLastTransform); + if (!isBounds()) + { + MatrixF axisFix = ColladaUtils::getOptions().axisCorrectionMat; + mLastTransform.mulL(axisFix); + } } // If this node is animated in the active sequence, fetch the animated transform diff --git a/Engine/source/ts/assimp/assimpShapeLoader.cpp b/Engine/source/ts/assimp/assimpShapeLoader.cpp index 33c42f537..88fcc68dd 100644 --- a/Engine/source/ts/assimp/assimpShapeLoader.cpp +++ b/Engine/source/ts/assimp/assimpShapeLoader.cpp @@ -380,7 +380,81 @@ void AssimpShapeLoader::getRootAxisTransform() meta->Get("CoordAxis", coordAxis); meta->Get("CoordAxisSign", coordSign); - ColladaUtils::getOptions().upAxis = (domUpAxisType)upAxis; + switch (upAxis) + { + case 0: ColladaUtils::getOptions().upAxis = UPAXISTYPE_X_UP; break; + case 1: ColladaUtils::getOptions().upAxis = UPAXISTYPE_Y_UP; break; + case 2: ColladaUtils::getOptions().upAxis = UPAXISTYPE_Z_UP; break; + default: ColladaUtils::getOptions().upAxis = UPAXISTYPE_Y_UP; break; + } + + MatrixF rot(true); + + // ===== Y-UP SOURCE ===== + if (upAxis == 1) + { + if (frontAxis == 2) + { + // Y-up, Z-forward → Z-up, Y-forward + // Rotate 180° Y, then 90° X + rot(0, 0) = -1.0f; + rot(1, 1) = 0.0f; rot(2, 1) = 1.0f; + rot(1, 2) = 1.0f; rot(2, 2) = 0.0f; + } + else if (frontAxis == 0) + { + // Y-up, X-forward → Z-up, Y-forward + // Rotate -90° around Z then 90° around X + rot(0, 0) = 0.0f; rot(0, 1) = -1.0f; + rot(1, 0) = 1.0f; rot(1, 1) = 0.0f; + rot(2, 2) = 1.0f; + } + } + + // ===== Z-UP SOURCE ===== + if (upAxis == 2) + { + if (frontAxis == 1) + { + // Already Z-up, Y-forward → no change + } + else if (frontAxis == 0) + { + // Z-up, X-forward → rotate -90° around Z + rot(0, 0) = 0.0f; rot(0, 1) = -1.0f; + rot(1, 0) = 1.0f; rot(1, 1) = 0.0f; + } + } + + // ===== X-UP SOURCE ===== + if (upAxis == 0) + { + if (frontAxis == 2) + { + // X-up, Z-forward → Z-up, Y-forward + // Rotate -90° around Y then -90° around Z + rot(0, 0) = 0.0f; rot(0, 1) = 0.0f; rot(0, 2) = -1.0f; + rot(1, 0) = 1.0f; rot(1, 1) = 0.0f; rot(1, 2) = 0.0f; + rot(2, 0) = 0.0f; rot(2, 1) = -1.0f; rot(2, 2) = 0.0f; + } + } + + // ===== SIGN FLIP ===== + if (upSign == -1) + { + rot(0, 2) = -rot(0, 2); + rot(1, 2) = -rot(1, 2); + rot(2, 2) = -rot(2, 2); + } + + if (frontSign == -1) + { + rot(0, 1) = -rot(0, 1); + rot(1, 1) = -rot(1, 1); + rot(2, 1) = -rot(2, 1); + } + + ColladaUtils::getOptions().axisCorrectionMat = rot; } void AssimpShapeLoader::processAnimations() diff --git a/Engine/source/ts/collada/colladaUtils.h b/Engine/source/ts/collada/colladaUtils.h index 90a8265f5..7d12ed7c1 100644 --- a/Engine/source/ts/collada/colladaUtils.h +++ b/Engine/source/ts/collada/colladaUtils.h @@ -120,6 +120,7 @@ namespace ColladaUtils eAnimTimingType animTiming; // How to import timing data as frames, seconds or milliseconds S32 animFPS; // FPS value to use if timing is set in frames and the animations does not have an fps set F32 formatScaleFactor; // Scale factor applied to convert the shape format default unit to meters + MatrixF axisCorrectionMat; ImportOptions() { From cc17dcdc17ee1b112fb311253e21bd5b0544c436 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Wed, 10 Dec 2025 08:21:03 +0000 Subject: [PATCH 04/21] Update assimpShapeLoader.cpp signage still causes issues --- Engine/source/ts/assimp/assimpShapeLoader.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Engine/source/ts/assimp/assimpShapeLoader.cpp b/Engine/source/ts/assimp/assimpShapeLoader.cpp index 88fcc68dd..4a1174391 100644 --- a/Engine/source/ts/assimp/assimpShapeLoader.cpp +++ b/Engine/source/ts/assimp/assimpShapeLoader.cpp @@ -439,21 +439,6 @@ void AssimpShapeLoader::getRootAxisTransform() } } - // ===== SIGN FLIP ===== - if (upSign == -1) - { - rot(0, 2) = -rot(0, 2); - rot(1, 2) = -rot(1, 2); - rot(2, 2) = -rot(2, 2); - } - - if (frontSign == -1) - { - rot(0, 1) = -rot(0, 1); - rot(1, 1) = -rot(1, 1); - rot(2, 1) = -rot(2, 1); - } - ColladaUtils::getOptions().axisCorrectionMat = rot; } From dd1486c8d8cd5df4257d7e504e99c537bb69b224 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Wed, 10 Dec 2025 08:22:20 +0000 Subject: [PATCH 05/21] Update build-macos-clang.yml --- .github/workflows/build-macos-clang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-clang.yml b/.github/workflows/build-macos-clang.yml index 8310a7588..4b9d61f9f 100644 --- a/.github/workflows/build-macos-clang.yml +++ b/.github/workflows/build-macos-clang.yml @@ -20,7 +20,7 @@ jobs: build-linux: if: github.repository == 'TorqueGameEngines/Torque3D' name: ${{matrix.config.name}} - runs-on: macos-13 + runs-on: macos-latest strategy: fail-fast: false matrix: From f57bc015a95158f72adc51bd51aab9ecd52b8cb2 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 10 Dec 2025 16:29:09 -0600 Subject: [PATCH 06/21] set default hdr postfx keyvalue to baseline --- .../scripts/default.postfxpreset.tscript | 2 +- .../levels/ExampleLevel.asset.taml | 2 +- .../ExampleModule/levels/ExampleLevel.mis | 64 ++++++++---------- .../levels/ExampleLevel.postfxpreset.tscript | 2 +- ...dced-11e9-a423-bb0e346e3870_Irradiance.dds | Bin 0 -> 262276 bytes ...-dced-11e9-a423-bb0e346e3870_Prefilter.dds | Bin 0 -> 262276 bytes 6 files changed, 30 insertions(+), 40 deletions(-) create mode 100644 Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel/probes/d5eb3afb-dced-11e9-a423-bb0e346e3870_Irradiance.dds create mode 100644 Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel/probes/d5eb3afb-dced-11e9-a423-bb0e346e3870_Prefilter.dds diff --git a/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript b/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript index b479c753b..1c0277d6e 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript @@ -9,7 +9,7 @@ $PostFX::HDRPostFX::whiteCutoff = 1; $PostFX::HDRPostFX::adaptRate = "0.134615391"; $PostFX::HDRPostFX::tonemapMode = "ACES"; $PostFX::HDRPostFX::enableAutoExposure = "1"; -$PostFX::HDRPostFX::keyValue = 0.18; +$PostFX::HDRPostFX::keyValue = 0.5; $PostFX::HDRPostFX::enableBloom = 1; $PostFX::HDRPostFX::threshold = 1; $PostFX::HDRPostFX::intensity = 1; diff --git a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.asset.taml b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.asset.taml index 7f67926e4..84ecc4f53 100644 --- a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.asset.taml +++ b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.asset.taml @@ -7,6 +7,6 @@ DecalsFile="@assetFile=ExampleLevel.mis.decals" ForestFile="@assetFile=ExampleLevel.forest" NavmeshFile="@assetFile=ExampleLevel.nav" + gameModesNames="ExampleGameMode" staticObjectAssetDependency0="@asset=Prototyping:FloorGray" - gameModesNames="ExampleGameMode;" VersionId="1"/> diff --git a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.mis b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.mis index 40bffd526..df0a7459b 100644 --- a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.mis +++ b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.mis @@ -1,82 +1,72 @@ //--- OBJECT WRITE BEGIN --- new Scene(ExampleLevel) { - Enabled = "1"; - gameModes="ExampleGameMode"; + isEditing = "1"; + gameModes = "ExampleGameMode"; + enabled = "1"; new LevelInfo(theLevelInfo) { - fogColor = "0.6 0.6 0.7 1"; + FogColor = "0.6 0.6 0.7 1"; fogDensityOffset = "700"; canvasClearColor = "0 0 0 255"; + ambientLightBlendCurve = "2.69146e+20 0"; soundAmbience = "AudioAmbienceDefault"; - advancedLightmapSupport = "0"; - Enabled = "1"; + advancedLightmapSupport = "0"; + enabled = "1"; }; new SkyBox(theSky) { MaterialAsset = "Core_Rendering:BlankSkyMat"; - drawBottom = "0"; - dirtyGameObject = "0"; + dirtyGameObject = "0"; }; new Sun(theSun) { azimuth = "230.396"; elevation = "45"; color = "0.968628 0.901961 0.901961 1"; ambient = "0.337255 0.533333 0.619608 1"; - brightness = "2"; texSize = "2048"; overDarkFactor = "3000 1500 750 250"; shadowDistance = "200"; shadowSoftness = "0.25"; logWeight = "0.9"; fadeStartDistance = "0"; - bias = "0.1"; - Blur = "1"; - dirtyGameObject = "0"; - dynamicRefreshFreq = "8"; - Enabled = "1"; - height = "1024"; - lightBleedFactor = "0.8"; - minVariance = "0"; - pointShadowType = "PointShadowType_Paraboloid"; - shadowBox = "-100 -100 -100 100 100 100"; - splitFadeDistances = "1 1 1 1"; - staticRefreshFreq = "250"; - width = "3072"; + bias = "0.1"; + Blur = "1"; + dirtyGameObject = "0"; + dynamicRefreshFreq = "8"; + enabled = "1"; + height = "1024"; + lightBleedFactor = "0.8"; + minVariance = "0"; + pointShadowType = "PointShadowType_Paraboloid"; + shadowBox = "-100 -100 -100 100 100 100"; + splitFadeDistances = "1 1 1 1"; + staticRefreshFreq = "250"; + width = "3072"; }; new GroundPlane() { scaleU = "25"; scaleV = "25"; MaterialAsset = "Prototyping:FloorGray"; - dirtyGameObject = "0"; - Enabled = "1"; - position = "0 0 0"; - rotation = "1 0 0 0"; - scale = "1 1 1"; + dirtyGameObject = "0"; + enabled = "1"; + position = "0 0 0"; + rotation = "1 0 0 0"; + scale = "1 1 1"; }; new Skylight() { position = "1.37009 -5.23561 46.5817"; persistentId = "d5eb3afb-dced-11e9-a423-bb0e346e3870"; - dirtyGameObject = "0"; + dirtyGameObject = "0"; }; - new SimGroup(CameraSpawnPoints) { - canSave = "1"; - canSaveDynamicFields = "1"; enabled = "1"; new SpawnSphere(DefaultCameraSpawnSphere) { - autoSpawn = "0"; - spawnTransform = "0"; radius = "1"; sphereWeight = "1"; indoorWeight = "1"; outdoorWeight = "1"; - isAIControlled = "0"; dataBlock = "SpawnSphereMarker"; position = "0 0 10"; - rotation = "1 0 0 0"; - scale = "1 1 1"; - canSave = "1"; - canSaveDynamicFields = "1"; enabled = "1"; homingCount = "0"; lockCount = "0"; diff --git a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript index 917c27ec5..90d2dbeaa 100644 --- a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript +++ b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript @@ -9,7 +9,7 @@ $PostFX::HDRPostFX::whiteCutoff = 1; $PostFX::HDRPostFX::adaptRate = 2; $PostFX::HDRPostFX::tonemapMode = "ACES"; $PostFX::HDRPostFX::enableAutoExposure = "0"; -$PostFX::HDRPostFX::keyValue = 0.18; +$PostFX::HDRPostFX::keyValue = 0.5; $PostFX::HDRPostFX::enableBloom = 1; $PostFX::HDRPostFX::threshold = 1; $PostFX::HDRPostFX::intensity = 1; diff --git a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel/probes/d5eb3afb-dced-11e9-a423-bb0e346e3870_Irradiance.dds b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel/probes/d5eb3afb-dced-11e9-a423-bb0e346e3870_Irradiance.dds new file mode 100644 index 0000000000000000000000000000000000000000..17ba487e501c6828b6dd77f33ccfe2365f9491be GIT binary patch literal 262276 zcmeI(J&FQB5P;G02NVen#zF0RQ(?Tc#0 z@!CHkV%yDQDEIW_S>+FZ-hKJIWqHQie)sDu>u!j6eSfkkzb?u%eQ);p=y|vt@25Ds zbub714>-U94sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh1 z4sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4 zIKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G z-~b0WzyS_$fCC)h00%h0ftDQzM*#&CP(T3%6i`3`1r$&~0R-N_}lK6Zh24J{F{IC?|mf>aDW3G-~b0W zzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h z00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70 z103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROii zbRZlB6i`3`1r$&~0RfoP#_8y-hd{ZN3M2}8&eH2`y}xXU<(S7dW9@6+rFkru=QVD!Id}*D0S7q1 z0S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K0 z2ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`2 z9N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8 zaDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0W zzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h z00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70 z103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh1 z4sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4 zIKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G z-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$ zfCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h0 z0S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K0 z2ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`2 z9N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8 zaDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0W zzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h z00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70 z103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh1 z4sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4 zIKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G z-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$ zfCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h0 z0S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K0 z2ROh14sd`29N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`2 z9N+*4IKTl8aDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8 zaDW3G-~b0WzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKTl8aDW3G-~b0W qzyS_$fCC)h00%h00S<70103K02ROh14sd`29N+*4IKYAbb>IcF4-!)V literal 0 HcmV?d00001 From 4c083d713d1691bf83b5d24e6449dd8e110a31f7 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 13 Dec 2025 17:41:21 -0600 Subject: [PATCH 07/21] physics findings rigid: main finding is rigid needs to take delta into account for integration (aka interpolation) also used POINT_EPSILON for thresholds for consistency for rigidshape/item/player, main finding was length calcs for the search area were all over the place, so we now derive the extended length of the cached area based on the velocity and the object's radius itself rather than guessin per class atrest gravity calc suplimental syncing between rigidshape and vehicle **remindernote POINT_EPSILO is 0.0001 --- Engine/source/T3D/item.cpp | 4 ++-- Engine/source/T3D/player.cpp | 2 +- Engine/source/T3D/rigid.cpp | 13 +++++++------ Engine/source/T3D/rigid.h | 2 +- Engine/source/T3D/rigidShape.cpp | 6 +++--- Engine/source/T3D/vehicles/vehicle.cpp | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Engine/source/T3D/item.cpp b/Engine/source/T3D/item.cpp index 3681774da..18f52ff5c 100644 --- a/Engine/source/T3D/item.cpp +++ b/Engine/source/T3D/item.cpp @@ -658,9 +658,9 @@ void Item::updateWorkingCollisionSet(const U32 mask, const F32 dt) { // It is assumed that we will never accelerate more than 10 m/s for gravity... // - Point3F scaledVelocity = mVelocity * dt; + Point3F scaledVelocity = mVelocity * dt * TickSec; F32 len = scaledVelocity.len(); - F32 newLen = len + (10 * dt); + F32 newLen = len + (mDataBlock->getShape()->mRadius * dt * TickSec); // Check to see if it is actually necessary to construct the new working list, // or if we can use the cached version from the last query. We use the x diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 3c187ea0d..96dcf0d1e 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -6097,7 +6097,7 @@ void Player::updateWorkingCollisionSet() // box by the possible movement in that tick. Point3F scaledVelocity = mVelocity * TickSec; F32 len = scaledVelocity.len(); - F32 newLen = len + (10.0f * TickSec); + F32 newLen = len + (mDataBlock->getShape()->mRadius * TickSec); // Check to see if it is actually necessary to construct the new working list, // or if we can use the cached version from the last query. We use the x diff --git a/Engine/source/T3D/rigid.cpp b/Engine/source/T3D/rigid.cpp index adb453879..83b9eb8b4 100644 --- a/Engine/source/T3D/rigid.cpp +++ b/Engine/source/T3D/rigid.cpp @@ -47,8 +47,8 @@ Rigid::Rigid() friction = 0.5f; atRest = false; - sleepLinearThreshold = 0.0004f; - sleepAngThreshold = 0.0004f; + sleepLinearThreshold = POINT_EPSILON; + sleepAngThreshold = POINT_EPSILON; sleepTimeThreshold = 0.75f; sleepTimer = 0.0f; } @@ -71,7 +71,7 @@ void Rigid::integrate(F32 delta) linVelocity = linMomentum * oneOverMass; // 2. advance orientation if ang vel significant - F32 angle = angVelocity.len(); + F32 angle = angVelocity.len()*delta; if (mFabs(angle)> POINT_EPSILON) { QuatF dq; @@ -101,7 +101,7 @@ void Rigid::integrate(F32 delta) } // 5. refresh ang velocity - updateAngularVelocity(); + updateAngularVelocity(delta); // 6. CoM update @@ -138,7 +138,7 @@ void Rigid::updateCenterOfMass() void Rigid::applyImpulse(const Point3F &r, const Point3F &impulse) { - if (impulse.lenSquared() < mass) return; + if ((impulse.lenSquared() - mass) < POINT_EPSILON) return; wake(); // Linear momentum and velocity @@ -304,7 +304,8 @@ void Rigid::trySleep(F32 dt) // If there is active force/torque, don’t sleep if (!force.isZero() || !torque.isZero()) { - sleepTimer = 0.0f; return; + sleepTimer = 0.0f; + return; } const F32 linV2 = linVelocity.lenSquared(); diff --git a/Engine/source/T3D/rigid.h b/Engine/source/T3D/rigid.h index c9fa9197e..ad66c0e0c 100644 --- a/Engine/source/T3D/rigid.h +++ b/Engine/source/T3D/rigid.h @@ -105,7 +105,7 @@ public: // void setSleepThresholds(F32 linVel2, F32 angVel2, F32 timeToSleep); void wake(); - TORQUE_FORCEINLINE void updateAngularVelocity() { invWorldInertia.mulV(angMomentum, &angVelocity); } + TORQUE_FORCEINLINE void updateAngularVelocity(F32 delta) { Point3F deltaVel = angVelocity * delta; invWorldInertia.mulV(angMomentum, &deltaVel); } }; diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index b43d9adfb..129c0dcf9 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -1138,7 +1138,7 @@ void RigidShape::updatePos(F32 dt) // Update collision information based on our current pos. bool collided = false; - if (!mDisableMove) + if (!mRigid.atRest && !mDisableMove) { collided = updateCollision(dt); @@ -1151,7 +1151,7 @@ void RigidShape::updatePos(F32 dt) { F32 k = mRigid.getKineticEnergy(); F32 G = mNetGravity* dt * TickMs / mDataBlock->integration; - F32 Kg = mRigid.mass * G * G; + F32 Kg = mRigid.mass * G * G * TickSec; if (k < sRestTol * Kg && ++restCount > sRestCount) mRigid.setAtRest(); } @@ -1447,7 +1447,7 @@ void RigidShape::updateWorkingCollisionSet(const U32 mask) // working list is updated on a Tick basis, which means we only expand our box by // the possible movement in that tick, plus some extra for caching purposes Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale()); - F32 len = (mRigid.linVelocity.len() + 50) * TickSec; + F32 len = (mRigid.linVelocity.len() + mDataBlock->getShape()->mRadius) * TickSec; F32 l = (len * 1.1) + 0.1; // fudge factor convexBox.minExtents -= Point3F(l, l, l); convexBox.maxExtents += Point3F(l, l, l); diff --git a/Engine/source/T3D/vehicles/vehicle.cpp b/Engine/source/T3D/vehicles/vehicle.cpp index 18ea38e10..c1750b61d 100644 --- a/Engine/source/T3D/vehicles/vehicle.cpp +++ b/Engine/source/T3D/vehicles/vehicle.cpp @@ -827,7 +827,7 @@ void Vehicle::updatePos(F32 dt) { F32 k = mRigid.getKineticEnergy(); F32 G = mNetGravity* dt * TickMs / mDataBlock->integration; - F32 Kg = 0.5 * mRigid.mass * G * G; + F32 Kg = mRigid.mass * G * G * TickSec; if (k < sRestTol * Kg && ++restCount > sRestCount) mRigid.setAtRest(); } From fad8e126677034ec84733a3cc3020fa9e6aff076 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 13 Dec 2025 20:52:36 -0600 Subject: [PATCH 08/21] take ibl amount into account for translucent opacity --- Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp | 6 +++--- Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp | 6 +++--- .../BaseGame/game/core/rendering/shaders/gl/lighting.glsl | 5 +++-- .../BaseGame/game/core/rendering/shaders/lighting.hlsl | 5 +++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 548eb0217..6c545b40f 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -3055,7 +3055,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList Var *ibl = (Var *)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float3"); + ibl = new Var("ibl", "float4"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3086,7 +3086,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList //Reflection vec String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,@,@,@,@,\r\n\t\t"); - computeForwardProbes += String("@,@).rgb; \r\n"); + computeForwardProbes += String("@,@); \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3100,7 +3100,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); output = meta; } diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index d65cced8f..9d6ea1923 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -3143,7 +3143,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList Var* ibl = (Var*)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float3"); + ibl = new Var("ibl", "float4"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3174,7 +3174,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,TORQUE_SAMPLER2D_MAKEARG(@),TORQUE_SAMPLER2D_MAKEARG(@), @, @,\r\n\t\t"); - computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n"); + computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)); \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3188,7 +3188,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); output = meta; } diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 5e0caa346..3daeb12c7 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -605,10 +605,11 @@ vec4 computeForwardProbes(Surface surface, finalColor *= surface.ao; if(isCapturing == 1) - return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); + return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); else { - return vec4(finalColor, 0); + float reflectionOpacity = min(max(surface.baseColor.a,length(specular+irradiance)),1.0); + return vec4(finalColor, reflectionOpacity); } } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 8a4c5be23..fc0abf7a1 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -610,10 +610,11 @@ float4 computeForwardProbes(Surface surface, finalColor *= surface.ao; if(isCapturing == 1) - return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); + return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); else { - return float4(finalColor, 0); + float reflectionOpacity = min(max(surface.baseColor.a,length(specular+irradiance)),1.0); + return float4(finalColor, reflectionOpacity); } } From 2199fb688171ad7d48ffdaf72d7e7adf557ba0c1 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 14 Dec 2025 02:29:31 -0600 Subject: [PATCH 09/21] use a nonlinear reflectionopacity curve, and the greater of metalness or reflectionopacity for ibl overtaking albedo --- .../game/core/rendering/shaders/gl/lighting.glsl | 9 +++++---- .../game/core/rendering/shaders/lighting.hlsl | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 3daeb12c7..35940b5a1 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -592,9 +592,11 @@ vec4 computeForwardProbes(Surface surface, specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha); } + float reflectionOpacity = clamp(surface.baseColor.a, pow(max(length(specular),length(irradiance)),2.2),1.0); + float reflectionInfluence = max(surface.metalness, reflectionOpacity); vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; - vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness); - vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; + vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), reflectionInfluence); + vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*reflectionInfluence; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); @@ -608,8 +610,7 @@ vec4 computeForwardProbes(Surface surface, return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); else { - float reflectionOpacity = min(max(surface.baseColor.a,length(specular+irradiance)),1.0); - return vec4(finalColor, reflectionOpacity); + return vec4(finalColor, reflectionInfluence); } } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index fc0abf7a1..25c9f446c 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -597,24 +597,25 @@ float4 computeForwardProbes(Surface surface, specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); } + float reflectionOpacity = clamp(surface.baseColor.a, pow(max(length(specular),length(irradiance)),2.2),1.0); + float reflectionInfluence = max(surface.metalness, reflectionOpacity); float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; - float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness); - float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; + float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, reflectionInfluence); + float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*reflectionInfluence; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); horizon *= horizon; // Final color output after environment lighting - float3 finalColor = diffuse + specularCol; + float3 finalColor = diffuse + specularCol* horizon; finalColor *= surface.ao; if(isCapturing == 1) - return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); + return float4(lerp((finalColor), surface.baseColor.rgb, surface.metalness),surface.baseColor.a); else { - float reflectionOpacity = min(max(surface.baseColor.a,length(specular+irradiance)),1.0); - return float4(finalColor, reflectionOpacity); + return float4(finalColor, reflectionInfluence); } } From f00b1d955f62d6e457e440b41f349142582e2de8 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 14 Dec 2025 12:40:19 -0600 Subject: [PATCH 10/21] revisions to ensure high saturation reflections overtake albedo --- .../game/core/rendering/shaders/gl/lighting.glsl | 11 +++++++---- .../game/core/rendering/shaders/lighting.hlsl | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 35940b5a1..2292d3f23 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -592,11 +592,14 @@ vec4 computeForwardProbes(Surface surface, specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha); } - float reflectionOpacity = clamp(surface.baseColor.a, pow(max(length(specular),length(irradiance)),2.2),1.0); - float reflectionInfluence = max(surface.metalness, reflectionOpacity); + float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance)),1.0); + float reflectionInfluence = max(surface.metalness, reflectionOpacity); + surface.metalness = reflectionInfluence; + surface.baseColor.rgb = lerp(surface.baseColor.rgb, vec3(1.0,1.0,1.0), reflectionInfluence); + updateSurface(surface); vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; - vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), reflectionInfluence); - vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*reflectionInfluence; + vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness); + vec3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 25c9f446c..6c646ad91 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -597,11 +597,14 @@ float4 computeForwardProbes(Surface surface, specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); } - float reflectionOpacity = clamp(surface.baseColor.a, pow(max(length(specular),length(irradiance)),2.2),1.0); + float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance)),1.0); float reflectionInfluence = max(surface.metalness, reflectionOpacity); + surface.metalness = reflectionInfluence; + surface.baseColor.rgb = lerp(surface.baseColor.rgb, float3(1.0,1.0,1.0), reflectionInfluence); + surface.Update(); float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; - float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, reflectionInfluence); - float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*reflectionInfluence; + float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness); + float3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); From 5893355d0a13fd4a419abe07704ddfac97cd35e7 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 14 Dec 2025 14:01:48 -0600 Subject: [PATCH 11/21] simplify calcs, account for roughness for better defered vs translucent pairing outcomes when fed textures --- .../BaseGame/game/core/rendering/shaders/gl/lighting.glsl | 6 ++---- .../BaseGame/game/core/rendering/shaders/lighting.hlsl | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 2292d3f23..8c4df444e 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -593,9 +593,7 @@ vec4 computeForwardProbes(Surface surface, } float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance)),1.0); - float reflectionInfluence = max(surface.metalness, reflectionOpacity); - surface.metalness = reflectionInfluence; - surface.baseColor.rgb = lerp(surface.baseColor.rgb, vec3(1.0,1.0,1.0), reflectionInfluence); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, vec3(1.0,1.0,1.0), reflectionOpacity*surface.roughness); updateSurface(surface); vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness); @@ -613,7 +611,7 @@ vec4 computeForwardProbes(Surface surface, return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); else { - return vec4(finalColor, reflectionInfluence); + return vec4(finalColor, reflectionOpacity); } } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 6c646ad91..dcdc12d4a 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -596,11 +596,8 @@ float4 computeForwardProbes(Surface surface, irradiance = lerp(irradiance,TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, surface.N, skylightCubemapIdx, 0).xyz,alpha); specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); } - float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance)),1.0); - float reflectionInfluence = max(surface.metalness, reflectionOpacity); - surface.metalness = reflectionInfluence; - surface.baseColor.rgb = lerp(surface.baseColor.rgb, float3(1.0,1.0,1.0), reflectionInfluence); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, float3(1.0,1.0,1.0), reflectionOpacity*surface.roughness); surface.Update(); float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness); @@ -618,7 +615,7 @@ float4 computeForwardProbes(Surface surface, return float4(lerp((finalColor), surface.baseColor.rgb, surface.metalness),surface.baseColor.a); else { - return float4(finalColor, reflectionInfluence); + return float4(finalColor, reflectionOpacity); } } From 681caf9392371b8b9dee0292c43f119b0aedb58c Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 14 Dec 2025 15:33:30 -0600 Subject: [PATCH 12/21] brdf calc fixes from mar, rake roughness into account for translucent reflections --- .../game/core/rendering/shaders/gl/lighting.glsl | 8 +++++--- .../BaseGame/game/core/rendering/shaders/lighting.hlsl | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 8c4df444e..7ded966fe 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -226,9 +226,11 @@ float getDistanceAtt( vec3 unormalizedLightVector , float invSqrAttRadius ) vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) { + if (surface.depth >= 0.9999f) + return float3(0.0,0.0,0.0); + // Compute Fresnel term vec3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); - F += lerp(vec3(0.04f,0.04f,0.04f), surface.baseColor.rgb, surface.metalness); // GGX Normal Distribution Function float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); @@ -592,8 +594,8 @@ vec4 computeForwardProbes(Surface surface, specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha); } - float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance)),1.0); - surface.baseColor.rgb = lerp(surface.baseColor.rgb, vec3(1.0,1.0,1.0), reflectionOpacity*surface.roughness); + float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance))*surface.roughness,1.0); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, vec3(reflectionOpacity,reflectionOpacity,reflectionOpacity), surface.roughness); updateSurface(surface); vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness); diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index dcdc12d4a..41181b894 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -226,9 +226,11 @@ float getDistanceAtt( float3 unormalizedLightVector , float invSqrAttRadius ) float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) { + if (surface.depth >= 0.9999f) + return float3(0.0,0.0,0.0); + // Compute Fresnel term float3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); - F += lerp(0.04f, surface.baseColor.rgb, surface.metalness); // GGX Normal Distribution Function float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); @@ -596,8 +598,9 @@ float4 computeForwardProbes(Surface surface, irradiance = lerp(irradiance,TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, surface.N, skylightCubemapIdx, 0).xyz,alpha); specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); } - float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance)),1.0); - surface.baseColor.rgb = lerp(surface.baseColor.rgb, float3(1.0,1.0,1.0), reflectionOpacity*surface.roughness); + + float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance))*surface.roughness,1.0); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, float3(reflectionOpacity,reflectionOpacity,reflectionOpacity), surface.roughness); surface.Update(); float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness); From f78f3606b51fd1069767e67ab36d868b13298ccd Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 14 Dec 2025 16:33:39 -0600 Subject: [PATCH 13/21] add executing file reporting to the trace(true/false) script command --- Engine/source/console/torquescript/runtime.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Engine/source/console/torquescript/runtime.cpp b/Engine/source/console/torquescript/runtime.cpp index ddb063699..45c3249ee 100644 --- a/Engine/source/console/torquescript/runtime.cpp +++ b/Engine/source/console/torquescript/runtime.cpp @@ -402,6 +402,8 @@ namespace TorqueScript #ifdef TORQUE_DEBUG Con::printf("Executing %s.", scriptFileName); #endif + if (Con::gTraceOn) + Con::printf("Executing %s.", scriptFileName); CodeBlock *newCodeBlock = new CodeBlock(); StringTableEntry name = StringTable->insert(scriptFileName); From 1a2ca353f10b4ba0ddee8ff884f1bc6690dedcbb Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 14 Dec 2025 17:37:40 -0600 Subject: [PATCH 14/21] clean up editor ui seperations --- .../BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui | 8 ++++---- .../game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui | 2 +- .../game/tools/worldEditor/gui/ToolsToolbar.ed.gui | 2 +- .../game/tools/worldEditor/scripts/EditorGui.ed.tscript | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui index e261713bf..bc1bc87ea 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui @@ -255,7 +255,7 @@ $guiContent = new GuiContainer(EditorGui,EditorGuiGroup) { HorizSizing = "width"; VertSizing = "bottom"; Position = "0 0"; - Extent = "800 40"; + Extent = "800 36"; MinExtent = "8 8"; Margin = "0 0 0 0"; Padding = "0 0 0 0"; @@ -1470,7 +1470,7 @@ $guiContent = new GuiContainer(EditorGui,EditorGuiGroup) { internalName = "AggregateControl"; horizSizing = "right"; vertSizing = "bottom"; - position = "0 60"; + position = "0 0"; extent = "1024 768"; minExtent = "8 8"; visible = "0"; @@ -1478,8 +1478,8 @@ $guiContent = new GuiContainer(EditorGui,EditorGuiGroup) { class = "EditorDropdownSliderContainer"; new GuiContainer(){ - position = firstWord(CameraSpeedDropdownContainer.position) + firstWord(EditorGuiToolbar.position) + -6 SPC - (getWord(CameraSpeedDropdownContainer, 1)) + 31; + internalName = "container"; + position = "0 0"; extent = "146 39"; isContainer = "1"; Profile = "IconDropdownProfile"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui index b7732d629..6f48d9315 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui @@ -23,7 +23,7 @@ $guiContent = new GuiControl() { VertSizing = "windowRelative"; Extent = "36 24"; MinExtent = "36 24"; - Position = "-1 73"; + Position = "0 64"; canSave = "1"; Visible = "1"; hovertime = "1000"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui index e7cdeac3c..7d0e7711c 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui @@ -7,7 +7,7 @@ $guiContent = new GuiContainer(EWToolsToolbar) { Profile = "ToolsMenubarProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "0 38"; + Position = "0 30"; Extent = "0 33"; MinExtent = "8 34"; canSave = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript index b57fdf092..8b6562f77 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript @@ -3359,11 +3359,11 @@ function TerrainSetHeightSliderCtrlContainer::onWake(%this) } //------------------------------------------------------------------------------------ -function CameraSpeedDropdownContainer::onWake(%this) +function CameraSpeedDropdownCtrlContainer::onWake(%this) { - %this-->slider.setValue(CameraSpeedDropdownCtrlContainer-->textEdit.getText()); - %pos = CameraSpeedDropdownCtrlContainer.getGlobalPosition(); - %this-->slider.setPositionGlobal(%pos.x, %pos.y + 25); + %this-->slider.setValue(CameraSpeedDropdownContainer-->textEdit.getText()); + %pos = CameraSpeedDropdownContainer.getGlobalPosition(); + %this-->container.setPositionGlobal(%pos.x, %pos.y + 25); } //------------------------------------------------------------------------------------ From 854bea324604664f8c17fff0fb6d46bb2bd0bb6e Mon Sep 17 00:00:00 2001 From: Brian Roberts Date: Mon, 15 Dec 2025 13:53:31 -0600 Subject: [PATCH 15/21] Revert "take ibl amount into account for translucent opacity" --- .../source/shaderGen/GLSL/shaderFeatureGLSL.cpp | 6 +++--- .../source/shaderGen/HLSL/shaderFeatureHLSL.cpp | 6 +++--- .../game/core/rendering/shaders/gl/lighting.glsl | 13 ++++--------- .../game/core/rendering/shaders/lighting.hlsl | 15 +++++---------- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 6c545b40f..548eb0217 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -3055,7 +3055,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList Var *ibl = (Var *)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float4"); + ibl = new Var("ibl", "float3"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3086,7 +3086,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList //Reflection vec String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,@,@,@,@,\r\n\t\t"); - computeForwardProbes += String("@,@); \r\n"); + computeForwardProbes += String("@,@).rgb; \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3100,7 +3100,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); output = meta; } diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 9d6ea1923..d65cced8f 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -3143,7 +3143,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList Var* ibl = (Var*)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float4"); + ibl = new Var("ibl", "float3"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3174,7 +3174,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,TORQUE_SAMPLER2D_MAKEARG(@),TORQUE_SAMPLER2D_MAKEARG(@), @, @,\r\n\t\t"); - computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)); \r\n"); + computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3188,7 +3188,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); output = meta; } diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 7ded966fe..5e0caa346 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -226,11 +226,9 @@ float getDistanceAtt( vec3 unormalizedLightVector , float invSqrAttRadius ) vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) { - if (surface.depth >= 0.9999f) - return float3(0.0,0.0,0.0); - // Compute Fresnel term vec3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); + F += lerp(vec3(0.04f,0.04f,0.04f), surface.baseColor.rgb, surface.metalness); // GGX Normal Distribution Function float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); @@ -594,12 +592,9 @@ vec4 computeForwardProbes(Surface surface, specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha); } - float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance))*surface.roughness,1.0); - surface.baseColor.rgb = lerp(surface.baseColor.rgb, vec3(reflectionOpacity,reflectionOpacity,reflectionOpacity), surface.roughness); - updateSurface(surface); vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness); - vec3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness; + vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); @@ -610,10 +605,10 @@ vec4 computeForwardProbes(Surface surface, finalColor *= surface.ao; if(isCapturing == 1) - return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); + return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); else { - return vec4(finalColor, reflectionOpacity); + return vec4(finalColor, 0); } } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 41181b894..8a4c5be23 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -226,11 +226,9 @@ float getDistanceAtt( float3 unormalizedLightVector , float invSqrAttRadius ) float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) { - if (surface.depth >= 0.9999f) - return float3(0.0,0.0,0.0); - // Compute Fresnel term float3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); + F += lerp(0.04f, surface.baseColor.rgb, surface.metalness); // GGX Normal Distribution Function float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); @@ -599,26 +597,23 @@ float4 computeForwardProbes(Surface surface, specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); } - float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance))*surface.roughness,1.0); - surface.baseColor.rgb = lerp(surface.baseColor.rgb, float3(reflectionOpacity,reflectionOpacity,reflectionOpacity), surface.roughness); - surface.Update(); float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness); - float3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness; + float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); horizon *= horizon; // Final color output after environment lighting - float3 finalColor = diffuse + specularCol* horizon; + float3 finalColor = diffuse + specularCol; finalColor *= surface.ao; if(isCapturing == 1) - return float4(lerp((finalColor), surface.baseColor.rgb, surface.metalness),surface.baseColor.a); + return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); else { - return float4(finalColor, reflectionOpacity); + return float4(finalColor, 0); } } From ec34e1a984161753c1114ef6071b546db07926eb Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 15 Dec 2025 14:33:47 -0600 Subject: [PATCH 16/21] fresnel corrections for prior exploratory pr --- .../BaseGame/game/core/rendering/shaders/gl/lighting.glsl | 6 ++++-- .../BaseGame/game/core/rendering/shaders/lighting.hlsl | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 5e0caa346..af36cb665 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -226,9 +226,11 @@ float getDistanceAtt( vec3 unormalizedLightVector , float invSqrAttRadius ) vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) { + if (surface.depth >= 0.9999f) + return float3(0.0,0.0,0.0); + // Compute Fresnel term vec3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); - F += lerp(vec3(0.04f,0.04f,0.04f), surface.baseColor.rgb, surface.metalness); // GGX Normal Distribution Function float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); @@ -594,7 +596,7 @@ vec4 computeForwardProbes(Surface surface, vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness); - vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; + vec3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 8a4c5be23..8aea64de7 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -226,9 +226,11 @@ float getDistanceAtt( float3 unormalizedLightVector , float invSqrAttRadius ) float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) { + if (surface.depth >= 0.9999f) + return float3(0.0,0.0,0.0); + // Compute Fresnel term float3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); - F += lerp(0.04f, surface.baseColor.rgb, surface.metalness); // GGX Normal Distribution Function float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); @@ -599,7 +601,7 @@ float4 computeForwardProbes(Surface surface, float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness); - float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; + float3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness; float horizonOcclusion = 1.3; float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); From 1b27b1372f024fac5ff279c838bf639363984fd0 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 15 Dec 2025 22:39:52 -0600 Subject: [PATCH 17/21] clean up manggled hdr vals reset standard samples to standard hdr key and adaptation rate values --- .../ExampleModule/levels/ExampleLevel.postfxpreset.tscript | 2 +- .../game/tools/levels/DefaultEditorLevel.postfxpreset.tscript | 4 ++-- .../tools/levels/EditorTemplateLevel.postfxpreset.tscript | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript index 90d2dbeaa..e61beeae2 100644 --- a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript +++ b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript @@ -6,7 +6,7 @@ $PostFX::HDRPostFX::saturationValue = 1; $PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0"; $PostFX::HDRPostFX::minLuminace = 0.001; $PostFX::HDRPostFX::whiteCutoff = 1; -$PostFX::HDRPostFX::adaptRate = 2; +$PostFX::HDRPostFX::adaptRate = "0.85"; $PostFX::HDRPostFX::tonemapMode = "ACES"; $PostFX::HDRPostFX::enableAutoExposure = "0"; $PostFX::HDRPostFX::keyValue = 0.5; diff --git a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.postfxpreset.tscript b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.postfxpreset.tscript index 23a6c3ced..f83e6ecd8 100644 --- a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.postfxpreset.tscript +++ b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.postfxpreset.tscript @@ -14,7 +14,7 @@ $PostFXManager::Settings::EnableLightRays = "1"; $PostFXManager::Settings::EnablePostFX = "1"; $PostFXManager::Settings::EnableSSAO = "1"; $PostFXManager::Settings::EnableVignette = "1"; -$PostFXManager::Settings::HDR::adaptRate = "2"; +$PostFXManager::Settings::HDR::adaptRate = "0.85"; $PostFXManager::Settings::HDR::blueShiftColor = "1.05 0.97 1.27"; $PostFXManager::Settings::HDR::brightPassThreshold = "1"; $PostFXManager::Settings::HDR::enableBloom = "1"; @@ -23,7 +23,7 @@ $PostFXManager::Settings::HDR::enableToneMapping = "0.5"; $PostFXManager::Settings::HDR::gaussMean = "0"; $PostFXManager::Settings::HDR::gaussMultiplier = "0.3"; $PostFXManager::Settings::HDR::gaussStdDev = "0.8"; -$PostFXManager::Settings::HDR::keyValue = "0.117347"; +$PostFXManager::Settings::HDR::keyValue = "0.5"; $PostFXManager::Settings::HDR::minLuminace = "0.0459184"; $PostFXManager::Settings::HDR::whiteCutoff = "1"; $PostFXManager::Settings::LightRays::brightScalar = "0.75"; diff --git a/Templates/BaseGame/game/tools/levels/EditorTemplateLevel.postfxpreset.tscript b/Templates/BaseGame/game/tools/levels/EditorTemplateLevel.postfxpreset.tscript index 23a6c3ced..f83e6ecd8 100644 --- a/Templates/BaseGame/game/tools/levels/EditorTemplateLevel.postfxpreset.tscript +++ b/Templates/BaseGame/game/tools/levels/EditorTemplateLevel.postfxpreset.tscript @@ -14,7 +14,7 @@ $PostFXManager::Settings::EnableLightRays = "1"; $PostFXManager::Settings::EnablePostFX = "1"; $PostFXManager::Settings::EnableSSAO = "1"; $PostFXManager::Settings::EnableVignette = "1"; -$PostFXManager::Settings::HDR::adaptRate = "2"; +$PostFXManager::Settings::HDR::adaptRate = "0.85"; $PostFXManager::Settings::HDR::blueShiftColor = "1.05 0.97 1.27"; $PostFXManager::Settings::HDR::brightPassThreshold = "1"; $PostFXManager::Settings::HDR::enableBloom = "1"; @@ -23,7 +23,7 @@ $PostFXManager::Settings::HDR::enableToneMapping = "0.5"; $PostFXManager::Settings::HDR::gaussMean = "0"; $PostFXManager::Settings::HDR::gaussMultiplier = "0.3"; $PostFXManager::Settings::HDR::gaussStdDev = "0.8"; -$PostFXManager::Settings::HDR::keyValue = "0.117347"; +$PostFXManager::Settings::HDR::keyValue = "0.5"; $PostFXManager::Settings::HDR::minLuminace = "0.0459184"; $PostFXManager::Settings::HDR::whiteCutoff = "1"; $PostFXManager::Settings::LightRays::brightScalar = "0.75"; From 8d0fde4d1c1b72fc5b8685e7de77de7a7eeaf16a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 16 Dec 2025 15:46:37 -0600 Subject: [PATCH 18/21] simplified translucent opacity nudging the basic articulable principle is the thicker and less translucent a given object is, the more it mimics standard solid objects. the more transparent, the less light bounces back since it continues on uninterrupted, casuing less backscatter. --- Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp | 6 +++--- Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp | 6 +++--- .../BaseGame/game/core/rendering/shaders/gl/lighting.glsl | 3 ++- .../BaseGame/game/core/rendering/shaders/lighting.hlsl | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 548eb0217..6c545b40f 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -3055,7 +3055,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList Var *ibl = (Var *)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float3"); + ibl = new Var("ibl", "float4"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3086,7 +3086,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList //Reflection vec String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,@,@,@,@,\r\n\t\t"); - computeForwardProbes += String("@,@).rgb; \r\n"); + computeForwardProbes += String("@,@); \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3100,7 +3100,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); output = meta; } diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index d65cced8f..9d6ea1923 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -3143,7 +3143,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList Var* ibl = (Var*)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float3"); + ibl = new Var("ibl", "float4"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3174,7 +3174,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,TORQUE_SAMPLER2D_MAKEARG(@),TORQUE_SAMPLER2D_MAKEARG(@), @, @,\r\n\t\t"); - computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n"); + computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)); \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3188,7 +3188,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); output = meta; } diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 5e0caa346..9e2d474b6 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -608,7 +608,8 @@ vec4 computeForwardProbes(Surface surface, return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); else { - return vec4(finalColor, 0); + float reflectionOpacity = min(surface.baseColor.a+surface.baseColor.a*length(finalColor),1.0); + return vec4(finalColor, reflectionOpacity); } } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 8a4c5be23..57ac40d11 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -613,7 +613,8 @@ float4 computeForwardProbes(Surface surface, return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); else { - return float4(finalColor, 0); + float reflectionOpacity = min(surface.baseColor.a+surface.baseColor.a*length(finalColor),1.0); + return float4(finalColor, reflectionOpacity); } } From 80c49ec69274d33ab3f1a65d7b9976cf3cffc1d3 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 17 Dec 2025 15:00:24 -0600 Subject: [PATCH 19/21] fix AnimValue smooth values on clients the dbs were not transmitting the bools --- Engine/source/T3D/lightAnimData.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Engine/source/T3D/lightAnimData.cpp b/Engine/source/T3D/lightAnimData.cpp index d88bd3add..8f7fae4a5 100644 --- a/Engine/source/T3D/lightAnimData.cpp +++ b/Engine/source/T3D/lightAnimData.cpp @@ -244,6 +244,7 @@ void LightAnimData::AnimValue::write( BitStream *stream ) const stream->write( value2[i] ); stream->write( period[i] ); stream->writeString( keys[i] ); + stream->writeFlag(smooth[i]); } } @@ -256,6 +257,7 @@ void LightAnimData::AnimValue::read( BitStream *stream ) stream->read( &value2[i] ); stream->read( &period[i] ); keys[i] = stream->readSTString(); + smooth[i] = stream->readFlag(); } } From 5b0f559c9fae7e1306a1af5d0cd3537ad8f091b7 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 17 Dec 2025 15:42:13 -0600 Subject: [PATCH 20/21] animation playback cleanups courtessy of marauder --- Engine/source/ts/assimp/assimpAppSequence.cpp | 55 ++++++------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/Engine/source/ts/assimp/assimpAppSequence.cpp b/Engine/source/ts/assimp/assimpAppSequence.cpp index 0c31b6ca0..c1d59971a 100644 --- a/Engine/source/ts/assimp/assimpAppSequence.cpp +++ b/Engine/source/ts/assimp/assimpAppSequence.cpp @@ -48,52 +48,33 @@ AssimpAppSequence::~AssimpAppSequence() void AssimpAppSequence::determineTimeMultiplier(aiAnimation* a) { - // Set fps from the file or use default - fps = (a->mTicksPerSecond > 0) ? a->mTicksPerSecond : 30.0f; - - if (fps >= 1000.0f) { // Indicates milliseconds (GLTF or similar formats) - mTimeMultiplier = 1.0f / 1000.0f; // Convert milliseconds to seconds - Con::printf("[Assimp] Detected milliseconds timing (FPS >= 1000). Time Multiplier: %f", mTimeMultiplier); - } - else if (fps > 0.0f) { // Standard FPS - fps = mClamp(fps, 5 /*TSShapeLoader::MinFrameRate*/, TSShapeLoader::MaxFrameRate); - mTimeMultiplier = 1.0f / fps; - Con::printf("[Assimp] Standard FPS detected. Time Multiplier: %f", mTimeMultiplier); - } - else { - // Fall back to 30 FPS as default - mTimeMultiplier = 1.0f / 30.0f; - Con::printf("[Assimp] FPS not specified. Using default 30 FPS. Time Multiplier: %f", mTimeMultiplier); - } + // Assimp convention: if mTicksPerSecond == 0, assume 25 Hz + const float ticksPerSecond = + (a->mTicksPerSecond > 0.0) + ? (float)a->mTicksPerSecond + : 25.0f; + mTimeMultiplier = 1.0f / ticksPerSecond; + Con::printf( + "[Assimp] TicksPerSecond: %f, Time Multiplier: %f", + ticksPerSecond, + mTimeMultiplier + ); } void AssimpAppSequence::calculateSequenceEnd(aiAnimation* a) { - for (U32 i = 0; i < a->mNumChannels; ++i) { - aiNodeAnim* nodeAnim = a->mChannels[i]; - F32 maxKeyTime = 0.0f; + // mDuration is in ticks + seqEnd = (F32)a->mDuration * mTimeMultiplier; - // Calculate the maximum time across all keyframes for this channel - for (U32 k = 0; k < nodeAnim->mNumPositionKeys; ++k) { - maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mPositionKeys[k].mTime); - } - for (U32 k = 0; k < nodeAnim->mNumRotationKeys; ++k) { - maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mRotationKeys[k].mTime); - } - for (U32 k = 0; k < nodeAnim->mNumScalingKeys; ++k) { - maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mScalingKeys[k].mTime); - } - - // Use the multiplier to convert to real sequence time - seqEnd = mTimeMultiplier * getMax(seqEnd, maxKeyTime); - } - - Con::printf("[Assimp] Sequence End Time: %f seconds", seqEnd); + Con::printf( + "[Assimp] Sequence End Time: %f seconds (Duration ticks: %f)", + seqEnd, + (F32)a->mDuration + ); } - void AssimpAppSequence::setActive(bool active) { if (active) From d8618be49904f382ccdf77cdb04aa469cfd4663b Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 17 Dec 2025 18:22:26 -0600 Subject: [PATCH 21/21] hdr format caching sidesteps reinitialization we never actually turn hdr off. so drop a few assumptions about it starting in the disabled state fix HDRPostFX::minLuminace --- .../core/postFX/scripts/HDR/HDRPostFX.tscript | 25 +++++++++++-------- .../scripts/default.postfxpreset.tscript | 2 +- .../core/rendering/Core_Rendering.tscript | 1 + .../rendering/scripts/renderManager.tscript | 7 ++++-- .../levels/ExampleLevel.postfxpreset.tscript | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript index ff2586d20..f83b43a52 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript @@ -46,7 +46,7 @@ $PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0"; /// 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. -$PostFX::HDRPostFX::minLuminace = 0.001; +$PostFX::HDRPostFX::minLuminace = 0.5; /// The rate of adaptation from the previous and new /// average scene luminance. @@ -241,7 +241,7 @@ singleton GFXStateBlockData( HDRStateBlock ) function HDRPostFX::setShaderConsts( %this ) { - %this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue ); + %this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue ); %minLuminace = $PostFX::HDRPostFX::minLuminace; if ( %minLuminace <= 0.0 ) @@ -357,17 +357,25 @@ function HDRPostFX::onEnabled( %this ) // disable this postFx. GammaPostFX.disable(); + if (%format $= %this.previousFormat) + return true; + // Set the right global shader define for HDR. if ( %format $= "GFXFormatR10G10B10A2" ) + { addGlobalShaderMacro( "TORQUE_HDR_RGB10" ); + removeGlobalShaderMacro( "TORQUE_HDR_RGB16" ); + } else if ( %format $= "GFXFormatR16G16B16A16F" ) + { addGlobalShaderMacro( "TORQUE_HDR_RGB16" ); - + removeGlobalShaderMacro( "TORQUE_HDR_RGB10" ); + } echo( "HDR FORMAT: " @ %format ); // Change the format of the offscreen surface // to an HDR compatible format. - %this.previousFormat = AL_FormatToken.format; + %this.previousFormat = %format; setReflectFormat( %format ); // Reset the light manager which will ensure the new @@ -390,10 +398,7 @@ function HDRPostFX::onDisabled( %this ) // Restore the non-HDR offscreen surface format. %format = %this.previousFormat; AL_FormatToken.format = %format; - setReflectFormat( %format ); - - removeGlobalShaderMacro( "TORQUE_HDR_RGB10" ); - removeGlobalShaderMacro( "TORQUE_HDR_RGB16" ); + setReflectFormat( %format ); // Reset the light manager which will ensure the new // hdr encoding takes effect in all the shaders. @@ -565,9 +570,9 @@ function HDRPostFX::SetupBloomFX( %this ) singleton PostEffect( HDRPostFX ) { - enabled = false; + enabled = true; allowReflectPass = false; - + previousFormat = AL_FormatToken.format; // Resolve the HDR before we render any editor stuff // and before we resolve the scene to the backbuffer. renderTime = "PFXBeforeBin"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript b/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript index 1c0277d6e..14bddc0ca 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript @@ -6,7 +6,7 @@ $PostFX::HDRPostFX::saturationValue = 1; $PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0"; $PostFX::HDRPostFX::minLuminace = "0.5"; $PostFX::HDRPostFX::whiteCutoff = 1; -$PostFX::HDRPostFX::adaptRate = "0.134615391"; +$PostFX::HDRPostFX::adaptRate = "0.85"; $PostFX::HDRPostFX::tonemapMode = "ACES"; $PostFX::HDRPostFX::enableAutoExposure = "1"; $PostFX::HDRPostFX::keyValue = 0.5; diff --git a/Templates/BaseGame/game/core/rendering/Core_Rendering.tscript b/Templates/BaseGame/game/core/rendering/Core_Rendering.tscript index 8675e3168..b394683cb 100644 --- a/Templates/BaseGame/game/core/rendering/Core_Rendering.tscript +++ b/Templates/BaseGame/game/core/rendering/Core_Rendering.tscript @@ -71,4 +71,5 @@ function Core_Rendering::initClient(%this) // we can hide any splash screen we have, and show the canvas. // This keeps things looking nice, instead of having a blank window Canvas.showWindow(); + resetLightManager(); //make sure } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript b/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript index a7ca0855f..44ab6e313 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript @@ -31,7 +31,7 @@ function initRenderManager() // PostEffect copies the result to the backbuffer. new RenderFormatToken(AL_FormatToken) { - enabled = "false"; + enabled = true; //When hdr is enabled this will be changed to the appropriate format format = "GFXFormatR16G16B16A16F"; @@ -46,6 +46,9 @@ function initRenderManager() // provided in $inTex resolveEffect = "AL_FormatCopy"; }; + addGlobalShaderMacro( "TORQUE_HDR_RGB16" ); + setReflectFormat( AL_FormatToken.format ); + DiffuseRenderPassManager.addManager( new RenderPassStateBin() { renderOrder = 0.001; stateToken = AL_FormatToken; } ); DiffuseRenderPassManager.addManager( new RenderProbeMgr(ProbeBin) { bintype = "Probes"; renderOrder = 0.019; processAddOrder = 0.019; } ); @@ -119,7 +122,7 @@ singleton PostEffect( AL_FormatCopy ) { // This PostEffect is used by 'AL_FormatToken' directly. It is never added to // the PostEffectManager. Do not call enable() on it. - enabled = false; + enabled = true; allowReflectPass = true; shader = PFX_PassthruShader; diff --git a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript index e61beeae2..07ef6ef9b 100644 --- a/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript +++ b/Templates/BaseGame/game/data/ExampleModule/levels/ExampleLevel.postfxpreset.tscript @@ -4,7 +4,7 @@ $PostFX::HDRPostFX::whitePoint = 1; $PostFX::HDRPostFX::logContrast = 1; $PostFX::HDRPostFX::saturationValue = 1; $PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0"; -$PostFX::HDRPostFX::minLuminace = 0.001; +$PostFX::HDRPostFX::minLuminace = 0.5; $PostFX::HDRPostFX::whiteCutoff = 1; $PostFX::HDRPostFX::adaptRate = "0.85"; $PostFX::HDRPostFX::tonemapMode = "ACES";