Moved unneeded modules to Templates/Modules

Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes
Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel
D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences
Added ability to collapse groups programmatically to GuiVariableInspector
Upped PSSM shadowmap max size to 4096
Caught GL deferred lighting/probes up to D3D11
Temporarily disabled forward lighting/probes on GL materials until conversion finished
Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced
Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings
Established current preset file for PostFXManager to use for reverting
WIP logic for forcing probes to update as part of level lighting load step in loading process
Streamlined PostFXManager code, removing unnecessary/redundant files
Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm
PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields
Changed PostFX editor to work with new callbacks via using VariableInspector
Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration
Made HDR on by default, removed enable field from editing
Made probe bake resolution a project setting
Updated many GL postFX shaders to have proper case for PostFx.glsl
Example module now loads ExampleGUI and ExamplePostEffect during init'ing
Removed unneeded autoload definitions from ExampleModule's module file
Fixed Graphics Adapter settings field to properly display as well as apply setting
Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent
Fixed coloration of tools button bitmap to make theming more consistent
Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text
Moved AssetBrowser field types to separated folder/files
Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation.
Removed unneded default autoload definitions from new modules
Added WIP for editing Module/Asset dependencies
Updated the PostEffectAsset to properly generate glsl and hlsl files from templates
Updated module editor window to display only necessary fields
Added WIP of TerrainAsset
Added shaderCache gitignore file so folder isn't lost
This commit is contained in:
Areloch 2019-09-29 06:44:43 -05:00
parent ff4c2d59fc
commit e7bf49e801
165 changed files with 2328 additions and 5095 deletions

View file

@ -81,6 +81,12 @@ void Scene::onRemove()
}*/
}
void Scene::onPostAdd()
{
if (isMethod("onPostAdd"))
Con::executef(this, "onPostAdd");
}
void Scene::addObject(SimObject* object)
{
//Child scene
@ -175,7 +181,7 @@ void Scene::unpackUpdate(NetConnection *conn, BitStream *stream)
}
//
Vector<SceneObject*> Scene::getObjectsByClass(String className)
Vector<SceneObject*> Scene::getObjectsByClass(String className, bool checkSubscenes)
{
return Vector<SceneObject*>();
}

View file

@ -50,6 +50,7 @@ public:
virtual bool onAdd();
virtual void onRemove();
virtual void onPostAdd();
virtual void interpolateTick(F32 delta);
virtual void processTick();
@ -67,7 +68,10 @@ public:
void unpackUpdate(NetConnection *conn, BitStream *stream);
//
Vector<SceneObject*> getObjectsByClass(String className);
Vector<SceneObject*> getObjectsByClass(String className, bool checkSubscenes);
template <class T>
Vector<T*> getObjectsByClass(bool checkSubscenes);
static Scene *getRootScene()
{
@ -79,3 +83,42 @@ public:
static Vector<Scene*> smSceneList;
};
template <class T>
Vector<T*> Scene::getObjectsByClass(bool checkSubscenes)
{
Vector<T*> foundObjects;
T* curObject;
//first, check ourself
for (U32 i = 0; i < mPermanentObjects.size(); i++)
{
curObject = dynamic_cast<T*>(mPermanentObjects[i]);
if (curObject)
foundObjects.push_back(curObject);
}
for (U32 i = 0; i < mDynamicObjects.size(); i++)
{
curObject = dynamic_cast<T*>(mDynamicObjects[i]);
if (curObject)
foundObjects.push_back(curObject);
}
if (checkSubscenes)
{
for (U32 i = 0; i < mSubScenes.size(); i++)
{
Vector<T*> appendList = mSubScenes[i]->getObjectsByClass<T>(true);
for (U32 a = 0; a < appendList.size(); a++)
{
foundObjects.push_back(appendList[a]);
}
}
}
return foundObjects;
}

View file

@ -88,6 +88,7 @@ LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
mLevelFile = StringTable->EmptyString();
mPreviewImage = StringTable->EmptyString();
mGamemodeName = StringTable->EmptyString();
mMainLevelAsset = StringTable->EmptyString();
}
@ -114,7 +115,7 @@ void LevelAsset::initPersistFields()
addProtectedField("PreviewImage", TypeAssetLooseFilePath, Offset(mPreviewImage, LevelAsset),
&setPreviewImageFile, &getPreviewImageFile, "Path to the image used for selection preview.");
addField("isSubScene", TypeString, Offset(mIsSubLevel, LevelAsset), "Is this a sublevel to another Scene");
addField("isSubScene", TypeBool, Offset(mIsSubLevel, LevelAsset), "Is this a sublevel to another Scene");
addField("gameModeName", TypeString, Offset(mGamemodeName, LevelAsset), "Name of the Game Mode to be used with this level");
}

