Merge branch 'Preview4_0' into feature-vfs-security

This commit is contained in:
Robert MacGregor 2022-06-13 08:05:26 -04:00
commit 161ffc62fe
3013 changed files with 348715 additions and 182470 deletions

View file

@ -71,6 +71,20 @@ function GameConnection::onControlObjectChange(%this)
//turnOffZoom();
}
function GameConnection::onConnectionTimedOut(%this)
{
// Called when an established connection times out
disconnectedCleanup();
MessageBoxOK( "TIMED OUT", "The server connection has timed out.");
}
function GameConnection::onConnectionDropped(%this, %msg)
{
// Established connection was dropped by the server
disconnectedCleanup();
MessageBoxOK( "DISCONNECT", "The server has dropped the connection: " @ %msg);
}
function GameConnection::onConnectionError(%this, %msg)
{
// General connection error, usually raised by ghosted objects

View file

@ -86,6 +86,13 @@ function loadMissionStage2()
// Create the mission group off the ServerGroup
$instantGroup = ServerGroup;
// Mission cleanup group. This is where run time components will reside. The MissionCleanup
// group will be added to the ServerGroup.
new SimGroup( MissionCleanup );
// Make the MissionCleanup group the place where all new objects will automatically be added.
$instantGroup = MissionCleanup;
// Make sure the mission exists
%file = $Server::MissionFile;
@ -120,12 +127,6 @@ function loadMissionStage2()
if( isObject( theLevelInfo ) )
$Server::MissionName = theLevelInfo.levelName;
// Mission cleanup group. This is where run time components will reside. The MissionCleanup
// group will be added to the ServerGroup.
new SimGroup( MissionCleanup );
// Make the MissionCleanup group the place where all new objects will automatically be added.
$instantGroup = MissionCleanup;
%hasGameMode = callGamemodeFunction("onCreateGame");

View file

@ -53,25 +53,10 @@ function ConsoleEntry::eval()
$Con::warnVoidAssignment = false;
echo("==>" @ %text);
if( !startsWith(%text, "function ")
&& !startsWith(%text, "datablock ")
&& !startsWith(%text, "foreach(")
&& !startsWith(%text, "foreach$(")
&& !startsWith(%text, "if(")
&& !startsWith(%text, "while(")
&& !startsWith(%text, "for(")
&& !startsWith(%text, "switch(")
&& !startsWith(%text, "switch$("))
%result = eval("return" SPC %text);
else
eval(%text);
eval(%text);
$Con::warnVoidAssignment = %oldWarnVoidAssignment;
ConsoleEntry.setValue("");
// Echo result.
if(%result !$= "")
echo(%result);
}
function ToggleConsole(%make)

View file

@ -0,0 +1,7 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="BasicRibbonMat"
scriptFile="@assetFile=BasicRibbonMat.tscript"
materialDefinitionName="BasicRibbonMat"
VersionId="1" />

View file

@ -0,0 +1,27 @@
singleton ShaderData( BasicRibbonShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/basicRibbonShaderV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/basicRibbonShaderP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/basicRibbonShaderV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/basicRibbonShaderP.glsl";
samplerNames[0] = "$ribTex";
pixVersion = 2.0;
};
singleton CustomMaterial( BasicRibbonMat )
{
shader = BasicRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
preload = true;
};

View file

@ -2,6 +2,13 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="DefaultDecalRoadMaterial"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="DefaultDecalRoadMaterial"
VersionId="1" />
VersionId="1">
<Material
Name="DefaultDecalRoadMaterial">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_GameObjects:defaultRoadTextureTop_image"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -2,6 +2,13 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="DefaultRoadMaterialOther"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="DefaultRoadMaterialOther"
VersionId="1" />
VersionId="1">
<Material
Name="DefaultRoadMaterialOther">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_GameObjects:defaultRoadTextureOther_image"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -2,6 +2,13 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="DefaultRoadMaterialTop"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="DefaultRoadMaterialTop"
VersionId="1" />
VersionId="1">
<Material
Name="DefaultRoadMaterialTop">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_GameObjects:defaultRoadTextureTop_image"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -2,6 +2,6 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="TexturedRibbonMat"
scriptFile="@assetFile=materials.tscript"
scriptFile="@assetFile=TexturedRibbonMat.tscript"
materialDefinitionName="TexturedRibbonMat"
VersionId="1" />

View file

@ -0,0 +1,29 @@
singleton ShaderData( TexturedRibbonShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/texRibbonShaderV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/texRibbonShaderP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/texRibbonShaderV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/texRibbonShaderP.glsl";
samplerNames[0] = "$ribTex";
pixVersion = 2.0;
};
singleton CustomMaterial( TexturedRibbonMat )
{
shader = TexturedRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
sampler["ribTex"] = "core/gameObjects/images/ribTex.png";
preload = true;
};

View file

@ -1,78 +0,0 @@
singleton ShaderData( BasicRibbonShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/basicRibbonShaderV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/basicRibbonShaderP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/basicRibbonShaderV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/basicRibbonShaderP.glsl";
samplerNames[0] = "$ribTex";
pixVersion = 2.0;
};
singleton CustomMaterial( BasicRibbonMat )
{
shader = BasicRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
preload = true;
};
singleton ShaderData( TexturedRibbonShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/texRibbonShaderV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/texRibbonShaderP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/texRibbonShaderV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/ribbons/gl/texRibbonShaderP.glsl";
samplerNames[0] = "$ribTex";
pixVersion = 2.0;
};
singleton CustomMaterial( TexturedRibbonMat )
{
shader = TexturedRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
sampler["ribTex"] = "core/gameObjects/images/ribTex.png";
preload = true;
};
singleton Material(DefaultDecalRoadMaterial)
{
diffuseMapAsset[0] = "Core_GameObjects:defaultRoadTextureTop_image";
mapTo = "unmapped_mat";
materialTag0 = "RoadAndPath";
};
singleton Material(DefaultRoadMaterialTop)
{
mapTo = "unmapped_mat";
diffuseMapAsset[0] = "Core_GameObjects:defaultRoadTextureTop_image";
materialTag0 = "RoadAndPath";
};
singleton Material(DefaultRoadMaterialOther)
{
mapTo = "unmapped_mat";
diffuseMapAsset[0] = "Core_GameObjects:defaultRoadTextureOther_image";
materialTag0 = "RoadAndPath";
};

View file

@ -1 +0,0 @@
constuctorFileName="@assetFile=camera.tscript" />

View file

@ -2,6 +2,19 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="CameraMat"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="CameraMat"
VersionId="1" />
VersionId="1">
<Material
Name="CameraMat"
doubleSided="1"
translucent="1"
translucentBlendOp="LerpAlpha"
castShadows="0">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_GameObjects:camera_image"
diffuseColor="0 0.627451 1 1"
emissive="1"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="Green"
scriptFile="@assetFile=green"
materialDefinitionName="Green"
originalFilePath="D:/Gamedev/Projects/Catographer/GameBuild/Templates/BaseGame/game/core/gameObjects/shapes/green" />

View file

@ -2,6 +2,18 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="OctahedronMat"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="OctahedronMat"
VersionId="1" />
VersionId="1">
<Material
Name="OctahedronMat"
mapTo="green"
translucent="1"
translucentBlendOp="PreMul"
castShadows="0">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_GameObjects:camera_image"
diffuseColor="0 1 0 1"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -1,196 +0,0 @@
//--- OBJECT WRITE BEGIN ---
new Material(OctahedronMat) {
mapTo = "green";
diffuseColor[0] = "0 1 0 1";
diffuseColor[1] = "1 1 1 1";
diffuseColor[2] = "1 1 1 1";
diffuseColor[3] = "1 1 1 1";
DiffuseMap[0] = "core/gameObjects/images/camera";
diffuseMapSRGB[0] = "1";
diffuseMapSRGB[1] = "1";
diffuseMapSRGB[2] = "1";
diffuseMapSRGB[3] = "1";
detailScale[0] = "2 2";
detailScale[1] = "2 2";
detailScale[2] = "2 2";
detailScale[3] = "2 2";
detailNormalMapStrength[0] = "1";
detailNormalMapStrength[1] = "1";
detailNormalMapStrength[2] = "1";
detailNormalMapStrength[3] = "1";
roughness[0] = "1";
roughness[1] = "1";
roughness[2] = "1";
roughness[3] = "1";
metalness[0] = "0";
metalness[1] = "0";
metalness[2] = "0";
metalness[3] = "0";
glowMul[0] = "0";
glowMul[1] = "0";
glowMul[2] = "0";
glowMul[3] = "0";
accuEnabled[0] = "0";
accuEnabled[1] = "0";
accuEnabled[2] = "0";
accuEnabled[3] = "0";
accuScale[0] = "1";
accuScale[1] = "1";
accuScale[2] = "1";
accuScale[3] = "1";
accuDirection[0] = "1";
accuDirection[1] = "1";
accuDirection[2] = "1";
accuDirection[3] = "1";
accuStrength[0] = "0.6";
accuStrength[1] = "0.6";
accuStrength[2] = "0.6";
accuStrength[3] = "0.6";
accuCoverage[0] = "0.9";
accuCoverage[1] = "0.9";
accuCoverage[2] = "0.9";
accuCoverage[3] = "0.9";
accuSpecular[0] = "16";
accuSpecular[1] = "16";
accuSpecular[2] = "16";
accuSpecular[3] = "16";
isSRGB[0] = "0";
isSRGB[1] = "0";
isSRGB[2] = "0";
isSRGB[3] = "0";
invertRoughness[0] = "0";
invertRoughness[1] = "0";
invertRoughness[2] = "0";
invertRoughness[3] = "0";
roughnessChan[0] = "0";
roughnessChan[1] = "0";
roughnessChan[2] = "0";
roughnessChan[3] = "0";
AOChan[0] = "1";
AOChan[1] = "1";
AOChan[2] = "1";
AOChan[3] = "1";
metalChan[0] = "2";
metalChan[1] = "2";
metalChan[2] = "2";
metalChan[3] = "2";
glow[0] = "0";
glow[1] = "0";
glow[2] = "0";
glow[3] = "0";
parallaxScale[0] = "0";
parallaxScale[1] = "0";
parallaxScale[2] = "0";
parallaxScale[3] = "0";
useAnisotropic[0] = "1";
useAnisotropic[1] = "1";
useAnisotropic[2] = "1";
useAnisotropic[3] = "1";
vertLit[0] = "0";
vertLit[1] = "0";
vertLit[2] = "0";
vertLit[3] = "0";
vertColor[0] = "0";
vertColor[1] = "0";
vertColor[2] = "0";
vertColor[3] = "0";
minnaertConstant[0] = "-1";
minnaertConstant[1] = "-1";
minnaertConstant[2] = "-1";
minnaertConstant[3] = "-1";
subSurface[0] = "0";
subSurface[1] = "0";
subSurface[2] = "0";
subSurface[3] = "0";
subSurfaceColor[0] = "1 0.2 0.2 1";
subSurfaceColor[1] = "1 0.2 0.2 1";
subSurfaceColor[2] = "1 0.2 0.2 1";
subSurfaceColor[3] = "1 0.2 0.2 1";
subSurfaceRolloff[0] = "0.2";
subSurfaceRolloff[1] = "0.2";
subSurfaceRolloff[2] = "0.2";
subSurfaceRolloff[3] = "0.2";
emissive[0] = "0";
emissive[1] = "0";
emissive[2] = "0";
emissive[3] = "0";
foreground[0] = "0";
foreground[1] = "0";
foreground[2] = "0";
foreground[3] = "0";
doubleSided = "0";
animFlags[0] = "0x00000000";
animFlags[1] = "0x00000000";
animFlags[2] = "0x00000000";
animFlags[3] = "0x00000000";
scrollDir[0] = "0 0";
scrollDir[1] = "0 0";
scrollDir[2] = "0 0";
scrollDir[3] = "0 0";
scrollSpeed[0] = "0";
scrollSpeed[1] = "0";
scrollSpeed[2] = "0";
scrollSpeed[3] = "0";
rotSpeed[0] = "0";
rotSpeed[1] = "0";
rotSpeed[2] = "0";
rotSpeed[3] = "0";
rotPivotOffset[0] = "0 0";
rotPivotOffset[1] = "0 0";
rotPivotOffset[2] = "0 0";
rotPivotOffset[3] = "0 0";
waveType[0] = "Sin";
waveType[1] = "Sin";
waveType[2] = "Sin";
waveType[3] = "Sin";
waveFreq[0] = "0";
waveFreq[1] = "0";
waveFreq[2] = "0";
waveFreq[3] = "0";
waveAmp[0] = "0";
waveAmp[1] = "0";
waveAmp[2] = "0";
waveAmp[3] = "0";
sequenceFramePerSec[0] = "0";
sequenceFramePerSec[1] = "0";
sequenceFramePerSec[2] = "0";
sequenceFramePerSec[3] = "0";
sequenceSegmentSize[0] = "0";
sequenceSegmentSize[1] = "0";
sequenceSegmentSize[2] = "0";
sequenceSegmentSize[3] = "0";
cellIndex[0] = "0 0";
cellIndex[1] = "0 0";
cellIndex[2] = "0 0";
cellIndex[3] = "0 0";
cellLayout[0] = "0 0";
cellLayout[1] = "0 0";
cellLayout[2] = "0 0";
cellLayout[3] = "0 0";
cellSize[0] = "0";
cellSize[1] = "0";
cellSize[2] = "0";
cellSize[3] = "0";
bumpAtlas[0] = "0";
bumpAtlas[1] = "0";
bumpAtlas[2] = "0";
bumpAtlas[3] = "0";
castShadows = "0";
planarReflection = "0";
translucent = "1";
translucentBlendOp = "PreMul";
translucentZWrite = "0";
alphaTest = "0";
alphaRef = "1";
dynamicCubemap = "0";
showFootprints = "1";
showDust = "0";
effectColor[0] = "0 0 0 0";
effectColor[1] = "0 0 0 0";
footstepSoundId = "-1";
impactSoundId = "-1";
ImpactFXIndex = "-1";
canSave = "1";
canSaveDynamicFields = "1";
};
//--- OBJECT WRITE END ---

View file

@ -1,95 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton Material(OctahedronMat)
{
mapTo = "green";
diffuseMapAsset[0] = "Core_GameObjects:camera_image";
translucent = "1";
translucentBlendOp = "PreMul";
emissive = "0";
castShadows = "0";
diffuseColor[0] = "0 1 0 1";
};
//--- camera.dts MATERIALS BEGIN ---
singleton Material(CameraMat)
{
mapTo = "pasted__phongE1";
diffuseMapAsset[0] = "Core_GameObjects:camera_image";
diffuseColor[0] = "0 0.627451 1 1";
specular[0] = "1 1 1 1";
specularPower[0] = 211;
pixelSpecular[0] = 1;
emissive[0] = 1;
doubleSided = 1;
translucent = true;
translucentBlendOp = "LerpAlpha";
castShadows = false;
materialTag0 = "Miscellaneous";
};
//--- camera.dts MATERIALS END ---
//--- noshapetext.dae MATERIALS BEGIN ---
singleton Material(noshapetext_lambert1)
{
mapTo = "lambert1";
diffuseMapAsset[0] = "";
diffuseColor[0] = "0.4 0.4 0.4 1";
specular[0] = "1 1 1 1";
specularPower[0] = 8;
pixelSpecular[0] = false;
emissive[0] = true;
doubleSided = false;
translucent = false;
translucentBlendOp = "None";
};
singleton Material(noshapetext_noshape_mat)
{
mapTo = "noshape_mat";
diffuseMapAsset[0] = "";
diffuseColor[0] = "0.4 0.3504 0.363784 0.33058";
specular[0] = "1 1 1 1";
specularPower[0] = 8;
pixelSpecular[0] = false;
emissive[0] = true;
doubleSided = false;
translucent = true;
translucentBlendOp = "None";
};
//--- noshapetext.dae MATERIALS END ---

View file

@ -3,4 +3,5 @@
canSaveDynamicFields="true"
AssetName="noshape"
fileName="@assetFile=noshape.dts"
materialSlot0="@asset=Core_Rendering:noShapeMat"
constuctorFileName="@assetFile=noshape.tscript" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="noshape_NoShape"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="noshape_NoShape"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="noshapetext_lambert1"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="noshapetext_lambert1"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="noshapetext_noshape_mat"
scriptFile="@assetFile=materials.tscript"
materialDefinitionName="noshapetext_noshape_mat"
VersionId="1" />

View file

@ -115,7 +115,7 @@ function configureCanvas()
"--Screen Mode : " @ %fsLabel NL
"--Bits Per Pixel : " @ %bpp NL
"--Refresh Rate : " @ %rate NL
"--FSAA Level : " @ %aa NL
"--FXAA Level : " @ %aa NL
"--------------");
// Actually set the new video mode

View file

