|
@@ -474,25 +474,11 @@ Var* ShaderFeatureGLSL::getInVpos( MultiLine *meta,
|
|
|
return inVpos;
|
|
|
|
|
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector*>( componentList[C_CONNECTOR] );
|
|
|
- /*
|
|
|
- if ( GFX->getPixelShaderVersion() >= 3.0f )
|
|
|
- {
|
|
|
- inVpos = connectComp->getElement( RT_VPOS );
|
|
|
- inVpos->setName( "vpos" );
|
|
|
- inVpos->setStructName( "IN" );
|
|
|
- inVpos->setType( "vec2" );
|
|
|
- return inVpos;
|
|
|
- }
|
|
|
- */
|
|
|
inVpos = connectComp->getElement( RT_TEXCOORD );
|
|
|
inVpos->setName( "inVpos" );
|
|
|
inVpos->setStructName( "IN" );
|
|
|
inVpos->setType( "vec4" );
|
|
|
-
|
|
|
- Var *vpos = new Var( "vpos", "vec2" );
|
|
|
- meta->addStatement( new GenOp( " @ = @.xy / @.w;\r\n", new DecOp( vpos ), inVpos, inVpos ) );
|
|
|
-
|
|
|
- return vpos;
|
|
|
+ return inVpos;
|
|
|
}
|
|
|
|
|
|
Var* ShaderFeatureGLSL::getInWorldToTangent( Vector<ShaderComponent*> &componentList )
|
|
@@ -779,6 +765,21 @@ Var* ShaderFeatureGLSL::getWsView( Var *wsPosition, MultiLine *meta )
|
|
|
return wsView;
|
|
|
}
|
|
|
|
|
|
+Var* ShaderFeatureGLSL::getInWorldNormal(Vector<ShaderComponent*>& componentList)
|
|
|
+{
|
|
|
+ Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
|
|
+ if (!wsNormal)
|
|
|
+ {
|
|
|
+ ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(componentList[C_CONNECTOR]);
|
|
|
+ wsNormal = connectComp->getElement(RT_TEXCOORD);
|
|
|
+ wsNormal->setName("wsNormal");
|
|
|
+ wsNormal->setStructName("IN");
|
|
|
+ wsNormal->setType("float3");
|
|
|
+ }
|
|
|
+
|
|
|
+ return wsNormal;
|
|
|
+}
|
|
|
+
|
|
|
Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &componentList,
|
|
|
MultiLine *meta,
|
|
|
bool useTexAnim,
|
|
@@ -865,21 +866,23 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|
|
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, roughness, metalness)); //reconstruct ormConfig, no ao darkening
|
|
|
}
|
|
|
|
|
|
- Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
|
|
Var* normal = (Var*)LangElement::find("normal");
|
|
|
if (!normal)
|
|
|
{
|
|
|
normal = new Var("normal", "vec3");
|
|
|
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
|
|
+
|
|
|
+ Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
|
|
if (!fd.features[MFT_NormalMap])
|
|
|
{
|
|
|
- Var* worldToTangent = getInWorldToTangent(componentList);
|
|
|
- meta->addStatement(new GenOp(" @ = normalize(tMul(@,vec3(0,0,1.0f)));\r\n\n", normal, worldToTangent));
|
|
|
+ if (!wsNormal)
|
|
|
+ wsNormal = getInWorldNormal(componentList);
|
|
|
+ meta->addStatement(new GenOp(" @ = normalize( @ );\r\n\n", normal, wsNormal));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- meta->addStatement(new GenOp(" @ = normalize( half3( @ ) );\r\n", normal, wsNormal));
|
|
|
- }
|
|
|
+ meta->addStatement(new GenOp(" @ = normalize( @ );\r\n", normal, wsNormal));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
|
@@ -1979,6 +1982,7 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
Var *envColor = new Var("envColor", "vec3");
|
|
|
meta->addStatement(new GenOp(" @ = @.rgb - (@.rgb * @);\r\n", new DecOp(dColor), targ, targ, metalness));
|
|
|
meta->addStatement(new GenOp(" @ = @.rgb*(@).rgb;\r\n", new DecOp(envColor), targ, texCube));
|
|
|
+ meta->addStatement(new GenOp(" @.rgb = @+@;\r\n", targ, dColor, envColor));
|
|
|
}
|
|
|
else if (lerpVal)
|
|
|
meta->addStatement(new GenOp(" @ *= vec4(@.rgb*@.a, @.a);\r\n", targ, texCube, lerpVal, targ));
|
|
@@ -2067,7 +2071,6 @@ RTLightingFeatGLSL::RTLightingFeatGLSL()
|
|
|
void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
|
const MaterialFeatureData &fd )
|
|
|
{
|
|
|
- if (fd.features[MFT_ImposterVert]) return;
|
|
|
MultiLine *meta = new MultiLine;
|
|
|
|
|
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
|
@@ -2104,12 +2107,15 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
|
|
+ getOutWorldToTangent(componentList, meta, fd);
|
|
|
+
|
|
|
+ output = meta;
|
|
|
+
|
|
|
// Find the incoming vertex normal.
|
|
|
Var *inNormal = (Var*)LangElement::find( "normal" );
|
|
|
-
|
|
|
- // Skip out on realtime lighting if we don't have a normal
|
|
|
- // or we're doing some sort of baked lighting.
|
|
|
+
|
|
|
if ( !inNormal ||
|
|
|
fd.features[MFT_LightMap] ||
|
|
|
fd.features[MFT_ToneMap] ||
|
|
@@ -2118,8 +2124,7 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
// If there isn't a normal map then we need to pass
|
|
|
// the world space normal to the pixel shader ourselves.
|
|
|
- //Temporarily disabled while we figure out how to better handle normals without a normal map
|
|
|
- /*if ( !fd.features[MFT_NormalMap] )
|
|
|
+ if ( !fd.features[MFT_NormalMap] )
|
|
|
{
|
|
|
Var *outNormal = connectComp->getElement( RT_TEXCOORD );
|
|
|
outNormal->setName( "wsNormal" );
|
|
@@ -2131,13 +2136,8 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
// Transform the normal to world space.
|
|
|
meta->addStatement( new GenOp( " @ = tMul( @, vec4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
|
|
- }*/
|
|
|
-
|
|
|
- addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
|
|
+ }
|
|
|
|
|
|
- getOutWorldToTangent(componentList, meta, fd);
|
|
|
-
|
|
|
- output = meta;
|
|
|
}
|
|
|
|
|
|
void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
@@ -2158,14 +2158,10 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
// Now the wsPosition and wsView.
|
|
|
Var *wsPosition = getInWsPosition( componentList );
|
|
|
+ Var* worldToTangent = getInWorldToTangent(componentList);
|
|
|
+ Var* wsNormal = getInWorldNormal(componentList);
|
|
|
Var *wsView = getWsView( wsPosition, meta );
|
|
|
|
|
|
- // Create temporaries to hold results of lighting.
|
|
|
- Var *rtShading = new Var( "rtShading", "vec4" );
|
|
|
- Var *specular = new Var( "specular", "vec4" );
|
|
|
- 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" );
|
|
@@ -2473,7 +2469,7 @@ void VisibilityFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
// Everything else does a fizzle.
|
|
|
Var *vPos = getInVpos( meta, componentList );
|
|
|
- meta->addStatement( new GenOp( " fizzle( @, @ );\r\n", vPos, visibility ) );
|
|
|
+ meta->addStatement( new GenOp( " fizzle( @.xy, @ );\r\n", vPos, visibility ) );
|
|
|
}
|
|
|
|
|
|
ShaderFeature::Resources VisibilityFeatGLSL::getResources( const MaterialFeatureData &fd )
|
|
@@ -2616,7 +2612,7 @@ void FoliageFeatureGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
|
tangent->setType( "vec3" );
|
|
|
tangent->setName( "T" );
|
|
|
LangElement *tangentDec = new DecOp( tangent );
|
|
|
- meta->addStatement( new GenOp( " @;\n", tangentDec ) );
|
|
|
+ meta->addStatement( new GenOp( " @ = vec3(1.0,0,0);\n", tangentDec ) );
|
|
|
|
|
|
// We add a float foliageFade to the OUT structure.
|
|
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
|
@@ -2978,6 +2974,8 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|
|
|
|
|
// Now the wsPosition and wsView.
|
|
|
Var *wsPosition = getInWsPosition(componentList);
|
|
|
+ Var *worldToTangent = getInWorldToTangent(componentList);
|
|
|
+ Var *wsNormal = getInWorldNormal(componentList);
|
|
|
Var *wsView = getWsView(wsPosition, meta);
|
|
|
|
|
|
//Reflection Probe WIP
|