Updating BaseGame to work with PBR, and a PBR example module

This commit is contained in:
Areloch 2019-05-08 01:27:51 -05:00
parent e83ec69292
commit cedbd387d9
98 changed files with 6762 additions and 2889 deletions

View file

@ -877,6 +877,24 @@ function ObjectBuilderGui::buildParticleSimulation(%this)
%this.process();
}
function ObjectBuilderGui::buildReflectionProbe(%this)
{
%this.objectClassName = "ReflectionProbe";
%this.process();
%defaultPath = filePath($Server::MissionFile) @ "/" @ fileBase($Server::MissionFile) @ "/probes/";
%this.addField("reflectionPath", "TypeFilepath", "reflectionPath", %defaultPath);
}
function ObjectBuilderGui::buildSkylight(%this)
{
%this.objectClassName = "Skylight";
%this.process();
%defaultPath = filePath($Server::MissionFile) @ "/" @ fileBase($Server::MissionFile) @ "/probes/";
%this.addField("reflectionPath", "TypeFilepath", "reflectionPath", %defaultPath);
}
//------------------------------------------------------------------------------
// Mission
//------------------------------------------------------------------------------

View file

@ -0,0 +1,192 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(ProbeBakeDlg) {
position = "0 0";
extent = "1024 768";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
new GuiWindowCtrl() {
text = "Update Environment Probes";
resizeWidth = "0";
resizeHeight = "0";
canMove = "1";
canClose = "1";
canMinimize = "0";
canMaximize = "0";
canCollapse = "0";
closeCommand = "Canvas.popDialog(ProbeBakeDlg);";
edgeSnap = "0";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "392 314";
extent = "270 164";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiWindowProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiTextCtrl() {
text = "Probe Resolution";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "11 32";
extent = "91 13";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiPopUpMenuCtrl(ProbeBakeDlg_ProbeResList) {
maxPopupHeight = "200";
sbUsesNAColor = "0";
reverseTextList = "0";
bitmapBounds = "16 16";
text = "64";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "103 29";
extent = "157 19";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiPopUpMenuProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "Number of bake iterations";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "11 56";
extent = "129 13";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextEditCtrl(ProbeBakeDlg_NumIterTxt) {
historySize = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
text = "1";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "150 53";
extent = "108 18";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiTextEditProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiButtonCtrl(ProbeBakeDlg_RunBake) {
text = "Update Probes";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "68 120";
extent = "140 30";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiProgressCtrl(ProbeBakeDlg_Progress) {
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "8 80";
extent = "251 25";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiProgressProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
//--- OBJECT WRITE END ---

View file

@ -44,6 +44,7 @@ function initializeWorldEditor()
exec("./gui/SelectObjectsWindow.ed.gui");
exec("./gui/ProceduralTerrainPainterGui.gui" );
exec("./gui/shadowViz.gui" );
exec("./gui/probeBakeDlg.gui" );
// Load Scripts.
exec("./scripts/menus.ed.cs");
@ -66,6 +67,7 @@ function initializeWorldEditor()
exec("./scripts/cameraCommands.ed.cs");
exec("./scripts/lightViz.cs");
exec("./scripts/shadowViz.cs");
exec("./scripts/probeBake.ed.cs");
// Load Custom Editors
loadDirectory(expandFilename("./scripts/editors"));
@ -120,16 +122,24 @@ function initializeWorldEditor()
EVisibility.addOption( "Debug Render: Light Frustums", "$Light::renderLightFrustums", "" );
EVisibility.addOption( "Debug Render: Bounding Boxes", "$Scene::renderBoundingBoxes", "" );
EVisibility.addOption( "Debug Render: Physics World", "$PhysicsWorld::render", "togglePhysicsDebugViz" );
EVisibility.addOption( "Debug Render: Reflection Probes", "$Light::renderReflectionProbes", "" );
EVisibility.addOption( "Debug Render: Probe Previews", "$Light::renderPreviewProbes", "" );
EVisibility.addOption( "AL: Disable Shadows", "$Shadows::disable", "" );
EVisibility.addOption( "AL: Light Color Viz", "$AL_LightColorVisualizeVar", "toggleLightColorViz" );
EVisibility.addOption( "AL: Light Specular Viz", "$AL_LightSpecularVisualizeVar", "toggleLightSpecularViz" );
EVisibility.addOption( "AL: Diffuse Lighting Viz", "$AL_LightColorVisualizeVar", "toggleLightColorViz" );
EVisibility.addOption( "AL: Specular Lighting Viz", "$AL_LightSpecularVisualizeVar", "toggleLightSpecularViz" );
EVisibility.addOption( "AL: Normals Viz", "$AL_NormalsVisualizeVar", "toggleNormalsViz" );
EVisibility.addOption( "AL: Depth Viz", "$AL_DepthVisualizeVar", "toggleDepthViz" );
EVisibility.addOption( "AL: Color Buffer", "$AL_ColorBufferShaderVar", "toggleColorBufferViz" );
EVisibility.addOption( "AL: Spec Map", "$AL_SpecMapShaderVar", "toggleSpecMapViz");
EVisibility.addOption( "AL: Spec Map(Rough)", "$AL_RoughMapShaderVar", "toggleRoughMapViz");
EVisibility.addOption( "AL: Spec Map(Metal)", "$AL_MetalMapShaderVar", "toggleMetalMapViz");
EVisibility.addOption( "AL: Backbuffer", "$AL_BackbufferVisualizeVar", "toggleBackbufferViz" );
EVisibility.addOption( "AL: Glow Buffer", "$AL_GlowVisualizeVar", "toggleGlowViz" );
EVisibility.addOption( "AL: PSSM Cascade Viz", "$AL::PSSMDebugRender", "" );
EVisibility.addOption( "Probes: Attenuation", "$Probes::showAttenuation", "" );
EVisibility.addOption( "Probes: Specular Cubemaps", "$Probes::showSpecularCubemaps", "" );
EVisibility.addOption( "Probes: Diffuse Cubemaps", "$Probes::showDiffuseCubemaps", "" );
EVisibility.addOption( "Probes: Contribution", "$Probes::showProbeContrib", "" );
EVisibility.addOption( "Frustum Lock", "$Scene::lockCull", "" );
EVisibility.addOption( "Disable Zone Culling", "$Scene::disableZoneCulling", "" );
EVisibility.addOption( "Disable Terrain Occlusion", "$Scene::disableTerrainOcclusion", "" );

View file

@ -55,6 +55,11 @@ function EWCreatorWindow::init( %this )
%this.registerMissionObject( "PointLight", "Point Light" );
%this.registerMissionObject( "SpotLight", "Spot Light" );
%this.registerMissionObject( "BoxEnvironmentProbe", "Box Environment Probe" );
%this.registerMissionObject( "SphereEnvironmentProbe", "Sphere Environment Probe" );
%this.registerMissionObject( "Skylight", "Skylight" );
%this.registerMissionObject( "GroundCover", "Ground Cover" );
%this.registerMissionObject( "TerrainBlock", "Terrain Block" );
%this.registerMissionObject( "GroundPlane", "Ground Plane" );

View file

@ -294,6 +294,28 @@ function TerrainMaterialDlg::changeNormal( %this )
//-----------------------------------------------------------------------------
function TerrainMaterialDlg::changecomposite( %this )
{
%ctrl = %this-->compositeTexCtrl;
%file = %ctrl.bitmap;
if( getSubStr( %file, 0 , 6 ) $= "tools/" )
%file = "";
%file = TerrainMaterialDlg._selectTextureFileDialog( %file );
if( %file $= "" )
{
if( %ctrl.bitmap !$= "" )
%file = %ctrl.bitmap;
else
%file = "tools/materialEditor/gui/unknownImage";
}
%file = makeRelativePath( %file, getMainDotCsDir() );
%ctrl.setBitmap( %file );
}
//-----------------------------------------------------------------------------
function TerrainMaterialDlg::newMat( %this )
{
// Create a unique material name.
@ -394,7 +416,12 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat )
%this-->normTexCtrl.setBitmap( "tools/materialEditor/gui/unknownImage" );
}else{
%this-->normTexCtrl.setBitmap( %mat.normalMap );
}
}
if (%mat.compositeMap $= ""){
%this-->compositeTexCtrl.setBitmap( "tools/materialEditor/gui/unknownImage" );
}else{
%this-->compositeTexCtrl.setBitmap( %mat.compositeMap );
}
%this-->detSizeCtrl.setText( %mat.detailSize );
%this-->baseSizeCtrl.setText( %mat.diffuseSize );
%this-->detStrengthCtrl.setText( %mat.detailStrength );
@ -448,6 +475,11 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
}else{
%newMacro = %this-->macroTexCtrl.bitmap;
}
if (%this-->compositeTexCtrl.bitmap $= "tools/materialEditor/gui/unknownImage"){
%newComposite = "";
}else{
%newComposite = %this-->compositeTexCtrl.bitmap;
}
%detailSize = %this-->detSizeCtrl.getText();
%diffuseSize = %this-->baseSizeCtrl.getText();
%detailStrength = %this-->detStrengthCtrl.getText();
@ -466,6 +498,7 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%mat.diffuseMap $= %newDiffuse &&
%mat.normalMap $= %newNormal &&
%mat.detailMap $= %newDetail &&
%mat.compositeMap $= %newComposite &&
%mat.macroMap $= %newMacro &&
%mat.detailSize == %detailSize &&
%mat.diffuseSize == %diffuseSize &&
@ -497,7 +530,8 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
}
%mat.diffuseMap = %newDiffuse;
%mat.normalMap = %newNormal;
%mat.normalMap = %newNormal;
%mat.compositeMap = %newComposite;
%mat.detailMap = %newDetail;
%mat.macroMap = %newMacro;
%mat.detailSize = %detailSize;
@ -544,6 +578,7 @@ function TerrainMaterialDlg::snapshotMaterials( %this )
diffuseMap = %mat.diffuseMap;
normalMap = %mat.normalMap;
detailMap = %mat.detailMap;
compositeMap = %mat.compositeMap;
macroMap = %mat.macroMap;
detailSize = %mat.detailSize;
diffuseSize = %mat.diffuseSize;
@ -578,6 +613,7 @@ function TerrainMaterialDlg::restoreMaterials( %this )
%mat.diffuseMap = %obj.diffuseMap;
%mat.normalMap = %obj.normalMap;
%mat.detailMap = %obj.detailMap;
%mat.compositeMap = %obj.compositeMap;
%mat.macroMap = %obj.macroMap;
%mat.detailSize = %obj.detailSize;
%mat.diffuseSize = %obj.diffuseSize;

View file

@ -61,39 +61,109 @@ function toggleColorBufferViz( %enable )
}
}
new ShaderData( AL_SpecMapShader )
//roughness map display (matinfo.b)
new ShaderData( AL_RoughMapShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = "./shaders/dbgSpecMapVisualizeP.hlsl";
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgRoughMapVisualizeP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = "./shaders/dbgSpecMapVisualizeP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgRoughMapVisualizeP.glsl";
samplerNames[0] = "matinfoTex";
pixVersion = 2.0;
};
singleton PostEffect( AL_SpecMapVisualize )
singleton PostEffect( AL_RoughMapVisualize )
{
shader = AL_SpecMapShader;
shader = AL_RoughMapShader;
stateBlock = AL_DefaultVisualizeState;
texture[0] = "#matinfo";
target = "$backBuffer";
renderPriority = 9999;
};
/// Toggles the visualization of the AL lighting specular power buffer.
function toggleSpecMapViz( %enable )
function toggleRoughMapViz( %enable )
{
if ( %enable $= "" )
{
$AL_SpecMapShaderVar = AL_SpecMapVisualize.isEnabled() ? false : true;
AL_SpecMapVisualize.toggle();
$AL_RoughMapShaderVar = AL_RoughMapVisualize.isEnabled() ? false : true;
AL_RoughMapVisualize.toggle();
}
else if ( %enable )
AL_SpecMapVisualize.enable();
AL_RoughMapVisualize.enable();
else if ( !%enable )
AL_SpecMapVisualize.disable();
AL_RoughMapVisualize.disable();
}
//metalness map display (matinfo.a)
new ShaderData( AL_MetalMapShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgMetalMapVisualizeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgMetalMapVisualizeP.glsl";
samplerNames[0] = "matinfoTex";
pixVersion = 2.0;
};
singleton PostEffect( AL_MetalMapVisualize )
{
shader = AL_MetalMapShader;
stateBlock = AL_DefaultVisualizeState;
texture[0] = "#matinfo";
target = "$backBuffer";
renderPriority = 9999;
};
function toggleMetalMapViz( %enable )
{
if ( %enable $= "" )
{
$AL_MetalMapShaderVar = AL_MetalMapVisualize.isEnabled() ? false : true;
AL_MetalMapVisualize.toggle();
}
else if ( %enable )
AL_MetalMapVisualize.enable();
else if ( !%enable )
AL_MetalMapVisualize.disable();
}
//Light map display (indirectLighting)
new ShaderData( AL_LightMapShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgLightMapVisualizeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgLightMapVisualizeP.glsl";
samplerNames[0] = "specularLightingBuffer";
pixVersion = 2.0;
};
singleton PostEffect( AL_LightMapVisualize )
{
shader = AL_LightMapShader;
stateBlock = AL_DefaultVisualizeState;
texture[0] = "#specularLighting";
target = "$backBuffer";
renderPriority = 9999;
};
function toggleLightMapViz( %enable )
{
if ( %enable $= "" )
{
$AL_LightMapShaderVar = AL_LightMapVisualize.isEnabled() ? false : true;
AL_LightMapVisualize.toggle();
}
else if ( %enable )
AL_LightMapVisualize.enable();
else if ( !%enable )
AL_LightMapVisualize.disable();
}
new GFXStateBlockData( AL_DepthVisualizeState )

View file

@ -61,3 +61,8 @@ function EditorLightingMenu::onMenuSelect( %this )
//%selSize = EWorldEditor.getSelectionSize();
%this.enableItem( 1, true /*%selSize == 1*/ );
}
function updateReflectionProbes()
{
Canvas.pushDialog(ProbeBakeDlg);
}

View file

@ -322,6 +322,8 @@ function EditorGui::buildMenus(%this)
item[0] = "Full Relight" TAB "Alt L" TAB "Editor.lightScene(\"\", forceAlways);";
item[1] = "Toggle ShadowViz" TAB "" TAB "toggleShadowViz();";
item[2] = "-";
item[3] = "Update Reflection Probes" TAB "" TAB "updateReflectionProbes();";
item[4] = "-";
// NOTE: The light managers will be inserted as the
// last menu items in EditorLightingMenu::onAdd().

View file

@ -0,0 +1,56 @@
function ProbeBakeDlg::onWake(%this)
{
//set up
ProbeBakeDlg_ProbeResList.add( "32" );
ProbeBakeDlg_ProbeResList.add( "64" );
ProbeBakeDlg_ProbeResList.add( "128" );
ProbeBakeDlg_ProbeResList.add( "256" );
ProbeBakeDlg_ProbeResList.add( "512" );
ProbeBakeDlg_ProbeResList.add( "1024" );
ProbeBakeDlg_ProbeResList.add( "2048" );
ProbeBakeDlg_ProbeResList.setSelected( 1, false );
ProbeBakeDlg_NumIterTxt.setText("1");
}
function ProbeBakeDlg_RunBake::onClick(%this)
{
%boxProbeIds = parseMissionGroupForIds("BoxEnvironmentProbe", "");
%sphereProbeIds = parseMissionGroupForIds("SphereEnvironmentProbe", "");
%skylightIds = parseMissionGroupForIds("Skylight", "");
%probeIds = rtrim(ltrim(%boxProbeIds SPC %sphereProbeIds));
%probeIds = rtrim(ltrim(%probeIds SPC %skylightIds));
%probeCount = getWordCount(%probeIds);
%numIter = ProbeBakeDlg_NumIterTxt.getText();
$pref::ReflectionProbes::BakeResolution = ProbeBakeDlg_ProbeResList.getText();
%progressStep = 100 / (%numIter * %probeCount);
%currentProgressValue = 0;
ProbeBakeDlg_Progress.setValue(%currentProgressValue);
Canvas.repaint();
for(%iter=0; %iter < %numIter; %iter++)
{
$pref::ReflectionProbes::RenderWithProbes = false;
if(%iter != 0)
$pref::ReflectionProbes::RenderWithProbes = true;
for(%i=0; %i < %probeCount; %i++)
{
%probe = getWord(%probeIds, %i);
$pref::ReflectionProbes::CurrentLevelPath = filePath($Server::MissionFile) @ "/" @ fileBase($Server::MissionFile) @ "/probes/";
ProbeBin.bakeProbe(%probe);
%currentProgressValue += %progressStep;
ProbeBakeDlg_Progress.setValue(%currentProgressValue);
Canvas.repaint();
}
}
EWorldEditor.isDirty = true;
}