@ -26,6 +26,10 @@ if($Gui::fontCacheDirectory $= "")
$Gui::fontCacheDirectory = expandFilename("data/cache/fonts");
}
$TextMediumEmphasisColor = "200 200 200";
$TextHighEmphasisColor = "224 224 224";
$TextDisabledColor = "108 108 108";
// ----------------------------------------------------------------------------
// GuiDefaultProfile is a special profile that all other profiles inherit
// defaults from. It must exist.
@ -77,6 +81,12 @@ new GuiControlProfile (GuiDefaultProfile)
cursorColor = "0 0 0 255";
};
if(!isObject(GuiNonModalDefaultProfile))
new GuiControlProfile (GuiNonModalDefaultProfile : GuiDefaultProfile)
{
modal = false;
};
if(!isObject(GuiToolTipProfile))
new GuiControlProfile (GuiToolTipProfile)
{
@ -137,13 +147,20 @@ new GuiControlProfile(GuiTextEditProfile)
category = "Core";
};
if(!isObject(GuiScrollProfile))
new GuiControlProfile(GuiScrollProfile)
if(!isObject(GuiMenuScrollProfile))
new GuiControlProfile(GuiMenuScrollProfile)
{
opaque = true;
fillcolor = "255 255 255";
fontColor = "0 0 0";
fontColorHL = "150 150 150";
fontColor = $TextMediumEmphasisColor;
fontColorHL = $TextMediumEmphasisColor;
fontColorNA = $TextDisabledColor;
fontColorSEL = $TextMediumEmphasisColor;
fillColor = "40 40 40";
fillColorHL = "56 56 56";
fillColorNA = "40 40 40";
borderColor = "87 87 87";
borderColorNA = "0 0 0";
borderColorHL = "255 255 255";
border = true;
bitmapAsset = "Core_GUI:scrollBar_image";
hasBitmapArray = true;
@ -234,3 +251,11 @@ new GuiControlProfile( GuiSliderProfile )
bitmapAsset = "Core_GUI:slider_image";
category = "Core";
};
//
if(!isObject(GuiScrollProfile))
new GuiControlProfile(GuiScrollProfile)
{
bitmapAsset = "Core_GUI:scrollBar_image";
category = "Core";
};

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="AL_ConvexLightState"
scriptFile="@assetFile=advancedLighting_Shaders.tscript"
materialDefinitionName="AL_ConvexLightState"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="AL_DefaultDeferredMaterial"
scriptFile="@assetFile=advancedLighting_Shaders.tscript"
materialDefinitionName="AL_DefaultDeferredMaterial"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="AL_DefaultShadowMaterial"
scriptFile="@assetFile=advancedLighting_Shaders.tscript"
materialDefinitionName="AL_DefaultShadowMaterial"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="AL_ParticlePointLightShader"
scriptFile="@assetFile=advancedLighting_Shaders.tscript"
materialDefinitionName="AL_ParticlePointLightShader"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="AL_SpotLightShader"
scriptFile="@assetFile=advancedLighting_Shaders.tscript"
materialDefinitionName="AL_SpotLightShader"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="BL_ProjectedShadowRPM"
scriptFile="@assetFile=basicLighting_Init.tscript"
materialDefinitionName="BL_ProjectedShadowRPM"
VersionId="1" />

View file

@ -1,7 +0,0 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="IrradianceShader"
scriptFile="@assetFile=advancedLighting_Shaders.tscript"
materialDefinitionName="IrradianceShader"
VersionId="1" />

View file

@ -474,7 +474,7 @@ function DepthOfFieldPostFX::populatePostFXSettings(%this)
function PostEffectEditorInspector::toggleDepthOfFieldPostFX(%this)
{
if($PostFX::DepthOfFieldPostFX::Enabled)
if($PostFX::DepthOfFieldPostFX::Enabled && $pref::PostFX::EnableDOF)
DepthOfFieldPostFX.enable();
else
DepthOfFieldPostFX.disable();
@ -482,7 +482,7 @@ function PostEffectEditorInspector::toggleDepthOfFieldPostFX(%this)
function DepthOfFieldPostFX::applyFromPreset(%this)
{
if($PostFX::DepthOfFieldPostFX::Enabled)
if($PostFX::DepthOfFieldPostFX::Enabled && $pref::PostFX::EnableDOF)
DepthOfFieldPostFX.enable();
else
DepthOfFieldPostFX.disable();

View file

@ -126,7 +126,7 @@ function LightRayPostFX::populatePostFXSettings(%this)
function PostEffectEditorInspector::toggleLightRayPostFX(%this)
{
if($PostFX::LightRayPostFX::Enabled)
if($PostFX::LightRayPostFX::Enabled && $pref::PostFX::EnableLightRays)
LightRayPostFX.enable();
else
LightRayPostFX.disable();
@ -134,7 +134,7 @@ function PostEffectEditorInspector::toggleLightRayPostFX(%this)
function LightRayPostFX::applyFromPreset(%this)
{
if($PostFX::LightRayPostFX::Enabled)
if($PostFX::LightRayPostFX::Enabled && $pref::PostFX::EnableLightRays)
%this.enable();
else
%this.disable();

View file

@ -15,4 +15,6 @@ singleton PostEffect( reflectionProbeArrayPostFX )
texture[0] = "#deferred";
texture[1] = "#color";
texture[2] = "#matinfo";
allowReflectPass = true;
};

View file

@ -165,7 +165,7 @@ function SSAOPostFx::populatePostFXSettings(%this)
function PostEffectEditorInspector::toggleSSAOPostFx(%this)
{
if($PostFX::SSAOPostFx::Enabled)
if($PostFX::SSAOPostFx::Enabled && $pref::PostFX::EnableSSAO)
SSAOPostFx.enable();
else
SSAOPostFx.disable();
@ -173,7 +173,7 @@ function PostEffectEditorInspector::toggleSSAOPostFx(%this)
function SSAOPostFx::applyFromPreset(%this)
{
if($PostFXManager::PostFX::Enable)
if($PostFXManager::PostFX::Enable && $pref::PostFX::EnableSSAO)
%this.enable();
else
%this.disable();

View file

@ -91,7 +91,7 @@ function VignettePostFX::populatePostFXSettings(%this)
//Allow us to easily toggle the postFX and have it respond immediately
function PostEffectEditorInspector::toggleVignettePostFX(%this)
{
if($PostFX::VignettePostFX::Enabled)
if($PostFX::VignettePostFX::Enabled && $pref::PostFX::EnableVignette)
VignettePostFX.enable();
else
VignettePostFX.disable();
@ -102,7 +102,7 @@ function PostEffectEditorInspector::toggleVignettePostFX(%this)
//when rendering. This allows us to modify things but still leave room for reverting or temporarily applying them
function VignettePostFX::applyFromPreset(%this)
{
if($PostFX::VignettePostFX::Enabled)
if($PostFX::VignettePostFX::Enabled && $pref::PostFX::EnableVignette)
%this.enable();
else
%this.disable();

View file

@ -5,8 +5,6 @@ function Core_Rendering::onCreate(%this)
$Core::UnAvailableTexturePath = "core/rendering/images/unavailable";
$Core::WarningTexturePath = "core/rendering/images/warnMat";
$Core::CommonShaderPath = "core/rendering/shaders";
$Core::DefaultIrradianceCubemap = "core/rendering/images/default_irradiance.dds";
$Core::DefaultPrefilterCubemap = "core/rendering/images/default_prefilter.dds";
$Core::BRDFTexture = "core/rendering/images/brdfTexture.dds";
$Core::NoImageAssetFallback = "Core_Rendering:missingTexture_image";
@ -56,11 +54,11 @@ function Core_Rendering::initClient(%this)
%prefPath = getPrefpath();
if ( isFile( %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension ) )
exec( %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension );
postFXInit();
configureCanvas();
postFXInit();
//Autodetect settings if it's our first time
if($pref::Video::autoDetect)
AutodetectGraphics();

View file

@ -0,0 +1,14 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="WarningMaterial"
materialDefinitionName="WarningMaterial"
VersionId="1">
<Material
Name="WarningMaterial">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_Rendering:missingTexture_image"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -1,8 +0,0 @@
<ImageAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="default_irradiance_image"
imageFile="@assetFile=default_irradiance.dds"
UseMips="true"
isHDRImage="false"
imageType="Albedo" />

View file

@ -1,8 +0,0 @@
<ImageAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="default_prefilter_image"
imageFile="@assetFile=default_prefilter.dds"
UseMips="true"
isHDRImage="false"
imageType="Albedo" />

View file

@ -1,32 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton Material( Empty )
{
};
singleton Material(WarningMaterial) {
detailMapAsset[0] = "Core_Rendering:missingTexture_image";
diffuseColor[0] = "25 16 0";
emissive[0] = false;
translucent = false;
};

View file

@ -2,6 +2,6 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="BlankSkyMat"
scriptFile="@assetFile=materials.tscript"
scriptFile="@assetFile=BlankSkyMat.tscript"
materialDefinitionName="BlankSkyMat"
VersionId="1" />

View file

@ -2,6 +2,6 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="NightSkyMat"
scriptFile="@assetFile=materials.tscript"
scriptFile="@assetFile=NightSkyMat.tscript"
materialDefinitionName="NightSkyMat"
VersionId="1" />

View file

@ -0,0 +1,15 @@
singleton CubemapData( NightCubemap )
{
cubeMapFaceAsset[0] = "Core_Rendering:NightSkybox_1";
cubeMapFaceAsset[1] = "Core_Rendering:NightSkybox_2";
cubeMapFaceAsset[2] = "Core_Rendering:NightSkybox_3";
cubeMapFaceAsset[3] = "Core_Rendering:NightSkybox_4";
cubeMapFaceAsset[4] = "Core_Rendering:NightSkybox_5";
cubeMapFaceAsset[5] = "Core_Rendering:NightSkybox_6";
};
singleton Material( NightSkyMat )
{
cubemap = NightCubemap;
materialTag0 = "Skies";
};

View file

@ -2,5 +2,13 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="NoMaterial"
scriptFile="@assetFile=NoMaterial"
materialDefinitionName="NoMaterial" />
materialDefinitionName="NoMaterial">
<Material
Name="NoMaterial"
mapTo="NoMaterial">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_Rendering:warnMat_image"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -1,6 +0,0 @@
//--- OBJECT WRITE BEGIN ---
singleton Material(NoMaterial) {
mapTo="NoMaterial";
DiffuseMapAsset[0] = "Core_Rendering:warnMat_image";
};
//--- OBJECT WRITE END ---

View file

@ -1,65 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//--- OBJECT WRITE BEGIN ---
singleton CubemapData( NightCubemap )
{
cubeMapFaceAsset[0] = "Core_Rendering:NightSkybox_1";
cubeMapFaceAsset[1] = "Core_Rendering:NightSkybox_2";
cubeMapFaceAsset[2] = "Core_Rendering:NightSkybox_3";
cubeMapFaceAsset[3] = "Core_Rendering:NightSkybox_4";
cubeMapFaceAsset[4] = "Core_Rendering:NightSkybox_5";
cubeMapFaceAsset[5] = "Core_Rendering:NightSkybox_6";
};
singleton Material( NightSkyMat )
{
cubemap = NightCubemap;
materialTag0 = "Skies";
};
singleton Material(moon_noglow) {
mapTo="moon_noglow";
DiffuseMapAsset = "Core_Rendering:moon_noglow_image";
emissive = true;
translucent = true;
vertColor[ 0 ] = true;
};
singleton Material(moon_wglow) {
mapTo="moon_wglow";
DiffuseMapAsset = "Core_Rendering:moon_wglow_image";
emissive = true;
translucent = true;
vertColor[ 0 ] = true;
};
singleton Material(moon_wcorona) {
mapTo="moon_wcorona";
DiffuseMapAsset = "Core_Rendering:moon_wcorona_image";
emissive = true;
translucent = true;
vertColor[ 0 ] = true;
};
//--- OBJECT WRITE END ---

View file

@ -2,6 +2,17 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="moon_noglow"
scriptFile="@assetFile=moon_noglow.tscript"
materialDefinitionName="moon_noglow"
imageMap0="@Asset=Core_Rendering:moon_noglow_image"/>
VersionId="1">
<Material
Name="moon_noglow"
mapTo="moon_noglow"
emissive="1"
translucent="1">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_Rendering:moon_noglow_image"
vertColor="1"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -1,9 +0,0 @@
//--- OBJECT WRITE BEGIN ---
singleton Material(moon_noglow) {
mapTo="moon_noglow";
DiffuseMapAsset = "Core_Rendering:moon_noglow_image";
emissive = true;
translucent = true;
vertColor[ 0 ] = true;
};
//--- OBJECT WRITE END ---

View file

@ -1,7 +1,7 @@
<ImageAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="moon_wcorona"
AssetName="moon_wcorona_image"
imageFile="@assetFile=moon_wcorona.png"
UseMips="true"
isHDRImage="false"

View file

@ -0,0 +1,18 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="moon_wcorona"
materialDefinitionName="moon_wcorona"
VersionId="1">
<Material
Name="moon_wcorona"
mapTo="moon_wcorona"
emissive="1"
translucent="1">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_Rendering:moon_wcorona_image"
vertColor="1"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -2,6 +2,17 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="moon_wglow"
scriptFile="@assetFile=moon_wglow.tscript"
materialDefinitionName="moon_wglow"
imageMap0="@Asset=Core_Rendering:moon_wglow_image"/>
VersionId="1">
<Material
Name="moon_wglow"
mapTo="moon_wglow"
emissive="1"
translucent="1">
<Material.Stages>
<Stages_beginarray
DiffuseMapAsset="Core_Rendering:moon_wglow_image"
vertColor="1";/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -1,9 +0,0 @@
//--- OBJECT WRITE BEGIN ---
singleton Material(moon_wglow) {
mapTo="moon_wglow";
DiffuseMapAsset = "Core_Rendering:moon_wglow_image";
emissive = true;
translucent = true;
vertColor[ 0 ] = true;
};
//--- OBJECT WRITE END ---

View file

@ -453,7 +453,7 @@ new SimGroup( LightingQualityList )
class = "GraphicsQualityLevel";
caseSensitive = true;
displayName = "High";
displayName = "Highest";
key["$pref::maximumNumOfLights"] = -1;
key["$pref::useLightFade"] = false;
@ -687,7 +687,7 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem )
$pref::PostFX::EnableVignette = false;
$pref::Video::AA = 0;
$pref::Video::disableVerticalSync = 0;
$pref::Video::defaultAnisotropy = 0;
}
else
{
@ -713,7 +713,7 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem )
$pref::PostFX::EnableVignette = false;
$pref::Video::AA = 0;
$pref::Video::disableVerticalSync = 0;
$pref::Video::defaultAnisotropy = 0;
}
}
else
@ -743,7 +743,7 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem )
$pref::PostFX::EnableVignette = true;
$pref::Video::AA = 4;
$pref::Video::disableVerticalSync = 16;
$pref::Video::defaultAnisotropy = 16;
}
else if ( %videoMem > 400 || %videoMem == 0 )
{
@ -769,7 +769,7 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem )
$pref::PostFX::EnableVignette = true;
$pref::Video::AA = 4;
$pref::Video::disableVerticalSync = 4;
$pref::Video::defaultAnisotropy = 4;
if ( %videoMem == 0 )
echo("Torque was unable to detect available video memory. Applying 'Medium' quality.");
@ -798,7 +798,7 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem )
$pref::PostFX::EnableVignette = false;
$pref::Video::AA = 0;
$pref::Video::disableVerticalSync = 0;
$pref::Video::defaultAnisotropy = 0;
}
}
@ -821,6 +821,11 @@ function _makePrettyResString( %resString, %giveAspectRation )
%width = getWord( %resString, $WORD::RES_X );
%height = getWord( %resString, $WORD::RES_Y );
//If it's an x, it means we've got the human-readable 'x' in the middle
//so skip it
if(%height $= "x")
%height = getWord( %resString, 2 );
%aspect = %width / %height;
%aspect = mRound( %aspect * 100 ) * 0.01;