View file

@ -0,0 +1,290 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2013 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.
//-----------------------------------------------------------------------------
#ifndef TERRAINASSET_H
#include "TerrainAsset.h"
#endif
#ifndef _ASSET_MANAGER_H_
#include "assets/assetManager.h"
#endif
#ifndef _CONSOLETYPES_H_
#include "console/consoleTypes.h"
#endif
#ifndef _TAML_
#include "persistence/taml/taml.h"
#endif
#ifndef _ASSET_PTR_H_
#include "assets/assetPtr.h"
#endif
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(TerrainAsset);
ConsoleType(TerrainAssetPtr, TypeTerrainAssetPtr, TerrainAsset, ASSET_ID_FIELD_PREFIX)
//-----------------------------------------------------------------------------
ConsoleGetType(TypeTerrainAssetPtr)
{
// Fetch asset Id.
return (*((AssetPtr<TerrainAsset>*)dptr)).getAssetId();
}
//-----------------------------------------------------------------------------
ConsoleSetType(TypeTerrainAssetPtr)
{
// Was a single argument specified?
if (argc == 1)
{
// Yes, so fetch field value.
const char* pFieldValue = argv[0];
// Fetch asset pointer.
AssetPtr<TerrainAsset>* pAssetPtr = dynamic_cast<AssetPtr<TerrainAsset>*>((AssetPtrBase*)(dptr));
// Is the asset pointer the correct type?
if (pAssetPtr == NULL)
{
// No, so fail.
//Con::warnf("(TypeMaterialAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
return;
}
// Set asset.
pAssetPtr->setAssetId(pFieldValue);
return;
}
// Warn.
Con::warnf("(TypeTerrainAssetPtr) - Cannot set multiple args to a single asset.");
}
//-----------------------------------------------------------------------------
TerrainAsset::TerrainAsset()
{
mTerrainFile = StringTable->EmptyString();
}
//-----------------------------------------------------------------------------
TerrainAsset::~TerrainAsset()
{
}
//-----------------------------------------------------------------------------
void TerrainAsset::initPersistFields()
{
// Call parent.
Parent::initPersistFields();
//addField("shaderGraph", TypeRealString, Offset(mShaderGraphFile, TerrainAsset), "");
addProtectedField("terrainFile", TypeAssetLooseFilePath, Offset(mTerrainFile, TerrainAsset),
&setTerrainFile, &getTerrainFile, "Path to the file containing the terrain data.");
}
void TerrainAsset::initializeAsset()
{
// Call parent.
Parent::initializeAsset();
if (!Platform::isFullPath(mTerrainFile))
mTerrainFile = getOwned() ? expandAssetFilePath(mTerrainFile) : mTerrainFile;
//if (Platform::isFile(mTerrainFile))
// Con::executeFile(mScriptFile, false, false);
}
void TerrainAsset::onAssetRefresh()
{
mTerrainFile = expandAssetFilePath(mTerrainFile);
//if (Platform::isFile(mScriptFile))
// Con::executeFile(mScriptFile, false, false);
}
void TerrainAsset::setTerrainFile(const char* pScriptFile)
{
// Sanity!
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
// Fetch image file.
pScriptFile = StringTable->insert(pScriptFile);
// Update.
mTerrainFile = getOwned() ? expandAssetFilePath(pScriptFile) : pScriptFile;
// Refresh the asset.
refreshAsset();
}
//------------------------------------------------------------------------------
void TerrainAsset::copyTo(SimObject* object)
{
// Call to parent.
Parent::copyTo(object);
}
//-----------------------------------------------------------------------------
// GuiInspectorTypeAssetId
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(GuiInspectorTypeTerrainAssetPtr);
ConsoleDocClass(GuiInspectorTypeTerrainAssetPtr,
"@brief Inspector field type for Material Asset Objects\n\n"
"Editor use only.\n\n"
"@internal"
);
void GuiInspectorTypeTerrainAssetPtr::consoleInit()
{
Parent::consoleInit();
ConsoleBaseType::getType(TypeTerrainAssetPtr)->setInspectorFieldType("GuiInspectorTypeTerrainAssetPtr");
}
GuiControl* GuiInspectorTypeTerrainAssetPtr::constructEditControl()
{
// Create base filename edit controls
mUseHeightOverride = true;
mHeightOverride = 100;
mMatEdContainer = new GuiControl();
mMatEdContainer->registerObject();
addObject(mMatEdContainer);
// Create "Open in ShapeEditor" button
mMatPreviewButton = new GuiBitmapButtonCtrl();
const char* matAssetId = getData();
TerrainAsset* matAsset = AssetDatabase.acquireAsset< TerrainAsset>(matAssetId);
TerrainMaterial* materialDef = nullptr;
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
/*if (!Sim::findObject(matAsset->getMaterialDefinitionName(), materialDef))
{
Con::errorf("GuiInspectorTypeTerrainAssetPtr::constructEditControl() - unable to find material in asset");
}
else
{
mMatPreviewButton->setBitmap(materialDef->mDiffuseMapFilename[0]);
}*/
mMatPreviewButton->setPosition(0, 0);
mMatPreviewButton->setExtent(100,100);
// Change filespec
char szBuffer[512];
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"TerrainAsset\", \"AssetBrowser.changeAsset\", %d, %s);",
mInspector->getComponentGroupTargetId(), mCaption);
mMatPreviewButton->setField("Command", szBuffer);
mMatPreviewButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
mMatPreviewButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
mMatPreviewButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
StringBuilder strbld;
/*strbld.append(matAsset->getMaterialDefinitionName());
strbld.append("\n");
strbld.append("Open this file in the Material Editor");*/
mMatPreviewButton->setDataField(StringTable->insert("tooltip"), NULL, strbld.data());
_registerEditControl(mMatPreviewButton);
//mMatPreviewButton->registerObject();
mMatEdContainer->addObject(mMatPreviewButton);
mMatAssetIdTxt = new GuiTextEditCtrl();
mMatAssetIdTxt->registerObject();
mMatAssetIdTxt->setActive(false);
mMatAssetIdTxt->setText(matAssetId);
mMatAssetIdTxt->setBounds(100, 0, 150, 18);
mMatEdContainer->addObject(mMatAssetIdTxt);
return mMatEdContainer;
}
bool GuiInspectorTypeTerrainAssetPtr::updateRects()
{
S32 dividerPos, dividerMargin;
mInspector->getDivider(dividerPos, dividerMargin);
Point2I fieldExtent = getExtent();
Point2I fieldPos = getPosition();
mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
if (mMatEdContainer != nullptr)
{
mMatPreviewButton->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
}
if (mMatPreviewButton != nullptr)
{
mMatPreviewButton->resize(Point2I::Zero, Point2I(100, 100));
}
if (mMatAssetIdTxt != nullptr)
{
mMatAssetIdTxt->resize(Point2I(100, 0), Point2I(mEditCtrlRect.extent.x - 100, 18));
}
return resized;
}
void GuiInspectorTypeTerrainAssetPtr::setMaterialAsset(String assetId)
{
mTargetObject->setDataField(mCaption, "", assetId);
//force a refresh
SimObject* obj = mInspector->getInspectObject();
mInspector->inspectObject(obj);
}
DefineEngineMethod(GuiInspectorTypeTerrainAssetPtr, setMaterialAsset, void, (String assetId), (""),
"Gets a particular shape animation asset for this shape.\n"
"@param animation asset index.\n"
"@return Shape Animation Asset.\n")
{
if (assetId == String::EmptyString)
return;
return object->setMaterialAsset(assetId);
}

