Commit 3b2d65e7 authored by unknown's avatar unknown
Browse files

OpenGL Light visualization (closes #30)

parent efb64485
<linespace version="1.0">
<item name="subdivisions" value="50"/>
<item name="subdivisions" value="30"/>
<item name="radial-subdivision" value="50"/>
<item name="generator" value="gpu"/>
</linespace>
#version 430
layout(location = 6) out vec4 out_final_lighting;
uniform vec4 u_color;
void main()
{
out_final_lighting = u_color;
}
#version 430
layout(location=0) in vec4 in_position;
layout(location=1) in vec4 in_normal;
layout(location=2) in vec2 in_texcoord;
layout(location=3) in vec4 in_tangent;
layout(location=4) in vec4 in_bitangent;
uniform mat4 u_view_projection;
uniform mat4 u_model_view;
uniform mat4 u_model;
uniform mat4 u_normal;
uniform vec3 u_camera_position;
void main()
{
gl_Position = u_view_projection * u_model * in_position;
}
......@@ -39,9 +39,12 @@ void main()
//Emission, just put the color in and continue
vec4 lighting = texelFetch(u_gbuffer.lighting, pixel, s);
if(lighting.rgb != vec3(0))
{
final_color_part += lighting;
//final_color_part += lighting;
out_final_color += lighting / u_samples;
continue;
}
......@@ -86,7 +89,7 @@ void main()
// Now we can add the previously calculated environment reflection or refraction
vec4 reflection_tint = is_transparent ? diffuse : specular;
// final_color_part = mix(final_color_part, reflection_tint * environment_reflect, shininess);
final_color_part = mix(final_color_part, reflection_tint * environment_reflect, shininess);
}
// Add resulting color to the finished image, and compensate for multisampling
......
......@@ -119,7 +119,7 @@ namespace glare
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_mirror_0r.dae", 1.f);
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_transparent.dae", 1.f);
//initializeScene(m_current_scene_root / "stmirror.dae", 1.f);
initializeScene(m_current_scene_root / "artifact_suzanne_x2_transparent.dae", 1.f);
initializeScene(m_current_scene_root / "funny.dae", 1.f);
initializeRenderRequirements();
initializeAdvanced();
......
......@@ -51,6 +51,19 @@ namespace glare
LightManager::getInstance().registerLightForNextPass({ m_light, shadow_map });
static std::unique_ptr<core::Material> m_material = std::make_unique<Material>("__light_mat", std::make_shared<Program>(std::vector<std::shared_ptr<Shader>>{
std::make_shared<Shader>(gl::ShaderType::eVertex, files::shader("lamp/lamp.vert")),
std::make_shared<Shader>(gl::ShaderType::eFragment, files::shader("lamp/lamp.frag"))
}));
static std::unique_ptr<Mesh> m_mesh = std::make_unique<Mesh>();
m_material->activate();
m_material->getShader()->uniform("u_view_projection", state::camera->getViewProjection());
m_material->getShader()->uniform("u_model_view", state::camera->getView()*getOwner()->c_worldTransform().matrix());
m_material->getShader()->uniform("u_model", glm::scale(getOwner()->c_worldTransform().matrix(), glm::vec3(0.1f)));
m_material->getShader()->uniform("u_color", m_color);
m_material->getShader()->uniform("u_normal", glm::inverse(glm::transpose(state::camera->getView()*getOwner()->c_worldTransform().matrix())));
m_mesh->draw();
} break;
case DrawMode::eNoColor:
// Don't rebuild shadow maps if a shadow map is currently built to prevent recursive loops.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment