1
0
Fork 0

HDR: Add support for glTF emissive objects

This commit is contained in:
Fernando García Liñán 2023-05-04 06:08:19 +02:00
parent 7ca349b82e
commit 5f4f51c8ea
5 changed files with 14 additions and 8 deletions

View file

@ -28,7 +28,7 @@ vec3 eotf_inverse_sRGB(vec3 srgb);
// shading_transparent.glsl
vec3 eval_lights_transparent(
vec3 base_color, float metallic, float roughness, float occlusion,
vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
mat4 view_matrix_inverse);
// normalmap.glsl
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
@ -54,7 +54,7 @@ void main()
N = perturb_normal(N, fs_in.view_vector, fs_in.texcoord);
vec3 color = eval_lights_transparent(
base_color.rgb, metallic, roughness, occlusion,
base_color.rgb, metallic, roughness, occlusion, emissive,
fs_in.view_vector, N, V, uv, fs_in.ap_color, osg_ViewMatrixInverse);
fragColor = vec4(color, base_color.a);

View file

@ -21,7 +21,7 @@ vec3 eotf_inverse_sRGB(vec3 srgb);
// shading_transparent.glsl
vec3 eval_lights_transparent(
vec3 base_color, float metallic, float roughness, float occlusion,
vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
mat4 view_matrix_inverse);
void main()
@ -35,7 +35,7 @@ void main()
vec2 uv = (gl_FragCoord.xy - fg_Viewport.xy) / fg_Viewport.zw;
vec3 color = eval_lights_transparent(
base_color, TRANSPARENT_METALLIC, TRANSPARENT_ROUGHNESS, 1.0,
base_color, TRANSPARENT_METALLIC, TRANSPARENT_ROUGHNESS, 1.0, vec3(0.0),
vP, N, V, uv, ap_color, osg_ViewMatrixInverse);
fragColor = vec4(color, alpha);

View file

@ -18,7 +18,7 @@ void gbuffer_unpack(in vec2 texcoord,
// shading_opaque.glsl
vec3 eval_lights(
vec3 base_color, float metallic, float roughness, float occlusion,
vec3 P, vec3 N, vec3 V, vec2 uv,
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv,
mat4 view_matrix_inverse, mat4 projection_matrix);
// pos_from_depth.glsl
vec3 get_view_space_from_depth(vec2 uv);
@ -36,6 +36,6 @@ void main()
fragColor = eval_lights(
base_color, metallic, roughness, occlusion,
P, N, V, texcoord,
emissive, P, N, V, texcoord,
fg_ViewMatrixInverse, fg_ProjectionMatrix);
}

View file

@ -29,7 +29,7 @@ vec3 apply_exposure(vec3 color);
vec3 eval_lights(
vec3 base_color, float metallic, float roughness, float occlusion,
vec3 P, vec3 N, vec3 V, vec2 uv,
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv,
mat4 view_matrix_inverse, mat4 projection_matrix)
{
vec3 f0 = f0_from_pbr(base_color, metallic);
@ -59,6 +59,9 @@ vec3 eval_lights(
base_color, metallic, roughness, f0,
ao, ws_N, ws_refl, NdotV);
// Add emissive contribution
color += emissive;
// Add aerial perspective
color = add_aerial_perspective(color, uv, length(P));

View file

@ -26,7 +26,7 @@ vec3 apply_exposure(vec3 color);
vec3 eval_lights_transparent(
vec3 base_color, float metallic, float roughness, float occlusion,
vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
mat4 view_matrix_inverse)
{
vec3 f0 = f0_from_pbr(base_color, metallic);
@ -53,6 +53,9 @@ vec3 eval_lights_transparent(
base_color, metallic, roughness, f0,
occlusion, ws_N, ws_refl, NdotV);
// Add emissive contribution
color += emissive;
// Add aerial perspective
color = mix_aerial_perspective(color, ap);