Corrected profile for GameObjectAsset type field button

Initial implementation of changeable TSStatic materials via material slots and drag and drop of material assets onto world editor from AB
Updated Volumetric Fog to support ShapeAsset for it's model data
Added cmake option to hide literal filename fields if the class supports asset fields for the same input
Added light viz modes to see diffuse, specular and detail lighting modes(currently just sun)
New raycast console function to return back material of hit object
Moved GameObject logic to SceneObject and started fixing up of editor behavior to allow any SceneObject to be converted into a GO, along with all supported behavior such as instance-template management and spawning GO via drag-and-drop from AB
Fixed inspector field tooltip text to be positioned in inspector footer properly again
Drag and drop of shape asset attempts to drop at raycast position now, instead of just at the camera ray position
This commit is contained in:
Areloch 2019-12-05 20:42:47 -06:00
parent 551df5e92a
commit 09c651c26d
25 changed files with 572 additions and 35 deletions

View file

@ -189,6 +189,38 @@ float3 BRDF_GetDiffuse(in Surface surface, in SurfaceToLight surfaceToLight)
return diffuse;
}
float3 BRDF_GetDebugSpecular(in Surface surface, in SurfaceToLight surfaceToLight)
{
float3 neutralColor = float3(0.5,0.5,0.5);
float3 f0 = lerp(0.04.xxx, neutralColor, surface.metalness);
float f90 = saturate(50.0 * dot(f0, 0.33));
float3 F = F_Schlick(f0, f90, surfaceToLight.HdotV);
float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.roughness_brdf);
float D = D_GGX(surfaceToLight.NdotH, surface.roughness_brdf);
float3 Fr = D * F * Vis / M_PI_F;
return Fr;
}
float3 BRDF_GetDebugDiffuse(in Surface surface, in SurfaceToLight surfaceToLight)
{
float3 neutralColor = float3(0.5,0.5,0.5);
//getting some banding with disney method, using lambert instead - todo futher testing
float Fd = 1.0 / M_PI_F;
float3 f0 = lerp(0.04.xxx, neutralColor, surface.metalness);
float f90 = saturate(50.0 * dot(f0, 0.33));
float3 F = F_Schlick(f0, f90, surface.NdotV);
//energy conservation - remove this if reverting back to disney method
float3 kD = 1.0.xxx - F;
kD *= 1.0 - surface.metalness;
float3 diffuse = kD * neutralColor * Fd;
return diffuse;
}
//attenuations functions from "moving frostbite to pbr paper"
//https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float smoothDistanceAtt ( float squaredDistance , float invSqrAttRadius )

View file

@ -230,6 +230,31 @@ float4 main(FarFrustumQuadConnectP IN) : SV_TARGET
#endif //NO_SHADOW
#ifdef DIFFUSE_LIGHT_VIZ
float3 factor = lightingColor.rgb * max(surfaceToLight.NdotL, 0) * shadow * lightBrightness;
float3 diffuse = BRDF_GetDebugDiffuse(surface,surfaceToLight) * factor;
float3 final = max(0.0f, diffuse);
return float4(final, 0);
#endif
#ifdef SPECULAR_LIGHT_VIZ
float3 factor = lightingColor.rgb * max(surfaceToLight.NdotL, 0) * shadow * lightBrightness;
float3 spec = BRDF_GetDebugSpecular(surface, surfaceToLight) * factor;
float3 final = max(0.0f, factor);
return float4(final, 0);
#endif
#ifdef DETAIL_LIGHTING_VIZ
float3 factor = lightingColor.rgb * max(surfaceToLight.NdotL, 0) * shadow * lightBrightness;
float3 diffuse = BRDF_GetDebugDiffuse(surface,surfaceToLight) * factor;
float3 spec = BRDF_GetDebugSpecular(surface,surfaceToLight) * factor;
float3 final = max(0.0f, diffuse + spec);
return float4(final,0);
#endif
//get directional light contribution
float3 lighting = getDirectionalLight(surface, surfaceToLight, lightingColor.rgb, lightBrightness, shadow);

View file

