mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
engine:
defines and alters a series of material features for deferred shading in order to define a fully fleshed out multiple render target gbuffer patterned after the general principles outlined http://www.catalinzima.com/xna/tutorials/deferred-rendering-in-xna/creating-the-g-buffer/ (though I cannot stress enough *not* using the identical layout) script: removes dead material features (ie: those that never functioned to begin with) shader: bool getFlag(float flags, int num) definition for retreiving data from the 3rd (matinfo) gbuffer slot's red channel (more on that shortly) purpose: _A)_ Small primer on how material features function: When a https://github.com/GarageGames/Torque3D/search?utf8=%E2%9C%93&q=_determineFeatures call is executed, certain conditions trigger a given .addFeature(MFT_SOMEFEATURE) call based upon material definition entries, be it a value, a texture reference, or even the presence or lack thereof for another feature. In general terms, the first to be executed is ProcessedShaderMaterial::_determineFeatures followed by ProcessedPrePassMaterial::_determineFeatures. The next commit will provide the bindings there. For now it's enough to understand that one of those two will trigger the shadergen subsystem, when rendering a material, to check it's associated list of features and spit out a shader if one is not already defined, or reference a pre-existing one that includes codelines determined by that list of features. Relevant execution of this is as follows: DeclareFeatureType( MFT_DeferredDiffuseMap ); - Name ImplementFeatureType( MFT_DeferredDiffuseMap, MFG_Texture, 2.0f, false ); - Codeline Insertion Order FEATUREMGR->registerFeature( MFT_DeferredDiffuseMap, new DeferredDiffuseMapHLSL ); - Hook to class which actually generates code alternately FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureHLSL( "Imposter" ) ); - a simple feature that serves no purpose further than as a test of it's existence (to modify other features for instance) class DeferredDiffuseMapHLSL : public ShaderFeatureHLSL - Class definition { getName -embeded in the proceedural shader as a remline both up top and before actual code insertions processPix - pixel shader codeline insertions getOutputTargets - used to determine which buffer is written to (assumes only one. depending on branched logic, older features that may be run for either forward or deferred rendering depending on circumstance may have a logical switch based on additional feature flags. as an example: TerrainBaseMapFeatHLSL::getOutputTargets) getResources - associated with the Resources struct, closely aligned with the hardware regestry getBlendOp - used to determine what blend operation to use if a material requires a second pass (defaults to overwriting) setTexData - ??? processVert - vertex shader codeline insertions }; _B)_ The resultant Gbuffer layout defined by the previous commit therefore is as follows: defaultrendertarget (referred to in shaders as out.col or col depending on GFX plugin) contains either lighting and normal data, or color data depending on if it is used in a deferred or forward lit manner (note for forward lit, this data is replaced as a second step with color. why custommaterials have traditionally had problems with lighting) color1 (referred to in shaders as out.col1 or col1 depending on GFX plugin) RGB color data and an A for blending operations (including transparency) color2 (referred to in shaders as out.col2 or col2 depending on GFX plugin) contains: red channel comprising material flags such as metalness, emissive, ect, green channel for translucency (light shining through, as oposed to see-through transparency), blue for blue for specular strength (how much light influences net color) alpha for specular power (generally how reflective/glossy an object is) long term purpose: further down the line, these will be used to condition data for use with a PBR subsystem, with further corrections to the underlying mathematics, strength being replaced by roughness, and power by metalness
This commit is contained in:
parent
5b5c6b9907
commit
196b214eae
25 changed files with 1257 additions and 486 deletions
|
|
@ -156,10 +156,10 @@ LangElement *ShaderFeatureGLSL::expandNormalMap( LangElement *sampleNormalOp,
|
|||
}
|
||||
else
|
||||
{
|
||||
// DXT Swizzle trick
|
||||
meta->addStatement( new GenOp( " @ = float4( @.ag * 2.0 - 1.0, 0.0, 0.0 ); // DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement( new GenOp( " @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // DXTnm\r\n", normalVar, normalVar, normalVar ) );
|
||||
}
|
||||
// DXT Swizzle trick
|
||||
meta->addStatement( new GenOp( " @ = float4( @.ag * 2.0 - 1.0, 0.0, 0.0 ); // DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement( new GenOp( " @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // DXTnm\r\n", normalVar, normalVar, normalVar ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -708,7 +708,7 @@ void ShaderFeatureGLSL::getWsPosition( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *objTrans = getObjTrans( componentList, useInstancing, meta );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, float4( @.xyz, 1 ) ).xyz;\r\n",
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, vec4( @.xyz, 1 ) ).xyz;\r\n",
|
||||
wsPosition, objTrans, inPosition ) );
|
||||
}
|
||||
|
||||
|
|
@ -847,12 +847,22 @@ void DiffuseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
}
|
||||
|
||||
U32 DiffuseMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// grab connector texcoord register
|
||||
Var *inTex = getInTexCoord( "texCoord", "vec2", true, componentList );
|
||||
|
||||
//determine output target
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -869,7 +879,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
MultiLine * meta = new MultiLine;
|
||||
output = meta;
|
||||
|
||||
if ( fd.features[MFT_CubeMap] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
|
|
@ -878,9 +887,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
inTex ) );
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement( new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor) );
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) );
|
||||
output = meta;
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else if(fd.features[MFT_DiffuseMapAtlas])
|
||||
{
|
||||
|
|
@ -946,8 +954,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
#ifdef DEBUG_ATLASED_UV_COORDS
|
||||
if(!fd.features[MFT_PrePassConditioner])
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = float4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @ = vec4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -961,20 +969,20 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
new DecOp(diffColor), diffuseMap, inTex));
|
||||
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
new DecOp(diffColor), diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1089,6 +1097,11 @@ void OverlayTexFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
// Diffuse color
|
||||
//****************************************************************************
|
||||
|
||||
U32 DiffuseFeatureGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -1099,7 +1112,33 @@ void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine* meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffuseMaterialColor, Material::Mul ) ) );
|
||||
Var *col = (Var*)LangElement::find("col");
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
col = (Var*)LangElement::find("col1");
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!col)
|
||||
{
|
||||
// create color var
|
||||
col = new Var;
|
||||
col->setType("vec4");
|
||||
col->setName(getOutputTargetVarName(targ));
|
||||
col->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @ = vec4(1.0);\r\n", col));
|
||||
}
|
||||
}
|
||||
|
||||
Material::BlendOp op;
|
||||
|
||||
if (fd.features[MFT_DiffuseMap])
|
||||
op = Material::Mul;
|
||||
else
|
||||
op = Material::None;
|
||||
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffuseMaterialColor, op, NULL, targ)));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1231,9 +1270,9 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Lightmap has already been included in the advanced light bin, so
|
||||
// no need to do any sampling or anything
|
||||
if(bPreProcessedLighting)
|
||||
statement = new GenOp( "float4(@, 1.0)", inColor );
|
||||
statement = new GenOp( "vec4(@, 1.0)", inColor );
|
||||
else
|
||||
statement = new GenOp( "tex2D(@, @) + float4(@.rgb, 0.0)", lightMap, inTex, inColor );
|
||||
statement = new GenOp( "tex2D(@, @) + vec4(@.rgb, 0.0)", lightMap, inTex, inColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1245,8 +1284,8 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ) );
|
||||
|
|
@ -1278,7 +1317,7 @@ void LightmapFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 LightmapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1372,8 +1411,8 @@ void TonemapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Assign to proper render target
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, blendOp ) ) );
|
||||
|
|
@ -1406,7 +1445,7 @@ void TonemapFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 TonemapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1512,17 +1551,17 @@ void VertLitGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// the dynamic light buffer, and it already has the baked-vertex-color
|
||||
// included in it
|
||||
if(bPreProcessedLighting)
|
||||
outColor = new GenOp( "float4(@.rgb, 1.0)", rtLightingColor );
|
||||
outColor = new GenOp( "vec4(@.rgb, 1.0)", rtLightingColor );
|
||||
else
|
||||
outColor = new GenOp( "float4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
||||
outColor = new GenOp( "vec4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
||||
}
|
||||
}
|
||||
|
||||
// Output the color
|
||||
if ( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, blendOp ) ) );
|
||||
|
|
@ -1532,7 +1571,7 @@ void VertLitGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
U32 VertLitGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1571,7 +1610,10 @@ void DetailFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// and a simple multiplication with the detail map.
|
||||
|
||||
LangElement *statement = new GenOp( "( tex2D(@, @) * 2.0 ) - 1.0", detailMap, inTex );
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
if ( fd.features[MFT_isDeferred])
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add, NULL, ShaderFeature::RenderTarget1 ) );
|
||||
else
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DetailFeatGLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -1630,7 +1672,7 @@ void VertPositionGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *modelview = getModelView( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, float4(@.xyz,1));\r\n",
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, vec4(@.xyz,1));\r\n",
|
||||
outPosition, modelview, inPosition ) );
|
||||
|
||||
output = meta;
|
||||
|
|
@ -1694,8 +1736,8 @@ void ReflectCubeFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
cubeNormal->setName( "cubeNormal" );
|
||||
cubeNormal->setType( "vec3" );
|
||||
LangElement *cubeNormDecl = new DecOp( cubeNormal );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = ( tMul( (@), vec4(@, 0) ) ).xyz;\r\n",
|
||||
|
||||
meta->addStatement( new GenOp( " @ = ( tMul( (@), vec4(@, 0) ) ).xyz;\r\n",
|
||||
cubeNormDecl, cubeTrans, inNormal ) );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = bool(length(@)) ? normalize(@) : @;\r\n",
|
||||
|
|
@ -1771,9 +1813,14 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
glossColor = (Var*) LangElement::find( "diffuseColor" );
|
||||
if( !glossColor )
|
||||
glossColor = (Var*) LangElement::find( "bumpNormal" );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
glossColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("specularColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("diffuseColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("bumpNormal");
|
||||
}
|
||||
|
||||
// grab connector texcoord register
|
||||
|
|
@ -1786,7 +1833,7 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// create cubemap var
|
||||
Var *cubeMap = new Var;
|
||||
cubeMap->setType( "samplerCUBE" );
|
||||
cubeMap->setType( "samplerCube" );
|
||||
cubeMap->setName( "cubeMap" );
|
||||
cubeMap->uniform = true;
|
||||
cubeMap->sampler = true;
|
||||
|
|
@ -1800,14 +1847,36 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if ( fd.materialFeatures[MFT_RTLighting] )
|
||||
attn =(Var*)LangElement::find("d_NL_Att");
|
||||
|
||||
LangElement *texCube = new GenOp( "texCUBE( @, @ )", cubeMap, reflectVec );
|
||||
LangElement *texCube = NULL;
|
||||
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
//first try and grab the gbuffer
|
||||
if (fd.features[MFT_isDeferred] && matinfo)
|
||||
{
|
||||
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
texCube = new GenOp("textureLod( @, @, (@.a*5) )", cubeMap, reflectVec, matinfo);
|
||||
else
|
||||
texCube = new GenOp("textureLod( @, @, (@.a/4) )", cubeMap, reflectVec, matinfo);
|
||||
}
|
||||
else if(glossColor) //failing that, rtry and find color data
|
||||
texCube = new GenOp("textureLod( @, @, @.a*5)", cubeMap, reflectVec, glossColor);
|
||||
else
|
||||
texCube = new GenOp("texture( @, @)", cubeMap, reflectVec);
|
||||
|
||||
LangElement *lerpVal = NULL;
|
||||
Material::BlendOp blendOp = Material::LerpAlpha;
|
||||
|
||||
// Note that the lerpVal needs to be a float4 so that
|
||||
// it will work with the LerpAlpha blend.
|
||||
|
||||
if ( glossColor )
|
||||
|
||||
if (matinfo)
|
||||
{
|
||||
if (attn)
|
||||
lerpVal = new GenOp("@ * saturate( @ )", matinfo, attn);
|
||||
else
|
||||
lerpVal = new GenOp("@", matinfo);
|
||||
}
|
||||
else if ( glossColor )
|
||||
{
|
||||
if ( attn )
|
||||
lerpVal = new GenOp( "@ * saturate( @ )", glossColor, attn );
|
||||
|
|
@ -1821,8 +1890,16 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
else
|
||||
blendOp = Material::Mul;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
Var* targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b));\r\n", targ, targ, texCube, lerpVal));
|
||||
else
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b*128/5));\r\n", targ, targ, texCube, lerpVal));
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1967,7 +2044,7 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
Var *objTrans = getObjTrans( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
||||
// Transform the normal to world space.
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, float4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, vec4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
||||
}
|
||||
|
||||
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
|
@ -2025,7 +2102,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// feature (this is done for BL terrain lightmaps).
|
||||
LangElement *lightMask = LangElement::find( "lightMask" );
|
||||
if ( !lightMask )
|
||||
lightMask = new GenOp( "float4( 1, 1, 1, 1 )" );
|
||||
lightMask = new GenOp( "vec4( 1, 1, 1, 1 )" );
|
||||
|
||||
// Get all the light constants.
|
||||
Var *inLightPos = new Var( "inLightPos", "vec4" );
|
||||
|
|
@ -2080,7 +2157,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
rtShading, specular ) );
|
||||
|
||||
// Apply the lighting to the diffuse color.
|
||||
LangElement *lighting = new GenOp( "float4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
LangElement *lighting = new GenOp( "vec4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -2351,7 +2428,9 @@ void AlphaTestGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
// If we don't have a color var then we cannot do an alpha test.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find( "col1" );
|
||||
if ( !color )
|
||||
color = (Var*)LangElement::find("col");
|
||||
if ( !color )
|
||||
{
|
||||
output = NULL;
|
||||
|
|
@ -2718,3 +2797,16 @@ void ImposterVertFeatureGLSL::determineFeature( Material *material,
|
|||
outFeatureData->features.addFeature( MFT_ImposterVert );
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// Vertex position
|
||||
//****************************************************************************
|
||||
void DeferredSkyGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *outPosition = (Var*)LangElement::find( "gl_Position" );
|
||||
MultiLine *meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @.w = @.z;\r\n", outPosition, outPosition ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue