-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorHalftone.anm
More file actions
73 lines (61 loc) · 2.96 KB
/
ColorHalftone.anm
File metadata and controls
73 lines (61 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--track0:サイズ,0,100,0,0.1
--track1:半径,0,200,120,0.1
--track2:トーン小,0,100,0,0.1
--track3:トーン大,0,100,100,0.1
--check0:再読込,0
--dialog:色1[表示]/chk,_0=1;色2[表示]/chk,_1=1;色3[表示]/chk,_2=1;色1/col,_3=0x00ffff;色2/col,_4=0xff00ff;色3/col,_5=0xffff00;背景色/col,_6=0xffffff;角度1,_7=15;角度2,_8=75;角度3,_9=30;混色方法[0:減法/1:加法]/chk,_10=0;滑らかさ[0-100],_11=1;
local function rotate(angle)
angle = math.rad(angle)
return { math.cos(angle), -math.sin(angle),
math.sin(angle), math.cos(angle) }
end
local chk1 = _0 _0 = nil
local chk2 = _1 _1 = nil
local chk3 = _2 _2 = nil
local r0, g0, b0 = RGB(_3) _3 = nil
local r1, g1, b1 = RGB(_4) _4 = nil
local r2, g2, b2 = RGB(_5) _5 = nil
local r3, g3, b3 = RGB(_6) _6 = nil
local angle1 = _7 or 0 _7 = nil
local angle2 = _8 or 0 _8 = nil
local angle3 = _9 or 0 _9 = nil
local mix_mode = _10 _10 = nil
local blur_strength = math.min(math.max(_11 or 0, 0), 100) _11 = nil
local GLShaderKit = require "GLShaderKit"
local shader_path = obj.getinfo("script_path") .. "ColorHalftone.frag"
local force_reload = obj.check0
local VERTEX_NUM = 1
obj.effect("ぼかし", "範囲", blur_strength, "サイズ固定", 1)
local data, w, h = obj.getpixeldata()
if GLShaderKit.isInitialized() then
GLShaderKit.activate()
GLShaderKit.setPlaneVertex(VERTEX_NUM)
GLShaderKit.setShader(shader_path, force_reload)
GLShaderKit.setFloat("resolution", w, h)
GLShaderKit.setFloat("time", obj.time)
GLShaderKit.setFloat("totalTime", obj.totaltime)
GLShaderKit.setInt("frame", obj.frame)
GLShaderKit.setInt("totalFrame", obj.totalframe)
GLShaderKit.setFloat("track", obj.track0, obj.track1, obj.track2, obj.track3)
GLShaderKit.setTexture2D(0, data, w, h)
GLShaderKit.setFloat("aspect_ratio", w / h)
GLShaderKit.setFloat("tone_size", (0.25 - obj.track0 / 400.0) * math.max(w, h));
GLShaderKit.setFloat("radius", obj.track1 / 200)
GLShaderKit.setFloat("min_radius", obj.track2 / 100)
GLShaderKit.setFloat("max_radius", 1 - obj.track3 / 100)
GLShaderKit.setFloat("visibility", chk1, chk2, chk3)
GLShaderKit.setFloat("tone_color1", r0 / 255, g0 / 255, b0 / 255)
GLShaderKit.setFloat("tone_color2", r1 / 255, g1 / 255, b1 / 255)
GLShaderKit.setFloat("tone_color3", r2 / 255, g2 / 255, b2 / 255)
GLShaderKit.setFloat("bg_color", r3 / 255, g3 / 255, b3 / 255)
GLShaderKit.setMatrix("rot1", "2x2", false, rotate(angle1))
GLShaderKit.setMatrix("rot2", "2x2", false, rotate(angle2))
GLShaderKit.setMatrix("rot3", "2x2", false, rotate(angle3))
GLShaderKit.setMatrix("rot1T", "2x2", true, rotate(angle1))
GLShaderKit.setMatrix("rot2T", "2x2", true, rotate(angle2))
GLShaderKit.setMatrix("rot3T", "2x2", true, rotate(angle3))
GLShaderKit.setFloat("mix_mode", mix_mode)
GLShaderKit.draw("TRIANGLES", data, w, h)
GLShaderKit.deactivate()
end
obj.putpixeldata(data)