Use specmap on others mats

This commit is contained in:
Vincent Lejeune 2014-10-05 20:37:49 +02:00
parent 0121ae8db6
commit 9f2b66d195
5 changed files with 27 additions and 19 deletions

View File

@ -1,10 +1,12 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D Albedo;
uniform sampler2D Detail;
uniform sampler2D SpecMap;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
flat in sampler2D thirdhandle;
#endif
in vec2 uv;
@ -17,6 +19,7 @@ void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 color = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
@ -24,7 +27,8 @@ void main(void)
#else
vec4 color = texture(Albedo, uv);
vec4 detail = texture(Detail, uv_bis);
float specmap = texture(SpecMap, uv).g;
#endif
color *= detail;
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.);
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.);
}

View File

@ -2,6 +2,7 @@
layout(bindless_sampler) uniform sampler2D dtex;
#else
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D dtex;
#endif
@ -9,6 +10,7 @@ uniform vec3 SunDir;
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
in vec3 nor;
in vec2 uv;
@ -20,11 +22,13 @@ void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 color = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
#else
vec4 color = texture(Albedo, uv);
float specmap = texture(SpecMap, uv).g;
#endif
if (color.a < 0.5) discard;
@ -44,6 +48,6 @@ void main(void)
float scattering = mix(fPowEdotL, fLdotNBack, .5);
vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), 1.);
vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap);
FragColor = vec4(LightFactor, 1.);
}

View File

@ -75,7 +75,7 @@ struct DefaultMaterial
};
const std::vector<size_t> DefaultMaterial::FirstPassTextures = { 1 };
const std::vector<size_t> DefaultMaterial::SecondPassTextures = { 0 };
const std::vector<size_t> DefaultMaterial::SecondPassTextures = { 0, 1 };
struct AlphaRef
{
@ -93,7 +93,7 @@ struct AlphaRef
};
const std::vector<size_t> AlphaRef::FirstPassTextures = { 0, 1 };
const std::vector<size_t> AlphaRef::SecondPassTextures = { 0 };
const std::vector<size_t> AlphaRef::SecondPassTextures = { 0, 1 };
struct SphereMap
{
@ -165,7 +165,7 @@ struct NormalMat
};
const std::vector<size_t> NormalMat::FirstPassTextures = { 2, 1 };
const std::vector<size_t> NormalMat::SecondPassTextures = { 0 };
const std::vector<size_t> NormalMat::SecondPassTextures = { 0, 1 };
struct DetailMat
{
@ -183,7 +183,7 @@ struct DetailMat
};
const std::vector<size_t> DetailMat::FirstPassTextures = { 1 };
const std::vector<size_t> DetailMat::SecondPassTextures = { 0, 2 };
const std::vector<size_t> DetailMat::SecondPassTextures = { 0, 2, 1 };
struct SplattingMat
{
@ -531,15 +531,15 @@ void IrrDriver::renderSolidSecondPass()
if (UserConfigParams::m_azdo)
{
multidraw2ndPass<DefaultMaterial>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0));
multidraw2ndPass<AlphaRef>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0));
multidraw2ndPass<DefaultMaterial>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<AlphaRef>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<SphereMap>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0));
multidraw2ndPass<UnlitMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0));
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
multidraw2ndPass<GrassMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle, 0), windDir, cb->getPosition());
multidraw2ndPass<GrassMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle, 0, 0), windDir, cb->getPosition());
multidraw2ndPass<NormalMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0));
multidraw2ndPass<DetailMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<NormalMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<DetailMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0, 0));
}
else if (irr_driver->hasARB_draw_indirect())
{

View File

@ -865,7 +865,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_object_pass2.frag").c_str());
AssignUniforms();
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
}
InstancedObjectRefPass2Shader::InstancedObjectRefPass2Shader()
@ -876,7 +876,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_objectref_pass2.frag").c_str());
AssignUniforms();
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
}
DetailledObjectPass2Shader::DetailledObjectPass2Shader()
@ -897,7 +897,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_detailledobject_pass2.frag").c_str());
AssignUniforms();
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap");
}
ObjectUnlitShader::ObjectUnlitShader()
@ -947,7 +947,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_grass_pass2.frag").c_str());
AssignUniforms("windDir", "SunDir");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 4, "SpecMap");
}
SphereMapShader::SphereMapShader()

View File

@ -107,13 +107,13 @@ public:
ObjectPass2Shader();
};
class InstancedObjectPass2Shader : public ShaderHelperSingleton<InstancedObjectPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
class InstancedObjectPass2Shader : public ShaderHelperSingleton<InstancedObjectPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
InstancedObjectPass2Shader();
};
class InstancedObjectRefPass2Shader : public ShaderHelperSingleton<InstancedObjectRefPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
class InstancedObjectRefPass2Shader : public ShaderHelperSingleton<InstancedObjectRefPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
InstancedObjectRefPass2Shader();
@ -125,7 +125,7 @@ public:
DetailledObjectPass2Shader();
};
class InstancedDetailledObjectPass2Shader : public ShaderHelperSingleton<InstancedDetailledObjectPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
class InstancedDetailledObjectPass2Shader : public ShaderHelperSingleton<InstancedDetailledObjectPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
InstancedDetailledObjectPass2Shader();
@ -155,7 +155,7 @@ public:
GrassPass2Shader();
};
class InstancedGrassPass2Shader : public ShaderHelperSingleton<InstancedGrassPass2Shader, core::vector3df, core::vector3df>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Nearest_Filtered, Trilinear_Anisotropic_Filtered>
class InstancedGrassPass2Shader : public ShaderHelperSingleton<InstancedGrassPass2Shader, core::vector3df, core::vector3df>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Nearest_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
InstancedGrassPass2Shader();