Merge branch 'development' of https://github.com/TorqueGameEngines/Torque3D into classPrototypingPresenter

This commit is contained in:
AzaezelX 2023-12-23 21:29:17 -06:00
commit 428f22d728
23 changed files with 310 additions and 179 deletions

View file

@ -66,6 +66,10 @@ uniform vec4 albedo;
#define DEBUGVIZ_CONTRIB 0
#endif
#ifndef CAPTURE_LIGHT_FLOOR
#define CAPTURE_LIGHT_FLOOR 0.04
#endif
vec3 getDistanceVectorToPlane( vec3 origin, vec3 direction, vec4 plane )
{
float denum = dot( plane.xyz, direction.xyz );
@ -234,7 +238,7 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
vec3 Fr = D * F * Vis;
#if CAPTURING == 1
return saturate(mix(Fd + Fr,surface.f0,surface.metalness));
return mix(Fd + Fr, surface.baseColor.rgb, surface.metalness);
#else
return Fd + Fr;
#endif
@ -243,23 +247,38 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
vec3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float shadow)
{
vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity, 0.0f);
#if CAPTURING == 1
float lightfloor = CAPTURE_LIGHT_FLOOR;
#else
float lightfloor = 0.0;
#endif
vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity, lightfloor);
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
}
vec3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, float shadow)
{
#if CAPTURING == 1
float lightfloor = CAPTURE_LIGHT_FLOOR;
#else
float lightfloor = 0.0;
#endif
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity * attenuation, 0.0f);
vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity * attenuation, lightfloor);
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
}
vec3 getSpotlight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, vec3 lightDir, vec2 lightSpotParams, float shadow)
{
#if CAPTURING == 1
float lightfloor = CAPTURE_LIGHT_FLOOR;
#else
float lightfloor = 0.0;
#endif
float attenuation = 1.0f;
attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
vec3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, 0.0f) ;
vec3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, lightfloor);
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
}

View file

