diff --git a/Engine/source/shaderGen/GLSL/accuFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/accuFeatureGLSL.cpp index 7d172179e..1ab722fd9 100644 --- a/Engine/source/shaderGen/GLSL/accuFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/accuFeatureGLSL.cpp @@ -55,7 +55,7 @@ void AccuTexFeatGLSL::processPix(Vector &componentList, output = meta; // OUT.col - Var *color = (Var*) LangElement::find( "col1" ); + Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1)); if (!color) { output = new GenOp(" //NULL COLOR!"); @@ -236,4 +236,4 @@ Var* AccuTexFeatGLSL::addOutAccuVec(Vector &componentList, Mul } return outAccuVec; -} \ No newline at end of file +} diff --git a/Engine/source/shaderGen/GLSL/bumpGLSL.cpp b/Engine/source/shaderGen/GLSL/bumpGLSL.cpp index ab034bc2d..36ff9ec46 100644 --- a/Engine/source/shaderGen/GLSL/bumpGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/bumpGLSL.cpp @@ -452,7 +452,7 @@ void NormalsOutFeatGLSL::processPix( Vector &componentList, } LangElement *normalOut; - Var *outColor = (Var*)LangElement::find( "col" ); + Var *outColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( outColor && !fd.features[MFT_AlphaTest] ) normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor ); else diff --git a/Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp index 22bb4c839..219ef07e9 100644 --- a/Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp @@ -30,7 +30,7 @@ void DebugVizGLSL::processPix(Vector& componentList, if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1)) { - Var* color = (Var*)LangElement::find("col"); + Var* color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if (color) { Var* specularColor = (Var*)LangElement::find("specularColor"); diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index b6c825864..2bd24931d 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -1181,13 +1181,13 @@ void DiffuseFeatureGLSL::processPix( Vector &componentList, diffuseMaterialColor->constSortPos = cspPotentialPrimitive; MultiLine* meta = new MultiLine; - Var *col = (Var*)LangElement::find("col"); + Var *col = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget; if (fd.features[MFT_isDeferred]) { targ = ShaderFeature::RenderTarget1; - col = (Var*)LangElement::find("col1"); + col = (Var*)LangElement::find(getOutputTargetVarName(targ)); meta = new MultiLine; if (!col) { @@ -1196,7 +1196,7 @@ void DiffuseFeatureGLSL::processPix( Vector &componentList, col->setType("vec4"); col->setName(getOutputTargetVarName(targ)); 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 &componentList, fogColor->constSortPos = cspPass; // Get the out color. - Var *color = (Var*) LangElement::find( "col" ); + Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( !color ) { color = new Var; @@ -2466,7 +2466,7 @@ void VisibilityFeatGLSL::processPix( Vector &componentList, // Translucent objects do a simple alpha fade. 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 ) ); return; } @@ -2507,9 +2507,9 @@ void AlphaTestGLSL::processPix( Vector &componentList, } // 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 ) - color = (Var*)LangElement::find("col"); + color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( !color ) { output = NULL; @@ -2542,7 +2542,7 @@ void GlowMaskGLSL::processPix( Vector &componentList, // // The shader compiler will optimize out all the other // 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 ) output = new GenOp( " @.rgb = vec3(0);\r\n", color ); } @@ -2574,7 +2574,7 @@ void HDROutGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Let the helper function do the work. - Var *color = (Var*)LangElement::find( "col" ); + Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( color ) output = new GenOp( " @ = hdrEncode( @ );\r\n", color, color ); } diff --git a/Engine/source/shaderGen/HLSL/accuFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/accuFeatureHLSL.cpp index 3c0ec061f..17ddd844b 100644 --- a/Engine/source/shaderGen/HLSL/accuFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/accuFeatureHLSL.cpp @@ -55,7 +55,7 @@ void AccuTexFeatHLSL::processPix( Vector &componentList, output = meta; // OUT.col - Var *color = (Var*) LangElement::find( "col1" ); + Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1)); if (!color) { output = new GenOp(" //NULL COLOR!"); diff --git a/Engine/source/shaderGen/HLSL/bumpHLSL.cpp b/Engine/source/shaderGen/HLSL/bumpHLSL.cpp index c916d8b38..c1cd2635e 100644 --- a/Engine/source/shaderGen/HLSL/bumpHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/bumpHLSL.cpp @@ -460,7 +460,7 @@ void NormalsOutFeatHLSL::processPix( Vector &componentList, } LangElement *normalOut; - Var *outColor = (Var*)LangElement::find( "col" ); + Var *outColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( outColor && !fd.features[MFT_AlphaTest] ) normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor ); else diff --git a/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp index fa0a3934e..c9e797fff 100644 --- a/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp @@ -68,136 +68,6 @@ void CustomFeatureHLSL::processPix(Vector& componentList, 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")) Con::executef(mOwner, "processPixelHLSL"); diff --git a/Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp index 84b724e29..fe2fdb3af 100644 --- a/Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp @@ -24,7 +24,7 @@ void DebugVizHLSL::processPix(Vector& componentList, { MultiLine* meta = new MultiLine; Var* surface = (Var*)LangElement::find("surface"); - Var* color = (Var*)LangElement::find("col"); + Var* color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if (!surface) return; diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 09fb93fc2..80601ad68 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -1192,13 +1192,13 @@ void DiffuseFeatureHLSL::processPix( Vector &componentList, diffuseMaterialColor->constSortPos = cspPotentialPrimitive; MultiLine* meta = new MultiLine; - Var *col = (Var*)LangElement::find("col"); + Var *col = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget; if (fd.features[MFT_isDeferred]) { targ = ShaderFeature::RenderTarget1; - col = (Var*)LangElement::find("col1"); + col = (Var*)LangElement::find(getOutputTargetVarName(targ)); if (!col) { // create color var @@ -2403,7 +2403,7 @@ void FogFeatHLSL::processPix( Vector &componentList, fogColor->constSortPos = cspPass; // Get the out color. - Var *color = (Var*) LangElement::find( "col" ); + Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( !color ) { color = new Var; @@ -2535,7 +2535,7 @@ void VisibilityFeatHLSL::processPix( Vector &componentList, // Translucent objects do a simple alpha fade. 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 ) ); return; } @@ -2577,9 +2577,9 @@ void AlphaTestHLSL::processPix( Vector &componentList, } // 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) - color = (Var*)LangElement::find("col"); + color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( !color ) { output = NULL; @@ -2612,7 +2612,7 @@ void GlowMaskHLSL::processPix( Vector &componentList, // // The shader compiler will optimize out all the other // 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 ) output = new GenOp( " @.rgb = 0;\r\n", color ); } @@ -2644,7 +2644,7 @@ void HDROutHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Let the helper function do the work. - Var *color = (Var*)LangElement::find( "col" ); + Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); if ( color ) output = new GenOp( " @ = hdrEncode( @ );\r\n", color, color ); }