View file

@ -0,0 +1,103 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2013 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.
//-----------------------------------------------------------------------------
#ifndef TERRAINASSET_H
#define TERRAINASSET_H
#ifndef _ASSET_BASE_H_
#include "assets/assetBase.h"
#endif
#ifndef _ASSET_DEFINITION_H_
#include "assets/assetDefinition.h"
#endif
#ifndef _STRINGUNIT_H_
#include "string/stringUnit.h"
#endif
#ifndef _ASSET_FIELD_TYPES_H_
#include "assets/assetFieldTypes.h"
#endif
#ifndef _GFXDEVICE_H_
#include "gfx/gfxDevice.h"
#endif
#ifndef _GUI_INSPECTOR_TYPES_H_
#include "gui/editor/guiInspectorTypes.h"
#endif
#include "terrain/terrData.h"
//-----------------------------------------------------------------------------
class TerrainAsset : public AssetBase
{
typedef AssetBase Parent;
StringTableEntry mTerrainFile;
public:
TerrainAsset();
virtual ~TerrainAsset();
/// Engine.
static void initPersistFields();
virtual void copyTo(SimObject* object);
void setTerrainFile(const char* pTerrainFile);
inline StringTableEntry getTerrainFile(void) const { return mTerrainFile; };
/// Declare Console Object.
DECLARE_CONOBJECT(TerrainAsset);
protected:
virtual void initializeAsset();
virtual void onAssetRefresh(void);
static bool setTerrainFile(void *obj, const char *index, const char *data) { static_cast<TerrainAsset*>(obj)->setTerrainFile(data); return false; }
static const char* getTerrainFile(void* obj, const char* data) { return static_cast<TerrainAsset*>(obj)->getTerrainFile(); }
};
DefineConsoleType(TypeTerrainAssetPtr, TerrainAsset)
//-----------------------------------------------------------------------------
// TypeAssetId GuiInspectorField Class
//-----------------------------------------------------------------------------
class GuiInspectorTypeTerrainAssetPtr : public GuiInspectorField
{
typedef GuiInspectorField Parent;
public:
GuiControl* mMatEdContainer;
GuiBitmapButtonCtrl *mMatPreviewButton;
GuiTextEditCtrl *mMatAssetIdTxt;
DECLARE_CONOBJECT(GuiInspectorTypeTerrainAssetPtr);
static void consoleInit();
virtual GuiControl* constructEditControl();
virtual bool updateRects();
void setMaterialAsset(String assetId);
};
#endif // _ASSET_BASE_H_

