Browse Source

cleanups for shadergen and the visibility feature
math fixes, feature inclusion removal. will still need to circle back on why the crosshatch.. isn't

AzaezelX 3 years ago
parent
commit
21c17d0ed1

+ 1 - 3
Engine/source/lighting/shadowMap/shadowMatHook.cpp

@@ -186,10 +186,8 @@ void ShadowMaterialHook::_overrideFeatures(  ProcessedMaterial *mat,
          type == MFT_TexAnim ||
          type == MFT_DiffuseMap ||
          type == MFT_IsTranslucent ||
-         type == MFT_Visibility ||
          type == MFT_UseInstancing ||
-         type == MFT_EyeSpaceDepthOut ||
-         type == MFT_DeferredConditioner)
+         type == MFT_EyeSpaceDepthOut)
             newFeatures.addFeature(type);
       else if (type.getGroup() == MFG_PreTransform ||
             type.getGroup() == MFG_Transform ||

+ 5 - 19
Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp

@@ -455,12 +455,12 @@ Var* ShaderFeatureGLSL::addOutVpos( MultiLine *meta,
       outVpos = connectComp->getElement( RT_TEXCOORD );
       outVpos->setName( "outVpos" );
       outVpos->setStructName( "OUT" );
-      outVpos->setType( "vec4" );
+      outVpos->setType( "vec3" );
 
       Var *outPosition = (Var*) LangElement::find( "gl_Position" );
       AssertFatal( outPosition, "ShaderFeatureGLSL::addOutVpos - Didn't find the output position." );
 
-      meta->addStatement( new GenOp( "   @ = @;\r\n", outVpos, outPosition ) );
+      meta->addStatement( new GenOp( "   @ = @.xyz;\r\n", outVpos, outPosition ) );
    }
 
    return outVpos;
@@ -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 )
@@ -2473,7 +2459,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 +2602,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] );

+ 3 - 3
Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp

@@ -453,12 +453,12 @@ Var* ShaderFeatureHLSL::addOutVpos( MultiLine *meta,
       outVpos = connectComp->getElement( RT_TEXCOORD );
       outVpos->setName( "outVpos" );
       outVpos->setStructName( "OUT" );
-      outVpos->setType( "float4" );
+      outVpos->setType( "float3" );
 
       Var *outPosition = (Var*) LangElement::find( "hpos" );
       AssertFatal( outPosition, "ShaderFeatureHLSL::addOutVpos - Didn't find the output position." );
 
-      meta->addStatement( new GenOp( "   @ = @;\r\n", outVpos, outPosition ) );
+      meta->addStatement( new GenOp( "   @ = @.xyz;\r\n", outVpos, outPosition ) );
    }
 
    return outVpos;
@@ -2686,7 +2686,7 @@ void FoliageFeatureHLSL::processVert( Vector<ShaderComponent*> &componentList,
    tangent->setType( "float3" );
    tangent->setName( "T" );
    LangElement *tangentDec = new DecOp( tangent );
-   meta->addStatement( new GenOp( "   @;\n", tangentDec ) );         
+   meta->addStatement( new GenOp( "   @ = float3(1.0,0,0);\n", tangentDec ) );         
 
    // We add a float foliageFade to the OUT structure.
    ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/gl/torque.glsl

@@ -291,8 +291,8 @@ void fizzle(vec2 vpos, float visibility)
    // I'm sure there are many more patterns here to 
    // discover for different effects.
    
-   mat2x2 m = mat2x2( vpos.x, vpos.y, 0.916, 0.350 );
-   if( (visibility - fract( determinant( m ) )) < 0 ) //if(a < 0) discard;
+   mat2x2 m = mat2x2( vpos.x, 0.916, vpos.y, 0.350 );
+   if( (visibility - fract( determinant( m ) )) < 0 )
       discard;
 }
 #endif //TORQUE_PIXEL_SHADER