-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx_renderparticle.jxs
More file actions
240 lines (171 loc) · 5.45 KB
/
x_renderparticle.jxs
File metadata and controls
240 lines (171 loc) · 5.45 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<jittershader name="texture2DRect:1-fill-flat-triangles">
<description>
An auto-generated shader for simulating deprecated OpenGL features in OpenGL 3.2+
</description>
<param name="position" type="vec3" state="POSITION" />
<param name="texcoord" type="vec2" state="TEXCOORD" />
<param name="velocity" type="vec3" state="NORMAL" />
<param name="tex0" type="int" default="0" />
<param name="textureMatrix0" type="mat4" state="TEXTURE0_MATRIX" />
<param name="modelViewProjectionMatrix" type="mat4" state="MODELVIEW_PROJECTION_MATRIX" />
<param name="color" type="vec4" state="COLOR" />
<param name="pointSize" type="float" default="1.0" />
<param name="hsv" type="vec3" default="1.0 1.0 1.0" />
<param name="useMovement" type="int" default="0" />
<param name="uMovementStrength" type="float" default="1.0" />
<param name="uMovement" type="float" default="0.0" />
<param name="uLuminance" type="float" default="0.0" />
<param name="uColormode" type="int" default="0" />
<param name="uAlpha" type="int" default="1" />
<param name="uDrawMode" type="int" default="0" />
<param name="uLuminanceSize" type="int" default="0" />
<param name="uInvertLuminance" type="int" default="0" />
<param name="uSoft" type="int" default="0" />
<language name="glsl" version="1.5">
<bind param="position" program="vp" />
<bind param="texcoord" program="vp" />
<bind param="tex0" program="vp" />
<bind param="tex0" program="fp" />
<bind param="textureMatrix0" program="vp" />
<bind param="modelViewProjectionMatrix" program="vp" />
<bind param="color" program="vp" />
<bind param="velocity" program="vp" />
<bind param="pointSize" program="vp" />
<bind param="hsv" program="fp" />
<bind param="useMovement" program="fp" />
<bind param="uMovementStrength" program="fp" />
<bind param="uMovement" program="fp" />
<bind param="uLuminance" program="fp" />
<bind param="uColormode" program="fp" />
<bind param="uAlpha" program="fp" />
<bind param="uDrawMode" program="fp" />
<bind param="uLuminanceSize" program="vp" />
<bind param="uInvertLuminance" program="vp" />
<bind param="uSoft" program="fp" />
<program name="vp" type="vertex">
<![CDATA[
// Preprocessor
#version 330 core
uniform mat4 modelViewProjectionMatrix;
uniform mat4 textureMatrix0;
uniform float pointSize;
uniform sampler2DRect tex0;
uniform int uLuminanceSize;
uniform int uInvertLuminance;
in vec3 position;
in vec4 color;
in vec2 texcoord;
in vec3 velocity;
const vec4 lumcoeff = vec4(0.2125,0.7154,0.0721,0.0);
out jit_PerVertex {
flat vec4 color;
vec2 texcoord0;
vec3 velocity;
} jit_out;
void main() {
gl_Position = modelViewProjectionMatrix * vec4(position, 1.);
jit_out.color = color;
jit_out.texcoord0 = vec2(textureMatrix0*vec4(texcoord, 0., 1.));
jit_out.velocity = velocity.xyz;
vec4 texColor = texture(tex0, jit_out.texcoord0);
float partSize;
if (uLuminanceSize == 1) {
float luminance = dot(texColor, lumcoeff);
if (uInvertLuminance == 1) {
luminance = 1-luminance;
}
luminance *= pointSize; // 1 - 10
luminance += 1.0; // 1-2
partSize = luminance;
} else {
partSize = pointSize;
}
gl_PointSize = partSize;
}
]]>
</program>
<program name="fp" type="fragment">
<![CDATA[
#version 330 core
in jit_PerVertex {
flat vec4 color;
vec2 texcoord0;
vec3 velocity;
} jit_in;
out vec4 color;
uniform sampler2DRect tex0;
uniform vec3 hsv;
uniform int useMovement;
uniform float uMovementStrength;
uniform int uColormode;
uniform float uMovement;
uniform float uLuminance;
uniform int uAlpha;
uniform int uDrawMode;
uniform int uSoft;
const vec4 lumcoeff = vec4(0.2125,0.7154,0.0721,0.0);
vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main() {
color = jit_in.color;
vec4 textureColor = texture(tex0, jit_in.texcoord0);
vec4 white = vec4(1.0,1.0,1.0,1.0);
float luminance = dot(textureColor, lumcoeff);
vec4 texColor = white;
switch(uColormode)
{
case 0:
// WHITE except Black
white.a = uAlpha == 0 ? 1.0 : luminance;
if (luminance > 0.05) {
texColor = white;
} else {
discard;
}
break;
case 1:
// BRIGHTNESS
if (luminance > 0.05) {
texColor = vec4(vec3(luminance),luminance);
} else {
discard;
}
break;
case 2:
textureColor.a = uAlpha == 0 ? 1.0 : luminance;
texColor = textureColor;
break;
}
float movefactor = uMovementStrength * 1000.0;
float movement = length(jit_in.velocity) * movefactor;
//movement = clamp(movement,0.0,1.0);
vec4 movementcolor = vec4(vec3(movement), 1.0);
movementcolor *= texColor;
texColor = useMovement == 0 ? texColor : movementcolor;
color = texColor;
float len = length(gl_PointCoord - 0.5);
// Selector for different DrawModes of Particles
// Size is set in VP of better GP?
switch(uDrawMode) {
case 0:
if (len >= 0.5) discard;
if (uSoft == 1) {
color.a = smoothstep(0.5,0.0,len);
}
break;
case 1:
//color.a = smoothstep(0.5,0.0,len);
break;
case 2:
break;
}
if (movement < uMovement) discard;
if (luminance < uLuminance) discard;
}
]]>
</program>
</language>
</jittershader>