View file

@ -760,6 +760,12 @@ GFXTextureObject *GFXTextureManager::createTexture( U32 width, U32 height, GFXFo
GFXFormat checkFmt = format;
_validateTexParams( localWidth, localHeight, profile, numMips, checkFmt );
//check to see if we've handled the mips just now, and if not, then handle them here
if (numMips == numMipLevels && (localWidth != width || localHeight != height))
{
numMips = mFloor(mLog2(mMax(localWidth, localHeight))) + 1;
}
// AssertFatal( checkFmt == format, "Anonymous texture didn't get the format it wanted." );
GFXTextureObject *outTex = NULL;

View file

@ -116,6 +116,32 @@ void GuiVariableInspector::endGroup()
mCurrentGroup = "";
}
void GuiVariableInspector::setGroupExpanded(const char* groupName, bool isExpanded)
{
String name = groupName;
for (U32 g = 0; g < mGroups.size(); g++)
{
if (mGroups[g]->getGroupName() == name)
{
if (isExpanded)
mGroups[g]->expand();
else
mGroups[g]->collapse();
}
}
}
void GuiVariableInspector::setGroupsExpanded(bool isExpanded)
{
for (U32 g = 0; g < mGroups.size(); g++)
{
if (isExpanded)
mGroups[g]->expand();
else
mGroups[g]->collapse();
}
}
void GuiVariableInspector::addField(const char* name, const char* label, const char* typeName, const char* description,
const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj)
{
@ -227,6 +253,17 @@ DefineEngineMethod(GuiVariableInspector, endGroup, void, (),, "endGroup()")
object->endGroup();
}
DefineEngineMethod(GuiVariableInspector, setGroupExpanded, void, (const char* groupName, bool isExpanded), ("", false), "setGroupExpanded()")
{
object->setGroupExpanded(groupName, isExpanded);
}
DefineEngineMethod(GuiVariableInspector, setGroupsExpanded, void, (bool isExpanded), (false), "setGroupsExpanded()")
{
object->setGroupsExpanded(isExpanded);
}
DefineEngineMethod(GuiVariableInspector, addField, void, (const char* name, const char* label, const char* typeName,
const char* description, const char* defaultValue, const char* dataValues, SimObject* ownerObj),
("","","","","", "", nullAsType<SimObject*>()), "addField( fieldName/varName, fieldLabel, fieldTypeName, description, defaultValue, defaultValues, ownerObject )")

View file

@ -51,6 +51,8 @@ public:
void startGroup(const char* name);
void endGroup();
void setGroupExpanded(const char* groupName, bool isExpanded);
void setGroupsExpanded(bool isExpanded);
void addField(const char* name, const char* label, const char* typeName, const char* description,
const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj);
@ -71,4 +73,4 @@ protected:
};
#endif // _GUI_VARIABLEINSPECTOR_H_
#endif // _GUI_VARIABLEINSPECTOR_H_

