mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 04:46:48 +01:00
Move paint's shader to an another folder to avoid unused variable warning.
This commit is contained in:
parent
ecda65d37b
commit
bb303112fe
@ -67,40 +67,3 @@ static const unsigned char unlock_layer_png[] = {
|
||||
};
|
||||
|
||||
// shaders block
|
||||
|
||||
static const char *background_shader_shader_code =
|
||||
""
|
||||
"shader_type canvas_item;"
|
||||
""
|
||||
"uniform float pixel_size : hint_range(0.01, 1.0);"
|
||||
""
|
||||
""
|
||||
"void fragment() {"
|
||||
" vec4 color = texture(TEXTURE, UV);"
|
||||
" "
|
||||
" float light = 0.8;"
|
||||
" float dark = 0.4;"
|
||||
" "
|
||||
" float val = dark;"
|
||||
" "
|
||||
" if ( int(UV.y * 8.0 * pixel_size) % 2 == 1 ) {"
|
||||
" if ( int(UV.x * 8.0 * pixel_size) % 2 == 1 ) {"
|
||||
" val = dark;"
|
||||
" }"
|
||||
" else {"
|
||||
" val = light;"
|
||||
" }"
|
||||
" }"
|
||||
" else {"
|
||||
" if ( int(UV.x * 8.0 * pixel_size) % 2 == 1 ) {"
|
||||
" val = light;"
|
||||
" }"
|
||||
" else {"
|
||||
" val = dark;"
|
||||
" }"
|
||||
" }"
|
||||
" "
|
||||
" color.rgb = vec3(val, val, val);"
|
||||
" "
|
||||
" COLOR = color;"
|
||||
"}";
|
||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
||||
#include "scene/resources/material.h"
|
||||
#include "scene/resources/shader.h"
|
||||
|
||||
#include "icons/paint_icons.h"
|
||||
#include "shaders/shaders.h"
|
||||
|
||||
float PaintCanvasBackground::get_pixel_size() const {
|
||||
return _pixel_size;
|
||||
|
77
modules/paint/shaders/make_header.py
Executable file
77
modules/paint/shaders/make_header.py
Executable file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import os
|
||||
|
||||
enc = "utf-8"
|
||||
|
||||
# Change to the directory where the script is located,
|
||||
# so that the script can be run from any location
|
||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
# Generate include files
|
||||
|
||||
f = open("shaders.h", "wb")
|
||||
|
||||
f.write(b"// THIS FILE HAS BEEN AUTOGENERATED, DON'T EDIT!!\n")
|
||||
|
||||
# Generate png image block
|
||||
f.write(b"\n// png image block\n")
|
||||
|
||||
pixmaps = glob.glob("*.png")
|
||||
pixmaps.sort()
|
||||
|
||||
for x in pixmaps:
|
||||
|
||||
var_str = x[:-4] + "_png"
|
||||
|
||||
s = "\nstatic const unsigned char " + var_str + "[] = {\n\t"
|
||||
f.write(s.encode(enc))
|
||||
|
||||
pngf = open(x, "rb")
|
||||
|
||||
b = pngf.read(1)
|
||||
while len(b) == 1:
|
||||
f.write(hex(ord(b)).encode(enc))
|
||||
b = pngf.read(1)
|
||||
if len(b) == 1:
|
||||
f.write(b", ")
|
||||
|
||||
f.write(b"\n};\n")
|
||||
pngf.close()
|
||||
|
||||
# Generate shaders block
|
||||
f.write(b"\n// shaders block\n")
|
||||
|
||||
shaders = glob.glob("*.gsl")
|
||||
shaders.sort()
|
||||
|
||||
for x in shaders:
|
||||
|
||||
var_str = x[:-4] + "_shader_code"
|
||||
|
||||
s = "\nstatic const char *" + var_str + " = \n"
|
||||
f.write(s.encode(enc))
|
||||
|
||||
sf = open(x, "rb")
|
||||
|
||||
b = sf.readline()
|
||||
while b != b"":
|
||||
if b.endswith(b"\r\n"):
|
||||
b = b[:-2]
|
||||
|
||||
if b.endswith(b"\n"):
|
||||
b = b[:-1]
|
||||
|
||||
s = b' "' + b
|
||||
f.write(s)
|
||||
b = sf.readline()
|
||||
|
||||
if b != b"":
|
||||
f.write(b'"\n')
|
||||
|
||||
f.write(b'";\n')
|
||||
sf.close()
|
||||
|
||||
f.close()
|
||||
|
42
modules/paint/shaders/shaders.h
Normal file
42
modules/paint/shaders/shaders.h
Normal file
@ -0,0 +1,42 @@
|
||||
// THIS FILE HAS BEEN AUTOGENERATED, DON'T EDIT!!
|
||||
|
||||
// png image block
|
||||
|
||||
// shaders block
|
||||
|
||||
static const char *background_shader_shader_code =
|
||||
""
|
||||
"shader_type canvas_item;"
|
||||
""
|
||||
"uniform float pixel_size : hint_range(0.01, 1.0);"
|
||||
""
|
||||
""
|
||||
"void fragment() {"
|
||||
" vec4 color = texture(TEXTURE, UV);"
|
||||
" "
|
||||
" float light = 0.8;"
|
||||
" float dark = 0.4;"
|
||||
" "
|
||||
" float val = dark;"
|
||||
" "
|
||||
" if ( int(UV.y * 8.0 * pixel_size) % 2 == 1 ) {"
|
||||
" if ( int(UV.x * 8.0 * pixel_size) % 2 == 1 ) {"
|
||||
" val = dark;"
|
||||
" }"
|
||||
" else {"
|
||||
" val = light;"
|
||||
" }"
|
||||
" }"
|
||||
" else {"
|
||||
" if ( int(UV.x * 8.0 * pixel_size) % 2 == 1 ) {"
|
||||
" val = light;"
|
||||
" }"
|
||||
" else {"
|
||||
" val = dark;"
|
||||
" }"
|
||||
" }"
|
||||
" "
|
||||
" color.rgb = vec3(val, val, val);"
|
||||
" "
|
||||
" COLOR = color;"
|
||||
"}";
|
Loading…
Reference in New Issue
Block a user