Half-lambert factor in Shader Info node

This commit is contained in:
2024-06-05 15:00:31 +01:00
committed by lateasusual
parent b007756ece
commit f2a7165384
4 changed files with 16 additions and 9 deletions
@@ -404,7 +404,8 @@ void calc_shader_info(vec3 position,
out vec4 half_light,
out float shadows,
out float self_shadows,
out vec4 ambient)
out vec4 ambient,
out float half_lambert)
{
calc_shader_info(position,
normal,
@@ -413,7 +414,8 @@ void calc_shader_info(vec3 position,
half_light,
shadows,
self_shadows,
ambient);
ambient,
half_lambert);
}
/* Use custom (Per-Node) light groups */
@@ -424,7 +426,8 @@ void calc_shader_info(vec3 position,
out vec4 half_light,
out float shadows,
out float self_shadows,
out vec4 ambient)
out vec4 ambient,
out float half_lambert)
{
ClosureEvalCommon cl_common = closure_Common_eval_init(CLOSURE_INPUT_COMMON_DEFAULT);
cl_common.P = position;
@@ -436,6 +439,7 @@ void calc_shader_info(vec3 position,
float self_shadow_accum = 0.0;
float light_accum = 0.0;
half_light = vec4(0.0);
half_lambert = 0.0;
for (int i = 0; i < laNumLight && i < MAX_LIGHT; i++) {
ClosureLightData light = closure_light_eval_init(cl_common, i);
@@ -459,6 +463,8 @@ void calc_shader_info(vec3 position,
float radiance = light_diffuse(light.data, n_n, cl_common.V, light.L);
half_light += vec4(light.data.l_color * light.data.l_diff * radiance, 0.0);
vec3 L = (ld.l_type == SUN) ? -ld.l_forward : (light.L.xyz / light.L.w);
half_lambert += 0.5 * dot(L, n_n) + 0.5;
}
shadows = (1.0 - (shadow_accum / max(light_accum, 1.0)));
@@ -48,8 +48,8 @@ Closure nodetree_exec();
vec4 closure_to_rgba(Closure cl);
/* Goo-engine node internals */
void calc_shader_info(vec3 position, vec3 normal, ivec4 light_groups, ivec4 light_group_shadows, out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient);
void calc_shader_info(vec3 position, vec3 normal, out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient);
void calc_shader_info(vec3 position, vec3 normal, ivec4 light_groups, ivec4 light_group_shadows, out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient, out float half_lambert);
void calc_shader_info(vec3 position, vec3 normal, out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient, out float half_lambert);
void screenspace_info(vec3 viewPos, out vec4 scene_col, out float scene_depth);
void screenspace_curvature(float iiterations, float sample_scale, float clamp_dist, vec3 scale, out float scene_curvature, out float scene_rim);
@@ -1,14 +1,14 @@
void node_shader_info(vec3 position, vec3 normal,
out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient)
out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient, out float half_lambert)
{
// Implicitly included by eevee shader linking.
calc_shader_info(position, normal, half_light, shadows, self_shadows, ambient);
calc_shader_info(position, normal, half_light, shadows, self_shadows, ambient, half_lambert);
}
void node_shader_info_light_groups(vec3 position, vec3 normal, vec4 light_groups, vec4 light_group_shadows,
out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient)
out vec4 half_light, out float shadows, out float self_shadows, out vec4 ambient, out float half_lambert)
{
// Implicitly included by eevee shader linking.
calc_shader_info(position, normal, floatBitsToInt(light_groups), floatBitsToInt(light_group_shadows), half_light, shadows, self_shadows, ambient);
calc_shader_info(position, normal, floatBitsToInt(light_groups), floatBitsToInt(light_group_shadows), half_light, shadows, self_shadows, ambient, half_lambert);
}
@@ -16,6 +16,7 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Cast Shadows"));
b.add_output<decl::Float>(N_("Self Shadows"));
b.add_output<decl::Color>(N_("Ambient Lighting"));
b.add_output<decl::Float>(N_("Half-lambert factor"));
}
static void node_shader_init_shader_info(bNodeTree* /*ntree*/, bNode *node)