summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-07-13 09:33:38 +0800
committerchai <chaifix@163.com>2020-07-13 09:33:38 +0800
commitefe7768e5b65022b2dd418feff017b97012a6b24 (patch)
tree7495aad22e54459338439464e2e1f45efd5c2699
parentcc3f158380415de84745a18f2b0ebc7b3855d60f (diff)
*misc
-rw-r--r--src/extend/mesh.c16
-rw-r--r--src/main.c2
-rw-r--r--src/shaders/common/core.c6
-rw-r--r--src/shaders/common/core.h4
-rw-r--r--src/shaders/common/light.h9
-rw-r--r--src/shaders/common/mathlib.c14
-rw-r--r--src/shaders/pbr.c3
7 files changed, 35 insertions, 19 deletions
diff --git a/src/extend/mesh.c b/src/extend/mesh.c
index 20153d9..a825860 100644
--- a/src/extend/mesh.c
+++ b/src/extend/mesh.c
@@ -1,7 +1,10 @@
#include "mesh.h"
-#define LINE_SIZE 1024
+//#define GENERATE_NORMAL
+
+#define GENERATE_TANGNET
+#define LINE_SIZE 1024
#define darray_push(darray, value) \
do { \
@@ -122,6 +125,10 @@ static Mesh *build_mesh(
return mesh;
}
+/************************************************************************/
+/* obj loader */
+/************************************************************************/
+
Mesh* mesh_loadfromobj(const char *filename) {
Vec3 *positions = NULL;
Vec2 *texcoords = NULL;
@@ -203,7 +210,6 @@ Mesh* mesh_loadfromobj(const char *filename) {
return mesh;
}
-//
-//
-//Mesh* mesh_loadfromobj(const char* path) {
-//}
+
+
+
diff --git a/src/main.c b/src/main.c
index 9fae2b9..561b816 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,7 +80,7 @@ int main(int argc, char* argv[]) {
CameraConfig cam_config = {
{0, 10, 800},
{0, 0, 0},
- 60, SCREEN_WIDTH / SCREEN_HEIGHT, 0.1, 100000,
+ 60, SCREEN_WIDTH / SCREEN_HEIGHT, 0.1, 2000,
{5, 5}, {150, 150},
4000,
};
diff --git a/src/shaders/common/core.c b/src/shaders/common/core.c
index 703458c..ffaa649 100644
--- a/src/shaders/common/core.c
+++ b/src/shaders/common/core.c
@@ -20,11 +20,11 @@ Vec2 texsize(Texture* texture) {
return size;
}
-float linear01depth(float depth) {
+float linear01Depth(float depth) {
float n = _proj_params.x, f = _proj_params.y;
return n / ((n-f)*depth + f);
}
-float lineareyedepth(float depth) {
- return _proj_params.y * linear01depth(depth);
+float linearEyeDepth(float depth) {
+ return _proj_params.y * linear01Depth(depth);
} \ No newline at end of file
diff --git a/src/shaders/common/core.h b/src/shaders/common/core.h
index 623409e..69ff48b 100644
--- a/src/shaders/common/core.h
+++ b/src/shaders/common/core.h
@@ -66,7 +66,7 @@ out_v3->x = color.x * 2 - 1; \
out_v3->y = color.y * 2 - 1; \
out_v3->z = color.z * 2 - 1;
-float linear01depth(float depth);
-float lineareyedepth(float depth);
+float linear01Depth(float depth);
+float linearEyeDepth(float depth);
#endif \ No newline at end of file
diff --git a/src/shaders/common/light.h b/src/shaders/common/light.h
index e69de29..44c54c3 100644
--- a/src/shaders/common/light.h
+++ b/src/shaders/common/light.h
@@ -0,0 +1,9 @@
+#ifndef _LIGHT_H_
+#define _LIGHT_H_
+
+#include "mathlib.h"
+
+
+
+
+#endif
diff --git a/src/shaders/common/mathlib.c b/src/shaders/common/mathlib.c
index 356357c..acac51a 100644
--- a/src/shaders/common/mathlib.c
+++ b/src/shaders/common/mathlib.c
@@ -16,8 +16,8 @@ Vec2 vec2(float x, float y) {
return v;
}
-INTERNAL_FUNCTION(Vec2, vec2_minus);
-INTERNAL_FUNCTION(Vec2, vec2_plus);
+INTERNAL_FUNCTION(Vec2, vec2_minus)
+INTERNAL_FUNCTION(Vec2, vec2_plus)
float vec2_dot(Vec2 v1, Vec2 v2) {
return internal_vec2_dot(&v1, &v2);
@@ -31,9 +31,9 @@ Vec3 vec3(float x, float y, float z) {
return v;
}
-INTERNAL_FUNCTION(Vec3, vec3_minus);
-INTERNAL_FUNCTION(Vec3, vec3_plus);
-INTERNAL_FUNCTION(Vec3, vec3_cross);
+INTERNAL_FUNCTION(Vec3, vec3_minus)
+INTERNAL_FUNCTION(Vec3, vec3_plus)
+INTERNAL_FUNCTION(Vec3, vec3_cross)
float vec3_dot(Vec3 v1, Vec3 v2) {
return internal_vec3_dot(&v1, &v2);
@@ -72,8 +72,8 @@ Vec4 vec4(float x, float y, float z, float w) {
return v;
}
-INTERNAL_FUNCTION(Vec4, vec4_minus);
-INTERNAL_FUNCTION(Vec4, vec4_plus);
+INTERNAL_FUNCTION(Vec4, vec4_minus)
+INTERNAL_FUNCTION(Vec4, vec4_plus)
Vec4 vec4_scale(Vec4 v, float scale) {
Vec4 out;
diff --git a/src/shaders/pbr.c b/src/shaders/pbr.c
index bbf1c2b..b8ee4be 100644
--- a/src/shaders/pbr.c
+++ b/src/shaders/pbr.c
@@ -43,11 +43,12 @@ static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Vec4* color)
//float rough = 1- internal_vec3_dot(&in->normal, light);
float depth = _clip_pos->x / _clip_pos->y;
depth = (depth + 1) / 2;
- depth = linear01depth(depth);
+ depth = linear01Depth(depth);
Vec4 c = tex2d(_albedo_tex, _texcoord);
//Color32 nc = tex2d(noramltex, in->texcoord);
//internal_vec3_scale(&c, roughness, &c);
*color = vec4_saturate(c);
+ //*color = vec4(depth, depth, depth, 1);
//internal_vec3_scale(color, 1 - depth, color);
return 1;
}