Core implementation of Physical Based Rendering.

This commit is contained in:
Areloch 2018-09-15 20:19:57 -05:00
parent 54f1d8c18e
commit b4a1d18f42
148 changed files with 4464 additions and 1016 deletions

View file

@ -116,11 +116,17 @@ Material::Material()
{
mDiffuse[i].set( 1.0f, 1.0f, 1.0f, 1.0f );
mDiffuseMapSRGB[i] = true;
mSpecular[i].set( 1.0f, 1.0f, 1.0f, 1.0f );
mSpecularPower[i] = 8.0f;
mSpecularStrength[i] = 1.0f;
mSmoothness[i] = 0.0f;
mMetalness[i] = 0.0f;
mPixelSpecular[i] = false;
mIsSRGb[i] = false;
mInvertSmoothness[i] = false;
mSmoothnessChan[i] = 0;
mAOChan[i] = 1;
mMetalChan[i] = 2;
mAccuEnabled[i] = false;
mAccuScale[i] = 1.0f;
@ -166,6 +172,9 @@ Material::Material()
// Deferred Shading
mMatInfoFlags[i] = 0.0f;
mRoughMapFilename[i].clear();
mAOMapFilename[i].clear();
mMetalMapFilename[i].clear();
}
dMemset(mCellIndex, 0, sizeof(mCellIndex));
@ -255,20 +264,12 @@ void Material::initPersistFields()
addField( "detailNormalMapStrength", TypeF32, Offset(mDetailNormalMapStrength, Material), MAX_STAGES,
"Used to scale the strength of the detail normal map when blended with the base normal map." );
addField("smoothness", TypeF32, Offset(mSmoothness, Material), MAX_STAGES,
"The degree of smoothness when not using a specularMap." );
addField("specular", TypeColorF, Offset(mSpecular, Material), MAX_STAGES,
"The color of the specular highlight when not using a specularMap." );
addField("specularPower", TypeF32, Offset(mSpecularPower, Material), MAX_STAGES,
"The hardness of the specular highlight when not using a specularMap." );
addField("specularStrength", TypeF32, Offset(mSpecularStrength, Material), MAX_STAGES,
"The strength of the specular highlight when not using a specularMap." );
addField("pixelSpecular", TypeBool, Offset(mPixelSpecular, Material), MAX_STAGES,
"This enables per-pixel specular highlights controlled by the alpha channel of the "
"normal map texture. Note that if pixel specular is enabled the DXTnm format will not "
"work with your normal map, unless you are also using a specular map." );
addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES,
"The degree of Metalness when not using a specularMap." );
addProtectedField( "accuEnabled", TYPEID< bool >(), Offset( mAccuEnabled, Material ),
&_setAccuEnabled, &defaultProtectedGetFn, MAX_STAGES, "Accumulation texture." );
@ -288,10 +289,31 @@ void Material::initPersistFields()
addField("accuSpecular", TypeF32, Offset(mAccuSpecular, Material), MAX_STAGES,
"Changes specularity to this value where the accumulated material is present.");
addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES,
"Substance Designer Workaround.");
addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES,
"Treat Smoothness as Roughness");
addField( "specularMap", TypeImageFilename, Offset(mSpecularMapFilename, Material), MAX_STAGES,
"The specular map texture. The RGB channels of this texture provide a per-pixel replacement for the 'specular' parameter on the material. "
"If this texture contains alpha information, the alpha channel of the texture will be used as the gloss map. "
"This provides a per-pixel replacement for the 'specularPower' on the material" );
"Prepacked specular map texture. The RGB channels of this texture provide per-pixel reference values for: "
"smoothness (R), Ambient Occlusion (G), and metalness(B)");
addField("roughMap", TypeImageFilename, Offset(mRoughMapFilename, Material), MAX_STAGES,
"smoothness map. will be packed into the R channel of a packed 'specular' map");
addField("smoothnessChan", TypeF32, Offset(mSmoothnessChan, Material), MAX_STAGES,
"The input channel smoothness maps use.");
addField("aoMap", TypeImageFilename, Offset(mAOMapFilename, Material), MAX_STAGES,
"Ambient Occlusion map. will be packed into the G channel of a packed 'specular' map");
addField("AOChan", TypeF32, Offset(mAOChan, Material), MAX_STAGES,
"The input channel AO maps use.");
addField("metalMap", TypeImageFilename, Offset(mMetalMapFilename, Material), MAX_STAGES,
"Metalness map. will be packed into the B channel of a packed 'specular' map");
addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES,
"The input channel metalness maps use.");
addField( "parallaxScale", TypeF32, Offset(mParallaxScale, Material), MAX_STAGES,
"Enables parallax mapping and defines the scale factor for the parallax effect. Typically "
@ -706,6 +728,13 @@ DefineConsoleMethod( Material, setAutoGenerated, void, (bool isAutoGenerated), ,
object->setAutoGenerated(isAutoGenerated);
}
DefineConsoleMethod(Material, getAutogeneratedFile, const char*, (), , "Get filename of autogenerated shader file")
{
SimObject *material = static_cast<SimObject *>(object);
return material->getFilename();
}
// Accumulation
bool Material::_setAccuEnabled( void *object, const char *index, const char *data )
{