diff options
Diffstat (limited to 'src/shaders')
-rw-r--r-- | src/shaders/common.h | 6 | ||||
-rw-r--r-- | src/shaders/default.c | 14 | ||||
-rw-r--r-- | src/shaders/pbr.c | 16 | ||||
-rw-r--r-- | src/shaders/unlit.c | 10 |
4 files changed, 23 insertions, 23 deletions
diff --git a/src/shaders/common.h b/src/shaders/common.h index 61066e5..8d0ac83 100644 --- a/src/shaders/common.h +++ b/src/shaders/common.h @@ -63,14 +63,14 @@ if(cond) return 0; \ #define MVP_PROCESS \ do{ \ static Vec4 p; p.xyz = in->vertex->position; p.w = 1; \ -mat4_mulvec4(uniforms->mvp, &p, clipcoord); \ +internal_mat4_mulvec4(uniforms->mvp, &p, clipcoord); \ }while(0) -#define object2clip(pos, out) mat4_mulvec4(_mvp_matrix, pos, out); +#define object2clip(pos, out) internal_mat4_mulvec4(_mvp_matrix, pos, out); /*need defined _it_model_matrix of model matrix, i-nverse, t-ranspose*/ #define object2world_normal(normal, out) \ -mat4_mulvec4(_it_model_matrix, normal, out) +internal_mat4_mulvec4(_it_model_matrix, normal, out) /*take sample from normal map and translate to normal*/ #define unpack_normal(color, out_v3) \ diff --git a/src/shaders/default.c b/src/shaders/default.c index f184e27..6d12c8e 100644 --- a/src/shaders/default.c +++ b/src/shaders/default.c @@ -13,29 +13,29 @@ static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoord) { static Vec4 p; p.xyz = in->vertex->position; p.w = 1; - mat4_mulvec4(uniforms->mvp, &p, clipcoord); + internal_mat4_mulvec4(uniforms->mvp, &p, clipcoord); Vec4 normal = { in->vertex->normal.x, in->vertex->normal.y, in->vertex->normal.z, 1 }; - Vec4 worldnormal; mat4_mulvec4(object2world, &normal, &worldnormal); - vec3_normalize(light, light); - *rough = 1 - vec3_dot(&worldnormal, light); + Vec4 worldnormal; internal_mat4_mulvec4(object2world, &normal, &worldnormal); + internal_vec3_normalize(light, light); + *rough = 1 - internal_vec3_dot(&worldnormal, light); } static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color32* color) { - vec3_normalize(light, light); + internal_vec3_normalize(light, light); float roughness = *rough; //(*color).r = 1; //(*color).g = 1; //(*color).b = 1; //(*color).a = 1; //return 1; - //float rough = 1- vec3_dot(&in->normal, light); + //float rough = 1- internal_vec3_dot(&in->normal, light); //Color32 nc = tex2d(noramltex, in->texcoord); - //vec3_scale(&c, roughness, &c); + //internal_vec3_scale(&c, roughness, &c); return 1; } diff --git a/src/shaders/pbr.c b/src/shaders/pbr.c index b6238f1..89556af 100644 --- a/src/shaders/pbr.c +++ b/src/shaders/pbr.c @@ -28,9 +28,9 @@ static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoor in->vertex->normal.z, 1 }; - Vec4 worldnormal; mat4_mulvec4(_object2world, &normal, &worldnormal); - vec3_normalize(_light, _light); - //*rough = 1 - vec3_dot(&worldnormal, light); + Vec4 worldnormal; internal_mat4_mulvec4(_object2world, &normal, &worldnormal); + internal_vec3_normalize(_light, _light); + //*rough = 1 - internal_vec3_dot(&worldnormal, light); //*vnormal = in->vertex->normal; *_texcoord = in->vertex->texcoord; _clip_pos->x = clipcoord->z; @@ -38,24 +38,24 @@ static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoor } static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color32* color) { - //vec3_normalize(light, light); - //vec3_normalize(vnormal, vnormal); + //internal_vec3_normalize(light, light); + //internal_vec3_normalize(vnormal, vnormal); //float roughness = *rough; //(*color).r = 1; //(*color).g = 1; //(*color).b = 1; //(*color).a = 1; //return 1; - //float rough = 1- vec3_dot(&in->normal, light); + //float rough = 1- internal_vec3_dot(&in->normal, light); float depth = _clip_pos->x / _clip_pos->y; depth = (depth + 1) / 2; depth = linear01depth(depth); Color32 c = tex2d(_albedo_tex, _texcoord); //Color32 nc = tex2d(noramltex, in->texcoord); - //vec3_scale(&c, roughness, &c); + //internal_vec3_scale(&c, roughness, &c); color32_saturate(&c); *color = c; - //vec3_scale(color, 1 - depth, color); + //internal_vec3_scale(color, 1 - depth, color); return 1; } diff --git a/src/shaders/unlit.c b/src/shaders/unlit.c index 9a807af..e887d07 100644 --- a/src/shaders/unlit.c +++ b/src/shaders/unlit.c @@ -10,20 +10,20 @@ static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoord) { static Vec4 p; p.xyz = in->vertex->position; p.w = 1; - mat4_mulvec4(uniforms->mvp, &p, clipcoord); + internal_mat4_mulvec4(uniforms->mvp, &p, clipcoord); Vec4 normal = { in->vertex->normal.x, in->vertex->normal.y, in->vertex->normal.z, 1 }; - Vec4 worldnormal; mat4_mulvec4(object2world, &normal, &worldnormal); - vec3_normalize(light, light); - *reg_num_00 = 1 - vec3_dot(&worldnormal, light); + Vec4 worldnormal; internal_mat4_mulvec4(object2world, &normal, &worldnormal); + internal_vec3_normalize(light, light); + *reg_num_00 = 1 - internal_vec3_dot(&worldnormal, light); } static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color32* color) { - vec3_normalize(light, light); + internal_vec3_normalize(light, light); return 1; } |