Commit 22ea6d63 authored by Tim Übelhör's avatar Tim Übelhör

fixed specular lighting

parent 92c9c91f
......@@ -9,7 +9,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/scigl_viewer",
"args": ["${workspaceFolder}/model/beckenkamm.dae"],
"args": ["${workspaceFolder}/model/monkey.blend"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
......
......@@ -3,7 +3,7 @@ from conans import ConanFile, CMake
class SciglRenderConan(ConanFile):
name = "scigl_render"
version = "0.3"
version = "0.4"
license = "MIT"
url = "https://git.rwth-aachen.de/robo_guide/scigl_render"
description = ("Library to simplify rendering objects via OpenGL."
......
R""(
#version 330 core
layout (location = 0) in vec3 position;
uniform mat4 model_matrix;
uniform mat4 view_matrix;
uniform mat4 projection_matrix;
out float depth;
out vec3 world_position;
// simple linear transformation into projection space
void main()
{
vec4 local_pos = vec4(position, 1.0);
vec4 view_pos = view_matrix * model_matrix * local_pos;
vec4 local_position = vec4(position, 1.0);
world_position = (model_matrix * local_position).xyz;
vec4 view_pos = view_matrix * vec4(world_position, 1.0);
depth = view_pos.z;
gl_Position = projection_matrix * view_pos;
})""
\ No newline at end of file
......@@ -32,15 +32,15 @@ void main()
vec3 diffuse_color = material.diffuse + diffuse_texture_strength
* texture(texture0, texture_coordinate).xyz;
float diff = max(dot(normal, light_direction), 0.0);
vec3 diffuse = diff * diffuse_color;
vec3 diffuse = diff * diffuse_color * light_color;
// specular
vec3 view_direction = normalize(camera_position - world_position);
vec3 reflection_direction = reflect(-light_direction, normal);
float spec = pow(max(dot(view_direction, reflection_direction), 0.0),
material.shininess);
vec3 specular = material.specular * spec;
vec3 specular = spec * material.specular * light_color;
// combined
vec3 result = (ambient + diffuse + specular) * light_color;
vec3 result = ambient + diffuse + specular;
fragment_color = vec4(result, 1.0);
}
)""
\ No newline at end of file
No preview for this file type
No preview for this file type
......@@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>scigl_render</name>
<version>0.3</version>
<version>0.4</version>
<description>
Library to simplify rendering objects via OpenGL. The intendet use case
is scientific (e.g. probabalistic filtering). It is not supposed to be a
......
......@@ -67,7 +67,11 @@ int main(int argc, char *argv[])
camera_intrinsics.c_y = 310;
camera_intrinsics.f_x = 511;
camera_intrinsics.f_y = 513;
camera_intrinsics.dist_coeffs[0] = 5;
camera_intrinsics.dist_coeffs[0] = 4.1925421198910247e-02;
camera_intrinsics.dist_coeffs[1] = -9.6463442423611379e-02;
camera_intrinsics.dist_coeffs[2] = -2.3391717576772839e-03;
camera_intrinsics.dist_coeffs[3] = 5.8792609967242386e-04;
camera_intrinsics.dist_coeffs[4] = 4.9171950039135250e-02;
CvCamera camera(camera_intrinsics);
// Test if Cartesian -> Quaternion works
CartesianPose camera_pose = {glm::vec3(0, 0, 0), glm::vec3(0, 0, 0)};
......@@ -77,7 +81,7 @@ int main(int argc, char *argv[])
model.pose.position = glm::vec3(0, 0, 0.5);
model.pose.orientation.x = 0.707;
model.pose.orientation.w = 0.707;
light.position = glm::vec3(0, 0, 0);
light.position = glm::vec3(0, -0.1, 0);
light.color = glm::vec3(1, 1, 1);
// main loop
......
......@@ -67,7 +67,7 @@ Mesh::Mesh(const aiMesh *mesh, const aiScene *scene)
material.diffuse = convert_color(diffuse_color);
}
aiColor3D specular_color;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_COLOR_DIFFUSE, specular_color))
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_COLOR_SPECULAR, specular_color))
{
material.specular = convert_color(specular_color);
}
......
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