mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Merge branch 'alpha40translucency2' of https://github.com/Azaezel/Torque3D into Preview4_0
This commit is contained in:
commit
5088197d05
1106 changed files with 62767 additions and 205088 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "scene/sceneRenderState.h"
|
||||
#include "core/util/systemInterfaceList.h"
|
||||
#include "core/util/SystemInterfaceList.h"
|
||||
#include "ts/tsShape.h"
|
||||
#include "ts/tsShapeInstance.h"
|
||||
#include "T3D/assets/ShapeAsset.h"
|
||||
|
|
@ -59,4 +59,4 @@ public:
|
|||
|
||||
//Render our particular interface's data
|
||||
static void renderInterface(U32 interfaceIndex, SceneRenderState* state);
|
||||
};
|
||||
};
|
||||
|
|
@ -639,8 +639,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
probeWorldToObjArray[effectiveProbeCount] = curEntry.getTransform();
|
||||
|
||||
Point3F refPos = curEntry.getPosition() + curEntry.mProbeRefOffset;
|
||||
Point3F refBoxMin = refPos - curEntry.mProbeRefScale * curEntry.getTransform().getScale();
|
||||
Point3F refBoxMax = refPos + curEntry.mProbeRefScale * curEntry.getTransform().getScale();
|
||||
Point3F refBoxMin = refPos - curEntry.mProbeRefScale/2 * curEntry.getTransform().getScale();
|
||||
Point3F refBoxMax = refPos + curEntry.mProbeRefScale/2 * curEntry.getTransform().getScale();
|
||||
|
||||
refBoxMinArray[mEffectiveProbeCount] = Point4F(refBoxMin.x, refBoxMin.y, refBoxMin.z, 0);
|
||||
refBoxMaxArray[mEffectiveProbeCount] = Point4F(refBoxMax.x, refBoxMax.y, refBoxMax.z, 0);
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public:
|
|||
|
||||
void clear();
|
||||
|
||||
inline bool operator ==(const ProbeRenderInst& b) const
|
||||
inline bool ProbeRenderInst::operator ==(const ProbeRenderInst& b) const
|
||||
{
|
||||
return mProbeIdx == b.mProbeIdx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -405,11 +405,8 @@ Var* ShaderFeatureHLSL::getInTexCoord( const char *name,
|
|||
texCoord->setType( type );
|
||||
}
|
||||
|
||||
//AssertFatal( dStrcmp( type, (const char*)texCoord->type ) == 0,
|
||||
// "ShaderFeatureHLSL::getInTexCoord - Type mismatch!" );
|
||||
|
||||
if (dStrcmp(type, (const char*)texCoord->type) != 0)
|
||||
return nullptr;
|
||||
AssertFatal( dStrcmp( type, (const char*)texCoord->type ) == 0,
|
||||
"ShaderFeatureHLSL::getInTexCoord - Type mismatch!" );
|
||||
|
||||
return texCoord;
|
||||
}
|
||||
|
|
@ -821,7 +818,7 @@ Var* ShaderFeatureHLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|||
return outTex;
|
||||
}
|
||||
|
||||
Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta)
|
||||
Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd)
|
||||
{
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(componentList[C_CONNECTOR]);
|
||||
|
||||
|
|
@ -856,22 +853,20 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
return nullptr;
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
if (!wsNormal)
|
||||
Var* normal = (Var*)LangElement::find("normal");
|
||||
if (!normal)
|
||||
{
|
||||
wsNormal = connectComp->getElement(RT_TEXCOORD);
|
||||
wsNormal->setName("wsNormal");
|
||||
wsNormal->setStructName("IN");
|
||||
wsNormal->setType("float3");
|
||||
|
||||
// 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));
|
||||
normal = new Var("normal", "float3");
|
||||
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
||||
if (!fd.features[MFT_NormalMap])
|
||||
{
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
meta->addStatement(new GenOp(" @ = normalize(mul(@,float3(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");
|
||||
|
|
@ -883,7 +878,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
if (!surface)
|
||||
{
|
||||
surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, wsNormal, matinfo,
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo,
|
||||
inTex, wsPosition, wsEyePos, wsView));
|
||||
}
|
||||
|
||||
|
|
@ -2122,6 +2117,7 @@ void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||
getOutWorldToTangent(componentList, meta, fd);
|
||||
|
||||
// Special case for lighting imposters. We dont have a vert normal and may not
|
||||
// have a normal map. Generate and pass the normal data the pixel shader needs.
|
||||
|
|
@ -2203,36 +2199,10 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
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( "float3" );
|
||||
|
||||
// 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 );
|
||||
|
||||
// Create temporaries to hold results of lighting.
|
||||
//Var *rtShading = new Var( "rtShading", "float4" );
|
||||
//Var *specular = new Var( "specular", "float4" );
|
||||
//meta->addStatement( new GenOp( " @; @;\r\n",
|
||||
// new DecOp( rtShading ), new DecOp( specular ) ) );
|
||||
|
||||
|
||||
// Look for a light mask generated from a previous
|
||||
// feature (this is done for BL terrain lightmaps).
|
||||
LangElement *lightMask = LangElement::find( "lightMask" );
|
||||
|
|
@ -2265,59 +2235,28 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
lightSpotParams->arraySize = 4;
|
||||
lightSpotParams->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var* surface = getSurface(componentList, meta);
|
||||
Var* surface = getSurface(componentList, meta, fd);
|
||||
if (!surface)
|
||||
{
|
||||
Con::errorf("ShaderGen::RTLightingFeatHLSL() - failed to generate surface!");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
Var *smoothness = (Var*)LangElement::find("smoothness");
|
||||
/*if (!fd.features[MFT_SpecularMap])
|
||||
{
|
||||
if (!smoothness)
|
||||
{
|
||||
smoothness = new Var("smoothness", "float");
|
||||
smoothness->uniform = true;
|
||||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
}*/
|
||||
|
||||
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", "float4" );
|
||||
ambient->uniform = true;
|
||||
ambient->constSortPos = cspPass;
|
||||
|
||||
// Calculate the diffuse shading and specular powers.
|
||||
/*meta->addStatement( new GenOp( " compute4Lights( @, @, @, @,\r\n"
|
||||
" @, @, @, @, @, @, @, @, @,\r\n"
|
||||
" @, @ );\r\n",
|
||||
wsView, wsPosition, wsNormal, lightMask,
|
||||
inLightPos, inLightConfigData, inLightColor, inLightSpotDir, inLightSpotAngle, lightSpotFalloff, smoothness, metalness, albedo,
|
||||
rtShading, specular ) );
|
||||
|
||||
// Apply the lighting to the diffuse color.
|
||||
LangElement *lighting = new GenOp( "float4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );*/
|
||||
|
||||
|
||||
Var* lighting = new Var("lighting", "float4");
|
||||
meta->addStatement(new GenOp(" @ = compute4Lights( @, @, @, @,\r\n"
|
||||
" @, @, @);\r\n",
|
||||
new DecOp(lighting), surface, lightMask, inLightPos, inLightConfigData, inLightColor, inLightSpotDir, lightSpotParams));
|
||||
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(lighting, Material::Add)));
|
||||
meta->addStatement(new GenOp(" @.rgb += @.rgb;\r\n", curColor, lighting));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -3136,35 +3075,28 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
irradianceCubemapARTex->texture = true;
|
||||
irradianceCubemapARTex->constNum = irradianceCubemapAR->constNum;
|
||||
|
||||
Var* surface = getSurface(componentList, meta);
|
||||
Var* surface = getSurface(componentList, meta, fd);
|
||||
|
||||
if (!surface)
|
||||
{
|
||||
Con::errorf("ShaderGen::ReflectionProbeFeatHLSL() - failed to generate surface!");
|
||||
return;
|
||||
}
|
||||
|
||||
Var *inTex = getInTexCoord("texCoord", "float2", componentList);
|
||||
if (!inTex)
|
||||
return;
|
||||
|
||||
Var *diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
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* worldToTangent = getInWorldToTangent(componentList);
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
|
||||
//Reflection vec
|
||||
String computeForwardProbes = String::String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n");
|
||||
|
||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), diffuseColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refBoxMinArray, refBoxMaxArray, inRefPosArray,
|
||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), curColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refBoxMinArray, refBoxMaxArray, inRefPosArray,
|
||||
skylightCubemapIdx, BRDFTexture,
|
||||
irradianceCubemapAR, specularCubemapAR));
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public:
|
|||
bool useInstancing,
|
||||
MultiLine *meta );
|
||||
|
||||
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta);
|
||||
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd);
|
||||
|
||||
// ShaderFeature
|
||||
Var* getVertTexCoord( const String &name );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue