summaryrefslogtreecommitdiff
path: root/src/shaders/pbr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shaders/pbr.c')
-rw-r--r--src/shaders/pbr.c19
1 files changed, 6 insertions, 13 deletions
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;
}