Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions addons/material_maker/engine/shader_material.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func set_shader(shader_code : String) -> bool:
var shader : Shader = Shader.new()
shader.code = shader_code
material.shader = shader
if material.shader.get_shader_uniform_list().is_empty():
material.shader = preload("res://material_maker/panels/preview_2d/shader_error.gdshader")
material.set_shader_parameter("error_tex", preload("res://material_maker/panels/preview_2d/shader_error.png"))
return true
return true

func get_parameters() -> Dictionary:
Expand Down
16 changes: 16 additions & 0 deletions material_maker/panels/preview_2d/shader_error.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
shader_type canvas_item;
uniform sampler2D error_tex;

float hash12(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}

void fragment() {
vec2 uv = UV;
vec2 s = fwidth(uv);
uv = (uv-0.5) * max(s.x,s.y)/s + 0.5;
float grain = hash12(floor(uv*512.0) + floor(TIME*24.0)*0.04);
COLOR = vec4(texture(error_tex, uv).rgb+grain-0.7, 1.0);
}
1 change: 1 addition & 0 deletions material_maker/panels/preview_2d/shader_error.gdshader.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://b4y52prpq2j3n
Binary file added material_maker/panels/preview_2d/shader_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions material_maker/panels/preview_2d/shader_error.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bgsenxed4lq0"
path="res://.godot/imported/shader_error.png-5cf4c3a93958a86da5be4103bc1b1070.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://material_maker/panels/preview_2d/shader_error.png"
dest_files=["res://.godot/imported/shader_error.png-5cf4c3a93958a86da5be4103bc1b1070.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1