void BumpFeatGLSL::processVert( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) { MultiLine *meta = new MultiLine; output = meta; const bool useTexAnim = fd.features[MFT_TexAnim]; // Output the texture coord. getOutTexCoord( "texCoord", "vec2", true, useTexAnim, meta, componentList ); if ( fd.features.hasFeature( MFT_DetailNormalMap ) ) addOutDetailTexCoord( componentList, meta, useTexAnim ); // Also output the worldToTanget transform which // we use to create the world space normal. getOutWorldToTangent( componentList, meta, fd ); }
void ParallaxFeatGLSL::processVert( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) { AssertFatal( GFX->getPixelShaderVersion() >= 2.0, "ParallaxFeatGLSL::processVert - We don't support SM 1.x!" ); MultiLine *meta = new MultiLine; // Add the texture coords. getOutTexCoord( "texCoord", "vec2", true, fd.features[MFT_TexAnim], meta, componentList ); // Grab the input position. Var *inPos = (Var*)LangElement::find( "inPosition" ); if ( !inPos ) inPos = (Var*)LangElement::find( "position" ); // Get the object space eye position and the // object to tangent space transform. Var *eyePos = _getUniformVar( "eyePos", "vec3", cspPrimitive ); Var *objToTangentSpace = getOutObjToTangentSpace( componentList, meta, fd ); // Now send the negative view vector in tangent space to the pixel shader. ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] ); Var *outNegViewTS = connectComp->getElement( RT_TEXCOORD ); outNegViewTS->setName( "outNegViewTS" ); outNegViewTS->setStructName( "OUT" ); outNegViewTS->setType( "vec3" ); meta->addStatement( new GenOp( " @ = tMul( @, float3( @.xyz - @ ) );\r\n", outNegViewTS, objToTangentSpace, inPos, eyePos ) ); // TODO: I'm at a loss at why i need to flip the binormal/y coord // to get a good view vector for parallax. Lighting works properly // with the TS matrix as is... but parallax does not. // // Someone figure this out! // meta->addStatement( new GenOp( " @.y = [email protected];\r\n", outNegViewTS, outNegViewTS ) ); // If we have texture anim matrix the tangent // space view vector may need to be rotated. Var *texMat = (Var*)LangElement::find( "texMat" ); if ( texMat ) { meta->addStatement( new GenOp( " @ = tMul(@, float4(@,0)).xyz;\r\n", outNegViewTS, texMat, outNegViewTS ) ); } output = meta; }
void DeferredBumpFeatHLSL::processVert( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) { if( fd.features[MFT_PrePassConditioner] ) { // There is an output conditioner active, so we need to supply a transform // to the pixel shader. MultiLine *meta = new MultiLine; // We need the view to tangent space transform in the pixel shader. getOutViewToTangent( componentList, meta, fd ); // Make sure there are texcoords if( !fd.features[MFT_Parallax] && !fd.features[MFT_DiffuseMap] ) { const bool useTexAnim = fd.features[MFT_TexAnim]; getOutTexCoord( "texCoord", "float2", true, useTexAnim, meta, componentList ); if ( fd.features.hasFeature( MFT_DetailNormalMap ) ) addOutDetailTexCoord( componentList, meta, useTexAnim ); } output = meta; } else if ( fd.materialFeatures[MFT_NormalsOut] || fd.features[MFT_ForwardShading] || //start jc fd.features[MFT_IsObjectSpaceNormals] || // end jc !fd.features[MFT_RTLighting] ) { Parent::processVert( componentList, fd ); return; } else { output = NULL; } }
void BumpFeatHLSL::processVert( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) { MultiLine *meta = new MultiLine; // Output the texture coord. getOutTexCoord( "texCoord", "float2", true, fd.features[MFT_TexAnim], meta, componentList ); // Also output the worldToTanget transform which // we use to create the world space normal. getOutWorldToTangent( componentList, meta ); // TODO: Restore this! /* // Check to see if we're rendering world space normals. if ( fd.materialFeatures[MFT_NormalsOut] ) { Var *inNormal = (Var*)LangElement::find( "normal" ); Var *outNormal = connectComp->getElement( RT_TEXCOORD ); outNormal->setName( "normal" ); outNormal->setStructName( "OUT" ); outNormal->setType( "float3" ); outNormal->mapsToSampler = false; meta->addStatement( new GenOp( " @ = @; // MFT_NormalsOut\r\n", outNormal, inNormal ) ); output = meta; return; } */ output = meta; }