Skip to content

Commit

Permalink
gltf pbr material load, gltf loader slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcypher89 committed Jul 2, 2024
1 parent a3222b3 commit 58cc7eb
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 269 deletions.
5 changes: 3 additions & 2 deletions src/carcockpit/gltf_viewer_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,16 @@ void gltf_viewer_widget::render(const ruis::matrix4& matrix) const
// application::inst()
// .shader_phong_v.render(*vaao2, mvp * mtrx, modelview * mtrx, this->tex_test->tex(), light_pos_view, light_int);

//phong_s->render(*this->light_vao, mvp_monkey, modelview_monkey, this->tex_test->tex(), light_pos_view, light_int);
// phong_s->render(*this->light_vao, mvp_monkey, modelview_monkey, this->tex_test->tex(), light_pos_view,
// light_int);

camrip->pos = camera_position;
camrip->target = camera_target;
camrip->up = ruis::vec3(0, 2, 0);
camrip->fovy = 3.1415926535f / 4.f;
camrip->near = 0.1;
camrip->far = 20.f;

sc_renderer->render();

// advanced_s->render(
Expand Down
7 changes: 5 additions & 2 deletions src/carcockpit/gltf_viewer_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class gltf_viewer_widget : public ruis::fraction_widget, public ruis::updateable
ruis::vec3 camera_position{camera_position_top};
ruis::vec3 camera_attractor{camera_position_front};

ruis::vec3 camera_target{0, 1, 0};
ruis::vec3 camera_target{0, -2, 0};

ruis::real camera_transition_duration = 0.2; // not seconds ;)
// bool camera_transition_ongoing = true;
Expand Down Expand Up @@ -122,7 +122,10 @@ class gltf_viewer_widget : public ruis::fraction_widget, public ruis::updateable
};

namespace make {
inline utki::shared_ref<gltf_viewer_widget> gltf_viewer_widget(utki::shared_ref<ruis::context> c, gltf_viewer_widget::all_parameters params)
inline utki::shared_ref<gltf_viewer_widget> gltf_viewer_widget(
utki::shared_ref<ruis::context> c,
gltf_viewer_widget::all_parameters params
)
{
return utki::make_shared<carcockpit::gltf_viewer_widget>(std::move(c), std::move(params));
}
Expand Down
2 changes: 1 addition & 1 deletion src/carcockpit/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <ruis/widgets/label/image.hpp>
#include <ruis/widgets/slider/slider.hpp>

#include "gltf_viewer_widget.hpp"
#include "gauge.hpp"
#include "gltf_viewer_widget.hpp"

using namespace std::string_literals;

Expand Down
4 changes: 2 additions & 2 deletions src/carcockpit/shaders/shader_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ shader_adv::shader_adv() :
light_dir = normalize( mat3_to_local * (light_position.xyz - pos) );
view_dir = mat3_to_local * normalize(-pos);
// Pass along the texture coordinate
tc = vec2(a1.x, a1.y); // * vec2(10, 10); // for supposed x10 tiling, if enabled in texture
tc = vec2(a1.x, 1.0 - a1.y); // * vec2(10, 10); // for supposed x10 tiling, if enabled in texture
gl_Position = matrix * a0;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ shader_adv::shader_adv() :
vec3 diffuse = max( Kd - metalness, 0.0 ) * sDotN * light_intensity;
vec3 spec = Ks * pow( max( dot(r, view_dir), 0.0 ), glossiness ) * light_intensity;
return (( ambient + diffuse + spec ) * diffR) + (env_refl * metalness);
return (( ambient + diffuse ) * diffR + spec ) + (env_refl * metalness);
}
void main()
Expand Down
Loading

0 comments on commit 58cc7eb

Please sign in to comment.