View file

@ -23,6 +23,8 @@
#include "./torque.glsl"
#include "./brdf.glsl"
uniform float maxProbeDrawDistance;
#ifndef TORQUE_SHADERGEN
#line 27
// These are the uniforms used by most lighting shaders.
@ -330,7 +332,7 @@ float defineSphereSpaceInfluence(vec3 wsPosition, vec3 wsProbePosition, float ra
{
vec3 L = wsProbePosition.xyz - wsPosition;
float contribution = 1.0 - length(L) / radius;
return contribution;
return saturate(contribution);
}
float getDistBoxToPoint(vec3 pt, vec3 extents)
@ -342,10 +344,9 @@ float getDistBoxToPoint(vec3 pt, vec3 extents)
float defineBoxSpaceInfluence(vec3 wsPosition, mat4 worldToObj, float attenuation)
{
vec3 surfPosLS = tMul(worldToObj, vec4(wsPosition, 1.0)).xyz;
float atten = 1.0 - attenuation;
float baseVal = 0.25;
float dist = getDistBoxToPoint(surfPosLS, vec3(baseVal, baseVal, baseVal));
return saturate(smoothstep(baseVal + 0.0001, atten*baseVal, dist));
return saturate(smoothstep(baseVal, (baseVal-attenuation/2), dist));
}
// Box Projected IBL Lighting
@ -367,9 +368,9 @@ vec3 boxProject(vec3 wsPosition, vec3 wsReflectVec, mat4 worldToObj, vec3 refSca
}
vec4 computeForwardProbes(Surface surface,
float cubeMips, int numProbes, mat4x4 worldToObjArray[MAX_FORWARD_PROBES], vec4 probeConfigData[MAX_FORWARD_PROBES],
vec4 inProbePosArray[MAX_FORWARD_PROBES], vec4 refScaleArray[MAX_FORWARD_PROBES], vec4 inRefPosArray[MAX_FORWARD_PROBES],
float skylightCubemapIdx, sampler2D BRDFTexture,
float cubeMips, int numProbes, mat4x4 inWorldToObjArray[MAX_FORWARD_PROBES], vec4 inProbeConfigData[MAX_FORWARD_PROBES],
vec4 inProbePosArray[MAX_FORWARD_PROBES], vec4 inRefScaleArray[MAX_FORWARD_PROBES], vec4 inRefPosArray[MAX_FORWARD_PROBES],
vec3 wsEyePos, float skylightCubemapIdx, sampler2D BRDFTexture,
samplerCubeArray irradianceCubemapAR, samplerCubeArray specularCubemapAR)
{
int i = 0;
@ -384,47 +385,37 @@ vec4 computeForwardProbes(Surface surface,
for (i = 0; i < numProbes; ++i)
{
contribution[i] = 0;
if (probeConfigData[i].r == 0) //box
float atten = 1.0-(length(wsEyePos-inProbePosArray[i].xyz)/maxProbeDrawDistance);
if (inProbeConfigData[i].r == 0) //box
{
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b);
if (contribution[i] > 0.0)
probehits++;
contribution[i] = defineBoxSpaceInfluence(surface.P, inWorldToObjArray[i], inProbeConfigData[i].b)*atten;
}
else if (probeConfigData[i].r == 1) //sphere
else if (inProbeConfigData[i].r == 1) //sphere
{
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, probeConfigData[i].g);
if (contribution[i] > 0.0)
probehits++;
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, inProbeConfigData[i].g)*atten;
}
contribution[i] = max(contribution[i], 0);
if (contribution[i]>0.0)
probehits++;
else
contribution[i] = 0.0;
blendSum += contribution[i];
invBlendSum += (1.0f - contribution[i]);
}
if (probehits > 1.0)
if (probehits > 1.0)//if we overlap
{
invBlendSum = (probehits - blendSum)/(probehits-1); //grab the remainder
for (i = 0; i < numProbes; i++)
{
blendFactor[i] = ((contribution[i] / blendSum)) / probehits;
blendFactor[i] *= ((contribution[i]) / invBlendSum);
blendFactor[i] = saturate(blendFactor[i]);
blendFacSum += blendFactor[i];
blendFactor[i] = contribution[i]/blendSum; //what % total is this instance
blendFactor[i] *= blendFactor[i] / invBlendSum; //what should we add to sum to 1
blendFacSum += blendFactor[i]; //running tally of results
}
// Normalize blendVal
if (blendFacSum == 0.0f) // Possible with custom weight
{
blendFacSum = 1.0f;
}
float invBlendSumWeighted = 1.0f / blendFacSum;
for (i = 0; i < numProbes; ++i)
{
blendFactor[i] *= invBlendSumWeighted;
contribution[i] *= blendFactor[i];
contribution[i] *= blendFactor[i]/blendFacSum; //normalize
}
}
@ -471,8 +462,8 @@ vec4 computeForwardProbes(Surface surface,
float contrib = contribution[i];
if (contrib > 0.0f)
{
float cubemapIdx = int(probeConfigData[i].a);
vec3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refScaleArray[i].xyz, inRefPosArray[i].xyz);
int cubemapIdx = int(inProbeConfigData[i].a);
vec3 dir = boxProject(surface.P, surface.R, inWorldToObjArray[i], inRefScaleArray[i].xyz, inRefPosArray[i].xyz);
irradiance += textureLod(irradianceCubemapAR, vec4(dir, cubemapIdx), 0).xyz * contrib;
specular += textureLod(specularCubemapAR, vec4(dir, cubemapIdx), lod).xyz * contrib;
@ -491,8 +482,8 @@ vec4 computeForwardProbes(Surface surface,
vec3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg;
//float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb;
@ -504,13 +495,16 @@ vec4 computeForwardProbes(Surface surface,
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled
#if CAPTURING == 1
return vec4(mix(surface.baseColor.rgb,(irradiance + specular* horizon) ,surface.metalness/2),0);
#else
return vec4((irradiance + specular* horizon) , 0);//alpha writes disabled
#endif
}
vec4 debugVizForwardProbes(Surface surface,
float cubeMips, int numProbes, mat4 worldToObjArray[MAX_FORWARD_PROBES], vec4 probeConfigData[MAX_FORWARD_PROBES],
vec4 inProbePosArray[MAX_FORWARD_PROBES], vec4 refScaleArray[MAX_FORWARD_PROBES], vec4 inRefPosArray[MAX_FORWARD_PROBES],
float cubeMips, int numProbes, mat4 inWorldToObjArray[MAX_FORWARD_PROBES], vec4 inProbeConfigData[MAX_FORWARD_PROBES],
vec4 inProbePosArray[MAX_FORWARD_PROBES], vec4 inRefScaleArray[MAX_FORWARD_PROBES], vec4 inRefPosArray[MAX_FORWARD_PROBES],
float skylightCubemapIdx, sampler2D BRDFTexture,
samplerCubeArray irradianceCubemapAR, samplerCubeArray specularCubemapAR, int showAtten, int showContrib, int showSpec, int showDiff)
{
@ -527,15 +521,15 @@ vec4 debugVizForwardProbes(Surface surface,
{
contribution[i] = 0;
if (probeConfigData[i].r == 0) //box
if (inProbeConfigData[i].r == 0) //box
{
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b);
contribution[i] = defineBoxSpaceInfluence(surface.P, inWorldToObjArray[i], inProbeConfigData[i].b);
if (contribution[i] > 0.0)
probehits++;
}
else if (probeConfigData[i].r == 1) //sphere
else if (inProbeConfigData[i].r == 1) //sphere
{
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, probeConfigData[i].g);
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, inProbeConfigData[i].g);
if (contribution[i] > 0.0)
probehits++;
}
@ -620,8 +614,8 @@ vec4 debugVizForwardProbes(Surface surface,
float contrib = contribution[i];
if (contrib > 0.0f)
{
float cubemapIdx = probeConfigData[i].a;
vec3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refScaleArray[i].xyz, inRefPosArray[i].xyz);
float cubemapIdx = inProbeConfigData[i].a;
vec3 dir = boxProject(surface.P, surface.R, inWorldToObjArray[i], inRefScaleArray[i].xyz, inRefPosArray[i].xyz);
irradiance += textureLod(irradianceCubemapAR, vec4(dir, cubemapIdx), 0).xyz * contrib;
specular += textureLod(specularCubemapAR, vec4(dir, cubemapIdx), lod).xyz * contrib;
@ -663,5 +657,5 @@ vec4 debugVizForwardProbes(Surface surface,
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled
return vec4((irradiance + specular* horizon) , 0);//alpha writes disabled
}

View file

@ -24,6 +24,9 @@
#include "./brdf.hlsl"
#include "./shaderModelAutoGen.hlsl"
//globals
uniform float3 eyePosWorld;
uniform float maxProbeDrawDistance;
#ifndef TORQUE_SHADERGEN
// These are the uniforms used by most lighting shaders.
@ -333,7 +336,7 @@ float defineSphereSpaceInfluence(float3 wsPosition, float3 wsProbePosition, floa
{
float3 L = wsProbePosition.xyz - wsPosition;
float contribution = 1.0 - length(L) / radius;
return contribution;
return saturate(contribution);
}
float getDistBoxToPoint(float3 pt, float3 extents)
@ -345,10 +348,9 @@ float getDistBoxToPoint(float3 pt, float3 extents)
float defineBoxSpaceInfluence(float3 wsPosition, float4x4 worldToObj, float attenuation)
{
float3 surfPosLS = mul(worldToObj, float4(wsPosition, 1.0)).xyz;
float atten = 1.0 - attenuation;
float baseVal = 0.25;
float dist = getDistBoxToPoint(surfPosLS, float3(baseVal, baseVal, baseVal));
return saturate(smoothstep(baseVal + 0.0001, atten*baseVal, dist));
return saturate(smoothstep(baseVal, (baseVal-attenuation/2), dist));
}
// Box Projected IBL Lighting
@ -370,9 +372,9 @@ float3 boxProject(float3 wsPosition, float3 wsReflectVec, float4x4 worldToObj, f
}
float4 computeForwardProbes(Surface surface,
float cubeMips, int numProbes, float4x4 worldToObjArray[MAX_FORWARD_PROBES], float4 probeConfigData[MAX_FORWARD_PROBES],
float4 inProbePosArray[MAX_FORWARD_PROBES], float4 refScaleArray[MAX_FORWARD_PROBES], float4 inRefPosArray[MAX_FORWARD_PROBES],
float skylightCubemapIdx, TORQUE_SAMPLER2D(BRDFTexture),
float cubeMips, int numProbes, float4x4 inWorldToObjArray[MAX_FORWARD_PROBES], float4 inProbeConfigData[MAX_FORWARD_PROBES],
float4 inProbePosArray[MAX_FORWARD_PROBES], float4 inRefScaleArray[MAX_FORWARD_PROBES], float4 inRefPosArray[MAX_FORWARD_PROBES],
float3 wsEyePos, float skylightCubemapIdx, TORQUE_SAMPLER2D(BRDFTexture),
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR))
{
int i = 0;
@ -384,50 +386,41 @@ float4 computeForwardProbes(Surface surface,
float probehits = 0;
//Set up our struct data
float contribution[MAX_FORWARD_PROBES];
//Process prooooobes
for (i = 0; i < numProbes; ++i)
{
contribution[i] = 0;
if (probeConfigData[i].r == 0) //box
contribution[i] = 0.0;
float atten = 1.0-(length(wsEyePos-inProbePosArray[i].xyz)/maxProbeDrawDistance);
if (inProbeConfigData[i].r == 0) //box
{
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b);
if (contribution[i] > 0.0)
probehits++;
contribution[i] = defineBoxSpaceInfluence(surface.P, inWorldToObjArray[i], inProbeConfigData[i].b)*atten;
}
else if (probeConfigData[i].r == 1) //sphere
else if (inProbeConfigData[i].r == 1) //sphere
{
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, probeConfigData[i].g);
if (contribution[i] > 0.0)
probehits++;
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, inProbeConfigData[i].g)*atten;
}
contribution[i] = max(contribution[i], 0);
if (contribution[i]>0.0)
probehits++;
else
contribution[i] = 0.0;
blendSum += contribution[i];
invBlendSum += (1.0f - contribution[i]);
}
if (probehits > 1.0)
if (probehits > 1.0)//if we overlap
{
invBlendSum = (probehits - blendSum)/(probehits-1); //grab the remainder
for (i = 0; i < numProbes; i++)
{
blendFactor[i] = ((contribution[i] / blendSum)) / probehits;
blendFactor[i] *= ((contribution[i]) / invBlendSum);
blendFactor[i] = saturate(blendFactor[i]);
blendFacSum += blendFactor[i];
blendFactor[i] = contribution[i]/blendSum; //what % total is this instance
blendFactor[i] *= blendFactor[i] / invBlendSum; //what should we add to sum to 1
blendFacSum += blendFactor[i]; //running tally of results
}
// Normalize blendVal
if (blendFacSum == 0.0f) // Possible with custom weight
{
blendFacSum = 1.0f;
}
float invBlendSumWeighted = 1.0f / blendFacSum;
for (i = 0; i < numProbes; ++i)
{
blendFactor[i] *= invBlendSumWeighted;
contribution[i] *= blendFactor[i];
contribution[i] *= blendFactor[i]/blendFacSum; //normalize
}
}
@ -474,8 +467,8 @@ float4 computeForwardProbes(Surface surface,
float contrib = contribution[i];
if (contrib > 0.0f)
{
int cubemapIdx = probeConfigData[i].a;
float3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refScaleArray[i].xyz, inRefPosArray[i].xyz);
int cubemapIdx = inProbeConfigData[i].a;
float3 dir = boxProject(surface.P, surface.R, inWorldToObjArray[i], inRefScaleArray[i].xyz, inRefPosArray[i].xyz);
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
@ -494,8 +487,8 @@ float4 computeForwardProbes(Surface surface,
float3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
//float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb;
@ -507,13 +500,16 @@ float4 computeForwardProbes(Surface surface,
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return float4((irradiance + specular) * horizon, 0);//alpha writes disabled
#if CAPTURING == 1
return float4(lerp(surface.baseColor.rgb,(irradiance + specular* horizon) ,surface.metalness/2),0);
#else
return float4((irradiance + specular* horizon) , 0);//alpha writes disabled
#endif
}
float4 debugVizForwardProbes(Surface surface,
float cubeMips, int numProbes, float4x4 worldToObjArray[MAX_FORWARD_PROBES], float4 probeConfigData[MAX_FORWARD_PROBES],
float4 inProbePosArray[MAX_FORWARD_PROBES], float4 refScaleArray[MAX_FORWARD_PROBES], float4 inRefPosArray[MAX_FORWARD_PROBES],
float cubeMips, int numProbes, float4x4 inWorldToObjArray[MAX_FORWARD_PROBES], float4 inProbeConfigData[MAX_FORWARD_PROBES],
float4 inProbePosArray[MAX_FORWARD_PROBES], float4 inRefScaleArray[MAX_FORWARD_PROBES], float4 inRefPosArray[MAX_FORWARD_PROBES],
float skylightCubemapIdx, TORQUE_SAMPLER2D(BRDFTexture),
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR), int showAtten, int showContrib, int showSpec, int showDiff)
{
@ -530,15 +526,15 @@ float4 debugVizForwardProbes(Surface surface,
{
contribution[i] = 0;
if (probeConfigData[i].r == 0) //box
if (inProbeConfigData[i].r == 0) //box
{
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b);
contribution[i] = defineBoxSpaceInfluence(surface.P, inWorldToObjArray[i], inProbeConfigData[i].b);
if (contribution[i] > 0.0)
probehits++;
}
else if (probeConfigData[i].r == 1) //sphere
else if (inProbeConfigData[i].r == 1) //sphere
{
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, probeConfigData[i].g);
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, inProbeConfigData[i].g);
if (contribution[i] > 0.0)
probehits++;
}
@ -623,8 +619,8 @@ float4 debugVizForwardProbes(Surface surface,
float contrib = contribution[i];
if (contrib > 0.0f)
{
int cubemapIdx = probeConfigData[i].a;
float3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refScaleArray[i].xyz, inRefPosArray[i].xyz);
int cubemapIdx = inProbeConfigData[i].a;
float3 dir = boxProject(surface.P, surface.R, inWorldToObjArray[i], inRefScaleArray[i].xyz, inRefPosArray[i].xyz);
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
@ -666,5 +662,5 @@ float4 debugVizForwardProbes(Surface surface,
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return float4((irradiance + specular) * horizon, 0);//alpha writes disabled
return float4((irradiance + specular* horizon) , 0);//alpha writes disabled
}

View file

@ -196,6 +196,38 @@ void main()
lightCol *= max(cookie.r, max(cookie.g, cookie.b));
#endif
#ifdef DIFFUSE_LIGHT_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDebugDiffuse(surface,surfaceToLight) * factor;
vec3 final = max(0.0f, diffuse);
OUT_col = vec4(final, 0);
return
#endif
#ifdef SPECULAR_LIGHT_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDebugSpecular(surface,surfaceToLight) * factor;
vec3 final = max(0.0f, diffuse);
OUT_col = vec4(final, 0);
return
#endif
#ifdef DETAIL_LIGHTING_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDiffuse(surface,surfaceToLight) * factor;
vec3 spec = BRDF_GetSpecular(surface,surfaceToLight) * factor;
vec3 final = max(vec3(0.0f), diffuse + spec * surface.F);
OUT_col = vec4(final, 0);
return
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadowed);
}

View file

@ -12,6 +12,7 @@ uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
uniform sampler2D BRDFTexture;
uniform vec3 ambientColor;
uniform vec4 rtParams0;
uniform vec4 vsFarPlane;
uniform mat4 cameraToWorld;
@ -84,78 +85,57 @@ void main()
{
contribution[i] = 0;
float atten =1.0-(length(eyePosWorld-probePosArray[i].xyz)/maxProbeDrawDistance);
if (probeConfigData[i].r == 0) //box
{
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b);
if (contribution[i]>0.0)
probehits++;
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b)*atten;
}
else if (probeConfigData[i].r == 1) //sphere
{
contribution[i] = defineSphereSpaceInfluence(surface.P, probePosArray[i].xyz, probeConfigData[i].g);
contribution[i] = defineSphereSpaceInfluence(surface.P, probePosArray[i].xyz, probeConfigData[i].g)*atten;
}
if (contribution[i]>0.0)
probehits++;
}
contribution[i] = max(contribution[i],0);
else
contribution[i] = 0;
blendSum += contribution[i];
invBlendSum += (1.0f - contribution[i]);
}
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.
// And as we invert, we need to divide by Num-1 to stay normalized (else sum is > 1).
// respect constraint B.
// Weight1 = normalized inverted NDF, so we have 1 at center, 0 at boundary
// and respect constraint A.
if (probehits > 1.0)
if (probehits > 1.0)//if we overlap
{
invBlendSum = (probehits - blendSum)/(probehits-1); //grab the remainder
for (i = 0; i < numProbes; i++)
{
blendFactor[i] = ((contribution[i] / blendSum)) / probehits;
blendFactor[i] *= ((contribution[i]) / invBlendSum);
blendFactor[i] = saturate(blendFactor[i]);
blendFacSum += blendFactor[i];
blendFactor[i] = contribution[i]/blendSum; //what % total is this instance
blendFactor[i] *= blendFactor[i] / invBlendSum; //what should we add to sum to 1
blendFacSum += blendFactor[i]; //running tally of results
}
// Normalize blendVal
if (blendFacSum == 0.0f) // Possible with custom weight
{
blendFacSum = 1.0f;
}
float invBlendSumWeighted = 1.0f / blendFacSum;
for (i = 0; i < numProbes; ++i)
{
blendFactor[i] *= invBlendSumWeighted;
contribution[i] *= blendFactor[i];
contribution[i] *= blendFactor[i]/blendFacSum; //normalize
}
}
#if DEBUGVIZ_ATTENUATION == 1
float contribAlpha = 1;
float contribAlpha = 0;
for (i = 0; i < numProbes; ++i)
{
contribAlpha -= contribution[i];
contribAlpha += contribution[i];
}
OUT_col = vec4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1);
OUT_col = vec4(contribAlpha,contribAlpha,contribAlpha, 1);
return;
#endif
#if DEBUGVIZ_CONTRIB == 1
vec3 finalContribColor = vec3(0, 0, 0);
float contribAlpha = 1;
for (i = 0; i < numProbes; ++i)
{
finalContribColor += contribution[i] *probeContribColors[i].rgb;
contribAlpha -= contribution[i];
finalContribColor += contribution[i] * vec3(fmod(i+1,2),fmod(i+1,3),fmod(i+1,4));
}
//Skylight coloration for anything not covered by probes above
if(skylightCubemapIdx != -1)
finalContribColor += vec3(0, 1, 0) * contribAlpha;
OUT_col = vec4(finalContribColor, 1);
return;
#endif
@ -178,7 +158,7 @@ void main()
float contrib = contribution[i];
if (contrib > 0.0f)
{
float cubemapIdx = probeConfigData[i].a;
int cubemapIdx = int(probeConfigData[i].a);
vec3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refScaleArray[i].xyz, refPosArray[i].xyz);
irradiance += textureLod(irradianceCubemapAR, vec4(dir, cubemapIdx), 0).xyz * contrib;
@ -188,7 +168,7 @@ void main()
}
#endif
if (skylightCubemapIdx != -1 && alpha > 0.001)
if (skylightCubemapIdx != -1 && alpha >= 0.001)
{
irradiance = lerp(irradiance,textureLod(irradianceCubemapAR, vec4(surface.R, skylightCubemapIdx), 0).xyz,alpha);
specular = lerp(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz,alpha);
@ -220,6 +200,9 @@ void main()
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
OUT_col = vec4(irradiance + specular, 0);//alpha writes disabled
#if CAPTURING == 1
OUT_col = vec4(mix(surface.baseColor.rgb,(irradiance + specular* horizon) ,surface.metalness/2),0);
#else
OUT_col = vec4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
#endif
}

