From 3c8d07a03efe1f19be9981666be6098547d606f0 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sat, 2 Jan 2021 02:08:22 +0100 Subject: [PATCH] Cleanup and fixes --- Engine/source/gfx/gfxTextureArray.cpp | 5 +- Engine/source/gfx/gfxTextureArray.h | 1 + Engine/source/gfx/gl/gfxGLTextureArray.cpp | 7 +- Engine/source/gfx/gl/gfxGLTextureArray.h | 2 - .../source/terrain/glsl/terrFeatureGLSL.cpp | 201 ++++++++---------- Engine/source/terrain/glsl/terrFeatureGLSL.h | 3 + .../source/terrain/hlsl/terrFeatureHLSL.cpp | 87 ++++---- Engine/source/terrain/hlsl/terrFeatureHLSL.h | 3 + Engine/source/terrain/terrCellMaterial.cpp | 22 +- Engine/source/terrain/terrData.h | 16 +- 10 files changed, 159 insertions(+), 188 deletions(-) diff --git a/Engine/source/gfx/gfxTextureArray.cpp b/Engine/source/gfx/gfxTextureArray.cpp index e7f3797ab..0a1164c7a 100644 --- a/Engine/source/gfx/gfxTextureArray.cpp +++ b/Engine/source/gfx/gfxTextureArray.cpp @@ -1,9 +1,9 @@ #include "gfxTextureArray.h" - #include "gfxDevice.h" #include "gfxTextureManager.h" +#include "bitmap/imageUtils.h" #include "console/console.h" void GFXTextureArray::set(U32 width, U32 height, U32 size, GFXFormat format, U32 mipLevels) @@ -12,7 +12,8 @@ void GFXTextureArray::set(U32 width, U32 height, U32 size, GFXFormat format, U32 mHeight = height; mArraySize = size; mFormat = format; - mMipLevels = mipLevels; + mIsCompressed = ImageUtil::isCompressedFormat(mFormat); + mMipLevels = getMax(mipLevels, static_cast(1)); mTextures.setSize(size); diff --git a/Engine/source/gfx/gfxTextureArray.h b/Engine/source/gfx/gfxTextureArray.h index 48067c3e1..7b96009d0 100644 --- a/Engine/source/gfx/gfxTextureArray.h +++ b/Engine/source/gfx/gfxTextureArray.h @@ -59,6 +59,7 @@ public: virtual const String describeSelf() const; GFXFormat mFormat; + bool mIsCompressed; U32 mWidth; U32 mHeight; U32 mArraySize; diff --git a/Engine/source/gfx/gl/gfxGLTextureArray.cpp b/Engine/source/gfx/gl/gfxGLTextureArray.cpp index cc19fff5d..f2b403bb0 100644 --- a/Engine/source/gfx/gl/gfxGLTextureArray.cpp +++ b/Engine/source/gfx/gl/gfxGLTextureArray.cpp @@ -11,8 +11,8 @@ GFXGLTextureArray::GFXGLTextureArray() void GFXGLTextureArray::init() { - glGenTextures(1, &mTextureArray); PRESERVE_2D_TEXTURE_ARRAY(); + glGenTextures(1, &mTextureArray); glBindTexture(GL_TEXTURE_2D_ARRAY, mTextureArray); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, mMin(mMipLevels - 1, 1)); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -20,7 +20,7 @@ void GFXGLTextureArray::init() glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexStorage3D(GL_TEXTURE_2D_ARRAY, mMipLevels, GL_RGBA8, mWidth, mHeight, mArraySize); + glTexStorage3D(GL_TEXTURE_2D_ARRAY, mMipLevels, GFXGLTextureInternalFormat[mFormat], mWidth, mHeight, mArraySize); } void GFXGLTextureArray::_setTexture(const GFXTexHandle& texture, U32 slot) @@ -73,9 +73,10 @@ void GFXGLTextureArray::bind(U32 textureUnit) const { glActiveTexture(GL_TEXTURE0 + textureUnit); glBindTexture(GL_TEXTURE_2D_ARRAY, mTextureArray); + dynamic_cast(getOwningDevice())->getOpenglCache()->setCacheBindedTex(textureUnit, GL_TEXTURE_2D_ARRAY, mTextureArray); - GFXGLStateBlockRef sb = static_cast(GFX)->getCurrentStateBlock(); + GFXGLStateBlockRef sb = dynamic_cast(GFX)->getCurrentStateBlock(); AssertFatal(sb, "GFXGLTextureArray::bind - No active stateblock!"); if (!sb) return; diff --git a/Engine/source/gfx/gl/gfxGLTextureArray.h b/Engine/source/gfx/gl/gfxGLTextureArray.h index 0134a050c..65e1d9729 100644 --- a/Engine/source/gfx/gl/gfxGLTextureArray.h +++ b/Engine/source/gfx/gl/gfxGLTextureArray.h @@ -29,8 +29,6 @@ protected: private: GLuint mTextureArray; - - bool mIsCompressed; }; diff --git a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp index 65cccf69a..60ee53b60 100644 --- a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp +++ b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp @@ -336,9 +336,11 @@ void TerrainBaseMapFeatGLSL::processPix( Vector &componentLis ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFeatureData &fd ) { - Resources res; + Resources res; + + // Sample base texture res.numTexReg = 1; - res.numTex = 1; + res.numTex = 1; return res; } @@ -521,73 +523,40 @@ void TerrainDetailMapFeatGLSL::processPix( Vector &component meta->addStatement( new GenOp( " @ = calcBlend( @.x, @.xy, @, @ );\r\n", new DecOp( detailBlend ), new IndexOp(detailInfo, detailIndex), inTex, layerSize, layerSample ) ); - // New terrain - - Var *lerpBlend = (Var*)LangElement::find("lerpBlend"); - if (!lerpBlend) + // If we had a parallax feature... then factor in the parallax + // amount so that it fades out with the layer blending. + if (fd.features.hasFeature(MFT_TerrainParallaxMap, detailIndex)) { - lerpBlend = new Var; - lerpBlend->setType("float"); - lerpBlend->setName("lerpBlend"); - lerpBlend->uniform = true; - lerpBlend->constSortPos = cspPrimitive; + // Get the normal map texture. + Var* normalMap = _getNormalMapSampler(); + + // Call the library function to do the rest. + if (fd.features.hasFeature(MFT_IsBC3nm, detailIndex)) + { + meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, vec3(@.xy, @.x), @, @.z * @ );\r\n", + inDet, normalMap, inDet, new IndexOp(detailInfo, detailIndex), negViewTS, new IndexOp(detailInfo, detailIndex), detailBlend)); + } + else + { + meta->addStatement(new GenOp(" @.xy += parallaxOffset( @, vec3(@.xy, @.x), @, @.z * @ );\r\n", + inDet, normalMap, inDet, new IndexOp(detailInfo, detailIndex), negViewTS, new IndexOp(detailInfo, detailIndex), detailBlend)); + } } - - Var *blendDepth = (Var*)LangElement::find(String::ToString("blendDepth%d", detailIndex)); - if (!blendDepth) - { - blendDepth = new Var; - blendDepth->setType("float"); - blendDepth->setName(String::ToString("blendDepth%d", detailIndex)); - blendDepth->uniform = true; - blendDepth->constSortPos = cspPrimitive; - } - - ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget; - - if (fd.features.hasFeature(MFT_isDeferred)) - target= ShaderFeature::RenderTarget1; - - Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) ); - - if (!outColor) - { - // create color var - outColor = new Var; - outColor->setType("vec4"); - outColor->setName("col"); - outColor->setStructName("OUT"); - meta->addStatement(new GenOp(" @;\r\n", outColor)); - } - - Var *detailColor = (Var*)LangElement::find(String::ToString("detailColor%d", detailIndex)); + Var* detailColor = (Var*)LangElement::find(String::ToString("detailColor%d", detailIndex)); if (!detailColor) { - detailColor = new Var; - detailColor->setType("vec4"); - detailColor->setName(String::ToString("detailColor%d", detailIndex)); - meta->addStatement(new GenOp(" @;\r\n", new DecOp(detailColor))); + detailColor = new Var; + detailColor->setType("vec4"); + detailColor->setName(String::ToString("detailColor%d", detailIndex)); + meta->addStatement(new GenOp(" @;\r\n", new DecOp(detailColor))); } // Get the detail texture. Var *detailMap = _getDetailMapSampler(); - // Get the normal map texture. - Var *normalMap = _getNormalMapSampler(); - - // Sample the normal map. - // - // We take two normal samples and lerp between them for - // side projection layers... else a single sample. - // - // Note that we're doing the standard greyscale detail - // map technique here which can darken and lighten the - // diffuse texture. - // - // We take two color samples and lerp between them for - // side projection layers... else a single sample. - // + // If we had a parallax feature... then factor in the parallax + // amount so that it fades out with the layer blending. if (fd.features.hasFeature(MFT_TerrainSideProject, detailIndex)) { meta->addStatement(new GenOp(" @ = ( lerp( tex2D( @, vec3(@.yz, @.x) ), tex2D( @, vec3(@.xz, @.x) ), @.z ) * 2.0 ) - 1.0;\r\n", @@ -602,31 +571,6 @@ void TerrainDetailMapFeatGLSL::processPix( Vector &component meta->addStatement(new GenOp(" @ *= @.y * @.w;\r\n", detailColor, new IndexOp(detailInfo, detailIndex), inDet)); - // If we had a parallax feature... then factor in the parallax - // amount so that it fades out with the layer blending. - if ( fd.features.hasFeature( MFT_TerrainParallaxMap, detailIndex ) ) - { - // Call the library function to do the rest. - if (fd.features.hasFeature(MFT_IsBC3nm, detailIndex)) - { - meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, vec3(@.xy, @.x), @, @.z * @ );\r\n", - inDet, normalMap, inDet, new IndexOp(detailInfo, detailIndex), negViewTS, new IndexOp(detailInfo, detailIndex), detailBlend)); - } - else - { - meta->addStatement(new GenOp(" @.xy += parallaxOffset( @, vec3(@.xy, @.x), @, @.z * @ );\r\n", - inDet, normalMap, inDet, new IndexOp(detailInfo, detailIndex), negViewTS, new IndexOp(detailInfo, detailIndex), detailBlend)); - } - } - - // Check to see if we have a gbuffer normal. - Var* viewToTangent = (Var*)LangElement::find("viewToTangent"); - if (!viewToTangent && fd.features.hasFeature(MFT_TerrainHeightBlend)) - { - // This needs to be here, to ensure consistent ordering of texcoords, be careful with moving it - getInViewToTangent(componentList); - } - if (!fd.features.hasFeature(MFT_TerrainHeightBlend)) { // Check to see if we have a gbuffer normal. @@ -651,6 +595,14 @@ void TerrainDetailMapFeatGLSL::processPix( Vector &component meta->addStatement(new GenOp(" if ( @ > 0.0f )\r\n", detailBlend)); meta->addStatement(new GenOp(" {\r\n")); + + ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget; + + if (fd.features.hasFeature(MFT_isDeferred)) + target = ShaderFeature::RenderTarget1; + + Var* outColor = (Var*)LangElement::find(getOutputTargetVarName(target)); + meta->addStatement(new GenOp(" @.rgb = toGamma(@.rgb);\r\n", outColor, outColor)); meta->addStatement(new GenOp(" @ += @ * @;\r\n", @@ -672,10 +624,10 @@ ShaderFeature::Resources TerrainDetailMapFeatGLSL::getResources( const MaterialF { // If this is the first detail pass then we // samples from the layer tex. - res.numTex += 1; - res.numTexReg += 1; + res.numTex = 1; + res.numTexReg = 1; - // Texture Array + // Add Detail TextureArray res.numTex += 1; res.numTexReg += 1; } @@ -930,9 +882,12 @@ void TerrainNormalMapFeatGLSL::processVert( Vector &component MultiLine *meta = new MultiLine; - // Make sure the world to tangent transform - // is created and available for the pixel shader. - getOutViewToTangent( componentList, meta, fd ); + if (!fd.features.hasFeature(MFT_TerrainHeightBlend)) + { + // Make sure the world to tangent transform + // is created and available for the pixel shader. + getOutViewToTangent(componentList, meta, fd); + } output = meta; } @@ -1018,24 +973,26 @@ ShaderFeature::Resources TerrainNormalMapFeatGLSL::getResources( const MaterialF { Resources res; - if (getProcessIndex() == 0) + // We only need to process normals during the deferred. + if (!fd.features.hasFeature(MFT_DeferredConditioner)) { - // Texture Array - res.numTex += 1; - res.numTexReg += 1; + return res; + } + + S32 featureIndex = 0, firstNormalMapIndex = 0; + for (int idx = 0; idx < fd.features.getCount(); ++idx) { + const FeatureType& type = fd.features.getAt(idx, &featureIndex); + if (type == MFT_TerrainNormalMap) { + firstNormalMapIndex = getMin(firstNormalMapIndex, featureIndex); + } } // We only need to process normals during the deferred. - if ( fd.features.hasFeature( MFT_DeferredConditioner ) ) + if (getProcessIndex() == firstNormalMapIndex) { - // If this is the first normal map and there - // are no parallax features then we will - // generate the worldToTanget transform. - if ( !fd.features.hasFeature( MFT_TerrainParallaxMap ) && - ( getProcessIndex() == 0 || !fd.features.hasFeature( MFT_TerrainNormalMap, getProcessIndex() - 1 ) ) ) - res.numTexReg = 3; - - res.numTex = 1; + // Normal Texture Array + res.numTexReg += 1; + res.numTex += 1; } return res; @@ -1260,10 +1217,23 @@ void TerrainORMMapFeatGLSL::processPix(Vector &componentList, ShaderFeature::Resources TerrainORMMapFeatGLSL::getResources(const MaterialFeatureData &fd) { - Resources res; - res.numTex = 1; - res.numTexReg += 1; - return res; + 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; + } + return res; } @@ -1312,8 +1282,23 @@ void TerrainBlankInfoMapFeatGLSL::processPix(Vector &component output = meta; } +void TerrainHeightMapBlendGLSL::processVert( + Vector &componentList, const MaterialFeatureData &fd) { + // We only need to process normals during the deferred. + if (!fd.features.hasFeature(MFT_DeferredConditioner)) + return; + + MultiLine* meta = new MultiLine; + + // Make sure the world to tangent transform + // is created and available for the pixel shader. + getOutViewToTangent(componentList, meta, fd); + + output = meta; +} + void TerrainHeightMapBlendGLSL::processPix(Vector& componentList, - const MaterialFeatureData& fd) + const MaterialFeatureData& fd) { ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget; diff --git a/Engine/source/terrain/glsl/terrFeatureGLSL.h b/Engine/source/terrain/glsl/terrFeatureGLSL.h index dcfde2204..5b48c0a51 100644 --- a/Engine/source/terrain/glsl/terrFeatureGLSL.h +++ b/Engine/source/terrain/glsl/terrFeatureGLSL.h @@ -182,6 +182,9 @@ class TerrainHeightMapBlendGLSL : public TerrainFeatGLSL { public: + virtual void processVert(Vector& componentList, + const MaterialFeatureData& fd); + virtual void processPix(Vector& componentList, const MaterialFeatureData& fd); diff --git a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp index 9b34b5022..dec19c3cb 100644 --- a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp +++ b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp @@ -30,6 +30,7 @@ #include "gfx/gfxDevice.h" #include "shaderGen/langElement.h" #include "shaderGen/shaderOp.h" +#include "shaderGen/featureType.h" #include "shaderGen/featureMgr.h" #include "shaderGen/shaderGen.h" #include "core/module.h" @@ -609,7 +610,6 @@ void TerrainDetailMapFeatHLSL::processPix( Vector &component } - Var *detailColor = (Var*)LangElement::find(String::ToString("detailColor%d", detailIndex)); if ( !detailColor ) { @@ -619,19 +619,6 @@ void TerrainDetailMapFeatHLSL::processPix( Vector &component meta->addStatement( new GenOp( " @;\r\n", new DecOp( detailColor ) ) ); } - // Sample the normal map. - // - // We take two normal samples and lerp between them for - // side projection layers... else a single sample. - // - // Note that we're doing the standard greyscale detail - // map technique here which can darken and lighten the - // diffuse texture. - // - // We take two color samples and lerp between them for - // side projection layers... else a single sample. - // - //Sampled detail texture that is not expanded Var* detailMapArray = _getDetailMapArray(); Var* detailMapSampler = _getDetailMapSampler(); @@ -650,15 +637,6 @@ void TerrainDetailMapFeatHLSL::processPix( Vector &component meta->addStatement(new GenOp(" @ *= @.y * @.w;\r\n", detailColor, new IndexOp(detailInfo, detailIndex), inDet)); - - // Check to see if we have a gbuffer normal. - Var* viewToTangent = (Var*)LangElement::find("viewToTangent"); - if (!viewToTangent && fd.features.hasFeature(MFT_TerrainHeightBlend)) - { - // This needs to be here, to ensure consistent ordering of texcoords, be careful with moving it - getInViewToTangent(componentList); - } - if (!fd.features.hasFeature(MFT_TerrainHeightBlend)) { // Check to see if we have a gbuffer normal. @@ -720,18 +698,6 @@ ShaderFeature::Resources TerrainDetailMapFeatHLSL::getResources( const MaterialF res.numTexReg += 1; } - // sample from the detail texture for diffuse coloring. - // res.numTex += 1; - - // If we have parallax for this layer then we'll also - // be sampling the normal map for the parallax heightmap. - //if ( fd.features.hasFeature( MFT_TerrainParallaxMap, getProcessIndex() ) ) - //res.numTex += 1; - - // Finally we always send the detail texture - // coord to the pixel shader. - // res.numTexReg += 1; - return res; } @@ -1003,9 +969,12 @@ void TerrainNormalMapFeatHLSL::processVert( Vector &component MultiLine *meta = new MultiLine; - // Make sure the world to tangent transform - // is created and available for the pixel shader. - getOutViewToTangent( componentList, meta, fd ); + if ( !fd.features.hasFeature(MFT_TerrainHeightBlend) ) + { + // Make sure the world to tangent transform + // is created and available for the pixel shader. + getOutViewToTangent(componentList, meta, fd); + } output = meta; } @@ -1092,20 +1061,26 @@ ShaderFeature::Resources TerrainNormalMapFeatHLSL::getResources( const MaterialF { Resources res; + if (!fd.features.hasFeature(MFT_DeferredConditioner)) + { + return res; + } - if (getProcessIndex() == 0) + S32 featureIndex = 0, firstNormalMapIndex = 0; + for (int idx = 0; idx < fd.features.getCount(); ++idx) { + const FeatureType &type = fd.features.getAt(idx, &featureIndex); + if (type == MFT_TerrainNormalMap) { + firstNormalMapIndex = getMin(firstNormalMapIndex, featureIndex); + } + } + + // We only need to process normals during the deferred. + if (getProcessIndex() == firstNormalMapIndex) { res.numTexReg += 1; res.numTex += 1; } - - // If this is the first normal map and there - // are no parallax features then we will - // generate the worldToTanget transform. - //if ( !fd.features.hasFeature( MFT_TerrainParallaxMap ) && - // ( getProcessIndex() == 0 || !fd.features.hasFeature( MFT_TerrainNormalMap, getProcessIndex() - 1 ) ) ) - // res.numTexReg = 3; - //res.numTex = 1; + return res; } @@ -1386,6 +1361,22 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector &component output = meta; } +void TerrainHeightMapBlendHLSL::processVert(Vector& componentList, + const MaterialFeatureData& fd) +{ + // We only need to process normals during the deferred. + if (!fd.features.hasFeature(MFT_DeferredConditioner)) + return; + + MultiLine* meta = new MultiLine; + + // Make sure the world to tangent transform + // is created and available for the pixel shader. + getOutViewToTangent(componentList, meta, fd); + + output = meta; +} + void TerrainHeightMapBlendHLSL::processPix(Vector& componentList, const MaterialFeatureData& fd) { @@ -1482,8 +1473,6 @@ void TerrainHeightMapBlendHLSL::processPix(Vector& componentLi for (S32 idx = 0; idx < detailCount; ++idx) { - Var* detCoord = (Var*)LangElement::find(String::ToString("detCoord%d", idx)); - Var* detailH = (Var*)LangElement::find(String::ToString("detailH%d", idx)); Var* detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", idx)); diff --git a/Engine/source/terrain/hlsl/terrFeatureHLSL.h b/Engine/source/terrain/hlsl/terrFeatureHLSL.h index 38bd46330..829af9c6f 100644 --- a/Engine/source/terrain/hlsl/terrFeatureHLSL.h +++ b/Engine/source/terrain/hlsl/terrFeatureHLSL.h @@ -188,6 +188,9 @@ class TerrainHeightMapBlendHLSL : public TerrainFeatHLSL { public: + virtual void processVert(Vector& componentList, + const MaterialFeatureData& fd); + virtual void processPix(Vector& componentList, const MaterialFeatureData& fd); diff --git a/Engine/source/terrain/terrCellMaterial.cpp b/Engine/source/terrain/terrCellMaterial.cpp index 583aa5abe..3228e70b9 100644 --- a/Engine/source/terrain/terrCellMaterial.cpp +++ b/Engine/source/terrain/terrCellMaterial.cpp @@ -53,23 +53,13 @@ Vector _initSamplerNames() { Vector samplerNames; samplerNames.push_back("$baseTexMap"); - samplerNames.push_back("$layerTex"); - //samplerNames.push_back("$macrolayerTex"); + samplerNames.push_back("$layerTex"); samplerNames.push_back("$lightMapTex"); samplerNames.push_back("$lightInfoBuffer"); samplerNames.push_back("$normalMapSampler"); samplerNames.push_back("$detailMapSampler"); samplerNames.push_back("$macroMapSampler"); - samplerNames.push_back("$ormMapSampler"); - // samplerNames.push_back("$ormConfigMapArray"); - - for(int i = 0; i < sgMaxTerrainMaterialsPerPass; ++i) - { - //samplerNames.push_back(avar("$normalMap%d",i)); - //samplerNames.push_back(avar("$detailMap%d",i)); - //samplerNames.push_back(avar("$macroMap%d", i)); - // samplerNames.push_back(avar("$ormConfigMap%d", i)); - } + samplerNames.push_back("$ormMapSampler"); return samplerNames; } @@ -783,13 +773,13 @@ bool TerrainCellMaterial::setupPass( const SceneRenderState *state, 0, mConsts ); - if (mDetailTexArrayConst->isValid()) + if (mDetailTexArrayConst->isValid() && mTerrain->getDetailTextureArray().isValid()) GFX->setTextureArray(mDetailTexArrayConst->getSamplerRegister(), mTerrain->getDetailTextureArray()); - if (mMacroTexArrayConst->isValid()) + if (mMacroTexArrayConst->isValid() && mTerrain->getMacroTextureArray().isValid()) GFX->setTextureArray(mMacroTexArrayConst->getSamplerRegister(), mTerrain->getMacroTextureArray()); - if (mNormalTexArrayConst->isValid()) + if (mNormalTexArrayConst->isValid() && mTerrain->getNormalTextureArray().isValid()) GFX->setTextureArray(mNormalTexArrayConst->getSamplerRegister(), mTerrain->getNormalTextureArray()); - if (mOrmTexArrayConst->isValid()) + if (mOrmTexArrayConst->isValid() && mTerrain->getOrmTextureArray().isValid()) GFX->setTextureArray(mOrmTexArrayConst->getSamplerRegister(), mTerrain->getOrmTextureArray()); mConsts->setSafe( mLayerSizeConst, (F32)mTerrain->mLayerTex.getWidth() ); diff --git a/Engine/source/terrain/terrData.h b/Engine/source/terrain/terrData.h index 4b33d6c61..cfef5c29d 100644 --- a/Engine/source/terrain/terrData.h +++ b/Engine/source/terrain/terrData.h @@ -135,10 +135,10 @@ protected: /// Vector mBaseTextures; - GFXTextureArray* mDetailTextureArray; - GFXTextureArray* mMacroTextureArray; - GFXTextureArray* mNormalTextureArray; - GFXTextureArray* mOrmTextureArray; + GFXTextureArrayHandle mDetailTextureArray; + GFXTextureArrayHandle mMacroTextureArray; + GFXTextureArrayHandle mNormalTextureArray; + GFXTextureArrayHandle mOrmTextureArray; /// GFXTexHandle mLayerTex; @@ -331,10 +331,10 @@ public: U32 getMaterialCount() const; - GFXTextureArray* getDetailTextureArray() const { return mDetailTextureArray; } - GFXTextureArray* getMacroTextureArray() const { return mMacroTextureArray; } - GFXTextureArray* getNormalTextureArray() const { return mNormalTextureArray; } - GFXTextureArray* getOrmTextureArray() const { return mOrmTextureArray; } + GFXTextureArrayHandle getDetailTextureArray() const { return mDetailTextureArray; } + GFXTextureArrayHandle getMacroTextureArray() const { return mMacroTextureArray; } + GFXTextureArrayHandle getNormalTextureArray() const { return mNormalTextureArray; } + GFXTextureArrayHandle getOrmTextureArray() const { return mOrmTextureArray; } //BaseMatInstance* getMaterialInst( U32 x, U32 y );