@ -59,7 +59,6 @@
profile = "ToolsGuiButtonProfile";
visible = "1";
active = "1";
command = "AssetBrowser_importAssetWindow.ImportAssets();";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "0";

View file

@ -123,6 +123,34 @@ function AssetBrowser::dragAndDropGameObjectAsset(%this, %assetDef, %dropTarget)
}
}
function AssetBrowser::onGameObjectAssetEditorDropped(%this, %assetDef, %position)
{
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
%targetPosition = EWorldEditor.unproject(%position SPC 1000);
%camPos = LocalClientConnection.camera.getPosition();
%rayResult = containerRayCast(%camPos, %targetPosition, -1);
%pos = EWCreatorWindow.getCreateObjectPosition();
if(%rayResult != 0)
{
%pos = getWords(%rayResult, 1, 3);
}
%gameObject = %assetDef.createObject();
getScene(0).add(%gameObject);
%gameObject.position = %pos;
EWorldEditor.clearSelection();
EWorldEditor.selectObject(%gameObject);
EWorldEditor.isDirty = true;
}
function AssetBrowser::renameGameObjectAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
{
%oldScriptFilePath = %assetDef.scriptFile;

View file

@ -452,6 +452,32 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData)
%previewData.tooltip = %assetDef.friendlyName @ "\n" @ %assetDef;
}
function AssetBrowser::onMaterialAssetEditorDropped(%this, %assetDef, %position)
{
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
//first, see if we hit a static shape
%mask = $TypeMasks::StaticObjectType | $TypeMasks::StaticShapeObjectType | $TypeMasks::TerrainObjectType;
%targetPosition = EWorldEditor.unproject(%position SPC 1000);
%camPos = LocalClientConnection.camera.getPosition();
%rayResult = materialRayCast(%camPos, %targetPosition, -1, 0, false);
%validTarget = false;
if(%rayResult != 0)
{
%obj = getWord(%rayResult, 0);
if(%obj.isMemberOfClass("TSStatic"))
{
//oh, cool a valid target!
%obj.materialSlot0 = %assetDef.getAssetId();
echo("MaterialSlot0 set to " @ %assetDef.getAssetId());
}
}
EWorldEditor.isDirty = true;
}
function GuiInspectorTypeMaterialAssetPtr::onControlDropped( %this, %payload, %position )
{
Canvas.popDialog(EditorDragAndDropLayer);

View file

@ -307,7 +307,7 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData)
%previewData.assetName = %assetDef.assetName;
%previewData.assetPath = %assetDef.fileName;
%previewData.previewImage = fileName;
%previewData.previewImage = %assetDef.fileName;
%previewData.assetFriendlyName = %assetDef.assetName;
%previewData.assetDesc = %assetDef.description;
@ -317,11 +317,20 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData)
function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
{
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
%assetId = %assetDef.getAssetId();
%targetPosition = EWorldEditor.unproject(%position SPC 1000);
%camPos = LocalClientConnection.camera.getPosition();
%rayResult = containerRayCast(%camPos, %targetPosition, -1);
%pos = EWCreatorWindow.getCreateObjectPosition();
if(%rayResult != 0)
{
%pos = getWords(%rayResult, 1, 3);
}
%assetId = %assetDef.getAssetId();
%newStatic = new TSStatic()
{
position = %pos;
@ -332,8 +341,9 @@ function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
EWorldEditor.clearSelection();
EWorldEditor.selectObject(%newStatic);
EWorldEditor.isDirty = true;
}
function GuiInspectorTypeShapeAssetPtr::onControlDropped( %this, %payload, %position )

View file

@ -126,7 +126,7 @@
Profile = "GuiInspectorFieldInfoMLTextProfile";
HorizSizing = "width";
VertSizing = "top";
Position = "6 205";
Position = 5 SPC EWInspectorWindow.extent.y - 40;
Extent = "197 35";
MinExtent = "8 2";
canSave = "1";

View file

@ -63,6 +63,7 @@ function EditorGui::init(%this)
{
EWTreeWindow.position = %this.extent.x - EWTreeWindow.Extent.x SPC EditorGuiToolbar.extent.y;
EWTreeWindow.extent = EWTreeWindow.extent.x SPC %this.extent.y - EditorGuiToolbar.extent.y - EditorGuiStatusBar.extent.y - 25;
FieldInfoControl.position = 5 SPC EWInspectorWindow.extent.y - 40;
}
}
}
@ -81,6 +82,7 @@ function EditorGui::init(%this)
{
EWInspectorWindow.position = EWTreeWindow.position.x SPC EWTreeWindow.extent.y;
EWInspectorWindow.extent = EWTreeWindow.extent.x SPC EWTreeWindow.extent.y;
FieldInfoControl.position = 5 SPC EWInspectorWindow.extent.y - 40;
}
}
}
@ -1455,6 +1457,8 @@ function EWorldEditor::onResize(%this, %newPosition, %newExtent)
EWInspectorWindow.resize(%inspPos.x, %inspPos.y, %inspExt.x, %inspExt.y);
}
FieldInfoControl.position = 5 SPC EWInspectorWindow.extent.y - 40;
}
//-----------------------------------------------------------------------------