View file

@ -96,6 +96,8 @@ void main()
if(dist < lightRange)
{
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
vec3 lightCol = lightColor.rgb;
#ifdef NO_SHADOW
float shadowed = 1.0;
#else
@ -107,19 +109,52 @@ void main()
//distance to light in shadow map space
float distToLight = pxlPosLightProj.z / lightRange;
float shadowed = softShadow_filter(shadowMap, ssPos.xy/ssPos.w, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
#ifdef USE_COOKIE_TEX
// Lookup the cookie sample.
vec4 cookie = texture(cookieMap, shadowCoord);
// Multiply the light with the cookie tex.
lightCol *= cookie.rgb;
// Use a maximum channel luminance to attenuate
// the lighting else we get specular in the dark
// regions of the cookie texture.
lightCol *= max(cookie.r, max(cookie.g, cookie.b));
#endif
#endif
vec3 lightCol = lightColor.rgb;
#ifdef USE_COOKIE_TEX
// Lookup the cookie sample.
vec4 cookie = texture(cookieMap, tMul(worldToLightProj, -surfaceToLight.L));
// Multiply the light with the cookie tex.
lightCol *= cookie.rgb;
// Use a maximum channel luminance to attenuate
// the lighting else we get specular in the dark
// regions of the cookie texture.
lightCol *= max(cookie.r, max(cookie.g, cookie.b));
#ifdef DIFFUSE_LIGHT_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDebugDiffuse(surface,surfaceToLight) * factor;
vec3 final = max(0.0f, diffuse) * getSpotAngleAtt(-surfaceToLight.L, lightDirection, lightSpotParams );
OUT_col = vec4(final, 0);
return;
#endif
#ifdef SPECULAR_LIGHT_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
float3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDebugSpecular(surface,surfaceToLight) * factor;
vec3 final = max(0.0f, diffuse) * getSpotAngleAtt(-surfaceToLight.L, lightDirection, lightSpotParams );
OUT_col = vec4(final, 0);
return;
#endif
#ifdef DETAIL_LIGHTING_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDiffuse(surface,surfaceToLight) * factor;
vec3 spec = BRDF_GetSpecular(surface,surfaceToLight) * factor;
vec3 final = max(vec3(0.0f), diffuse + spec * surface.F) * getSpotAngleAtt(-surfaceToLight.L, lightDirection, lightSpotParams );
OUT_col = vec4(final, 0);
return;
#endif
//get Punctual light contribution

View file

@ -216,15 +216,46 @@ void main()
lightingColor = shadowed_colors.rgb;
#endif
shadow = lerp( shadow, 1.0, saturate( fadeOutAmt ) );
shadow = mix( shadow, 1.0, saturate( fadeOutAmt ) );
#ifdef PSSM_DEBUG_RENDER
if ( fadeOutAmt > 1.0 )
lightingColor = 1.0;
lightingColor = vec3(1.0,1.0,1.0);
#endif
#endif //NO_SHADOW
#ifdef DIFFUSE_LIGHT_VIZ
vec3 factor = lightingColor.rgb * max(surfaceToLight.NdotL, 0) * shadow * lightBrightness;
vec3 diffuse = BRDF_GetDebugDiffuse(surface,surfaceToLight) * factor;
vec3 final = max(vec3(0.0f,0.0f,0.0f), diffuse);
OUT_col = vec4(final, 0);
return;
#endif
#ifdef SPECULAR_LIGHT_VIZ
vec3 factor = lightingColor.rgb * max(surfaceToLight.NdotL, 0) * shadow * lightBrightness;
vec3 spec = BRDF_GetDebugSpecular(surface, surfaceToLight) * factor;
vec3 final = max(vec3(0.0f,0.0f,0.0f), factor);
OUT_col = vec4(final, 0);
return;
#endif
#ifdef DETAIL_LIGHTING_VIZ
vec3 factor = lightingColor.rgb * max(surfaceToLight.NdotL, 0) * shadow * lightBrightness;
vec3 diffuse = BRDF_GetDebugDiffuse(surface,surfaceToLight) * factor;
vec3 spec = BRDF_GetDebugSpecular(surface,surfaceToLight) * factor;
vec3 final = max(vec3(0.0f,0.0f,0.0f), diffuse + spec);
OUT_col = vec4(final, 0);
return;
#endif
//get directional light contribution
vec3 lighting = getDirectionalLight(surface, surfaceToLight, lightingColor.rgb, lightBrightness, shadow);

View file

@ -134,7 +134,6 @@ uniform float shadowSoftness;
uniform float4x4 worldToCamera;
uniform float3x3 worldToLightProj;
uniform float3 eyePosWorld;
uniform float4x4 cameraToWorld;
float4 main( ConvexConnectP IN ) : SV_TARGET
@ -218,12 +217,12 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
#ifdef DETAIL_LIGHTING_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
float3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDiffuse(surface,surfaceToLight) * factor;
vec3 spec = BRDF_GetSpecular(surface,surfaceToLight) * factor;
float3 diffuse = BRDF_GetDiffuse(surface,surfaceToLight) * factor;
float3 spec = BRDF_GetSpecular(surface,surfaceToLight) * factor;
vec3 final = max(vec3(0.0f), diffuse + spec * surface.F);
float3 final = max(float3(0.0f), diffuse + spec * surface.F);
return final;
#endif

View file

@ -8,11 +8,10 @@ TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 1);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 2);
TORQUE_UNIFORM_SAMPLER2D(BRDFTexture, 3);
uniform float3 ambientColor;
uniform float4 rtParams0;
uniform float4 vsFarPlane;
uniform float4x4 cameraToWorld;
uniform float3 eyePosWorld;
//cubemap arrays require all the same size. so shared mips# value
uniform float cubeMips;
@ -76,79 +75,58 @@ float4 main(PFXVertToPix IN) : SV_TARGET
//Process prooooobes
for (i = 0; i < numProbes; ++i)
{
contribution[i] = 0;
contribution[i] = 0.0;
float atten =1.0-(length(eyePosWorld-probePosArray[i].xyz)/maxProbeDrawDistance);
if (probeConfigData[i].r == 0) //box
{
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b);
if (contribution[i]>0.0)
probehits++;
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b)*atten;
}
else if (probeConfigData[i].r == 1) //sphere
{
contribution[i] = defineSphereSpaceInfluence(surface.P, probePosArray[i].xyz, probeConfigData[i].g);
contribution[i] = defineSphereSpaceInfluence(surface.P, probePosArray[i].xyz, probeConfigData[i].g)*atten;
}
if (contribution[i]>0.0)
probehits++;
}
contribution[i] = max(contribution[i],0);
else
contribution[i] = 0.0;
blendSum += contribution[i];
invBlendSum += (1.0f - contribution[i]);
}
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.
// And as we invert, we need to divide by Num-1 to stay normalized (else sum is > 1).
// respect constraint B.
// Weight1 = normalized inverted NDF, so we have 1 at center, 0 at boundary
// and respect constraint A.
if (probehits > 1.0)
if (probehits > 1.0)//if we overlap
{
invBlendSum = (probehits - blendSum)/(probehits-1); //grab the remainder
for (i = 0; i < numProbes; i++)
{
blendFactor[i] = ((contribution[i] / blendSum)) / probehits;
blendFactor[i] *= ((contribution[i]) / invBlendSum);
blendFactor[i] = saturate(blendFactor[i]);
blendFacSum += blendFactor[i];
blendFactor[i] = contribution[i]/blendSum; //what % total is this instance
blendFactor[i] *= blendFactor[i] / invBlendSum; //what should we add to sum to 1
blendFacSum += blendFactor[i]; //running tally of results
}
// Normalize blendVal
if (blendFacSum == 0.0f) // Possible with custom weight
{
blendFacSum = 1.0f;
}
float invBlendSumWeighted = 1.0f / blendFacSum;
for (i = 0; i < numProbes; ++i)
{
blendFactor[i] *= invBlendSumWeighted;
contribution[i] *= blendFactor[i];
contribution[i] *= blendFactor[i]/blendFacSum; //normalize
}
}
#if DEBUGVIZ_ATTENUATION == 1
float contribAlpha = 1;
float contribAlpha = 0;
for (i = 0; i < numProbes; ++i)
{
contribAlpha -= contribution[i];
contribAlpha += contribution[i];
}
return float4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1);
return float4(contribAlpha,contribAlpha,contribAlpha, 1);
#endif
#if DEBUGVIZ_CONTRIB == 1
float3 finalContribColor = float3(0, 0, 0);
float contribAlpha = 1;
for (i = 0; i < numProbes; ++i)
{
finalContribColor += contribution[i] *probeContribColors[i].rgb;
contribAlpha -= contribution[i];
finalContribColor += contribution[i] * float3(fmod(i+1,2),fmod(i+1,3),fmod(i+1,4));
}
//Skylight coloration for anything not covered by probes above
if(skylightCubemapIdx != -1)
finalContribColor += float3(0, 1, 0) * contribAlpha;
return float4(finalContribColor, 1);
#endif
}
@ -209,6 +187,9 @@ float4 main(PFXVertToPix IN) : SV_TARGET
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return float4((irradiance + specular) * horizon, 0);//alpha writes disabled
#if CAPTURING == 1
return float4(lerp(surface.baseColor.rgb,(irradiance + specular* horizon) ,surface.metalness/2),0);
#else
return float4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
#endif
}

