Godot shader load error

What if im downloading shader from my server and apply it on my panel with this code:

func _on_shader_loaded(result, response_code, headers, body, node):
    if response_code == 200:
        var shader_code = body.get_string_from_utf8()
        var shader = Shader.new()
        shader.set_code(shader_code)
        print(shader_code)
        node.material = ShaderMaterial.new()
        node.material.shader = shader
    else:
        push_warning("Failed to load shader. Response code: %d" % response_code)

But when i try to play, i get the error: E 0:00:04:0032 version_get_shader: Parameter “version” is null. <Source code C++>./servers/rendering/renderer_rd/shader_rd.h:165 @ version_get_shader() I’m sure my shader code is fine.

Are you sure your shader code is correct? I just tested it with:

extends Node


@onready var http_request: HTTPRequest = $HTTPRequest
@onready var sprite_2d: Sprite2D = $Sprite2D


func _ready() -> void:
	http_request.request_completed.connect(func(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray):
		var shader = Shader.new()
		shader.code = body.get_string_from_utf8()
		var material = ShaderMaterial.new()
		material.shader = shader
		sprite_2d.material = material
	)

	http_request.request('http://localhost:8000/shader.txt')

and it works fine.

This is the contents of shader.txt:

shader_type canvas_item;

void fragment() {
	COLOR = vec4(1.0, 0.0, 0.0, COLOR.a);
}
1 Like

The problem is that I have not understood why I have a console endlessly displays this error.

Despite the fact that _process(delta) doesn’t even have any call that could infinitely output it to the console.

This error can happen if I switched from Godot 3.5 to 4.2.1, but all the shaders work and display correctly, so I think the error is just a phantom error, but very much interferes with work

I have a same issue.
This error message appears when Godot is opened.