Fix lightmap colour blending
This commit is contained in:
parent
1539d1910d
commit
ae243fcd58
|
@ -3,14 +3,33 @@
|
||||||
[sub_resource type="Shader" id="Shader_eumy4"]
|
[sub_resource type="Shader" id="Shader_eumy4"]
|
||||||
code = "shader_type spatial;
|
code = "shader_type spatial;
|
||||||
render_mode blend_mix,depth_draw_opaque,cull_back,unshaded;
|
render_mode blend_mix,depth_draw_opaque,cull_back,unshaded;
|
||||||
uniform sampler2D texture_albedo : source_color,filter_linear_mipmap,repeat_enable;
|
uniform sampler2D texture_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
|
||||||
uniform sampler2D lightmap_albedo : source_color,filter_linear_mipmap,repeat_enable;
|
uniform sampler2D lightmap_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
|
||||||
uniform float lightmap_modulation;
|
uniform float lightmap_modulation;
|
||||||
|
|
||||||
|
float srgb_to_linear_e(float input) {
|
||||||
|
float output;
|
||||||
|
if (input <= 0.04045) {
|
||||||
|
output = input / 12.92;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output = pow((input + 0.055) / 1.055, 2.4);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 srgb_to_linear(vec3 input) {
|
||||||
|
vec3 output;
|
||||||
|
output.r = srgb_to_linear_e(input.r);
|
||||||
|
output.g = srgb_to_linear_e(input.g);
|
||||||
|
output.b = srgb_to_linear_e(input.b);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
vec4 albedo_tex = texture(texture_albedo,UV);
|
vec4 albedo_tex = texture(texture_albedo,UV);
|
||||||
vec4 lightmap_tex = texture(lightmap_albedo,UV2) * lightmap_modulation;
|
vec4 lightmap_tex = texture(lightmap_albedo,UV2) * lightmap_modulation;
|
||||||
ALBEDO = albedo_tex.rgb * lightmap_tex.rgb;
|
ALBEDO = srgb_to_linear((albedo_tex * lightmap_tex).rgb);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue