GL_TEXTURE0(スロット0のテクスチャ)以降のすべてのテクスチャは黒です。
フラグメントシェーダー(重みを変更してさまざまなテクスチャをチェックするサンプルコード):
#version 330
uniform sampler2D g_ColorTex;
uniform sampler2D g_DepthTex;
uniform sampler2D g_DofNearBlurTex;
uniform sampler2D g_DofDownBlurTex;
in vec4 g_VertexPosition;
in vec2 g_ScreenCoords;
layout (location = 0) out vec4 FragColor;
void main()
{
// Changing weights to check textures
FragColor = 1.00001f * vec4(texture(g_ColorTex , g_ScreenCoords).rgb, 1.0f);
FragColor += 0.00001f * vec4(texture(g_DepthTex , g_ScreenCoords).rgb, 1.0f);
FragColor += 0.00001f * vec4(texture(g_DofNearBlurTex, g_ScreenCoords).rgb, 1.0f);
FragColor += 0.00001f * vec4(texture(g_DofDownBlurTex, g_ScreenCoords).rgb, 1.0f);
}
そのようなテクスチャをアップロードします(抜粋!):
::glUseProgram(ShaderHandle);
unsigned int TextureIndex;
TextureIndex = ::glGetUniformLocation(ShaderHandle, "g_ColorTex");
::glUniform1i(TextureIndex, 0);
::glActiveTexture(GL_TEXTURE0);
::glBindTexture(GL_TEXTURE_2D, TextureHandle);
::glBindSampler(GL_TEXTURE0, SamplerHandle);
TextureIndex = ::glGetUniformLocation(ShaderHandle, "g_DepthTex");
::glUniform1i(TextureIndex, 1);
::glActiveTexture(GL_TEXTURE1);
::glBindTexture(GL_TEXTURE_2D, TextureHandle);
::glBindSampler(GL_TEXTURE1, SamplerHandle);
TextureIndex = ::glGetUniformLocation(ShaderHandle, "g_DofNearBlurTex");
::glUniform1i(TextureIndex, 2);
::glActiveTexture(GL_TEXTURE2);
::glBindTexture(GL_TEXTURE_2D, TextureHandle);
::glBindSampler(GL_TEXTURE2, SamplerHandle);
TextureIndex = ::glGetUniformLocation(ShaderHandle, "g_DofDownBlurTex");
::glUniform1i(TextureIndex, 3);
::glActiveTexture(GL_TEXTURE3);
::glBindTexture(GL_TEXTURE_2D, TextureHandle);
::glBindSampler(GL_TEXTURE3, SamplerHandle);
//...
::glDrawElements(GL_TRIANGLES, Mesh->m_Indices.size() * 3, GL_UNSIGNED_INT, 0);
テクスチャスロットを変更して別のテクスチャをアップロードしようとしましたが、GL_TEXTURE0でテクスチャを使用するまで、常に黒い画面が表示されます。