rimlight control
parent
70678e6ee1
commit
1b294f1a27
|
@ -25,6 +25,10 @@ int main() {
|
||||||
model_t mdl = model("Stan.fbx", MODEL_RIMLIGHT);
|
model_t mdl = model("Stan.fbx", MODEL_RIMLIGHT);
|
||||||
anims_t a = animations("Stan.fbx", 0);
|
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
|
// load all postfx files in all subdirs
|
||||||
fx_load("fx**.fs");
|
fx_load("fx**.fs");
|
||||||
|
|
||||||
|
@ -133,6 +137,19 @@ int main() {
|
||||||
}
|
}
|
||||||
ui_panel_end();
|
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) ) {
|
if( ui_panel("FX", 0) ) {
|
||||||
for( int i = 0; i < 64; ++i ) {
|
for( int i = 0; i < 64; ++i ) {
|
||||||
char *name = fx_name(i); if( !name ) break;
|
char *name = fx_name(i); if( !name ) break;
|
||||||
|
|
|
@ -11,6 +11,8 @@ in vec3 v_position;
|
||||||
uniform mat4 M; // RIM
|
uniform mat4 M; // RIM
|
||||||
uniform vec3 u_rimcolor = vec3(0.2,0.2,0.2);
|
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_rimrange = vec3(0.11,0.98,0.5);
|
||||||
|
uniform vec3 u_rimpivot = vec3(0,0,0);
|
||||||
|
uniform bool u_rimambient = true;
|
||||||
#endif
|
#endif
|
||||||
in vec3 v_normal, v_normal_ws;
|
in vec3 v_normal, v_normal_ws;
|
||||||
in vec2 v_texcoord;
|
in vec2 v_texcoord;
|
||||||
|
@ -68,7 +70,10 @@ if(u_matcaps) {
|
||||||
#ifdef RIM
|
#ifdef RIM
|
||||||
{vec3 n = normalize(mat3(M) * v_normal); // convert normal to view space
|
{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 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);
|
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));
|
vec3 col = u_rimcolor*(pow(smoothstep(1.0-u_rimrange.x,u_rimrange.y,rim), u_rimrange.z));
|
||||||
fragcolor += vec4(col, 1.0);}
|
fragcolor += vec4(col, 1.0);}
|
||||||
|
|
|
@ -96,19 +96,19 @@ void main() {
|
||||||
if(!SKINNED) {
|
if(!SKINNED) {
|
||||||
objPos = att_position;
|
objPos = att_position;
|
||||||
v_normal = att_normal;
|
v_normal = att_normal;
|
||||||
} else {
|
} else {
|
||||||
mat3x4 m = vsBoneMatrix[int(att_indexes.x)] * att_weights.x;
|
mat3x4 m = vsBoneMatrix[int(att_indexes.x)] * att_weights.x;
|
||||||
m += vsBoneMatrix[int(att_indexes.y)] * att_weights.y;
|
m += vsBoneMatrix[int(att_indexes.y)] * att_weights.y;
|
||||||
m += vsBoneMatrix[int(att_indexes.z)] * att_weights.z;
|
m += vsBoneMatrix[int(att_indexes.z)] * att_weights.z;
|
||||||
m += vsBoneMatrix[int(att_indexes.w)] * att_weights.w;
|
m += vsBoneMatrix[int(att_indexes.w)] * att_weights.w;
|
||||||
objPos = vec4(att_position, 1.0) * m;
|
objPos = vec4(att_position, 1.0) * m;
|
||||||
|
|
||||||
// blendshapes
|
// blendshapes
|
||||||
// objPos += evaluate_blend_shape(int(att_vertexindex));
|
// objPos += evaluate_blend_shape(int(att_vertexindex));
|
||||||
|
|
||||||
v_normal = vec4(att_normal, 0.0) * m;
|
v_normal = vec4(att_normal, 0.0) * m;
|
||||||
//@todo: tangents
|
//@todo: tangents
|
||||||
}
|
}
|
||||||
|
|
||||||
// vec3 tangent = att_tangent.xyz;
|
// vec3 tangent = att_tangent.xyz;
|
||||||
// vec3 bitangent = cross(att_normal, att_tangent.xyz) * att_tangent.w;
|
// vec3 bitangent = cross(att_normal, att_tangent.xyz) * att_tangent.w;
|
||||||
|
|
|
@ -344064,6 +344064,7 @@ void model_destroy(model_t m) {
|
||||||
anims_t animations(const char *pathfile, int flags) {
|
anims_t animations(const char *pathfile, int flags) {
|
||||||
anims_t a = {0};
|
anims_t a = {0};
|
||||||
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
|
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
|
||||||
|
if (!anim_file) return a;
|
||||||
for each_substring(anim_file, "\r\n", anim) {
|
for each_substring(anim_file, "\r\n", anim) {
|
||||||
int from, to;
|
int from, to;
|
||||||
char anim_name[128] = {0};
|
char anim_name[128] = {0};
|
||||||
|
|
|
@ -4498,6 +4498,7 @@ void model_destroy(model_t m) {
|
||||||
anims_t animations(const char *pathfile, int flags) {
|
anims_t animations(const char *pathfile, int flags) {
|
||||||
anims_t a = {0};
|
anims_t a = {0};
|
||||||
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
|
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
|
||||||
|
if (!anim_file) return a;
|
||||||
for each_substring(anim_file, "\r\n", anim) {
|
for each_substring(anim_file, "\r\n", anim) {
|
||||||
int from, to;
|
int from, to;
|
||||||
char anim_name[128] = {0};
|
char anim_name[128] = {0};
|
||||||
|
|
|
@ -14762,6 +14762,7 @@ void model_destroy(model_t m) {
|
||||||
anims_t animations(const char *pathfile, int flags) {
|
anims_t animations(const char *pathfile, int flags) {
|
||||||
anims_t a = {0};
|
anims_t a = {0};
|
||||||
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
|
char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
|
||||||
|
if (!anim_file) return a;
|
||||||
for each_substring(anim_file, "\r\n", anim) {
|
for each_substring(anim_file, "\r\n", anim) {
|
||||||
int from, to;
|
int from, to;
|
||||||
char anim_name[128] = {0};
|
char anim_name[128] = {0};
|
||||||
|
|
Loading…
Reference in New Issue