rimlight control

main
Dominik Madarász 2023-09-21 12:10:36 +02:00
parent 70678e6ee1
commit 1b294f1a27
6 changed files with 39 additions and 14 deletions

View File

@ -25,6 +25,10 @@ int main() {
model_t mdl = model("Stan.fbx", MODEL_RIMLIGHT);
anims_t a = animations("Stan.fbx", 0);
// shader_bind(mdl.program);
// shader_vec3("u_rimcolor", vec3(0.12,0.23,0.34));
// shader_vec3("u_rimrange", vec3(0.06,0.74,0.5));
// load all postfx files in all subdirs
fx_load("fx**.fs");
@ -133,6 +137,19 @@ int main() {
}
ui_panel_end();
}
if ( ui_panel("Rim lighting", 0) ) {
static vec3 rimcolor = {0.2,0.2,0.2};
static vec3 rimrange = {0.11,0.98,0.5};
ui_color3f("Color", &rimcolor.x);
ui_clampf("Low", &rimrange.x, 0, 1);
ui_clampf("High", &rimrange.y, 0, 1);
ui_clampf("Mix", &rimrange.z, 0, 1);
// ui_vec
shader_bind(mdl.program);
shader_vec3("u_rimcolor", rimcolor);
shader_vec3("u_rimrange", rimrange);
ui_panel_end();
}
if( ui_panel("FX", 0) ) {
for( int i = 0; i < 64; ++i ) {
char *name = fx_name(i); if( !name ) break;

View File

@ -11,6 +11,8 @@ in vec3 v_position;
uniform mat4 M; // RIM
uniform vec3 u_rimcolor = vec3(0.2,0.2,0.2);
uniform vec3 u_rimrange = vec3(0.11,0.98,0.5);
uniform vec3 u_rimpivot = vec3(0,0,0);
uniform bool u_rimambient = true;
#endif
in vec3 v_normal, v_normal_ws;
in vec2 v_texcoord;
@ -68,7 +70,10 @@ if(u_matcaps) {
#ifdef RIM
{vec3 n = normalize(mat3(M) * v_normal); // convert normal to view space
vec3 p = (M * vec4(v_position,1.0)).xyz; // convert position to view space
vec3 v = normalize(vpeye.xyz-p); // eye vector
vec3 v = vec3(0,-1,0);
if (!u_rimambient) {
v = normalize(u_rimpivot-p);
}
float rim = 1.0 - max(dot(v,n), 0.0);
vec3 col = u_rimcolor*(pow(smoothstep(1.0-u_rimrange.x,u_rimrange.y,rim), u_rimrange.z));
fragcolor += vec4(col, 1.0);}

View File

@ -344064,6 +344064,7 @@ void model_destroy(model_t m) {
anims_t animations(const char *pathfile, int flags) {
anims_t a = {0};
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
if (!anim_file) return a;
for each_substring(anim_file, "\r\n", anim) {
int from, to;
char anim_name[128] = {0};

View File

@ -4498,6 +4498,7 @@ void model_destroy(model_t m) {
anims_t animations(const char *pathfile, int flags) {
anims_t a = {0};
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
if (!anim_file) return a;
for each_substring(anim_file, "\r\n", anim) {
int from, to;
char anim_name[128] = {0};

View File

@ -14762,6 +14762,7 @@ void model_destroy(model_t m) {
anims_t animations(const char *pathfile, int flags) {
anims_t a = {0};
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
if (!anim_file) return a;
for each_substring(anim_file, "\r\n", anim) {
int from, to;
char anim_name[128] = {0};