1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Workaround to make the Dithering shader work in WebGL 1.0

Not the best way to do this, but it works.
This commit is contained in:
Emmanouil Papadeas 2023-02-06 14:29:27 +02:00
parent 6ae8d9afed
commit ea746538cf
2 changed files with 7 additions and 7 deletions

View file

@ -71,7 +71,12 @@ void fragment() {
modified_uv = mirror_fract(modified_uv);
vec4 output;
for (int i = 1; i <= n_of_colors; i++) {
// Note for the future, please remember to change 100 to n_of_colors when we
// use GLES3 for the Web version. A constant number is used to make it work in WebGL 1.0.
for (int i = 1; i <= 100; i++) {
if(i > n_of_colors) {
break;
}
float colors_minus = float(n_of_colors - 1);
float off = texture(offset_texture, vec2(float(i) / colors_minus)).r;
float off_prev = texture(offset_texture, vec2(float(i - 1) / colors_minus)).r;

View file

@ -3,7 +3,7 @@ extends ImageEffect
enum { LINEAR, RADIAL, LINEAR_DITHERING, RADIAL_DITHERING }
var shader_linear: Shader = preload("res://src/Shaders/Gradients/Linear.gdshader")
var shader_linear_dither: Shader
var shader_linear_dither: Shader = preload("res://src/Shaders/Gradients/LinearDithering.gdshader")
var shader: Shader = shader_linear
var dither_matrices := [
@ -42,11 +42,6 @@ func _ready() -> void:
var sm := ShaderMaterial.new()
sm.shader = shader
preview.set_material(sm)
if _is_webgl1():
dithering_label.visible = false
dithering_option_button.visible = false
else:
shader_linear_dither = load("res://src/Shaders/Gradients/LinearDithering.gdshader")
for matrix in dither_matrices:
dithering_option_button.add_item(matrix.name)