mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Added Forward Material debug viz for HLSL(so far) and integrated it back into editor flagging.
Re-added logic to track existing probe shader consts instead of constantly recreating it Added logic for pre multiplied translucency mode
This commit is contained in:
parent
c74b669f5e
commit
72ceede272
16 changed files with 424 additions and 30 deletions
|
|
@ -85,7 +85,8 @@ ImplementEnumType( MaterialBlendOp,
|
|||
{ Material::Add, "Add", "Adds the color of the material to the frame buffer with full alpha for each pixel." },
|
||||
{ Material::AddAlpha, "AddAlpha", "The color is modulated by the alpha channel before being added to the frame buffer." },
|
||||
{ Material::Sub, "Sub", "Subtractive Blending. Reverses the color model, causing dark colors to have a stronger visual effect." },
|
||||
{ Material::LerpAlpha, "LerpAlpha", "Linearly interpolates between Material color and frame buffer color based on alpha." }
|
||||
{ Material::LerpAlpha, "LerpAlpha", "Linearly interpolates between Material color and frame buffer color based on alpha." },
|
||||
{ Material::PreMult, "PreMult", "" }
|
||||
EndImplementEnumType;
|
||||
|
||||
ImplementEnumType( MaterialWaveType,
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ public:
|
|||
Sub,
|
||||
LerpAlpha, // linear interpolation modulated with alpha channel
|
||||
ToneMap,
|
||||
PreMult,
|
||||
NumBlendTypes
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ ImplementFeatureType( MFT_GlowMask, MFG_PostLighting, 1.0f, true );
|
|||
ImplementFeatureType( MFT_Visibility, MFG_PostLighting, 2.0f, true );
|
||||
ImplementFeatureType( MFT_Fog, MFG_PostProcess, 3.0f, true );
|
||||
|
||||
ImplementFeatureType(MFT_DebugViz, MFG_PostProcess, 998.0f, true);
|
||||
|
||||
ImplementFeatureType( MFT_HDROut, MFG_PostProcess, 999.0f, true );
|
||||
|
||||
ImplementFeatureType( MFT_IsBC3nm, U32(-1), -1, true );
|
||||
|
|
|
|||
|
|
@ -153,6 +153,8 @@ DeclareFeatureType( MFT_Fog );
|
|||
/// dynamic range color into the correct HDR encoded format.
|
||||
DeclareFeatureType( MFT_HDROut );
|
||||
|
||||
DeclareFeatureType( MFT_DebugViz );
|
||||
|
||||
///
|
||||
DeclareFeatureType( MFT_DeferredConditioner );
|
||||
DeclareFeatureType( MFT_InterlacedDeferred );
|
||||
|
|
|
|||
|
|
@ -142,6 +142,13 @@ void ProcessedMaterial::_setBlendState(Material::BlendOp blendOp, GFXStateBlockD
|
|||
break;
|
||||
}
|
||||
|
||||
case Material::PreMult:
|
||||
{
|
||||
desc.blendSrc = GFXBlendOne;
|
||||
desc.blendDest = GFXBlendInvSrcAlpha;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
// default to LerpAlpha
|
||||
|
|
|
|||
|
|
@ -415,6 +415,11 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
fd.features.addFeature( MFT_NormalMapAtlas );
|
||||
}
|
||||
|
||||
if (!fd.features.hasFeature(MFT_ForwardShading))
|
||||
{
|
||||
fd.features.removeFeature(MFT_DebugViz);
|
||||
}
|
||||
|
||||
// Grab other features like normal maps, base texture, etc.
|
||||
FeatureSet mergeFeatures;
|
||||
mStages[stageNum].getFeatureSet( &mergeFeatures );
|
||||
|
|
@ -513,6 +518,8 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
//
|
||||
fd.features.addFeature( MFT_HDROut );
|
||||
|
||||
fd.features.addFeature(MFT_DebugViz);
|
||||
|
||||
// If vertex color is enabled on the material's stage and
|
||||
// color is present in vertex format, add diffuse vertex
|
||||
// color feature.
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ ProbeShaderConstants* RenderProbeMgr::getProbeShaderConstants(GFXShaderConstBuff
|
|||
|
||||
// Check to see if this is the same shader, we'll get hit repeatedly by
|
||||
// the same one due to the render bin loops.
|
||||
/*if (mLastShader.getPointer() != shader)
|
||||
if (mLastShader.getPointer() != shader)
|
||||
{
|
||||
ProbeConstantMap::Iterator iter = mConstantLookup.find(shader);
|
||||
if (iter != mConstantLookup.end())
|
||||
|
|
@ -538,13 +538,16 @@ ProbeShaderConstants* RenderProbeMgr::getProbeShaderConstants(GFXShaderConstBuff
|
|||
|
||||
// Set our new shader
|
||||
mLastShader = shader;
|
||||
}
|
||||
|
||||
/*if (mLastConstants == nullptr)
|
||||
{
|
||||
ProbeShaderConstants* psc = new ProbeShaderConstants();
|
||||
mConstantLookup[shader] = psc;
|
||||
|
||||
mLastConstants = psc;
|
||||
}*/
|
||||
|
||||
ProbeShaderConstants* psc = new ProbeShaderConstants();
|
||||
mConstantLookup[shader] = psc;
|
||||
|
||||
mLastConstants = psc;
|
||||
|
||||
// Make sure that our current lighting constants are initialized
|
||||
if (mLastConstants && !mLastConstants->mInit)
|
||||
mLastConstants->init(shader);
|
||||
|
|
|
|||
106
Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp
Normal file
106
Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#include "shaderGen/GLSL/debugVizFeatureGLSL.h"
|
||||
#include "shaderGen/shaderGen.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
#include "shaderGen/shaderGenVars.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "materials/matInstance.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "core/util/autoPtr.h"
|
||||
|
||||
//****************************************************************************
|
||||
// HDR Output
|
||||
//****************************************************************************
|
||||
|
||||
DebugVizGLSL::DebugVizGLSL()
|
||||
: mTorqueDep(ShaderGen::smCommonShaderPath + String("/gl/torque.glsl"))
|
||||
{
|
||||
addDependency(&mTorqueDep);
|
||||
}
|
||||
|
||||
void DebugVizGLSL::processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd)
|
||||
{
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var* surface = (Var*)LangElement::find("surface");
|
||||
|
||||
//0 == display both forward and deferred viz, 1 = display forward only viz, 2 = display deferred only viz
|
||||
S32 vizDisplayMode = Con::getIntVariable("$Viz_DisplayMode", 0);
|
||||
|
||||
if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
|
||||
{
|
||||
Var* color = (Var*)LangElement::find("col");
|
||||
if (color)
|
||||
{
|
||||
Var* specularColor = (Var*)LangElement::find("specularColor");
|
||||
|
||||
S32 surfaceVizMode = Con::getIntVariable("$Viz_SurfacePropertiesModeVar", -1);
|
||||
|
||||
switch (surfaceVizMode)
|
||||
{
|
||||
case 0:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.baseColor.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 1:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.N.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 2:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.ao.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 3:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.roughness.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 4:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.metalness.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 5:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.depth.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 6:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.albedo.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 7:
|
||||
if (!specularColor)
|
||||
{
|
||||
specularColor = new Var("specularColor", "float3");
|
||||
specularColor->uniform = false;
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = @.baseColor.rgb * @.ao;\r\n", specularColor, surface, surface));
|
||||
meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", color, specularColor));
|
||||
break;
|
||||
case 8:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.matFlag.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 9:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.P.xyz;\r\n", color, surface));
|
||||
break;
|
||||
case 10:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.R.xyz;\r\n", color, surface));
|
||||
break;
|
||||
case 11:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.F.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 12: //TODO
|
||||
/*Var * ssaoMaskTex = (Var*)LangElement::find("ssaoMaskTex");
|
||||
if (!ssaoMaskTex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @.rgb = @.N;\r\n", color, surface));*/
|
||||
meta->addStatement(new GenOp(" @.rgb = vec3(0,0,0);\r\n", color));
|
||||
break;
|
||||
case 13: //TODO
|
||||
meta->addStatement(new GenOp(" @.rgb = vec3(0,0,0);\r\n", color));
|
||||
break;
|
||||
case 14: //TODO
|
||||
meta->addStatement(new GenOp(" @.rgb = vec3(0,0,0);\r\n", color));
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
output = meta;
|
||||
}
|
||||
41
Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.h
Normal file
41
Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
|
||||
#include "shaderGen/GLSL/shaderFeatureGLSL.h"
|
||||
#endif
|
||||
#ifndef _LANG_ELEMENT_H_
|
||||
#include "shaderGen/langElement.h"
|
||||
#endif
|
||||
#ifndef _GFXDEVICE_H_
|
||||
#include "gfx/gfxDevice.h"
|
||||
#endif
|
||||
#ifndef _FEATUREMGR_H_
|
||||
#include "shaderGen/featureMgr.h"
|
||||
#endif
|
||||
#ifndef _MATERIALFEATURETYPES_H_
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#endif
|
||||
#ifndef _MATERIALFEATUREDATA_H_
|
||||
#include "materials/materialFeatureData.h"
|
||||
#endif
|
||||
|
||||
/// This should be the final feature on most pixel shaders which
|
||||
/// encodes the color for the current HDR target format.
|
||||
/// @see HDRPostFx
|
||||
/// @see LightManager
|
||||
/// @see torque.hlsl
|
||||
class DebugVizGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
protected:
|
||||
|
||||
ShaderIncludeDependency mTorqueDep;
|
||||
|
||||
public:
|
||||
|
||||
DebugVizGLSL();
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd);
|
||||
|
||||
virtual String getName() { return "Debug Viz"; }
|
||||
};
|
||||
106
Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp
Normal file
106
Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#include "shaderGen/HLSL/debugVizFeatureHLSL.h"
|
||||
#include "shaderGen/shaderGen.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
#include "shaderGen/shaderGenVars.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "materials/matInstance.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "core/util/autoPtr.h"
|
||||
|
||||
//****************************************************************************
|
||||
// HDR Output
|
||||
//****************************************************************************
|
||||
|
||||
DebugVizHLSL::DebugVizHLSL()
|
||||
: mTorqueDep(ShaderGen::smCommonShaderPath + String("/torque.hlsl"))
|
||||
{
|
||||
addDependency(&mTorqueDep);
|
||||
}
|
||||
|
||||
void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd)
|
||||
{
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var* surface = (Var*)LangElement::find("surface");
|
||||
|
||||
//0 == display both forward and deferred viz, 1 = display forward only viz, 2 = display deferred only viz
|
||||
S32 vizDisplayMode = Con::getIntVariable("$Viz_DisplayMode", 0);
|
||||
|
||||
if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
|
||||
{
|
||||
Var* color = (Var*)LangElement::find("col");
|
||||
if (color)
|
||||
{
|
||||
Var* specularColor = (Var*)LangElement::find("specularColor");
|
||||
|
||||
S32 surfaceVizMode = Con::getIntVariable("$Viz_SurfacePropertiesModeVar", -1);
|
||||
|
||||
switch (surfaceVizMode)
|
||||
{
|
||||
case 0:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.baseColor.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 1:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.N.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 2:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.ao.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 3:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.roughness.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 4:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.metalness.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 5:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.depth.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 6:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.albedo.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 7:
|
||||
if (!specularColor)
|
||||
{
|
||||
specularColor = new Var("specularColor", "float3");
|
||||
specularColor->uniform = false;
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = @.baseColor.rgb * @.ao;\r\n", specularColor, surface, surface));
|
||||
meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", color, specularColor));
|
||||
break;
|
||||
case 8:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.matFlag.rrr;\r\n", color, surface));
|
||||
break;
|
||||
case 9:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.P.xyz;\r\n", color, surface));
|
||||
break;
|
||||
case 10:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.R.xyz;\r\n", color, surface));
|
||||
break;
|
||||
case 11:
|
||||
meta->addStatement(new GenOp(" @.rgb = @.F.rgb;\r\n", color, surface));
|
||||
break;
|
||||
case 12: //TODO
|
||||
/*Var * ssaoMaskTex = (Var*)LangElement::find("ssaoMaskTex");
|
||||
if (!ssaoMaskTex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @.rgb = @.N;\r\n", color, surface));*/
|
||||
meta->addStatement(new GenOp(" @.rgb = float3(0,0,0);\r\n", color));
|
||||
break;
|
||||
case 13: //TODO
|
||||
meta->addStatement(new GenOp(" @.rgb = float3(0,0,0);\r\n", color));
|
||||
break;
|
||||
case 14: //TODO
|
||||
meta->addStatement(new GenOp(" @.rgb = float3(0,0,0);\r\n", color));
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
output = meta;
|
||||
}
|
||||
41
Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.h
Normal file
41
Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
|
||||
#include "shaderGen/HLSL/shaderFeatureHLSL.h"
|
||||
#endif
|
||||
#ifndef _LANG_ELEMENT_H_
|
||||
#include "shaderGen/langElement.h"
|
||||
#endif
|
||||
#ifndef _GFXDEVICE_H_
|
||||
#include "gfx/gfxDevice.h"
|
||||
#endif
|
||||
#ifndef _FEATUREMGR_H_
|
||||
#include "shaderGen/featureMgr.h"
|
||||
#endif
|
||||
#ifndef _MATERIALFEATURETYPES_H_
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#endif
|
||||
#ifndef _MATERIALFEATUREDATA_H_
|
||||
#include "materials/materialFeatureData.h"
|
||||
#endif
|
||||
|
||||
/// This should be the final feature on most pixel shaders which
|
||||
/// encodes the color for the current HDR target format.
|
||||
/// @see HDRPostFx
|
||||
/// @see LightManager
|
||||
/// @see torque.hlsl
|
||||
class DebugVizHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
protected:
|
||||
|
||||
ShaderIncludeDependency mTorqueDep;
|
||||
|
||||
public:
|
||||
|
||||
DebugVizHLSL();
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd);
|
||||
|
||||
virtual String getName() { return "Debug Viz"; }
|
||||
};
|
||||
|
|
@ -111,6 +111,10 @@ LangElement* ShaderFeatureHLSL::assignColor( LangElement *elem,
|
|||
assign = new GenOp( "@ -= @", color, elem );
|
||||
break;
|
||||
|
||||
case Material::PreMult:
|
||||
assign = new GenOp("@ *= @", color, elem);
|
||||
break;
|
||||
|
||||
case Material::Mul:
|
||||
assign = new GenOp( "@ *= @", color, elem );
|
||||
break;
|
||||
|
|
@ -2223,7 +2227,10 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
|
||||
// Now the wsPosition and wsView.
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
Var* wsNormal = getInWorldNormal(componentList);
|
||||
Var *wsPosition = getInWsPosition( componentList );
|
||||
|
||||
Var *wsView = getWsView( wsPosition, meta );
|
||||
|
||||
// Look for a light mask generated from a previous
|
||||
|
|
@ -3037,7 +3044,9 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
MultiLine *meta = new MultiLine;
|
||||
|
||||
// Now the wsPosition and wsView.
|
||||
Var *wsPosition = getInWsPosition(componentList);
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
Var *wsNormal = getInWorldNormal(componentList);
|
||||
Var* wsPosition = getInWsPosition(componentList);
|
||||
Var *wsView = getWsView(wsPosition, meta);
|
||||
|
||||
//Reflection Probe WIP
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "shaderGen/HLSL/bumpHLSL.h"
|
||||
#include "shaderGen/HLSL/pixSpecularHLSL.h"
|
||||
#include "shaderGen/HLSL/depthHLSL.h"
|
||||
#include "shaderGen/HLSL/debugVizFeatureHLSL.h"
|
||||
#include "shaderGen/HLSL/paraboloidHLSL.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "core/module.h"
|
||||
|
|
@ -89,6 +90,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
|||
|
||||
FEATUREMGR->registerFeature( MFT_HDROut, new HDROutHLSL );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_DebugViz, new DebugVizHLSL);
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_ParaboloidVertTransform, new ParaboloidVertTransformHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_IsSinglePassParaboloid, new NamedFeatureHLSL( "Single Pass Paraboloid" ) );
|
||||
FEATUREMGR->registerFeature( MFT_UseInstancing, new NamedFeatureHLSL( "Hardware Instancing" ) );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue