Custom 2.5D shadows in Godot 4 - Tutorial
Автор: Speckhofer Enterprises
Загружено: 2023-12-03
Просмотров: 1408
A tutorial for my custom 2.5D shadow system built on top of Godot 4's built-in 2D lighting system.
Original video: • Custom 2.5D shadows in Godot 4.0
Shader code:
Remark: If you are using a Camera2D, then its Zoom values must be set to 1.0 or else the value of uv_height in the shader code must be multiplied by the current zoom value!
Wall shader:
// WallShader.gdshader
shader_type canvas_item;
render_mode unshaded;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
void fragment()
{
float uv_height = SCREEN_PIXEL_SIZE.y / TEXTURE_PIXEL_SIZE.y;
float bottom_y = SCREEN_UV.y + (1.02 - UV.y) * uv_height;
vec4 lighting = textureLod(SCREEN_TEXTURE, vec2(SCREEN_UV.x, bottom_y), 2.0);
COLOR = texture(TEXTURE, UV) * 2.0 * lighting;
}
Multiply shader:
// MultiplyShader.gdshader
shader_type canvas_item;
render_mode unshaded;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
void fragment()
{
COLOR = texture(TEXTURE, UV) * 2.0 * texture(SCREEN_TEXTURE, SCREEN_UV);
}
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: