diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 6df9a01bf..b41dfc234 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -1982,6 +1982,7 @@ void ReflectCubeFeatGLSL::processPix( Vector &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)); diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index eae07aa95..0b5f79e4d 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -892,6 +892,14 @@ Var* ShaderFeatureHLSL::getSurface(Vector& componentList, Mult } Var* wsEyePos = (Var*)LangElement::find("eyePosWorld"); + + if (!wsEyePos) + { + wsEyePos = new Var("eyePosWorld", "float3"); + wsEyePos->uniform = true; + wsEyePos->constSortPos = cspPass; + } + Var* wsPosition = getInWsPosition(componentList); Var* wsView = getWsView(wsPosition, meta); diff --git a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp index d30e639ec..3b66006ce 100644 --- a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp +++ b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp @@ -281,6 +281,8 @@ void TerrainBaseMapFeatGLSL::processVert( Vector &componentLis Var *squareSize = _getUniformVar( "squareSize", "float", cspPass ); meta->addStatement( new GenOp( " @ = normalize( vec3( @, 0, @ ) );\r\n", new DecOp( inTanget ), squareSize, inTangentZ ) ); + + getOutViewToTangent(componentList, meta, fd); } void TerrainBaseMapFeatGLSL::processPix( Vector &componentList, @@ -331,6 +333,8 @@ void TerrainBaseMapFeatGLSL::processPix( Vector &componentLis meta->addStatement(new GenOp(" @ = float4(0.0, 1.0, 1.0, 0.0);\r\n", ormConfig)); output = meta; + + Var* viewToTangent = getInViewToTangent(componentList); } ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFeatureData &fd ) @@ -781,6 +785,22 @@ void TerrainMacroMapFeatGLSL::processPix( Vector &componentL meta->addStatement( new GenOp( " @ = calcBlend( @.x, @.xy, @, @ );\r\n", new DecOp( detailBlend ), detailInfo, inTex, layerSize, layerSample ) ); + // Check to see if we have a gbuffer normal. + Var* gbNormal = (Var*)LangElement::find("gbNormal"); + + // If we have a gbuffer normal and we don't have a + // normal map feature then we need to lerp in a + // default normal else the normals below this layer + // will show thru. + if (gbNormal && + !fd.features.hasFeature(MFT_TerrainNormalMap, detailIndex)) + { + Var* viewToTangent = getInViewToTangent(componentList); + + meta->addStatement(new GenOp(" @ = lerp( @, @[2], min( @, @.w ) );\r\n", + gbNormal, gbNormal, viewToTangent, detailBlend, inDet)); + } + Var *detailColor = (Var*)LangElement::find( "macroColor" ); if ( !detailColor ) { @@ -1224,21 +1244,7 @@ void TerrainORMMapFeatGLSL::processPix(Vector &componentList, ShaderFeature::Resources TerrainORMMapFeatGLSL::getResources(const MaterialFeatureData &fd) { Resources res; - - S32 featureIndex = 0, firstOrmMapIndex = 0; - for (int idx = 0; idx < fd.features.getCount(); ++idx) { - const FeatureType& type = fd.features.getAt(idx, &featureIndex); - if (type == MFT_TerrainORMMap) { - firstOrmMapIndex = getMin(firstOrmMapIndex, featureIndex); - } - } - - // We only need to process normals during the deferred. - if (getProcessIndex() == firstOrmMapIndex) - { - res.numTexReg = 1; - res.numTex = 1; - } + res.numTex = 1; return res; } @@ -1283,7 +1289,10 @@ void TerrainBlankInfoMapFeatGLSL::processPix(Vector &component String matinfoName(String::ToString("matinfoCol%d", compositeIndex)); - meta->addStatement(new GenOp(" @.gba += vec3(@, @, 0.0);\r\n", ormConfig, detailBlend, detailBlend)); + if (!fd.features.hasFeature(MFT_TerrainHeightBlend)) + { + meta->addStatement(new GenOp(" @.gba += vec3(@, @, 0.0);\r\n", ormConfig, detailBlend, detailBlend)); + } output = meta; }