浏览代码

be clear where we're referencing gbuffer render targets

AzaezelX 4 年之前
父节点
当前提交
2287c28d32

+ 2 - 2
Engine/source/shaderGen/GLSL/accuFeatureGLSL.cpp

@@ -55,7 +55,7 @@ void AccuTexFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
    output = meta;
    output = meta;
 
 
    // OUT.col
    // OUT.col
-   Var *color = (Var*) LangElement::find( "col1" );
+   Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
    if (!color)
    if (!color)
    {
    {
       output = new GenOp("   //NULL COLOR!");
       output = new GenOp("   //NULL COLOR!");
@@ -236,4 +236,4 @@ Var* AccuTexFeatGLSL::addOutAccuVec(Vector<ShaderComponent*> &componentList, Mul
    }
    }
 
 
    return outAccuVec;
    return outAccuVec;
-}
+}

+ 1 - 1
Engine/source/shaderGen/GLSL/bumpGLSL.cpp

@@ -452,7 +452,7 @@ void NormalsOutFeatGLSL::processPix(   Vector<ShaderComponent*> &componentList,
    }
    }
 	
 	
    LangElement *normalOut;
    LangElement *normalOut;
-   Var *outColor = (Var*)LangElement::find( "col" );
+   Var *outColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( outColor && !fd.features[MFT_AlphaTest] )
    if ( outColor && !fd.features[MFT_AlphaTest] )
       normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor );
       normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor );
    else
    else

+ 1 - 1
Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp

@@ -30,7 +30,7 @@ void DebugVizGLSL::processPix(Vector<ShaderComponent*>& componentList,
 
 
    if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
    if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
    {
    {
-      Var* color = (Var*)LangElement::find("col");
+      Var* color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
       if (color)
       if (color)
       {
       {
          Var* specularColor = (Var*)LangElement::find("specularColor");
          Var* specularColor = (Var*)LangElement::find("specularColor");

+ 9 - 9
Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp

@@ -1181,13 +1181,13 @@ void DiffuseFeatureGLSL::processPix(   Vector<ShaderComponent*> &componentList,
    diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
    diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
 
 
    MultiLine* meta = new MultiLine;
    MultiLine* meta = new MultiLine;
-   Var *col = (Var*)LangElement::find("col");
+   Var *col = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
    ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
    if (fd.features[MFT_isDeferred])
    if (fd.features[MFT_isDeferred])
    {
    {
       targ = ShaderFeature::RenderTarget1;
       targ = ShaderFeature::RenderTarget1;
 
 
-      col = (Var*)LangElement::find("col1");
+      col = (Var*)LangElement::find(getOutputTargetVarName(targ));
       meta = new MultiLine;
       meta = new MultiLine;
       if (!col)
       if (!col)
       {
       {
@@ -1196,7 +1196,7 @@ void DiffuseFeatureGLSL::processPix(   Vector<ShaderComponent*> &componentList,
          col->setType("vec4");
          col->setType("vec4");
          col->setName(getOutputTargetVarName(targ));
          col->setName(getOutputTargetVarName(targ));
          col->setStructName("OUT");
          col->setStructName("OUT");
-         meta->addStatement(new GenOp("   @ = vec4(1.0);\r\n", col));
+         meta->addStatement(new GenOp("   @ = vec4(1.0,1.0,1.0,1.0);\r\n", col));
       }
       }
    }
    }
 
 
@@ -2334,7 +2334,7 @@ void FogFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
    fogColor->constSortPos = cspPass;
    fogColor->constSortPos = cspPass;
 	
 	
    // Get the out color.
    // Get the out color.
-   Var *color = (Var*) LangElement::find( "col" );
+   Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( !color )
    if ( !color )
    {
    {
       color = new Var;
       color = new Var;
@@ -2466,7 +2466,7 @@ void VisibilityFeatGLSL::processPix(   Vector<ShaderComponent*> &componentList,
    // Translucent objects do a simple alpha fade.
    // Translucent objects do a simple alpha fade.
    if ( fd.features[ MFT_IsTranslucent ] )
    if ( fd.features[ MFT_IsTranslucent ] )
    {
    {
-      Var *color = (Var*) LangElement::find( "col" );
+      Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
       meta->addStatement( new GenOp( "   @.a *= @;\r\n", color, visibility ) );
       meta->addStatement( new GenOp( "   @.a *= @;\r\n", color, visibility ) );
       return;
       return;
       }
       }
@@ -2507,9 +2507,9 @@ void AlphaTestGLSL::processPix(  Vector<ShaderComponent*> &componentList,
    }
    }
 
 
    // If we don't have a color var then we cannot do an alpha test.
    // If we don't have a color var then we cannot do an alpha test.
-   Var *color = (Var*)LangElement::find( "col1" );
+   Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1) );
    if ( !color )
    if ( !color )
-	   color = (Var*)LangElement::find("col");
+	   color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( !color )
    if ( !color )
    {
    {
       output = NULL;
       output = NULL;
@@ -2542,7 +2542,7 @@ void GlowMaskGLSL::processPix(   Vector<ShaderComponent*> &componentList,
    //
    //
    // The shader compiler will optimize out all the other
    // The shader compiler will optimize out all the other
    // code above that doesn't contribute to the alpha mask.
    // code above that doesn't contribute to the alpha mask.
-   Var *color = (Var*)LangElement::find( "col" );
+   Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( color )
    if ( color )
       output = new GenOp( "   @.rgb = vec3(0);\r\n", color );
       output = new GenOp( "   @.rgb = vec3(0);\r\n", color );
 }
 }
@@ -2574,7 +2574,7 @@ void HDROutGLSL::processPix(  Vector<ShaderComponent*> &componentList,
 									 const MaterialFeatureData &fd )
 									 const MaterialFeatureData &fd )
 {
 {
    // Let the helper function do the work.
    // Let the helper function do the work.
-   Var *color = (Var*)LangElement::find( "col" );
+   Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( color )
    if ( color )
       output = new GenOp( "   @ = hdrEncode( @ );\r\n", color, color );
       output = new GenOp( "   @ = hdrEncode( @ );\r\n", color, color );
 }
 }

+ 1 - 1
Engine/source/shaderGen/HLSL/accuFeatureHLSL.cpp

@@ -55,7 +55,7 @@ void AccuTexFeatHLSL::processPix(   Vector<ShaderComponent*> &componentList,
    output = meta;
    output = meta;
 
 
    // OUT.col
    // OUT.col
-   Var *color = (Var*) LangElement::find( "col1" );
+   Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
    if (!color)
    if (!color)
    {
    {
       output = new GenOp("   //NULL COLOR!");
       output = new GenOp("   //NULL COLOR!");

+ 1 - 1
Engine/source/shaderGen/HLSL/bumpHLSL.cpp

@@ -460,7 +460,7 @@ void NormalsOutFeatHLSL::processPix(   Vector<ShaderComponent*> &componentList,
    }
    }
 
 
    LangElement *normalOut;
    LangElement *normalOut;
-   Var *outColor = (Var*)LangElement::find( "col" );
+   Var *outColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( outColor && !fd.features[MFT_AlphaTest] )
    if ( outColor && !fd.features[MFT_AlphaTest] )
       normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor );
       normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor );
    else
    else

+ 0 - 130
Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp

@@ -68,136 +68,6 @@ void CustomFeatureHLSL::processPix(Vector<ShaderComponent*>& componentList,
 
 
    mOutputState = PixelOutput;
    mOutputState = PixelOutput;
 
 
-   /*MultiLine *meta = new MultiLine;
-
-   output = meta;
-
-   // OUT.col
-   Var *color = (Var*) LangElement::find( "col1" );
-   if (!color)
-   {
-   output = new GenOp("   //NULL COLOR!");
-   return;
-   }
-
-   // accu map
-   Var *accuMap = new Var;
-   accuMap->setType("SamplerState");
-
-   accuMap->setName( "accuMap" );
-   accuMap->uniform = true;
-   accuMap->sampler = true;
-   accuMap->constNum = Var::getTexUnitNum();     // used as texture unit num here
-
-   // accuColor var
-   Var *accuColor = new Var;
-   accuColor->setType( "float4" );
-   accuColor->setName( "accuColor" );
-   LangElement *colorAccuDecl = new DecOp( accuColor );
-
-   // plc (placement)
-   Var *accuPlc = new Var;
-   accuPlc->setType( "float4" );
-   accuPlc->setName( "plc" );
-   LangElement *plcAccu = new DecOp( accuPlc );
-
-   // accu constants
-   Var *accuScale = (Var*)LangElement::find( "accuScale" );
-   if ( !accuScale )
-   {
-   accuScale = new Var;
-   accuScale->setType( "float" );
-   accuScale->setName( "accuScale" );
-   accuScale->uniform = true;
-   accuScale->sampler = false;
-   accuScale->constSortPos = cspPotentialPrimitive;
-   }
-   Var *accuDirection = (Var*)LangElement::find( "accuDirection" );
-   if ( !accuDirection )
-   {
-   accuDirection = new Var;
-   accuDirection->setType( "float" );
-   accuDirection->setName( "accuDirection" );
-   accuDirection->uniform = true;
-   accuDirection->sampler = false;
-   accuDirection->constSortPos = cspPotentialPrimitive;
-   }
-   Var *accuStrength = (Var*)LangElement::find( "accuStrength" );
-   if ( !accuStrength )
-   {
-   accuStrength = new Var;
-   accuStrength->setType( "float" );
-   accuStrength->setName( "accuStrength" );
-   accuStrength->uniform = true;
-   accuStrength->sampler = false;
-   accuStrength->constSortPos = cspPotentialPrimitive;
-   }
-   Var *accuCoverage = (Var*)LangElement::find( "accuCoverage" );
-   if ( !accuCoverage )
-   {
-   accuCoverage = new Var;
-   accuCoverage->setType( "float" );
-   accuCoverage->setName( "accuCoverage" );
-   accuCoverage->uniform = true;
-   accuCoverage->sampler = false;
-   accuCoverage->constSortPos = cspPotentialPrimitive;
-   }
-   Var *accuSpecular = (Var*)LangElement::find( "accuSpecular" );
-   if ( !accuSpecular )
-   {
-   accuSpecular = new Var;
-   accuSpecular->setType( "float" );
-   accuSpecular->setName( "accuSpecular" );
-   accuSpecular->uniform = true;
-   accuSpecular->sampler = false;
-   accuSpecular->constSortPos = cspPotentialPrimitive;
-   }
-
-   Var *inTex = getInTexCoord( "texCoord", "float2", componentList );
-   Var *accuVec = getInTexCoord( "accuVec", "float3", componentList );
-   Var *bumpNorm = (Var *)LangElement::find( "bumpSample" );
-   if( bumpNorm == NULL )
-   {
-   bumpNorm = (Var *)LangElement::find( "bumpNormal" );
-   if (!bumpNorm)
-   return;
-   }
-
-   // get the accu pixel color
-
-   Var *accuMapTex = new Var;
-   accuMapTex->setType("Texture2D");
-   accuMapTex->setName("accuMapTex");
-   accuMapTex->uniform = true;
-   accuMapTex->texture = true;
-   accuMapTex->constNum = accuMap->constNum;
-   meta->addStatement(new GenOp("   @ = @.Sample(@, @ * @);\r\n", colorAccuDecl, accuMapTex, accuMap, inTex, accuScale));
-
-   // scale up normals
-   meta->addStatement( new GenOp( "   @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
-
-   // assign direction
-   meta->addStatement( new GenOp( "   @.z *= @*2.0;\r\n", accuVec, accuDirection ) );
-
-   // saturate based on strength
-   meta->addStatement( new GenOp( "   @ = saturate( dot( @.xyz, @.xyz * pow(@, 5) ) );\r\n", plcAccu, bumpNorm, accuVec, accuStrength ) );
-
-   // add coverage
-   meta->addStatement( new GenOp( "   @.a += (2 * pow(@/2, 5)) - 0.5;\r\n", accuPlc, accuCoverage ) );
-
-   // clamp to a sensible value
-   meta->addStatement( new GenOp( "   @.a = clamp(@.a, 0, 1);\r\n", accuPlc, accuPlc ) );
-
-   // light
-   Var *lightColor = (Var*) LangElement::find( "d_lightcolor" );
-   if(lightColor != NULL)
-   meta->addStatement( new GenOp( "   @ *= float4(@, 1.0);\r\n\r\n", accuColor, lightColor ) );
-
-   // lerp with current pixel - use the accu alpha as well
-   meta->addStatement( new GenOp( "   @ = lerp( @, @, @.a * @.a);\r\n", color, color, accuColor, accuPlc, accuColor ) );
-
-   // the result should always be opaque
-   meta->addStatement( new GenOp( "   @.a = 1.0;\r\n", color ) );*/
    if (mOwner->isMethod("processPixelHLSL"))
    if (mOwner->isMethod("processPixelHLSL"))
       Con::executef(mOwner, "processPixelHLSL");
       Con::executef(mOwner, "processPixelHLSL");
 
 

+ 1 - 1
Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp

@@ -24,7 +24,7 @@ void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
 {
 {
    MultiLine* meta = new MultiLine;
    MultiLine* meta = new MultiLine;
    Var* surface = (Var*)LangElement::find("surface");
    Var* surface = (Var*)LangElement::find("surface");
-   Var* color = (Var*)LangElement::find("col");
+   Var* color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
 
 
    if (!surface)
    if (!surface)
       return;
       return;

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

@@ -1192,13 +1192,13 @@ void DiffuseFeatureHLSL::processPix(   Vector<ShaderComponent*> &componentList,
    diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
    diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
 
 
    MultiLine* meta = new MultiLine;
    MultiLine* meta = new MultiLine;
-   Var *col = (Var*)LangElement::find("col");
+   Var *col = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
    ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
    if (fd.features[MFT_isDeferred])
    if (fd.features[MFT_isDeferred])
    {
    {
       targ = ShaderFeature::RenderTarget1;
       targ = ShaderFeature::RenderTarget1;
 
 
-      col = (Var*)LangElement::find("col1");
+      col = (Var*)LangElement::find(getOutputTargetVarName(targ));
       if (!col)
       if (!col)
       {
       {
          // create color var
          // create color var
@@ -2403,7 +2403,7 @@ void FogFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
    fogColor->constSortPos = cspPass;
    fogColor->constSortPos = cspPass;
 
 
    // Get the out color.
    // Get the out color.
-   Var *color = (Var*) LangElement::find( "col" );
+   Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( !color )
    if ( !color )
    {
    {
       color = new Var;
       color = new Var;
@@ -2535,7 +2535,7 @@ void VisibilityFeatHLSL::processPix(   Vector<ShaderComponent*> &componentList,
    // Translucent objects do a simple alpha fade.
    // Translucent objects do a simple alpha fade.
    if ( fd.features[ MFT_IsTranslucent ] )
    if ( fd.features[ MFT_IsTranslucent ] )
    {
    {
-      Var *color = (Var*)LangElement::find( "col" );      
+      Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
       meta->addStatement( new GenOp( "   @.a *= @;\r\n", color, visibility ) );
       meta->addStatement( new GenOp( "   @.a *= @;\r\n", color, visibility ) );
       return;
       return;
    }
    }
@@ -2577,9 +2577,9 @@ void AlphaTestHLSL::processPix(  Vector<ShaderComponent*> &componentList,
    }
    }
 
 
    // If we don't have a color var then we cannot do an alpha test.
    // If we don't have a color var then we cannot do an alpha test.
-   Var *color = (Var*)LangElement::find( "col1" );
+   Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
    if (!color)
    if (!color)
-	   color = (Var*)LangElement::find("col");
+	   color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( !color )
    if ( !color )
    {
    {
       output = NULL;
       output = NULL;
@@ -2612,7 +2612,7 @@ void GlowMaskHLSL::processPix(   Vector<ShaderComponent*> &componentList,
    //
    //
    // The shader compiler will optimize out all the other
    // The shader compiler will optimize out all the other
    // code above that doesn't contribute to the alpha mask.
    // code above that doesn't contribute to the alpha mask.
-   Var *color = (Var*)LangElement::find( "col" );
+   Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( color )
    if ( color )
       output = new GenOp( "   @.rgb = 0;\r\n", color );
       output = new GenOp( "   @.rgb = 0;\r\n", color );
 }
 }
@@ -2644,7 +2644,7 @@ void HDROutHLSL::processPix(  Vector<ShaderComponent*> &componentList,
                               const MaterialFeatureData &fd )
                               const MaterialFeatureData &fd )
 {
 {
    // Let the helper function do the work.
    // Let the helper function do the work.
-   Var *color = (Var*)LangElement::find( "col" );
+   Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
    if ( color )
    if ( color )
       output = new GenOp( "   @ = hdrEncode( @ );\r\n", color, color );
       output = new GenOp( "   @ = hdrEncode( @ );\r\n", color, color );
 }
 }