@ -68,6 +68,10 @@ uniform float4 albedo;
#define DEBUGVIZ_CONTRIB 0
#endif
#ifndef CAPTURE_LIGHT_FLOOR
#define CAPTURE_LIGHT_FLOOR 0.04
#endif
inline float3 getDistanceVectorToPlane( float3 origin, float3 direction, float4 plane )
{
float denum = dot( plane.xyz, direction.xyz );
@ -235,7 +239,7 @@ float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
float3 Fr = D * F * Vis;
#if CAPTURING == 1
return saturate(lerp(Fd + Fr,surface.f0,surface.metalness));
return lerp(Fd + Fr,surface.baseColor.rgb,surface.metalness);
#else
return Fd + Fr;
#endif
@ -244,25 +248,41 @@ float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
float3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float shadow)
{
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity, 0.0f) ;
#if CAPTURING == 1
float lightfloor = CAPTURE_LIGHT_FLOOR;
#else
float lightfloor = 0.0;
#endif
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity, lightfloor) ;
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
}
float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float shadow)
{
#if CAPTURING == 1
float lightfloor = CAPTURE_LIGHT_FLOOR;
#else
float lightfloor = 0.0;
#endif
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, 0.0f) ;
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, lightfloor) ;
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
}
float3 getSpotlight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float3 lightDir, float2 lightSpotParams, float shadow)
{
#if CAPTURING == 1
float lightfloor = CAPTURE_LIGHT_FLOOR;
#else
float lightfloor = 0.0;
#endif
float attenuation = 1.0f;
attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, 0.0f) ;
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, lightfloor) ;
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
}
float computeSpecOcclusion( float NdotV , float AO , float roughness )
{
return saturate (pow( abs(NdotV + AO) , exp2 ( -16.0f * roughness - 1.0f )) - 1.0f + AO );

View file

@ -86,7 +86,7 @@ vec3 ImportanceSampleGGX(vec2 Xi, vec3 N)
vec3 prefilterEnvMap(vec3 R)
{
int sampleCount = resolution*2;
int sampleCount = 1024;
vec3 N = R;
vec3 V = R;
float totalWeight = 0.0;
@ -107,7 +107,7 @@ vec3 prefilterEnvMap(vec3 R)
float HdotV = max(dot(H, V), 0.0);
float pdf = D * NdotH / (4.0 * HdotV) + 0.0001;
float saTexel = 4.0 * M_PI_F / float(6.0 * sampleCount * sampleCount);
float saTexel = 4.0 * M_PI_F / float(6.0 * resolution * resolution);
float saSample = 1.0 / (float(sampleCount) * pdf + 0.0001);
float mipLevel = roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel);

View file

@ -88,7 +88,7 @@ float3 ImportanceSampleGGX(float2 Xi, float3 N)
float4 prefilterEnvMap(float3 R)
{
int sampleCount = resolution*2;
int sampleCount = 1024;
float3 N = R;
float3 V = R;
float totalWeight = 0.0;
@ -109,7 +109,7 @@ float4 prefilterEnvMap(float3 R)
float HdotV = max(dot(H, V), 0.0);
float pdf = D * NdotH / (4.0 * HdotV) + 0.0001;
float saTexel = 4.0 * M_PI_F / (6.0 * sampleCount * sampleCount);
float saTexel = 4.0 * M_PI_F / (6.0 * resolution * resolution);
float saSample = 1.0 / (float(sampleCount) * pdf + 0.0001);
float mipLevel = roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel);

View file

@ -20,6 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//command variable feilds. do not trip them by unsetting or resetting these
$undoIgnoreList = "docsURL EditPosOffset Bake EditPostEffects selectAll sync Prototype";
//---------------------------------------------------------------------------------------------
@ -451,6 +453,15 @@ function GenericUndoAction::undo(%this)
for(%j = 0; %j < getWordCount(%fieldNames); %j++)
{
%field = getWord(%fieldNames, %j);
%skip = false;
for(%k = 0; %k < getWordCount($undoIgnoreList); %k++)
{
if(%field $= getWord(%fieldNames, %k)) //specialty field, we can't 'undo' it
%skip = true;
}
if (%skip)
continue;
%object.setFieldValue(%field, %this.fieldValues[%object, %field]);
}
// null out the fields in the null list
@ -469,7 +480,6 @@ function GenericUndoAction::undo(%this)
function GenericUndoAction::redo(%this)
{
// set the objects to the new values
// set the objects to the new values
// scan through our objects
%objectList = %this.objectIdList;
@ -481,6 +491,15 @@ function GenericUndoAction::redo(%this)
for(%j = 0; %j < getWordCount(%fieldNames); %j++)
{
%field = getWord(%fieldNames, %j);
%skip = false;
for(%k = 0; %k < getWordCount($undoIgnoreList); %k++)
{
if(%field $= getWord(%fieldNames, %k)) //specialty field, we can't 'redo' it
%skip = true;
}
if (%skip)
continue;
%object.setFieldValue(%field, %this.newFieldValues[%object, %field]);
}
// null out the fields in the null list

View file

@ -286,10 +286,7 @@ function doEditorResetDefaultLevel()
function EditorSaveMissionMenu()
{
if(EditorGui.saveAs)
AssetBrowser.setupCreateNewAsset("LevelAsset", AssetBrowser.selectedModule, "EditorSaveMissionAs");
else
EditorSaveMission();
EditorSaveMission();
}
function EditorSaveMission()
@ -387,6 +384,8 @@ function EditorSaveMission()
function EditorSaveMissionAs( %levelAsset )
{
EditorGui.saveAs = true;
AssetBrowser.setupCreateNewAsset("LevelAsset", AssetBrowser.selectedModule,"");
// If we didn't get passed a new mission name then
// prompt the user for one.
if ( %levelAsset $= "" )

View file

@ -142,7 +142,7 @@ function EditorGui::buildMenus(%this)
%fileMenu.appendItem("Open Recent" TAB RecentLevelsPopupMenu);
%fileMenu.appendItem("-");
%fileMenu.appendItem("Save Level" TAB %cmdCtrl SPC "S" TAB "EditorSaveMissionMenu();");
%fileMenu.appendItem("Save Level As..." TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule, \"EditorSaveMissionAs\");");
%fileMenu.appendItem("Save Level As..." TAB "" TAB "EditorSaveMissionAs();");
%fileMenu.appendItem("-");
%fileMenu.appendItem("Save Current Scene as Editor Default" TAB "" TAB "EditorSaveAsDefaultLevel();");
%fileMenu.appendItem("Reset Editor Default" TAB "" TAB "EditorResetDefaultLevel();");