Looks like the G-buffer debug is working alright

This commit is contained in:
Hugo Willaume 2019-06-10 14:02:05 +09:00
parent fe5a3b2541
commit 551b408fe3
5 changed files with 15 additions and 12 deletions

View File

@ -12,8 +12,6 @@ uniform sampler2D tex;
void main()
{
gPosition = FragPos;
//gPosition = normalize(abs(FragPos));
//gPosition = vec3(1,1,1);
gNormal = normalize(Normal);

View File

@ -15,10 +15,8 @@ uniform mat4 ModelMatrix;
void main(void)
{
Normal = v_normal * NormalMatrix;
Normal = NormalMatrix * v_normal;
TexCoords = v_texmap;
gl_Position = mvp * vec4(coord3d, 1.0f);
FragPos = (ModelMatrix * vec4(coord3d, 1.0f)).xyz;
//FragPos = coord3.xyz;
//FragPos = gl_Position.xyz;
}

View File

@ -96,7 +96,9 @@ private:
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &shaderStatus);
if (shaderStatus == GL_FALSE)
{
throw std::runtime_error(shaderTypeString + " compilation failed: " + getInfoLog(ObjectType::SHADER, shaderId));
std::string err = getInfoLog(ObjectType::SHADER, shaderId);
std::cout << err << std::endl;
throw std::runtime_error(shaderTypeString + " compilation failed: " + err);
}
else
{

View File

@ -352,11 +352,11 @@ void Mesh::draw(SceneContext &ctx) {
ctx.modelMatrix = model.getMatrix();
ctx.mvpMatrix = ctx.projectionMatrix * ctx.viewMatrix * ctx.modelMatrix;
ctx.modelViewMatrix = ctx.viewMatrix * ctx.modelMatrix;
ctx.normalMatrix = glm::mat3(glm::transpose(glm::inverse(ctx.modelViewMatrix)));
ctx.normalMatrix = glm::transpose(glm::inverse(glm::mat3(ctx.modelMatrix)));
shader.addUniform("mvp", ctx.mvpMatrix);
//shader.addUniform("NormalMatrix", ctx.normalMatrix);
//shader.addUniform("ModelMatrix", ctx.modelMatrix);
shader.addUniform("NormalMatrix", ctx.normalMatrix);
shader.addUniform("ModelMatrix", ctx.modelMatrix);
glActiveTexture(GL_TEXTURE0);

View File

@ -150,12 +150,12 @@ void MyGlWindow::setup()
float pos_x = std::rand() % 100 - 50;
float pos_z = std::rand() % 100 - 50;
/*meshes[cube_name]->addStartTranslation(glm::vec4(0, 1, 0, 0));
meshes[cube_name]->addStartTranslation(glm::vec4(0, 1, 0, 0));
meshes[cube_name]->addStartTranslation(glm::vec4(pos_x, 0, 0, 0));
meshes[cube_name]->addStartTranslation(glm::vec4(0, 0, pos_z, 0));
meshes[cube_name]->addStartRotation(glm::vec4(1, 0, 0, std::rand() % 360));
meshes[cube_name]->addStartRotation(glm::vec4(0, 1, 0, std::rand() % 360));
meshes[cube_name]->addStartRotation(glm::vec4(0, 0, 1, std::rand() % 360));*/
meshes[cube_name]->addStartRotation(glm::vec4(0, 0, 1, std::rand() % 360));
float light_r = (40 + std::rand() % 60) / 100.f;
float light_g = (40 + std::rand() % 60) / 100.f;
@ -186,10 +186,15 @@ void MyGlWindow::draw()
_multipassManager.enableFrameBufferTexture("position_buffer");
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
for (auto it = meshes.begin(); it != meshes.end(); it++)
(*it).second->draw(_scnctx);
glDisable(GL_CULL_FACE);
_multipassManager.drawResultToScreen(_scnctx);
}
void MyGlWindow::resize(int w, int h)