From a0439c8d387579a1727ad00c2e105e7602aedbb6 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 12 Jul 2020 13:31:28 +0800 Subject: +mathlib --- src/shaders/pbr.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/shaders/pbr.c') diff --git a/src/shaders/pbr.c b/src/shaders/pbr.c index 89556af..bbf1c2b 100644 --- a/src/shaders/pbr.c +++ b/src/shaders/pbr.c @@ -1,4 +1,4 @@ -#include "common.h" +#include "common/core.h" /*uniforms*/ #define _object2world UM4(0) @@ -22,14 +22,8 @@ static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoord) { static Vec4 p; p.xyz = in->vertex->position; p.w = 1; object2clip(&p, clipcoord); - Vec4 normal = { - in->vertex->normal.x, - in->vertex->normal.y, - in->vertex->normal.z, - 1 - }; - Vec4 worldnormal; internal_mat4_mulvec4(_object2world, &normal, &worldnormal); - internal_vec3_normalize(_light, _light); + Vec3 worldnormal = mat4_mulvec3(*_object2world, in->vertex->normal); + worldnormal = vec3_normalize(worldnormal); //*rough = 1 - internal_vec3_dot(&worldnormal, light); //*vnormal = in->vertex->normal; *_texcoord = in->vertex->texcoord; @@ -37,7 +31,7 @@ static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoor _clip_pos->y = clipcoord->w; } -static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color32* color) { +static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Vec4* color) { //internal_vec3_normalize(light, light); //internal_vec3_normalize(vnormal, vnormal); //float roughness = *rough; @@ -50,11 +44,10 @@ static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color32* col float depth = _clip_pos->x / _clip_pos->y; depth = (depth + 1) / 2; depth = linear01depth(depth); - Color32 c = tex2d(_albedo_tex, _texcoord); + Vec4 c = tex2d(_albedo_tex, _texcoord); //Color32 nc = tex2d(noramltex, in->texcoord); //internal_vec3_scale(&c, roughness, &c); - color32_saturate(&c); - *color = c; + *color = vec4_saturate(c); //internal_vec3_scale(color, 1 - depth, color); return 1; } -- cgit v1.1-26-g67d0