enable analytical lights for PBR shading mode
parent
fff2db7ea5
commit
9ed0c978a3
|
@ -112,7 +112,7 @@ surface_t surface() {
|
|||
pbr_mat.metallic = s.metallic;
|
||||
pbr_mat.alpha = s.alpha;
|
||||
|
||||
// Lo += lighting(pbr_mat);
|
||||
Lo += lighting(pbr_mat);
|
||||
|
||||
s.light_indirect = sample_colormap( map_ambient, v_texcoord ).xyz;
|
||||
vec3 diffuse_ambient;
|
||||
|
@ -200,6 +200,21 @@ surface_t surface() {
|
|||
s.fragcolor *= shadowing();
|
||||
s.fragcolor.rgb += get_rimlight();
|
||||
|
||||
#ifdef SHADING_PBR
|
||||
{
|
||||
// aces film (CC0, src: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/)
|
||||
vec3 x = s.fragcolor.rgb;
|
||||
float a = 2.51f;
|
||||
float b = 0.03f;
|
||||
float c = 2.43f;
|
||||
float d = 0.59f;
|
||||
float e = 0.14f;
|
||||
vec3 color = clamp((x*(a*x+b))/(x*(c*x+d)+e), 0.0, 1.0);
|
||||
// gamma correction
|
||||
s.fragcolor.rgb = pow( color, vec3(1.0/2.2) );
|
||||
}
|
||||
#endif
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
//version 400
|
||||
|
||||
// original PBR shader by @seece (Public Domain). link: https://github.com/Gargaj/Foxotron/pull/12
|
||||
|
||||
//#define textureQueryLod(t,c) vec2(0.0,0.0) // version 400 required
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
//version 330 core
|
||||
|
||||
layout(location = 0) in vec3 in_pos;
|
||||
layout(location = 1) in vec2 in_texcoord;
|
||||
layout(location = 2) in vec3 in_normal;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#version 330 core
|
||||
|
||||
in vec3 out_worldpos;
|
||||
|
||||
uniform float texture_lod;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#version 330 core
|
||||
|
||||
in vec3 in_pos;
|
||||
|
||||
uniform mat4 mat_mvp;
|
||||
|
|
|
@ -386344,12 +386344,14 @@ void model_shading_custom(model_t *m, int shading, const char *vs, const char *f
|
|||
"SHADING_PBR",
|
||||
};
|
||||
|
||||
ASSERT(shading < countof(shading_defines));
|
||||
const char *shading_define = shading_defines[shading];
|
||||
|
||||
// rebind shader
|
||||
// @fixme: app crashes rn
|
||||
// glUseProgram(0);
|
||||
// glDeleteProgram(m->program);
|
||||
glUseProgram(0);
|
||||
if (m->program)
|
||||
glDeleteProgram(m->program);
|
||||
const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM
|
||||
int shaderprog = shader(strlerp(1,symbols,vs), strlerp(1,symbols,fs), //fs,
|
||||
"att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor",
|
||||
|
|
|
@ -4687,12 +4687,14 @@ void model_shading_custom(model_t *m, int shading, const char *vs, const char *f
|
|||
"SHADING_PBR",
|
||||
};
|
||||
|
||||
ASSERT(shading < countof(shading_defines));
|
||||
const char *shading_define = shading_defines[shading];
|
||||
|
||||
// rebind shader
|
||||
// @fixme: app crashes rn
|
||||
// glUseProgram(0);
|
||||
// glDeleteProgram(m->program);
|
||||
glUseProgram(0);
|
||||
if (m->program)
|
||||
glDeleteProgram(m->program);
|
||||
const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM
|
||||
int shaderprog = shader(strlerp(1,symbols,vs), strlerp(1,symbols,fs), //fs,
|
||||
"att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor",
|
||||
|
|
|
@ -21486,12 +21486,14 @@ void model_shading_custom(model_t *m, int shading, const char *vs, const char *f
|
|||
"SHADING_PBR",
|
||||
};
|
||||
|
||||
ASSERT(shading < countof(shading_defines));
|
||||
const char *shading_define = shading_defines[shading];
|
||||
|
||||
// rebind shader
|
||||
// @fixme: app crashes rn
|
||||
// glUseProgram(0);
|
||||
// glDeleteProgram(m->program);
|
||||
glUseProgram(0);
|
||||
if (m->program)
|
||||
glDeleteProgram(m->program);
|
||||
const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM
|
||||
int shaderprog = shader(strlerp(1,symbols,vs), strlerp(1,symbols,fs), //fs,
|
||||
"att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor",
|
||||
|
|
Loading…
Reference in New Issue