From 8518e135ff5c312bd5a3b496d400c751aa3bd5b3 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 8 Dec 2019 02:39:57 +0800 Subject: =?UTF-8?q?*=E5=85=89=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shaders/unlit.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/shaders/unlit.c') 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 }; -- cgit v1.1-26-g67d0