View file

@ -595,7 +595,7 @@ ShadowMapParams::ShadowMapParams( LightInfo *light )
overDarkFactor.set(2000.0f, 1000.0f, 500.0f, 100.0f);
numSplits = 4;
logWeight = 0.91f;
texSize = 512;
texSize = 1024;
shadowDistance = 400.0f;
shadowSoftness = 0.15f;
fadeStartDist = 0.0f;
@ -655,9 +655,9 @@ void ShadowMapParams::_validate()
// based on the split count to keep the total
// shadow texture size within 4096.
if ( numSplits == 2 || numSplits == 4 )
maxTexSize = 2048;
maxTexSize = 4096;
if ( numSplits == 3 )
maxTexSize = 1024;
maxTexSize = 2048;
}
else
numSplits = 1;

View file

@ -827,6 +827,73 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
return outTex;
}
Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd)
{
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(componentList[C_CONNECTOR]);
/*Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var* matinfo = (Var*)LangElement::find("PBRConfig");
if (!matinfo)
{
Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness)
{
metalness = new Var("metalness", "float");
metalness->uniform = true;
metalness->constSortPos = cspPotentialPrimitive;
}
Var* smoothness = (Var*)LangElement::find("smoothness");
if (!smoothness)
{
smoothness = new Var("smoothness", "float");
smoothness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive;
}
matinfo = new Var("PBRConfig", "vec4");
LangElement* colorDecl = new DecOp(matinfo);
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
}
Var* wsNormal = (Var*)LangElement::find("wsNormal");
Var* normal = (Var*)LangElement::find("normal");
if (!normal)
{
normal = new Var("normal", "vec3");
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
if (!fd.features[MFT_NormalMap])
{
Var* worldToTangent = getInWorldToTangent(componentList);
meta->addStatement(new GenOp(" @ = normalize(tMul(@,vec3(0,0,1.0f)));\r\n\n", normal, worldToTangent));
}
else
{
meta->addStatement(new GenOp(" @ = normalize( half3( @ ) );\r\n", normal, wsNormal));
}
}
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
Var* wsPosition = getInWsPosition(componentList);
Var* wsView = getWsView(wsPosition, meta);
Var* surface = (Var*)LangElement::find("surface");
if (!surface)
{
surface = new Var("surface", "Surface");
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo,
wsPosition, wsEyePos, wsView));
}*/
Var* surface = (Var*)LangElement::find("surface");
if (!surface)
{
surface = new Var("surface", "float");
}
return surface;
}
//****************************************************************************
// Base Texture
//****************************************************************************
@ -2060,33 +2127,13 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
// TODO: We can totally detect for this in the material
// feature setup... we should move it out of here!
//
if ( fd.features[MFT_LightMap] || fd.features[MFT_ToneMap] || fd.features[MFT_VertLit] )
//if ( fd.features[MFT_LightMap] || fd.features[MFT_ToneMap] || fd.features[MFT_VertLit] )
return;
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
MultiLine *meta = new MultiLine;
// Look for a wsNormal or grab it from the connector.
Var *wsNormal = (Var*)LangElement::find( "wsNormal" );
if ( !wsNormal )
{
wsNormal = connectComp->getElement( RT_TEXCOORD );
wsNormal->setName( "wsNormal" );
wsNormal->setStructName( "IN" );
wsNormal->setType( "vec3" );
// If we loaded the normal its our responsibility
// to normalize it... the interpolators won't.
//
// Note we cast to half here to get partial precision
// optimized code which is an acceptable loss of
// precision for normals and performs much better
// on older Geforce cards.
//
meta->addStatement( new GenOp( " @ = normalize( half3( @ ) );\r\n", wsNormal, wsNormal ) );
}
// Now the wsPosition and wsView.
Var *wsPosition = getInWsPosition( componentList );
Var *wsView = getWsView( wsPosition, meta );
@ -2106,12 +2153,13 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
// Get all the light constants.
Var *inLightPos = new Var( "inLightPos", "vec4" );
inLightPos->uniform = true;
inLightPos->arraySize = 3;
inLightPos->arraySize = 4;
inLightPos->constSortPos = cspPotentialPrimitive;
Var *inLightInvRadiusSq = new Var( "inLightInvRadiusSq", "vec4" );
inLightInvRadiusSq->uniform = true;
inLightInvRadiusSq->constSortPos = cspPotentialPrimitive;
Var * inLightConfigData = new Var( "inLightConfigData", "vec4" );
inLightConfigData->uniform = true;
inLightConfigData->arraySize = 4;
inLightConfigData->constSortPos = cspPotentialPrimitive;
Var *inLightColor = new Var( "inLightColor", "vec4" );
inLightColor->uniform = true;
@ -2120,56 +2168,54 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
Var *inLightSpotDir = new Var( "inLightSpotDir", "vec4" );
inLightSpotDir->uniform = true;
inLightSpotDir->arraySize = 3;
inLightSpotDir->arraySize = 4;
inLightSpotDir->constSortPos = cspPotentialPrimitive;
Var *inLightSpotAngle = new Var( "inLightSpotAngle", "vec4" );
inLightSpotAngle->uniform = true;
inLightSpotAngle->constSortPos = cspPotentialPrimitive;
Var * lightSpotParams = new Var( "lightSpotParams", "vec4" );
lightSpotParams->uniform = true;
lightSpotParams->arraySize = 4;
lightSpotParams->constSortPos = cspPotentialPrimitive;
Var *lightSpotFalloff = new Var( "inLightSpotFalloff", "vec4" );
lightSpotFalloff->uniform = true;
lightSpotFalloff->constSortPos = cspPotentialPrimitive;
Var* hasVectorLight = new Var("hasVectorLight", "int");
hasVectorLight->uniform = true;
hasVectorLight->constSortPos = cspPotentialPrimitive;
Var *smoothness = (Var*)LangElement::find("smoothness");
if (!fd.features[MFT_SpecularMap])
Var* vectorLightDirection = new Var("vectorLightDirection", "vec4");
vectorLightDirection->uniform = true;
vectorLightDirection->constSortPos = cspPotentialPrimitive;
Var* vectorLightColor = new Var("vectorLightColor", "vec4");
vectorLightColor->uniform = true;
vectorLightColor->constSortPos = cspPotentialPrimitive;
Var* vectorLightBrightness = new Var("vectorLightBrightness", "float");
vectorLightBrightness->uniform = true;
vectorLightBrightness->constSortPos = cspPotentialPrimitive;
Var* surface = getSurface(componentList, meta, fd);
if (!surface)
{
if (!smoothness)
{
smoothness = new Var("smoothness", "float");
smoothness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive;
}
}
Con::errorf("ShaderGen::RTLightingFeatGLSL() - failed to generate surface!");
return;
}
Var *smoothness = (Var*)LangElement::find("smoothness");
Var *metalness = (Var*)LangElement::find("metalness");
if (!fd.features[MFT_SpecularMap])
{
if (!metalness)
{
metalness = new Var("metalness", "float");
metalness->uniform = true;
metalness->constSortPos = cspPotentialPrimitive;
}
}
Var *albedo = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var *ambient = new Var( "ambient", "vec4" );
ambient->uniform = true;
ambient->constSortPos = cspPass;
Var* lighting = new Var("lighting", "vec4");
meta->addStatement(new GenOp(" @ = compute4Lights( @, @, @, @,\r\n"
" @, @, @, @, @, @, @);\r\n",
new DecOp(lighting), surface, lightMask, inLightPos, inLightConfigData, inLightColor, inLightSpotDir, lightSpotParams,
hasVectorLight, vectorLightDirection, vectorLightColor, vectorLightBrightness));
// Calculate the diffuse shading and specular powers.
meta->addStatement( new GenOp( " compute4Lights( @, @, @, @,\r\n"
" @, @, @, @, @, @, @, @, @,\r\n"
" @, @ );\r\n",
wsView, wsPosition, wsNormal, lightMask,
inLightPos, inLightInvRadiusSq, inLightColor, inLightSpotDir, inLightSpotAngle, lightSpotFalloff, smoothness, metalness, albedo,
rtShading, specular ) );
meta->addStatement(new GenOp(" @.rgb += @.rgb;\r\n", curColor, lighting));
// Apply the lighting to the diffuse color.
LangElement *lighting = new GenOp( "vec4( @.rgb + @.rgb, 1 )", rtShading, ambient );
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );
output = meta;
}
@ -2872,7 +2918,7 @@ void HardwareSkinningFeatureGLSL::processVert(Vector<ShaderComponent*> &componen
}
//****************************************************************************
// ReflectionProbeFeatHLSL
// ReflectionProbeFeatGLSL
//****************************************************************************
ReflectionProbeFeatGLSL::ReflectionProbeFeatGLSL()
@ -2880,6 +2926,17 @@ ReflectionProbeFeatGLSL::ReflectionProbeFeatGLSL()
{
addDependency(&mDep);
}
void ReflectionProbeFeatGLSL::processVert(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd)
{
//MultiLine* meta = new MultiLine;
//output = meta;
// Also output the worldToTanget transform which
// we use to create the world space normal.
//getOutWorldToTangent(componentList, meta, fd);
}
void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd)
{
@ -2889,7 +2946,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
// TODO: We can totally detect for this in the material
// feature setup... we should move it out of here!
//
if (fd.features[MFT_LightMap] || fd.features[MFT_ToneMap] || fd.features[MFT_VertLit])
//if (fd.features[MFT_LightMap] || fd.features[MFT_ToneMap] || fd.features[MFT_VertLit])
return;
ShaderConnector * connectComp = dynamic_cast<ShaderConnector*>(componentList[C_CONNECTOR]);
@ -2897,15 +2954,13 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
MultiLine * meta = new MultiLine;
// Now the wsPosition and wsView.
Var * wsPosition = getInWsPosition(componentList);
Var * wsView = getWsView(wsPosition, meta);
Var * albedo = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var *wsPosition = getInWsPosition(componentList);
Var *wsView = getWsView(wsPosition, meta);
//Reflection Probe WIP
U32 MAX_FORWARD_PROBES = 4;
Var * numProbes = new Var("numProbes", "float");
Var * numProbes = new Var("numProbes", "int");
numProbes->uniform = true;
numProbes->constSortPos = cspPotentialPrimitive;
@ -2913,9 +2968,9 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
cubeMips->uniform = true;
cubeMips->constSortPos = cspPotentialPrimitive;
Var * hasSkylight = new Var("hasSkylight", "float");
hasSkylight->uniform = true;
hasSkylight->constSortPos = cspPotentialPrimitive;
Var * skylightCubemapIdx = new Var("skylightCubemapIdx", "float");
skylightCubemapIdx->uniform = true;
skylightCubemapIdx->constSortPos = cspPotentialPrimitive;
Var * inProbePosArray = new Var("inProbePosArray", "vec4");
inProbePosArray->arraySize = MAX_FORWARD_PROBES;
@ -2942,7 +2997,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
probeConfigData->uniform = true;
probeConfigData->constSortPos = cspPotentialPrimitive;
Var * worldToObjArray = new Var("worldToObjArray", "mat4x4");
Var * worldToObjArray = new Var("worldToObjArray", "mat4");
worldToObjArray->arraySize = MAX_FORWARD_PROBES;
worldToObjArray->uniform = true;
worldToObjArray->constSortPos = cspPotentialPrimitive;
@ -2965,87 +3020,29 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
irradianceCubemapAR->sampler = true;
irradianceCubemapAR->constNum = Var::getTexUnitNum();
Var * skylightSpecularMap = new Var("skylightSpecularMap", "samplerCube");
skylightSpecularMap->uniform = true;
skylightSpecularMap->sampler = true;
skylightSpecularMap->constNum = Var::getTexUnitNum();
Var* surface = getSurface(componentList, meta, fd);
Var * skylightIrradMap = new Var("skylightIrradMap", "samplerCube");
skylightIrradMap->uniform = true;
skylightIrradMap->sampler = true;
skylightIrradMap->constNum = Var::getTexUnitNum();
Var * inTex = getInTexCoord("texCoord", "vec2", componentList);
if (!inTex)
if (!surface)
{
Con::errorf("ShaderGen::ReflectionProbeFeatGLSL() - failed to generate surface!");
return;
Var * diffuseColor = (Var*)LangElement::find("diffuseColor");
if (!diffuseColor)
{
diffuseColor = new Var;
diffuseColor->setType("vec4");
diffuseColor->setName("diffuseColor");
LangElement* colorDecl = new DecOp(diffuseColor);
meta->addStatement(new GenOp(" @ = vec4(1.0,1.0,1.0,1.0);\r\n", colorDecl)); //default to flat white
}
Var* matinfo = (Var*)LangElement::find("PBRConfig");
if (!matinfo)
{
Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness)
{
metalness = new Var("metalness", "float");
metalness->uniform = true;
metalness->constSortPos = cspPotentialPrimitive;
}
Var* smoothness = (Var*)LangElement::find("smoothness");
if (!smoothness)
{
smoothness = new Var("smoothness", "float");
smoothness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive;
}
matinfo = new Var("PBRConfig", "vec4");
LangElement* colorDecl = new DecOp(matinfo);
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
}
Var* bumpNormal = (Var*)LangElement::find("bumpNormal");
if (!bumpNormal)
{
bumpNormal = new Var("bumpNormal", "vec4");
LangElement* colorDecl = new DecOp(bumpNormal);
meta->addStatement(new GenOp(" @ = vec4(1.0,0.0,0.0,0.0);\r\n", colorDecl)); //default to identity normal
}
Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var *matinfo = (Var*)LangElement::find("PBRConfig");
Var* metalness = (Var*)LangElement::find("metalness");
Var* smoothness = (Var*)LangElement::find("smoothness");
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
Var* worldToCamera = (Var*)LangElement::find("worldToCamera");
if (!worldToCamera)
{
worldToCamera = new Var;
worldToCamera->setType("mat4x4");
worldToCamera->setName("worldToCamera");
worldToCamera->uniform = true;
worldToCamera->constSortPos = cspPass;
}
//Reflection vec
Var* surface = new Var("surface", "Surface");
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, bumpNormal, matinfo,
inTex, wsPosition, wsEyePos, wsView, worldToCamera));
String computeForwardProbes = String(" @.rgb += computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
String computeForwardProbes = String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
computeForwardProbes += String("@,@,\r\n\t\t");
computeForwardProbes += String("@, @, \r\n\t\t");
computeForwardProbes += String("@,@).rgb; \r\n");
meta->addStatement(new GenOp(computeForwardProbes.c_str(), albedo, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refBoxMinArray, refBoxMaxArray, inRefPosArray,
hasSkylight, BRDFTexture,
skylightIrradMap, skylightSpecularMap,
meta->addStatement(new GenOp(computeForwardProbes.c_str(), curColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refBoxMinArray, refBoxMaxArray, inRefPosArray,
skylightCubemapIdx, BRDFTexture,
irradianceCubemapAR, specularCubemapAR));
output = meta;
@ -3055,8 +3052,8 @@ ShaderFeature::Resources ReflectionProbeFeatGLSL::getResources(const MaterialFea
{
Resources res;
res.numTex = 5;
res.numTexReg = 5;
res.numTex = 3;
res.numTexReg = 3;
return res;
}
@ -3075,9 +3072,5 @@ void ReflectionProbeFeatGLSL::setTexData(Material::StageData& stageDat,
passData.mTexType[texIndex++] = Material::SGCube;
passData.mSamplerNames[texIndex] = "irradianceCubemapAR";
passData.mTexType[texIndex++] = Material::SGCube;
passData.mSamplerNames[texIndex] = "skylightSpecularMap";
passData.mTexType[texIndex++] = Material::SGCube;
passData.mSamplerNames[texIndex] = "skylightIrradMap";
passData.mTexType[texIndex++] = Material::SGCube;
}
}

View file

@ -134,6 +134,8 @@ public:
Var* getInvWorldView( Vector<ShaderComponent*> &componentList,
bool useInstancing,
MultiLine *meta );
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd);
// ShaderFeature
Var* getVertTexCoord( const String &name );
@ -678,6 +680,9 @@ protected:
public:
ReflectionProbeFeatGLSL();
virtual void processVert(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd);
virtual void processPix(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd);

View file

@ -86,7 +86,7 @@ bool TSMesh::smUseEncodedNormals = false;
const F32 TSMesh::VISIBILITY_EPSILON = 0.0001f;
S32 TSMesh::smMaxInstancingVerts = 200;
S32 TSMesh::smMaxInstancingVerts = 2000;
MatrixF TSMesh::smDummyNodeTransform(1);
// quick function to force object to face camera -- currently throws out roll :(
@ -3473,4 +3473,4 @@ void TSSkinMesh::printVerts()
bw._indexes.x, bw._indexes.y, bw._indexes.z, bw._indexes.w,
bw._weights.x, bw._weights.y, bw._weights.z, bw._weights.w);
}
}
}

View file

@ -73,7 +73,7 @@ MODULE_BEGIN( TSShapeInstance )
Con::addVariable("$pref::TS::maxInstancingVerts", TypeS32, &TSMesh::smMaxInstancingVerts,
"@brief Enables mesh instancing on non-skin meshes that have less that this count of verts.\n"
"The default value is 200. Higher values can degrade performance.\n"
"The default value is 2000. Higher values can degrade performance.\n"
"@ingroup Rendering\n" );
}