View file

@ -43,7 +43,7 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
#ifdef USE_COOKIE_TEX
/// The texture for cookie rendering.
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 3);
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 2);
#endif
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 5);
@ -67,7 +67,6 @@ uniform float4x4 worldToLightProj;
uniform float4 lightParams;
uniform float shadowSoftness;
uniform float3 eyePosWorld;
uniform float4x4 cameraToWorld;
uniform float4x4 worldToCamera;
@ -102,6 +101,8 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
if(dist < lightRange)
{
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
float3 lightCol = lightColor.rgb;
#ifdef NO_SHADOW
float shadowed = 1.0;
#else
@ -109,23 +110,20 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
float4 pxlPosLightProj = mul( worldToLightProj, float4( surface.P, 1 ) );
float2 shadowCoord = ( ( pxlPosLightProj.xy / pxlPosLightProj.w ) * 0.5 ) + float2( 0.5, 0.5 );
shadowCoord.y = 1.0f - shadowCoord.y;
//distance to light in shadow map space
//distance to light in shadow map space
float distToLight = pxlPosLightProj.z / lightRange;
float shadowed = softShadow_filter(TORQUE_SAMPLER2D_MAKEARG(shadowMap), ssPos.xy, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
#endif
float3 lightCol = lightColor.rgb;
#ifdef USE_COOKIE_TEX
// Lookup the cookie sample.
float4 cookie = TORQUE_TEXCUBE(cookieMap, mul(worldToLightProj, -surfaceToLight.L));
// Multiply the light with the cookie tex.
lightCol *= cookie.rgb;
// Use a maximum channel luminance to attenuate
// the lighting else we get specular in the dark
// regions of the cookie texture.
lightCol *= max(cookie.r, max(cookie.g, cookie.b));
#endif
#ifdef USE_COOKIE_TEX
// Lookup the cookie sample.
float4 cookie = TORQUE_TEX2D(cookieMap, shadowCoord);
// Multiply the light with the cookie tex.
lightCol *= cookie.rgb;
// Use a maximum channel luminance to attenuate
// the lighting else we get specular in the dark
// regions of the cookie texture.
lightCol *= max(cookie.r, max(cookie.g, cookie.b));
#endif
#endif
#ifdef DIFFUSE_LIGHT_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
@ -147,12 +145,12 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
#ifdef DETAIL_LIGHTING_VIZ
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
vec3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
float3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
vec3 diffuse = BRDF_GetDiffuse(surface,surfaceToLight) * factor;
vec3 spec = BRDF_GetSpecular(surface,surfaceToLight) * factor;
float3 diffuse = BRDF_GetDiffuse(surface,surfaceToLight) * factor;
float3 spec = BRDF_GetSpecular(surface,surfaceToLight) * factor;
vec3 final = max(vec3(0.0f), diffuse + spec * surface.F) * getSpotAngleAtt(-surfaceToLight.L, lightDirection, lightSpotParams );
vec3 final = max(float3(0.0f), diffuse + spec * surface.F) * getSpotAngleAtt(-surfaceToLight.L, lightDirection, lightSpotParams );
return final;
#endif

View file

@ -42,7 +42,6 @@ uniform float4 lightColor;
uniform float4 lightAmbient;
uniform float shadowSoftness;
uniform float3 eyePosWorld;
uniform float4 atlasXOffset;
uniform float4 atlasYOffset;

View file

@ -1,16 +0,0 @@
//--- noshape.dts MATERIALS BEGIN ---
singleton Material(noshape_NoShape)
{
mapTo = "NoShape";
diffuseMapAsset[0] = "";
diffuseColor[0] = "0.8 0.003067 0 .8";
emissive[0] = 0;
doubleSided = false;
translucent = 1;
translucentBlendOp = "LerpAlpha";
castShadows = false;
materialTag0 = "WorldEditor";
};
//--- noshape.dts MATERIALS END ---

View file

@ -0,0 +1,18 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="NoShapeMat"
materialDefinitionName="NoShapeMat"
VersionId="1">
<Material
Name="NoShapeMat"
mapTo="NoShape"
translucent="1"
translucentBlendOp="LerpAlpha";
castShadows="0">
<Material.Stages>
<Stages_beginarray
diffuseColor="0.8 0.003067 0 .8"/>
</Material.Stages>
</Material>
</MaterialAsset>

View file

@ -3,4 +3,5 @@
canSaveDynamicFields="true"
AssetName="noshape"
fileName="@assetFile=noshape.dts"
materialSlot0="@asset=Core_Rendering:NoShapeMat"
VersionId="1" />

View file

@ -6,7 +6,8 @@ if (!isObject(ExecFilesList))
function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6)
{
//clear per module group file execution chain
ExecFilesList.empty();
%execArray = new ArrayObject("callOn" @ %functionName @ "_" @ %moduleGroup);
ExecFilesList.push_back(%execArray);
//Get our modules so we can exec any specific client-side loading/handling
%modulesList = ModuleDatabase.findModules(false);
for(%i=0; %i < getWordCount(%modulesList); %i++)
@ -23,12 +24,22 @@ function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3,
%module.scopeSet.call(%functionName, %var0, %var1, %var2, %var3, %var4, %var5, %var6);
}
%execFilecount = ExecFilesList.count();
%execFilecount = %execArray.count();
if($traceModuleCalls)
{
error("ExecFilesList at actual exec point:");
%execArray.echo();
}
for (%i=0;%i<%execFilecount;%i++)
{
%filename = ExecFilesList.getKey(%i);
%filename = %execArray.getKey(%i);
exec(%filename);
}
ExecFilesList.pop_back(); //cleanup
%execArray.delete();
}
function loadModuleMaterials(%moduleGroup)
@ -213,7 +224,7 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
return;
}
if(!isObject(ExecFilesList))
if(!isObject(ExecFilesList) || ExecFilesList.count() == 0)
{
error("Module::queueExec() - ExecFilesList array object doesn't exist!");
return;
@ -225,10 +236,11 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
%fullPath = pathConcat(%moduleDef.ModulePath, %execFilePath);
///go through all entries
%locked = false;
%execFilecount = ExecFilesList.count();
%execFileList = ExecFilesList.getKey(ExecFilesList.count()-1);
%execFilecount = %execFileList.count();
for (%i=0;%i<%execFilecount;%i++)
{
%check = ExecFilesList.getKey(%i);
%check = %execFileList.getKey(%i);
//look for a substring match
%isMatch = strIsMatchExpr("*"@ strReplace(%execFilePath,"./","/"),%check );
if (%isMatch)
@ -237,13 +249,13 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
//and kill off any duplicates
//do note that doing it in this order means setting exclusive twice
//allows one to override exclusive with exclusive
%locked = ExecFilesList.getValue(%i);
%locked = %execFileList.getValue(%i);
if ((%locked && !%isExclusive)&&($reportModuleFileConflicts))
error("found" SPC %execFilePath SPC "duplicate file!");
if (%isExclusive)
{ // Replacing an existing entry, update in-place
ExecFilesList.setKey(%fullPath, %i);
ExecFilesList.setValue(%isExclusive, %i);
%execFileList.setKey(%fullPath, %i);
%execFileList.setValue(%isExclusive, %i);
%locked = true; //Done, but don't return and bypass trace logging below
}
break;
@ -251,9 +263,9 @@ function SimSet::queueExec(%scopeSet, %execFilePath, %isExclusive)
}
//if we're not locked, go ahead and add it to the pile
if (!%locked)
ExecFilesList.add(%fullPath,%isExclusive);
%execFileList.add(%fullPath,%isExclusive);
if ($traceModuleCalls)
ExecFilesList.echo();
%execFileList.echo();
}
function SimSet::unQueueExec(%scopeSet, %execFilePath)
@ -269,7 +281,7 @@ function SimSet::unQueueExec(%scopeSet, %execFilePath)
return;
}
if(!isObject(ExecFilesList))
if(!isObject(ExecFilesList) || ExecFilesList.count() == 0)
{
error("Module::unRegisterDatablock() - ExecFilesList array object doesn't exist!");
return;
@ -280,23 +292,24 @@ function SimSet::unQueueExec(%scopeSet, %execFilePath)
%fullPath = pathConcat(%moduleDef.ModulePath, %relativePath);
///go through all entries
%locked = false;
%execFilecount = ExecFilesList.count();
%execFileList = ExecFilesList.getKey(ExecFilesList.count()-1);
%execFilecount = %execFileList.count();
for (%i=0;%i<%execFilecount;%i++)
{
%check = ExecFilesList.getKey(%i);
%check = %execFileList.getKey(%i);
//look for a substring match
%isMatch = strIsMatchExpr("*"@ %execFilePath,%check );
if (%isMatch)
{
//check if we're already locked in. if not, kill it.
%locked = ExecFilesList.getValue(%i);
%locked = %execFileList.getValue(%i);
if (!%locked)
{
ExecFilesList.erase(%i);
%execFileList.erase(%i);
}
}
}
if ($traceModuleCalls)
ExecFilesList.echo();
%execFileList.echo();
}