Added ambient lighting
This commit is contained in:
parent
dea312a704
commit
482205b96e
9 changed files with 69 additions and 9 deletions
|
@ -32,8 +32,8 @@ add_custom_command(TARGET movement POST_BUILD
|
|||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $<TARGET_FILE_DIR:movement>/assets
|
||||
)
|
||||
|
||||
# if(WIN32)
|
||||
# add_custom_command(TARGET movement POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:movement>
|
||||
# )
|
||||
# endif()
|
||||
if(WIN32)
|
||||
add_custom_command(TARGET movement POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:movement>
|
||||
)
|
||||
endif()
|
|
@ -201,6 +201,9 @@ int main(int argc, char** argv)
|
|||
oglu::Texture crate = oglu::MakeTexture("assets/crate.jpg");
|
||||
oglu::Texture opengl = oglu::MakeTexture("assets/opengl.png");
|
||||
|
||||
oglu::AmbientLight ambient;
|
||||
ambient.intensity = 0.1f;
|
||||
|
||||
camera.Move(0.0f, 0.0f, 5.0f);
|
||||
|
||||
// Window loop
|
||||
|
@ -209,7 +212,7 @@ int main(int argc, char** argv)
|
|||
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
|
||||
oglu::Color bgColor(0.29f, 0.13f, 0.23f);
|
||||
oglu::Color bgColor = oglu::Color::Black;
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
processInput(window);
|
||||
|
@ -222,6 +225,8 @@ int main(int argc, char** argv)
|
|||
shader->Use();
|
||||
shader->SetUniformTexture("texture1", crate, 0);
|
||||
shader->SetUniformTexture("texture2", opengl, 1);
|
||||
shader->SetUniform("ambientStrength", ambient.intensity);
|
||||
shader->SetUniform("ambientColor", ambient.color, true);
|
||||
shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(camera.GetMatrix()));
|
||||
shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(camera.GetProjection()));
|
||||
|
||||
|
|
|
@ -6,7 +6,12 @@ out vec4 FragColor;
|
|||
uniform sampler2D texture1;
|
||||
uniform sampler2D texture2;
|
||||
|
||||
uniform float ambientStrength;
|
||||
uniform vec3 ambientColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = mix(texture(texture1, oUV), texture(texture2, oUV), 0.2);
|
||||
vec3 ambient = ambientColor * ambientStrength;
|
||||
|
||||
FragColor = mix(texture(texture1, oUV), texture(texture2, oUV), 0.2) * vec4(ambient, 1.0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue