- Edited
I'm trying to do some custom rendering. I draw a background, then punch holes through it using by drawing with BLEND_MODE_SUB. I got this working in GameMaker relatively easily, but I can't get it to work in Godot.
I am using a CanvasItemMaterial
for my Node2D, but only the final blend_mode
I set on it has any effect, probably because Godot is caching the draw calls. Is there a way to basically force Godot to render the current draw calls, then continue on my way? Or is there a better way of doing things?
Code:
extends Node2D
var _material: CanvasItemMaterial = load("res://materials/MaterialBlendSub.tres");
export (Texture) var LightTexture;
# Called when the node enters the scene tree for the first time.
func _ready():
material = _material;
func _draw():
material.blend_mode = BLEND_MODE_MIX;
self.draw_rect(Rect2(0, 0, 500, 500), global.COLOR_BLACK);
material.blend_mode = BLEND_MODE_SUB;
for child in self.get_children():
var transform: Transform2D = child.transform;
draw_set_transform_matrix(transform);
self.draw_texture(LightTexture, Vector2(0,0));
draw_set_transform_matrix(self.transform);
EDIT: I want to do something similar to what's described in this post, but I didn't see a satisfactory answer there, and I'm not inclined to necro-post like that.