From b3e124b93efe37c06100044919527978c0ec66cf Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 20 Sep 2014 18:48:22 +0200 Subject: [PATCH] Some fixes --- data/shaders/instanced_object_pass1.frag | 4 ---- src/graphics/render_geometry.cpp | 26 ++++++++++++------------ src/graphics/shaders.cpp | 2 +- src/graphics/shaders.hpp | 2 +- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/data/shaders/instanced_object_pass1.frag b/data/shaders/instanced_object_pass1.frag index 76e109a0d..bf76fbf22 100644 --- a/data/shaders/instanced_object_pass1.frag +++ b/data/shaders/instanced_object_pass1.frag @@ -1,10 +1,8 @@ #ifndef GL_ARB_bindless_texture -uniform sampler2D tex; uniform sampler2D glosstex; #endif #ifdef GL_ARB_bindless_texture -flat in sampler2D handle; flat in sampler2D secondhandle; #endif in vec3 nor; @@ -16,10 +14,8 @@ vec2 EncodeNormal(vec3 n); void main(void) { #ifdef GL_ARB_bindless_texture - vec4 col = texture(handle, uv); float glossmap = texture(secondhandle, uv).x; #else - vec4 col = texture(tex, uv); float glossmap = texture(glosstex, uv).x; #endif EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5; diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index 5e8ea6132..04da47830 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -80,7 +80,7 @@ struct DefaultMaterial { typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectPass2Shader InstancedSecondPassShader; - typedef ListInstancedMatDefault List; + typedef ListInstancedMatDefault InstancedList; static const enum E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum MeshMaterial MaterialType = MAT_DEFAULT; static const enum InstanceType Instance = InstanceTypeDualTex; @@ -88,14 +88,14 @@ struct DefaultMaterial static const std::vector SecondPassTextures; }; -const std::vector DefaultMaterial::FirstPassTextures = { 0, 1 }; +const std::vector DefaultMaterial::FirstPassTextures = { 1 }; const std::vector DefaultMaterial::SecondPassTextures = { 0 }; struct AlphaRef { typedef MeshShader::InstancedObjectRefPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectRefPass2Shader InstancedSecondPassShader; - typedef ListInstancedMatAlphaRef List; + typedef ListInstancedMatAlphaRef InstancedList; static const enum E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum MeshMaterial MaterialType = MAT_ALPHA_REF; static const enum InstanceType Instance = InstanceTypeDualTex; @@ -110,7 +110,7 @@ struct SphereMap { typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedSphereMapShader InstancedSecondPassShader; - typedef ListInstancedMatSphereMap List; + typedef ListInstancedMatSphereMap InstancedList; static const enum E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum MeshMaterial MaterialType = MAT_SPHEREMAP; static const enum InstanceType Instance = InstanceTypeDualTex; @@ -118,14 +118,14 @@ struct SphereMap static const std::vector SecondPassTextures; }; -const std::vector SphereMap::FirstPassTextures = { 0, 1 }; +const std::vector SphereMap::FirstPassTextures = { 1 }; const std::vector SphereMap::SecondPassTextures = { 0 }; struct UnlitMat { typedef MeshShader::InstancedObjectRefPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectUnlitShader InstancedSecondPassShader; - typedef ListInstancedMatUnlit List; + typedef ListInstancedMatUnlit InstancedList; static const enum E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum MeshMaterial MaterialType = MAT_UNLIT; static const enum InstanceType Instance = InstanceTypeDualTex; @@ -140,7 +140,7 @@ struct GrassMat { typedef MeshShader::InstancedGrassPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedGrassPass2Shader InstancedSecondPassShader; - typedef ListInstancedMatGrass List; + typedef ListInstancedMatGrass InstancedList; static const enum E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum MeshMaterial MaterialType = MAT_GRASS; static const enum InstanceType Instance = InstanceTypeDualTex; @@ -155,7 +155,7 @@ struct NormalMat { typedef MeshShader::InstancedNormalMapShader InstancedFirstPassShader; typedef MeshShader::InstancedObjectPass2Shader InstancedSecondPassShader; - typedef ListInstancedMatNormalMap List; + typedef ListInstancedMatNormalMap InstancedList; static const enum E_VERTEX_TYPE VertexType = video::EVT_TANGENTS; static const enum MeshMaterial MaterialType = MAT_NORMAL_MAP; static const enum InstanceType Instance = InstanceTypeThreeTex; @@ -168,9 +168,9 @@ const std::vector NormalMat::SecondPassTextures = { 0 }; struct DetailMat { - typedef MeshShader::InstancedNormalMapShader InstancedFirstPassShader; + typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedDetailledObjectPass2Shader InstancedSecondPassShader; - typedef ListInstancedMatDetails List; + typedef ListInstancedMatDetails InstancedList; static const enum E_VERTEX_TYPE VertexType = video::EVT_2TCOORDS; static const enum MeshMaterial MaterialType = MAT_DETAIL; static const enum InstanceType Instance = InstanceTypeThreeTex; @@ -178,7 +178,7 @@ struct DetailMat static const std::vector SecondPassTextures; }; -const std::vector DetailMat::FirstPassTextures = { 0, 1 }; +const std::vector DetailMat::FirstPassTextures = { 1 }; const std::vector DetailMat::SecondPassTextures = { 0, 2 }; namespace RenderGeometry @@ -304,7 +304,7 @@ template void renderInstancedMeshes1stPass(Args...args) { const std::vector &TexUnits = T::FirstPassTextures; - std::vector &meshes = T::List::getInstance()->SolidPass; + std::vector &meshes = T::InstancedList::getInstance()->SolidPass; glUseProgram(T::InstancedFirstPassShader::getInstance()->Program); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance)); for (unsigned i = 0; i < meshes.size(); i++) @@ -434,7 +434,7 @@ void renderMeshes2ndPass(const std::vector &TexUnits, std::vector void renderInstancedMeshes2ndPass(const std::vector &Prefilled_tex, Args...args) { - std::vector &meshes = T::List::getInstance()->SolidPass; + std::vector &meshes = T::InstancedList::getInstance()->SolidPass; const std::vector &TexUnits = T::SecondPassTextures; glUseProgram(T::InstancedSecondPassShader::getInstance()->Program); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance)); diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index aa8abde27..698655f6b 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -817,7 +817,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_object_pass1.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "tex", 1, "glosstex"); + AssignSamplerNames(Program, 0, "glosstex"); } InstancedObjectRefPass1Shader::InstancedObjectRefPass1Shader() diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 8f552c648..933f2122c 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -77,7 +77,7 @@ public: NormalMapShader(); }; -class InstancedObjectPass1Shader : public ShaderHelperSingleton, public TextureRead +class InstancedObjectPass1Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedObjectPass1Shader();