View file

@ -379,7 +379,7 @@ function setLightingMode(%mode)
$Shadows::disable = true;
EVisibilityLightingModesOptions.checkItem(2, true);
case "DetailLighting":
//$Viz_ColorblindnessModeVar = "0";
$AL::DetailLightingViz = true;
EVisibilityLightingModesOptions.checkItem(3, true);
case "LightingOnly":
$Light::renderReflectionProbes = false;
@ -388,6 +388,8 @@ function setLightingMode(%mode)
$Light::disableLights = true;
EVisibilityLightingModesOptions.checkItem(5, true);
}
reInitMaterials();
}
function resetLightingMode()
@ -400,6 +402,7 @@ function resetLightingMode()
$Light::renderReflectionProbes = true;
$Light::disableLights = false;
$Shadows::disable = false;
$AL::DetailLightingViz = false;
EVisibilityLightingModesOptions.checkItem(0, true);
}
@ -427,6 +430,48 @@ function disableLightFrustumViz()
$Light::renderLightFrustums = false;
}
function toggleLightViz(%mode)
{
setLightingMode("Lit");
if($AL::DiffuseLightViz == 1)
%lastMode = "Diffuse";
else if($AL::SpecularLightViz == 1)
%lastMode = "Specular";
$AL::DiffuseLightViz = 0;
$AL::SpecularLightViz = 0;
EVisibilityLightsOptions.checkItem(2, false);
EVisibilityLightsOptions.checkItem(3, false);
if(%mode $= %lastMode)
{
//forces the forward materials to get dis viz properly
reInitMaterials();
return;
}
switch$(%mode)
{
case "Diffuse":
$AL::DiffuseLightViz = 1;
EVisibilityLightsOptions.checkItem(2, true);
case "Specular":
$AL::SpecularLightViz = 1;
EVisibilityLightsOptions.checkItem(3, true);
}
//forces the forward materials to get dis viz properly
reInitMaterials();
}
function disableLightViz()
{
toggleLightViz(-1);
}
//Lighting Viz
singleton Material( Viz_DetailLightingMat )
{

View file

@ -31,6 +31,7 @@ function toggleProbeViz(%mode)
else
{
setLightingMode("ReflectionsOnly");
toggleLightViz(-1);
}
switch$(%mode)

View file

@ -132,13 +132,10 @@ function setupEditorVisibilityMenu()
item[ 0 ] = "Show Light Frustums" TAB "" TAB "toggleLightFrustumViz();";
item[ 1 ] = "Show Shadowmap Cascades" TAB "" TAB "togglePSSMDebugViz();";
item[ 2 ] = "Show Specular Light" TAB "" TAB "";
item[ 3 ] = "Show Diffuse Light" TAB "" TAB "";
item[ 2 ] = "Show Diffuse Light" TAB "" TAB "toggleLightViz(\"Diffuse\");";
item[ 3 ] = "Show Specular Light" TAB "" TAB "toggleLightViz(\"Specular\");";
};
%lightspopup.enableItem(2, false);
%lightspopup.enableItem(3, false);
//
//Probes
%probespopup = new PopupMenu(EVisibilityProbesOptions)