thief-mission-viewer/project/materials/base.tres

48 lines
1.2 KiB
Plaintext
Raw Normal View History

2024-08-05 20:46:03 +00:00
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://ck8h6dvojuegj"]
[sub_resource type="Shader" id="Shader_eumy4"]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,unshaded;
2024-08-10 10:50:46 +00:00
uniform sampler2D texture_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
uniform sampler2DArray lightmap_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
uniform bool lightmap_2x;
2024-08-05 20:46:03 +00:00
2024-08-10 10:50:46 +00:00
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;
}
2024-08-05 20:46:03 +00:00
void fragment() {
vec4 albedo_tex = texture(texture_albedo,UV);
vec4 lightmap_tex = vec4(0.0);
for (int i = 0; i < 33; i++) {
lightmap_tex += texture(lightmap_albedo, vec3(UV2, float(i)));
}
lightmap_tex = min(vec4(1.0), lightmap_tex);
if (lightmap_2x) {
lightmap_tex *= 2.0f;
}
2024-08-10 10:50:46 +00:00
ALBEDO = srgb_to_linear((albedo_tex * lightmap_tex).rgb);
2024-08-05 20:46:03 +00:00
}
"
[resource]
render_priority = 0
shader = SubResource("Shader_eumy4")
shader_parameter/lightmap_2x = null