How to duplicate viewport for drop shadow effect
Asked Answered
R

1

0

Welcome to the forums @ArtcadeDev!

If you add a Viewport node, make sure own world is turned off, set transparent BG to true in the properties, and then make it the same size as the game view, you should be able to get a Viewport texture that renders the scene but with a transparent background. From there, you can assign the ViewportTexture from the Viewport node, set it to full rect in the layout button (select the TextureRect, green button called layout in the top of the editor view) and then slightly offset it's position. This should make it always fit the screen but with a slight offset.

To change the color, you just need a super simple shader on the TextureRect. Something like this should work:

shader_type canvas_item;
uniform vec4 color_to_use : hint_color;

void fragment() {
	vec4 image_col = texture(TEXTURE, UV)
	if (image_col.a > 0) {
		COLOR = image_col;
	}
	else {
		discard;
	}
}
Rendarender answered 6/6, 2021 at 15:10 Comment(0)
P
0

In case anyone is looking for a better solution, here is a shader that works on a ColorRect.

2D Drop Shadow
https://godotshaders.com/shader/2d-drop-shadow/

Purusha answered 10/8, 2023 at 3:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.