From 9f11f132d37e5475d66159a7408406ebb966224a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 26 Mar 2025 06:22:01 -0500 Subject: [PATCH 01/11] fix wetness --- .../game/core/rendering/shaders/gl/lighting.glsl | 16 ++++++++++++---- .../game/core/rendering/shaders/lighting.hlsl | 16 ++++++++++++---- .../advanced/gl/reflectionProbeArrayP.glsl | 2 +- .../lighting/advanced/reflectionProbeArrayP.hlsl | 9 +++++---- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 8f67787b3..0e5b7a585 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -433,16 +433,24 @@ void dampen(inout Surface surface, sampler2D WetnessTexture, float accumTime, fl vec3 n = abs(surface.N); float ang = clamp(n.z, 0.04, 0.96); - float speed = accumTime*(1.0-surface.roughness)*ang; - vec2 wetoffset = vec2(speed,speed/2); - + float speed = -accumTime*(1.0-surface.linearRoughnessSq)*clamp((2.0-ang), 0.04, 0.96); + if ((n.x > 0.0) || (n.y > 0.0)) + speed *= -1.0; + vec2 wetoffset = vec2(speed,speed)*0.1; + + vec3 wetNormal = texture(WetnessTexture, float2(surface.P.xy*0.1+wetoffset)).xyz; + wetNormal = lerp(wetNormal,texture(WetnessTexture,float2(surface.P.zx*0.1+wetoffset)).rgb ,n.y); + wetNormal = lerp(wetNormal,texture(WetnessTexture,float2(surface.P.zy*0.1+wetoffset)).rgb ,n.x); + surface.N = lerp(surface.N, wetNormal, degree); + float wetness = texture(WetnessTexture, vec2(surface.P.xy*0.1+wetoffset)).b; wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zx*0.1+wetoffset)).b,n.y); wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zy*0.1+wetoffset)).b,n.x); wetness = pow(wetness*ang*degree,3); surface.roughness = lerp(surface.roughness, 0.04f, wetness); - surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.96+vec3(0.04,0.04,0.04), pow(wetness,5)); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.6+float3(0.4,0.4,0.4)*wetness, wetness); + surface.metalness = lerp(surface.metalness, 0.96, wetness); updateSurface(surface); } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index b263d0250..fa381711f 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -436,16 +436,24 @@ void dampen(inout Surface surface, TORQUE_SAMPLER2D(WetnessTexture), float accum float3 n = abs(surface.N); float ang = clamp(n.z, 0.04, 0.96); - float speed = accumTime*(1.0-surface.roughness)*ang; - float2 wetoffset = float2(speed,speed/2); - + float speed = -accumTime*(1.0-surface.linearRoughnessSq)*clamp((2.0-ang), 0.04, 0.96); + if ((n.x > 0.0) || (n.y > 0.0)) + speed *= -1.0; + float2 wetoffset = float2(speed,speed)*0.1; + + float3 wetNormal = TORQUE_TEX2D(WetnessTexture, float2(surface.P.xy*0.1+wetoffset)).xyz; + wetNormal = lerp(wetNormal,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zx*0.1+wetoffset)).rgb ,n.y); + wetNormal = lerp(wetNormal,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.1+wetoffset)).rgb ,n.x); + surface.N = lerp(surface.N, wetNormal, degree); + float wetness = TORQUE_TEX2D(WetnessTexture, float2(surface.P.xy*0.1+wetoffset)).b; wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zx*0.1+wetoffset)).b,n.y); wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.1+wetoffset)).b,n.x); wetness = pow(wetness*ang*degree,3); surface.roughness = lerp(surface.roughness, 0.04f, wetness); - surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.96+float3(0.04,0.04,0.04), pow(wetness,5)); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.6+float3(0.4,0.4,0.4)*wetness, wetness); + surface.metalness = lerp(surface.metalness, 0.96, wetness); surface.Update(); } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl index 4eb3770ac..9d4a589cb 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl @@ -206,7 +206,7 @@ void main() 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/advanced/reflectionProbeArrayP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl index d26511959..df444d666 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl @@ -156,6 +156,7 @@ float4 main(PFXVertToPix IN) : SV_TARGET if (SkylightDamp>0) wetAmmout += alpha; + dampen(surface, TORQUE_SAMPLER2D_MAKEARG(WetnessTexture), accumTime, wetAmmout*dampness); // Radiance (Specular) @@ -179,9 +180,9 @@ float4 main(PFXVertToPix IN) : SV_TARGET specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib; } } -#endif +#endif if(skylightCubemapIdx != -1 && alpha >= 0.001) - { + { irradiance = lerp(irradiance,TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, surface.N, skylightCubemapIdx, 0).xyz,alpha); specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); } @@ -193,8 +194,8 @@ float4 main(PFXVertToPix IN) : SV_TARGET #endif 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, float3(0.04f,0.04f,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 289d42cc10bc6c19235d49f039c65342f72c178c Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 26 Mar 2025 22:12:19 -0500 Subject: [PATCH 02/11] flowMagnitude and ripplespeed can go negative --- Engine/source/environment/river.cpp | 2 +- Engine/source/environment/waterObject.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/environment/river.cpp b/Engine/source/environment/river.cpp index 13e8088e8..acefb66b3 100644 --- a/Engine/source/environment/river.cpp +++ b/Engine/source/environment/river.cpp @@ -640,7 +640,7 @@ void River::initPersistFields() "For purposes of generating the renderable geometry River segments are further subdivided " "such that no quad is of greater width or length than this distance in meters." ); - addFieldV( "FlowMagnitude", TypeRangedF32, Offset( mFlowMagnitude, River ), &CommonValidators::PositiveFloat, + addFieldV( "FlowMagnitude", TypeRangedF32, Offset( mFlowMagnitude, River ), &CommonValidators::F32Range, "Magnitude of the force vector applied to dynamic objects within the River." ); addFieldV( "LowLODDistance", TypeRangedF32, Offset( mLodDistance, River ), &CommonValidators::PositiveFloat, diff --git a/Engine/source/environment/waterObject.cpp b/Engine/source/environment/waterObject.cpp index f4dbb2af6..dba34615a 100644 --- a/Engine/source/environment/waterObject.cpp +++ b/Engine/source/environment/waterObject.cpp @@ -305,7 +305,7 @@ void WaterObject::initPersistFields() addArray( "Ripples (texture animation)", MAX_WAVES ); addField( "rippleDir", TypePoint2F, Offset( mRippleDir, WaterObject ), MAX_WAVES, "Modifies the direction of ripples on the surface." ); - addFieldV( "rippleSpeed", TypeRangedF32, Offset( mRippleSpeed, WaterObject ), &CommonValidators::PositiveFloat, MAX_WAVES, "Modifies speed of surface ripples."); + addFieldV( "rippleSpeed", TypeRangedF32, Offset( mRippleSpeed, WaterObject ), &CommonValidators::F32Range, MAX_WAVES, "Modifies speed of surface ripples."); addField( "rippleTexScale", TypePoint2F, Offset( mRippleTexScale, WaterObject ), MAX_WAVES, "Intensifies the affect of the normal map " "applied to the surface."); addFieldV( "rippleMagnitude", TypeRangedF32, Offset( mRippleMagnitude, WaterObject ), &CommonValidators::PositiveFloat, MAX_WAVES, "Intensifies the vertext modification of the surface." ); From b92b5b34fd360b63d8c5dc5ec9f232160c0ad6d0 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 29 Mar 2025 14:43:03 -0500 Subject: [PATCH 03/11] clean up shadergen ambient handling fallback needs to a) set the same value as elswhere. b) treat uniforms the same. c) exist on both ends to ensure order of ops doesn't mangle things --- .../source/shaderGen/GLSL/shaderFeatureGLSL.cpp | 16 ++++++++++------ .../source/shaderGen/HLSL/shaderFeatureHLSL.cpp | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 1fd6276d3..548eb0217 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -2212,9 +2212,13 @@ void RTLightingFeatGLSL::processPix( Vector &componentList, Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - Var *ambient = new Var( "ambient", "vec4" ); - ambient->uniform = true; - ambient->constSortPos = cspPass; + Var* ambient = (Var*)LangElement::find("ambient"); + if (!ambient) + { + ambient = new Var("ambient", "vec4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; + } Var* lighting = new Var("lighting", "vec4"); meta->addStatement(new GenOp(" @ = compute4Lights( @, @, @, @,\r\n" @@ -3091,9 +3095,9 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList Var *ambient = (Var *)LangElement::find("ambient"); if (!ambient) { - ambient = new Var("ambient", "vec3"); - eyePos->uniform = true; - eyePos->constSortPos = cspPass; + ambient = new Var("ambient", "vec4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 8e7542052..d65cced8f 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -2284,9 +2284,13 @@ void RTLightingFeatHLSL::processPix( Vector &componentList, Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - Var *ambient = new Var( "ambient", "float4" ); - ambient->uniform = true; - ambient->constSortPos = cspPass; + Var* ambient = (Var*)LangElement::find("ambient"); + if (!ambient) + { + ambient = new Var("ambient", "float4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; + } Var* lighting = new Var("lighting", "float4"); meta->addStatement(new GenOp(" @ = compute4Lights( @, @, @, @,\r\n" @@ -3179,9 +3183,9 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList Var *ambient = (Var *)LangElement::find("ambient"); if (!ambient) { - ambient = new Var("ambient","float3"); - eyePos->uniform = true; - eyePos->constSortPos = cspPass; + ambient = new Var("ambient","float4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); From d82e8dbec4740bb66973d4d0ecfef2f7d2112101 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 1 Apr 2025 18:23:29 -0500 Subject: [PATCH 04/11] clean up (some) shader variation redundencies don't need to use macros for the shader textfile hashkeys several no longer used GFXVertexFormats removed --- Engine/source/gfx/gfxVertexTypes.cpp | 34 -------------- Engine/source/gfx/gfxVertexTypes.h | 67 --------------------------- Engine/source/shaderGen/shaderGen.cpp | 8 +--- 3 files changed, 1 insertion(+), 108 deletions(-) diff --git a/Engine/source/gfx/gfxVertexTypes.cpp b/Engine/source/gfx/gfxVertexTypes.cpp index bfc194104..d4420513b 100644 --- a/Engine/source/gfx/gfxVertexTypes.cpp +++ b/Engine/source/gfx/gfxVertexTypes.cpp @@ -29,32 +29,12 @@ GFXImplementVertexFormat( GFXVertexP ) addElement( "POSITION", GFXDeclType_Float3 ); } -GFXImplementVertexFormat( GFXVertexPad ) -{ - addElement("PADDING", GFXDeclType_UByte4); -} - GFXImplementVertexFormat( GFXVertexPT ) { addElement( "POSITION", GFXDeclType_Float3 ); addElement( "TEXCOORD", GFXDeclType_Float2, 0 ); } -GFXImplementVertexFormat( GFXVertexPTT ) -{ - addElement( "POSITION", GFXDeclType_Float3 ); - addElement( "TEXCOORD", GFXDeclType_Float2, 0 ); - addElement( "TEXCOORD", GFXDeclType_Float2, 1 ); -} - -GFXImplementVertexFormat( GFXVertexPTTT ) -{ - addElement( "POSITION", GFXDeclType_Float3 ); - addElement( "TEXCOORD", GFXDeclType_Float2, 0 ); - addElement( "TEXCOORD", GFXDeclType_Float2, 1 ); - addElement( "TEXCOORD", GFXDeclType_Float2, 2 ); -} - GFXImplementVertexFormat( GFXVertexPC ) { addElement( "POSITION", GFXDeclType_Float3 ); @@ -75,20 +55,6 @@ GFXImplementVertexFormat( GFXVertexPCT ) addElement( "TEXCOORD", GFXDeclType_Float2, 0 ); } -GFXImplementVertexFormat( GFXVertexPCTT ) -{ - addElement( "POSITION", GFXDeclType_Float3 ); - addElement( "COLOR", GFXDeclType_Color ); - addElement( "TEXCOORD", GFXDeclType_Float2, 0 ); - addElement( "TEXCOORD", GFXDeclType_Float2, 1 ); -} - -GFXImplementVertexFormat( GFXVertexPN ) -{ - addElement( "POSITION", GFXDeclType_Float3 ); - addElement( "NORMAL", GFXDeclType_Float3 ); -} - GFXImplementVertexFormat( GFXVertexPNT ) { addElement( "POSITION", GFXDeclType_Float3 ); diff --git a/Engine/source/gfx/gfxVertexTypes.h b/Engine/source/gfx/gfxVertexTypes.h index 005aca02b..2a9a152cb 100644 --- a/Engine/source/gfx/gfxVertexTypes.h +++ b/Engine/source/gfx/gfxVertexTypes.h @@ -36,11 +36,6 @@ #include "math/mPoint3.h" #endif -GFXDeclareVertexFormat( GFXVertexPad ) -{ - U32 data; -}; - GFXDeclareVertexFormat( GFXVertexP ) { Point3F point; @@ -52,21 +47,6 @@ GFXDeclareVertexFormat( GFXVertexPT ) Point2F texCoord; }; -GFXDeclareVertexFormat( GFXVertexPTT ) -{ - Point3F point; - Point2F texCoord1; - Point2F texCoord2; -}; - -GFXDeclareVertexFormat( GFXVertexPTTT ) -{ - Point3F point; - Point2F texCoord1; - Point2F texCoord2; - Point2F texCoord3; -}; - GFXDeclareVertexFormat( GFXVertexPC ) { Point3F point; @@ -87,20 +67,6 @@ GFXDeclareVertexFormat( GFXVertexPCT ) Point2F texCoord; }; -GFXDeclareVertexFormat( GFXVertexPCTT ) -{ - Point3F point; - GFXVertexColor color; - Point2F texCoord; - Point2F texCoord2; -}; - -GFXDeclareVertexFormat( GFXVertexPN ) -{ - Point3F point; - Point3F normal; -}; - GFXDeclareVertexFormat( GFXVertexPNT ) { Point3F point; @@ -133,27 +99,6 @@ GFXDeclareVertexFormat( GFXVertexPNTBT ) Point2F texCoord; }; -/* - -DEFINE_VERT( GFXVertexPCNT, - GFXVertexFlagXYZ | GFXVertexFlagNormal | GFXVertexFlagDiffuse | GFXVertexFlagTextureCount1 | GFXVertexFlagUV0) -{ - Point3F point; - Point3F normal; - GFXVertexColor color; - Point2F texCoord; -}; - -DEFINE_VERT( GFXVertexPCNTT, - GFXVertexFlagXYZ | GFXVertexFlagNormal | GFXVertexFlagDiffuse | GFXVertexFlagTextureCount2 | GFXVertexFlagUV0 | GFXVertexFlagUV1) -{ - Point3F point; - Point3F normal; - GFXVertexColor color; - Point2F texCoord[2]; -}; -*/ - GFXDeclareVertexFormat( GFXVertexPNTTB ) { Point3F point; @@ -164,16 +109,4 @@ GFXDeclareVertexFormat( GFXVertexPNTTB ) Point2F texCoord2; }; -/* -DEFINE_VERT( GFXVertexPNTB, - GFXVertexFlagXYZ | GFXVertexFlagNormal | GFXVertexFlagTextureCount2 | - GFXVertexFlagUV0 | GFXVertexFlagUVW1 ) -{ - Point3F point; - Point3F normal; - Point2F texCoord; - Point3F binormal; -}; -*/ - #endif // _GFXVERTEXTYPES_H_ diff --git a/Engine/source/shaderGen/shaderGen.cpp b/Engine/source/shaderGen/shaderGen.cpp index 54b297772..3339aaea5 100644 --- a/Engine/source/shaderGen/shaderGen.cpp +++ b/Engine/source/shaderGen/shaderGen.cpp @@ -459,18 +459,12 @@ GFXShader* ShaderGen::getShader( const MaterialFeatureData &featureData, const G // Build a description string from the features // and vertex format combination ( and macros ). String shaderDescription = vertexFormat->getDescription() + features.getDescription(); - if ( macros && !macros->empty() ) - { - String macroStr; - GFXShaderMacro::stringize( *macros, ¯oStr ); - shaderDescription += macroStr; - } - // Generate a single 64bit hash from the description string. // // Don't get paranoid! This has 1 in 18446744073709551616 // chance for collision... it won't happen in this lifetime. // + shaderDescription.replace("\n", " "); U64 hash = Torque::hash64( (const U8*)shaderDescription.c_str(), shaderDescription.length(), 0 ); hash = convertHostToLEndian(hash); U32 high = (U32)( hash >> 32 ); From 8ac9da0e9f641a243d5f9cc54780aaeec536e8c7 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 1 Apr 2025 20:48:50 -0500 Subject: [PATCH 05/11] fix spawn failure reports also force the fallbacks on failures --- .../scripts/server/connectionToClient.tscript | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript index c4b409b80..ec14ce358 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript @@ -144,13 +144,20 @@ function GameConnectionListener::onSetSpawnObjectTypeComplete( %this, %client ) // a new one could result in an uncontrolled player object. error("Attempting to create a player for a client that already has one!"); } - + if ((!isClass(%client.spawnClass)) || (!isClass(%client.spawnDBType)) || (!isObject(%client.spawnDBType))) + %this.onSetSpawnObjectTypeFailed(%client, false ); + %client.setSpawnPoint(); } function GameConnectionListener::onSetSpawnObjectTypeFailed( %this, %client, %canContinueOnFail ) { - errorf("Failed to properly set Spawn Object Type for client: " @ %client); + error("Failed to properly set Spawn Object Type for client: " @ %client); + //baseline controlObject spawn type with extention points + %client.spawnClass = "Camera"; + %client.spawnDBType = "CameraData"; + %client.spawnDataBlock = "Observer"; + %client.onSetSpawnObjectTypeComplete(%client); } function GameConnection::setSpawnPoint( %this ) @@ -246,7 +253,15 @@ function GameConnectionListener::onSetSpawnPointComplete( %this, %client ) function GameConnectionListener::onSetSpawnPointFailed( %this, %client, %canContinueOnFail ) { - errorf("Failed to properly set Spawn Object Type for client: " @ %client); + error("Failed to properly set Spawn Location for client: " @ %client); + + //baseline spawn point config rules with extention points + %this.playerSpawnGroups = "PlayerSpawnPoints PlayerDropPoints"; + %this.spawnPoint = ""; + %this.spawnLocation = "0 0 0"; + %this.spawnProperties = ""; + %this.spawnScript = ""; + %this.onSetSpawnPointComplete(%client); } function GameConnection::onPostSpawn( %this ) From 3d2a923a308ace2bb1060491416918ced22d61f9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 2 Apr 2025 15:33:39 -0500 Subject: [PATCH 06/11] add 0-100 percent ranges F32 and S32 apply to guibitmapbarctrl --- Engine/source/console/typeValidators.cpp | 2 ++ Engine/source/console/typeValidators.h | 2 ++ Engine/source/gui/controls/guiBitmapBarCtrl.cpp | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Engine/source/console/typeValidators.cpp b/Engine/source/console/typeValidators.cpp index 9d6eb3644..7aa62e5d5 100644 --- a/Engine/source/console/typeValidators.cpp +++ b/Engine/source/console/typeValidators.cpp @@ -105,6 +105,7 @@ namespace CommonValidators FRangeValidator PositiveFloat(0.0f, F32_MAX); FRangeValidator PositiveNonZeroFloat((F32)POINT_EPSILON, F32_MAX); FRangeValidator NormalizedFloat(0.0f, 1.0f); + FRangeValidator F32Percent(0.0f, 100.0f); FRangeValidator F32_8BitPercent(0.0f, 1.0f, BIT(8)); FRangeValidator F32_16BitPercent(0.0f, 1.0f, BIT(16)); @@ -116,6 +117,7 @@ namespace CommonValidators IRangeValidator NegDefaultInt(-1, S32_MAX); IRangeValidator PositiveInt(0, S32_MAX); IRangeValidator NaturalNumber(1, S32_MAX); + IRangeValidator S32Percent(0.0f, 100); //see "T3D/gameBase/processList.h" for TickMs = 32 IRangeValidator MSTickRange(32, S32_MAX); diff --git a/Engine/source/console/typeValidators.h b/Engine/source/console/typeValidators.h index 1b0920bce..e59f3d8e6 100644 --- a/Engine/source/console/typeValidators.h +++ b/Engine/source/console/typeValidators.h @@ -120,6 +120,7 @@ namespace CommonValidators extern FRangeValidator PositiveFloat; extern FRangeValidator PositiveNonZeroFloat; extern FRangeValidator NormalizedFloat; + extern FRangeValidator F32Percent; extern FRangeValidator F32_8BitPercent; extern FRangeValidator F32_16BitPercent; extern FRangeValidator ValidSlopeAngle; @@ -130,6 +131,7 @@ namespace CommonValidators extern IRangeValidator NegDefaultInt; extern IRangeValidator PositiveInt; extern IRangeValidator NaturalNumber; + extern FRangeValidator S32Percent; extern IRangeValidator MSTickRange; extern IRangeValidator S32_8BitCap; extern IRangeValidator S32_16BitCap; diff --git a/Engine/source/gui/controls/guiBitmapBarCtrl.cpp b/Engine/source/gui/controls/guiBitmapBarCtrl.cpp index 1ee2d1a32..edf644204 100644 --- a/Engine/source/gui/controls/guiBitmapBarCtrl.cpp +++ b/Engine/source/gui/controls/guiBitmapBarCtrl.cpp @@ -44,7 +44,7 @@ GuiBitmapBarCtrl::GuiBitmapBarCtrl(void) void GuiBitmapBarCtrl::initPersistFields() { docsURL; - addFieldV("percent", TypeRangedF32, Offset(mPercent, GuiBitmapBarCtrl), &CommonValidators::NormalizedFloat, + addFieldV("percent", TypeRangedF32, Offset(mPercent, GuiBitmapBarCtrl), &CommonValidators::F32Percent, "% shown"); addField("vertical", TypeBool, Offset(mVertical, GuiBitmapBarCtrl), "If true, the bitmap is clipped vertically."); From b299b54467545c49439c8335e2e3ca61af023c1d Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 2 Apr 2025 15:38:43 -0500 Subject: [PATCH 07/11] encapsulate tool-only code for levelassets --- Engine/source/T3D/assets/LevelAsset.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Engine/source/T3D/assets/LevelAsset.cpp b/Engine/source/T3D/assets/LevelAsset.cpp index e47a6f563..808fb1a22 100644 --- a/Engine/source/T3D/assets/LevelAsset.cpp +++ b/Engine/source/T3D/assets/LevelAsset.cpp @@ -443,6 +443,7 @@ DefineEngineMethod(LevelAsset, unloadDependencies, void, (), , return object->unloadDependencies(); } +#ifdef TORQUE_TOOLS //----------------------------------------------------------------------------- // GuiInspectorTypeAssetId //----------------------------------------------------------------------------- @@ -545,3 +546,5 @@ void GuiInspectorTypeLevelAssetId::consoleInit() ConsoleBaseType::getType(TypeLevelAssetId)->setInspectorFieldType("GuiInspectorTypeLevelAssetId"); } + +#endif From 664e9db571791fd079554df222950b84823d4f03 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 2 Apr 2025 15:44:49 -0500 Subject: [PATCH 08/11] fix S32Percent type-o --- Engine/source/console/typeValidators.cpp | 2 +- Engine/source/console/typeValidators.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/console/typeValidators.cpp b/Engine/source/console/typeValidators.cpp index 7aa62e5d5..c5178a547 100644 --- a/Engine/source/console/typeValidators.cpp +++ b/Engine/source/console/typeValidators.cpp @@ -117,7 +117,7 @@ namespace CommonValidators IRangeValidator NegDefaultInt(-1, S32_MAX); IRangeValidator PositiveInt(0, S32_MAX); IRangeValidator NaturalNumber(1, S32_MAX); - IRangeValidator S32Percent(0.0f, 100); + IRangeValidator S32Percent(0, 100); //see "T3D/gameBase/processList.h" for TickMs = 32 IRangeValidator MSTickRange(32, S32_MAX); diff --git a/Engine/source/console/typeValidators.h b/Engine/source/console/typeValidators.h index e59f3d8e6..76d142692 100644 --- a/Engine/source/console/typeValidators.h +++ b/Engine/source/console/typeValidators.h @@ -131,7 +131,7 @@ namespace CommonValidators extern IRangeValidator NegDefaultInt; extern IRangeValidator PositiveInt; extern IRangeValidator NaturalNumber; - extern FRangeValidator S32Percent; + extern IRangeValidator S32Percent; extern IRangeValidator MSTickRange; extern IRangeValidator S32_8BitCap; extern IRangeValidator S32_16BitCap; From 3b2651c0ab80b1b3fa358a7bcae8e2fe61a15959 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 2 Apr 2025 17:40:37 -0500 Subject: [PATCH 09/11] typofix for bad %client.spawnDataBlock filtering --- .../core/clientServer/scripts/server/connectionToClient.tscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript index ec14ce358..b804ac046 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript @@ -144,7 +144,7 @@ function GameConnectionListener::onSetSpawnObjectTypeComplete( %this, %client ) // a new one could result in an uncontrolled player object. error("Attempting to create a player for a client that already has one!"); } - if ((!isClass(%client.spawnClass)) || (!isClass(%client.spawnDBType)) || (!isObject(%client.spawnDBType))) + if ((!isClass(%client.spawnClass)) || (!isClass(%client.spawnDBType)) || (!isObject(%client.spawnDataBlock))) %this.onSetSpawnObjectTypeFailed(%client, false ); %client.setSpawnPoint(); From 0e78312e95afc2cf0b8e84c557289a415ba4472a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 2 Apr 2025 23:07:09 -0500 Subject: [PATCH 10/11] fix (?) rotation set the behaviour back to prior calcs, plus allow the desired scroll combo to work --- .../source/materials/processedShaderMaterial.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index 22e4b613d..17768ef38 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -942,20 +942,18 @@ void ProcessedShaderMaterial::_setTextureTransforms(const U32 pass) ? waveOffset * M_2PI : mMaterial->mRotPos[pass]; - MatrixF rotationMat(EulerF(0.0f, 0.0f, rotationAngle)); - Point3F pivotPoint( mMaterial->mRotPivotOffset[pass].x, mMaterial->mRotPivotOffset[pass].y, 0.0f); - - MatrixF finalRotationMat(true); - finalRotationMat.setColumn(3, pivotPoint); - finalRotationMat.mul(rotationMat); - finalRotationMat.setColumn(3, -pivotPoint); - + + MatrixF rotationMat = MatrixF(EulerF(0.0, 0.0, rotationAngle), Point3F(0.5, 0.5, 0.0)); + MatrixF test(true); + test.setColumn(3, pivotPoint); + rotationMat.mul(test); + rotationMat.displace(texMat.getPosition()); // Apply final rotation matrix - texMat.mul(finalRotationMat); + texMat = rotationMat; } // --- Scale Animation --- From 2d974cebf5ed6eae23178cb28eb118cd1c3368bc Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 3 Apr 2025 16:52:49 -0500 Subject: [PATCH 11/11] add difFloatPi range validator player: apply to player min/max angle allow fallingspeedthreshold to go negative splashdata: velocity, hieght, acceleration and startradius can all be negative wrap material animation range from -1 to 1 --- Engine/source/T3D/fx/particleEmitter.cpp | 2 +- Engine/source/T3D/fx/splash.cpp | 8 ++++---- Engine/source/T3D/player.cpp | 6 +++--- Engine/source/console/typeValidators.cpp | 1 + Engine/source/console/typeValidators.h | 1 + Engine/source/materials/materialDefinition.cpp | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Engine/source/T3D/fx/particleEmitter.cpp b/Engine/source/T3D/fx/particleEmitter.cpp index 1817e51f0..c9887f619 100644 --- a/Engine/source/T3D/fx/particleEmitter.cpp +++ b/Engine/source/T3D/fx/particleEmitter.cpp @@ -197,7 +197,7 @@ EndImplementEnumType; IRangeValidator ejectPeriodIValidator(1, 2047); IRangeValidator periodVarianceIValidator(0, 2047); -FRangeValidator ejectionFValidator(0.f, 655.35f); +FRangeValidator ejectionFValidator(-655.35f, 655.35f); FRangeValidator velVarianceFValidator(0.f, 163.83f); //----------------------------------------------------------------------------- diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index fbe43fb03..68bbee0c3 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -127,9 +127,9 @@ void SplashData::initPersistFields() addFieldV("lifetimeVariance", TypeRangedS32, Offset(lifetimeVariance, SplashData), &CommonValidators::PositiveInt, "Time variance for lifetimeMS.\n"); addFieldV("width", TypeRangedF32, Offset(width, SplashData), &CommonValidators::PositiveFloat, "Width for the X and Y coordinates to create this effect within."); addFieldV("numSegments", TypeRangedS32, Offset(numSegments, SplashData), &CommonValidators::NaturalNumber, "Number of ejection points in the splash ring.\n"); - addFieldV("velocity", TypeRangedF32, Offset(velocity, SplashData), &CommonValidators::PositiveFloat, "Velocity for the splash effect to travel.\n"); - addFieldV("height", TypeRangedF32, Offset(height, SplashData), &CommonValidators::PositiveFloat, "Height for the splash to reach.\n"); - addFieldV("acceleration", TypeRangedF32, Offset(acceleration, SplashData), &CommonValidators::PositiveFloat, "Constant acceleration value to place upon the splash effect.\n"); + addFieldV("velocity", TypeRangedF32, Offset(velocity, SplashData), &CommonValidators::F32Range, "Velocity for the splash effect to travel.\n"); + addFieldV("height", TypeRangedF32, Offset(height, SplashData), &CommonValidators::F32Range, "Height for the splash to reach.\n"); + addFieldV("acceleration", TypeRangedF32, Offset(acceleration, SplashData), &CommonValidators::F32Range, "Constant acceleration value to place upon the splash effect.\n"); addFieldV("times", TypeRangedF32, Offset(times, SplashData), &CommonValidators::NormalizedFloat, NUM_TIME_KEYS, "Times to transition through the splash effect. Up to 4 allowed. Values are 0.0 - 1.0, and corrispond to the life of the particle where 0 is first created and 1 is end of lifespace.\n" ); addField("colors", TypeColorF, Offset(colors, SplashData), NUM_TIME_KEYS, "Color values to set the splash effect, rgba. Up to 4 allowed. Will transition through colors based on values set in the times value. Example: colors[0] = \"0.6 1.0 1.0 0.5\".\n" ); @@ -140,7 +140,7 @@ void SplashData::initPersistFields() addFieldV("ejectionFreq", TypeRangedF32, Offset(ejectionFreq, SplashData), &CommonValidators::PositiveFloat, "Frequency in which to emit splash rings.\n"); addFieldV("ejectionAngle", TypeRangedF32, Offset(ejectionAngle, SplashData), &CommonValidators::DegreeRange, "Rotational angle to create a splash ring.\n"); addFieldV("ringLifetime", TypeRangedF32, Offset(ringLifetime, SplashData), &CommonValidators::PositiveFloat, "Lifetime, in milliseconds, for a splash ring.\n"); - addFieldV("startRadius", TypeRangedF32, Offset(startRadius, SplashData), &CommonValidators::PositiveFloat, "Starting radius size of a splash ring.\n"); + addFieldV("startRadius", TypeRangedF32, Offset(startRadius, SplashData), &CommonValidators::F32Range, "Starting radius size of a splash ring.\n"); addField("explosion", TYPEID< ExplosionData >(), Offset(explosion, SplashData), "ExplosionData object to create at the creation position of this splash effect.\n"); Parent::initPersistFields(); diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index e474ec7de..801df58df 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -726,10 +726,10 @@ void PlayerData::initPersistFields() addField( "firstPersonShadows", TypeBool, Offset(firstPersonShadows, PlayerData), "@brief Forces shadows to be rendered in first person when renderFirstPerson is disabled. Defaults to false.\n\n" ); - addFieldV( "minLookAngle", TypeRangedF32, Offset(minLookAngle, PlayerData), &CommonValidators::PositiveFloat, + addFieldV( "minLookAngle", TypeRangedF32, Offset(minLookAngle, PlayerData), &CommonValidators::DirFloatPi, "@brief Lowest angle (in radians) the player can look.\n\n" "@note An angle of zero is straight ahead, with positive up and negative down." ); - addFieldV( "maxLookAngle", TypeRangedF32, Offset(maxLookAngle, PlayerData), &CommonValidators::PositiveFloat, + addFieldV( "maxLookAngle", TypeRangedF32, Offset(maxLookAngle, PlayerData), &CommonValidators::DirFloatPi, "@brief Highest angle (in radians) the player can look.\n\n" "@note An angle of zero is straight ahead, with positive up and negative down." ); addFieldV( "maxFreelookAngle", TypeRangedF32, Offset(maxFreelookAngle, PlayerData), &CommonValidators::PositiveFloat, @@ -948,7 +948,7 @@ void PlayerData::initPersistFields() addGroup( "Falling" ); - addFieldV( "fallingSpeedThreshold", TypeRangedF32, Offset(fallingSpeedThreshold, PlayerData), &CommonValidators::PositiveFloat, + addFieldV( "fallingSpeedThreshold", TypeRangedF32, Offset(fallingSpeedThreshold, PlayerData), &CommonValidators::F32Range, "@brief Downward speed at which we consider the player falling.\n\n" ); addFieldV( "recoverDelay", TypeRangedS32, Offset(recoverDelay, PlayerData), &CommonValidators::PositiveInt, diff --git a/Engine/source/console/typeValidators.cpp b/Engine/source/console/typeValidators.cpp index c5178a547..d3a04d050 100644 --- a/Engine/source/console/typeValidators.cpp +++ b/Engine/source/console/typeValidators.cpp @@ -101,6 +101,7 @@ namespace CommonValidators { FRangeValidator F32Range(F32_MIN_EX, F32_MAX); FRangeValidator DirFloat(-1.0f, 1.0f); + FRangeValidator DirFloatPi(-M_PI_F, M_PI_F); FRangeValidator NegDefaultF32(-1.0f, F32_MAX); FRangeValidator PositiveFloat(0.0f, F32_MAX); FRangeValidator PositiveNonZeroFloat((F32)POINT_EPSILON, F32_MAX); diff --git a/Engine/source/console/typeValidators.h b/Engine/source/console/typeValidators.h index 76d142692..78c9e4bdb 100644 --- a/Engine/source/console/typeValidators.h +++ b/Engine/source/console/typeValidators.h @@ -116,6 +116,7 @@ namespace CommonValidators // Floats extern FRangeValidator F32Range; extern FRangeValidator DirFloat; + extern FRangeValidator DirFloatPi; extern FRangeValidator NegDefaultF32; extern FRangeValidator PositiveFloat; extern FRangeValidator PositiveNonZeroFloat; diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index 076f39cd6..02f15ea57 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -638,8 +638,8 @@ void Material::updateTimeBasedParams() for (U32 i = 0; i < MAX_STAGES; i++) { mScrollOffset[i] += mScrollDir[i] * mScrollSpeed[i] * dt; - mScrollOffset[i].x = mWrapF(mScrollOffset[i].x, 0.0, 1.0); - mScrollOffset[i].y = mWrapF(mScrollOffset[i].y, 0.0, 1.0); + mScrollOffset[i].x = mWrapF(mScrollOffset[i].x, -1.0, 1.0); + mScrollOffset[i].y = mWrapF(mScrollOffset[i].y, -1.0, 1.0); mRotPos[i] = mWrapF((mRotPos[i] + (mRotSpeed[i] * dt)), 0.0, 360.0); mWavePos[i] = mWrapF((mWavePos[i] + (mWaveFreq[i] * dt)), 0.0, 1.0); }