diff options
author | chai <chaifix@163.com> | 2019-12-08 02:39:57 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-12-08 02:39:57 +0800 |
commit | 8518e135ff5c312bd5a3b496d400c751aa3bd5b3 (patch) | |
tree | 96ea48d2046b0ecc3ff791efd8fe7a5780ad52e5 /src/shaders | |
parent | 0c4b1e68d64996a4aa5b136ddb6ee5643e159ef2 (diff) |
*光源
Diffstat (limited to 'src/shaders')
-rw-r--r-- | src/shaders/common_header.h | 1 | ||||
-rw-r--r-- | src/shaders/unlit.c | 17 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/shaders/common_header.h b/src/shaders/common_header.h index 848fe98..9741a36 100644 --- a/src/shaders/common_header.h +++ b/src/shaders/common_header.h @@ -3,5 +3,6 @@ #include "../core/shader.h" +extern void ssrR_putline(int x0, int y0, int x1, int y1, Color color); #endif
\ No newline at end of file diff --git a/src/shaders/unlit.c b/src/shaders/unlit.c index ec6949f..ab060cd 100644 --- a/src/shaders/unlit.c +++ b/src/shaders/unlit.c @@ -1,23 +1,26 @@ #include "common_header.h" -#define model_matrix UM4(0) +#define light UV3(0) -#define world_normal reg_v3_00 -#define vcolor reg_v4_00 +#define vert_color reg_v4_00 static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoord) { static Vec4 p; p.xyz = in->vertex->position; p.w = 1; mat4_applytovec4(uniforms->mvp, &p, clipcoord); - model_matrix; + color_tocolor32(in->vertex->color, vert_color); } static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color* color) { - *color = in->color; - world_normal; + vec3_normalize(light, light); + vec3_normalize(&in->normal, &in->normal); + float strongness = vec3_dot(light, &in->normal); + vec3_scale(vert_color, 1 - clamp(strongness, 0, 1), vert_color); + *color = color32_tocolor(vert_color); + return 1; } Program ssr_built_in_shader_unlit = { vert, frag, - VARYING_COLOR + VARYING_NORMAL | VARYING_V4_00 }; |