mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 06:34:36 +00:00
Direct3D11 Engine/source changes
This commit is contained in:
parent
3a9b50f702
commit
41e5caf22b
81 changed files with 1291 additions and 617 deletions
|
|
@ -126,6 +126,18 @@ void DeferredRTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
lightInfoBuffer->sampler = true;
|
||||
lightInfoBuffer->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var* lightBufferTex = NULL;
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
lightInfoBuffer->setType("SamplerState");
|
||||
lightBufferTex = new Var;
|
||||
lightBufferTex->setName("lightInfoBufferTex");
|
||||
lightBufferTex->setType("Texture2D");
|
||||
lightBufferTex->uniform = true;
|
||||
lightBufferTex->texture = true;
|
||||
lightBufferTex->constNum = lightInfoBuffer->constNum;
|
||||
}
|
||||
|
||||
// Declare the RTLighting variables in this feature, they will either be assigned
|
||||
// in this feature, or in the tonemap/lightmap feature
|
||||
Var *d_lightcolor = new Var( "d_lightcolor", "float3" );
|
||||
|
|
@ -140,8 +152,12 @@ void DeferredRTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
|
||||
// Perform the uncondition here.
|
||||
String unconditionLightInfo = String::ToLower( AdvancedLightBinManager::smBufferName ) + "Uncondition";
|
||||
meta->addStatement( new GenOp( avar( " %s(tex2D(@, @), @, @, @);\r\n",
|
||||
unconditionLightInfo.c_str() ), lightInfoBuffer, uvScene, d_lightcolor, d_NL_Att, d_specular ) );
|
||||
if (mIsDirect3D11)
|
||||
meta->addStatement(new GenOp(avar(" %s(@.Sample(@, @), @, @, @);\r\n",
|
||||
unconditionLightInfo.c_str()), lightBufferTex, lightInfoBuffer, uvScene, d_lightcolor, d_NL_Att, d_specular));
|
||||
else
|
||||
meta->addStatement(new GenOp(avar(" %s(tex2D(@, @), @, @, @);\r\n",
|
||||
unconditionLightInfo.c_str()), lightInfoBuffer, uvScene, d_lightcolor, d_NL_Att, d_specular));
|
||||
|
||||
// If this has an interlaced pre-pass, do averaging here
|
||||
if( fd.features[MFT_InterlacedPrePass] )
|
||||
|
|
@ -157,8 +173,12 @@ void DeferredRTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
}
|
||||
|
||||
meta->addStatement( new GenOp( " float id_NL_Att, id_specular;\r\n float3 id_lightcolor;\r\n" ) );
|
||||
meta->addStatement( new GenOp( avar( " %s(tex2D(@, @ + float2(0.0, @.y)), id_lightcolor, id_NL_Att, id_specular);\r\n",
|
||||
unconditionLightInfo.c_str() ), lightInfoBuffer, uvScene, oneOverTargetSize ) );
|
||||
if (mIsDirect3D11)
|
||||
meta->addStatement(new GenOp(avar(" %s(@.Sample(@, @ + float2(0.0, @.y)), id_lightcolor, id_NL_Att, id_specular);\r\n",
|
||||
unconditionLightInfo.c_str()), lightBufferTex, lightInfoBuffer, uvScene, oneOverTargetSize));
|
||||
else
|
||||
meta->addStatement(new GenOp(avar(" %s(tex2D(@, @ + float2(0.0, @.y)), id_lightcolor, id_NL_Att, id_specular);\r\n",
|
||||
unconditionLightInfo.c_str()), lightInfoBuffer, uvScene, oneOverTargetSize));
|
||||
|
||||
meta->addStatement( new GenOp(" @ = lerp(@, id_lightcolor, 0.5);\r\n", d_lightcolor, d_lightcolor ) );
|
||||
meta->addStatement( new GenOp(" @ = lerp(@, id_NL_Att, 0.5);\r\n", d_NL_Att, d_NL_Att ) );
|
||||
|
|
@ -272,8 +292,17 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// create texture var
|
||||
Var *bumpMap = getNormalMapTex();
|
||||
Var *texCoord = getInTexCoord( "texCoord", "float2", true, componentList );
|
||||
LangElement *texOp = new GenOp( "tex2D(@, @)", bumpMap, texCoord );
|
||||
Var *texCoord = getInTexCoord("texCoord", "float2", true, componentList);
|
||||
|
||||
LangElement *texOp = NULL;
|
||||
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
Var *bumpMapTex = (Var*)LangElement::find("bumpMapTex");
|
||||
texOp = new GenOp("@.Sample(@, @)", bumpMapTex, bumpMap, texCoord);
|
||||
}
|
||||
else
|
||||
texOp = new GenOp("tex2D(@, @)", bumpMap, texCoord);
|
||||
|
||||
// create bump normal
|
||||
Var *bumpNorm = new Var;
|
||||
|
|
@ -295,8 +324,25 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
bumpMap->sampler = true;
|
||||
bumpMap->constNum = Var::getTexUnitNum();
|
||||
|
||||
texCoord = getInTexCoord( "detCoord", "float2", true, componentList );
|
||||
texOp = new GenOp( "tex2D(@, @)", bumpMap, texCoord );
|
||||
Var* detailNormalTex = NULL;
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
bumpMap->setType("SamplerState");
|
||||
detailNormalTex = new Var;
|
||||
detailNormalTex->setName("detailBumpMapTex");
|
||||
detailNormalTex->setType("Texture2D");
|
||||
detailNormalTex->uniform = true;
|
||||
detailNormalTex->texture = true;
|
||||
detailNormalTex->constNum = bumpMap->constNum;
|
||||
}
|
||||
|
||||
|
||||
texCoord = getInTexCoord("detCoord", "float2", true, componentList);
|
||||
|
||||
if (mIsDirect3D11)
|
||||
texOp = new GenOp("@.Sample(@, @)", detailNormalTex, bumpMap, texCoord);
|
||||
else
|
||||
texOp = new GenOp("tex2D(@, @)", bumpMap, texCoord);
|
||||
|
||||
Var *detailBump = new Var;
|
||||
detailBump->setName( "detailBump" );
|
||||
|
|
@ -333,25 +379,32 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
else if (fd.features[MFT_AccuMap])
|
||||
{
|
||||
Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
|
||||
if( bumpSample == NULL )
|
||||
if (bumpSample == NULL)
|
||||
{
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
Var *texCoord = getInTexCoord( "texCoord", "float2", true, componentList );
|
||||
Var *texCoord = getInTexCoord("texCoord", "float2", true, componentList);
|
||||
|
||||
Var *bumpMap = getNormalMapTex();
|
||||
|
||||
bumpSample = new Var;
|
||||
bumpSample->setType( "float4" );
|
||||
bumpSample->setName( "bumpSample" );
|
||||
LangElement *bumpSampleDecl = new DecOp( bumpSample );
|
||||
bumpSample->setType("float4");
|
||||
bumpSample->setName("bumpSample");
|
||||
LangElement *bumpSampleDecl = new DecOp(bumpSample);
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n", bumpSampleDecl, bumpMap, texCoord ) );
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
Var *bumpMapTex = (Var *)LangElement::find("bumpMapTex");
|
||||
output = new GenOp(" @ = @.Sample(@, @);\r\n", bumpSampleDecl, bumpMapTex, bumpMap, texCoord);
|
||||
}
|
||||
else
|
||||
output = new GenOp(" @ = tex2D(@, @);\r\n", bumpSampleDecl, bumpMap, texCoord);
|
||||
|
||||
if ( fd.features.hasFeature( MFT_DetailNormalMap ) )
|
||||
{
|
||||
Var *bumpMap = (Var*)LangElement::find( "detailBumpMap" );
|
||||
if ( !bumpMap ) {
|
||||
if ( !bumpMap )
|
||||
{
|
||||
bumpMap = new Var;
|
||||
bumpMap->setType( "sampler2D" );
|
||||
bumpMap->setName( "detailBumpMap" );
|
||||
|
|
@ -360,8 +413,24 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
bumpMap->constNum = Var::getTexUnitNum();
|
||||
}
|
||||
|
||||
Var* bumpMapTex = (Var*)LangElement::find("detailBumpMap");
|
||||
if (mIsDirect3D11 && !bumpMapTex)
|
||||
{
|
||||
bumpMap->setType("SamplerState");
|
||||
bumpMapTex = new Var;
|
||||
bumpMapTex->setName("detailBumpMapTex");
|
||||
bumpMapTex->setType("Texture2D");
|
||||
bumpMapTex->uniform = true;
|
||||
bumpMapTex->texture = true;
|
||||
bumpMapTex->constNum = bumpMap->constNum;
|
||||
}
|
||||
|
||||
texCoord = getInTexCoord( "detCoord", "float2", true, componentList );
|
||||
LangElement *texOp = new GenOp( "tex2D(@, @)", bumpMap, texCoord );
|
||||
LangElement *texOp = NULL;
|
||||
if (mIsDirect3D11)
|
||||
texOp = new GenOp("@.Sample(@, @)", bumpMap, bumpMapTex, texCoord);
|
||||
else
|
||||
texOp = new GenOp( "tex2D(@, @)", bumpMap, texCoord );
|
||||
|
||||
Var *detailBump = new Var;
|
||||
detailBump->setName( "detailBump" );
|
||||
|
|
@ -402,7 +471,14 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
bumpSample->setName( "bumpSample" );
|
||||
LangElement *bumpSampleDecl = new DecOp( bumpSample );
|
||||
|
||||
output = new GenOp( " @ = tex2D(@, @);\r\n", bumpSampleDecl, bumpMap, texCoord );
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
Var *bumpMapTex = (Var *)LangElement::find("bumpMapTex");
|
||||
output = new GenOp(" @ = @.Sample(@, @);\r\n", bumpSampleDecl, bumpMapTex, bumpMap, texCoord);
|
||||
}
|
||||
else
|
||||
output = new GenOp(" @ = tex2D(@, @);\r\n", bumpSampleDecl, bumpMap, texCoord);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -547,7 +623,8 @@ void DeferredPixelSpecularHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
AssertFatal( lightInfoSamp && d_specular && d_NL_Att,
|
||||
"DeferredPixelSpecularHLSL::processPix - Something hosed the deferred features!" );
|
||||
|
||||
if (fd.features[ MFT_AccuMap ]) {
|
||||
if (fd.features[ MFT_AccuMap ])
|
||||
{
|
||||
// change specularity where the accu texture is applied
|
||||
Var *accuPlc = (Var*) LangElement::find( "plc" );
|
||||
Var *accuSpecular = (Var*)LangElement::find( "accuSpecular" );
|
||||
|
|
@ -671,6 +748,18 @@ void DeferredMinnaertHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
prepassBuffer->sampler = true;
|
||||
prepassBuffer->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var* prePassTex = NULL;
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
prepassBuffer->setType("SamplerState");
|
||||
prePassTex = new Var;
|
||||
prePassTex->setName("prePassTex");
|
||||
prePassTex->setType("Texture2D");
|
||||
prePassTex->uniform = true;
|
||||
prePassTex->texture = true;
|
||||
prePassTex->constNum = prepassBuffer->constNum;
|
||||
}
|
||||
|
||||
// Texture coord
|
||||
Var *uvScene = (Var*) LangElement::find( "uvScene" );
|
||||
AssertFatal(uvScene != NULL, "Unable to find UVScene, no RTLighting feature?");
|
||||
|
|
@ -684,7 +773,11 @@ void DeferredMinnaertHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *d_NL_Att = (Var*)LangElement::find( "d_NL_Att" );
|
||||
|
||||
meta->addStatement( new GenOp( avar( " float4 normalDepth = %s(@, @);\r\n", unconditionPrePassMethod.c_str() ), prepassBuffer, uvScene ) );
|
||||
if (mIsDirect3D11)
|
||||
meta->addStatement(new GenOp(avar(" float4 normalDepth = %s(@, ,@, @);\r\n", unconditionPrePassMethod.c_str()), prepassBuffer, prePassTex, uvScene));
|
||||
else
|
||||
meta->addStatement(new GenOp(avar(" float4 normalDepth = %s(@, @);\r\n", unconditionPrePassMethod.c_str()), prepassBuffer, uvScene));
|
||||
|
||||
meta->addStatement( new GenOp( " float vDotN = dot(normalDepth.xyz, @);\r\n", wsViewVec ) );
|
||||
meta->addStatement( new GenOp( " float Minnaert = pow( @, @) * pow(vDotN, 1.0 - @);\r\n", d_NL_Att, minnaertConstant, minnaertConstant ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(Minnaert, Minnaert, Minnaert, 1.0)" ), Material::Mul ) ) );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue