1/*
2 * Copyright (c) 2022-2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16var shaderFastVs = `
17attribute vec3 position;
18attribute vec2 aTexCoord;
19attribute vec4 ext1;//x,y,sw,sh,
20attribute vec4 ext2;//ra,ox,oy,i
21attribute float inColor;
22uniform mat4 uMat;
23
24varying vec2 TexCoord;
25varying float tex_point;
26varying vec4 clr_filter;
27void main()
28{
29    mat4 tmpMat=mat4(ext1[0],ext1[2],0.0,ext2[1],
30                      ext1[1],ext1[3],0.0,ext2[2],
31                      0.0,0.0,ext2[0],0.0,
32                      0.0,0.0,0.0,1.0);
33
34    vec4 tv=vec4(position.x, position.y, position.z, 1.0)*tmpMat*uMat;
35    gl_Position = tv;
36    TexCoord = aTexCoord;
37    tex_point = ext2[3];
38
39    clr_filter=vec4(0.0,0.0,0.0,1.0);
40    int tt=int(inColor);
41    clr_filter.b=0.015873015873*float(tt-tt/64*64);
42    tt=tt/64;
43    clr_filter.g=0.015873015873*float(tt-tt/64*64);
44    tt=tt/64;
45    clr_filter.r=0.015873015873*float(tt-tt/64*64);
46    tt=tt/64;
47    clr_filter.a=0.015873015873*float(tt-tt/64*64);
48}
49`;
50
51var shaderFastFs = `
52precision mediump float;
53
54varying vec2 TexCoord;
55varying float tex_point;
56varying vec4 clr_filter;
57uniform sampler2D tex0;
58uniform sampler2D tex1;
59uniform sampler2D tex2;
60uniform sampler2D tex3;
61uniform sampler2D tex4;
62uniform sampler2D tex5;
63uniform sampler2D tex6;
64uniform sampler2D tex7;
65uniform sampler2D tex8;
66uniform sampler2D tex9;
67uniform sampler2D tex10;
68uniform sampler2D tex11;
69uniform sampler2D tex12;
70uniform sampler2D tex13;
71uniform sampler2D tex14;
72uniform sampler2D tex15;
73
74void main()
75{
76    if(tex_point<0.5)gl_FragColor = texture2D(tex0, TexCoord);
77    else if(tex_point<1.5)gl_FragColor = texture2D(tex1, TexCoord);
78    else if(tex_point<2.5)gl_FragColor = texture2D(tex2, TexCoord);
79    else if(tex_point<3.5)gl_FragColor = texture2D(tex3, TexCoord);
80    else if(tex_point<4.5)gl_FragColor = texture2D(tex4, TexCoord);
81    else if(tex_point<5.5)gl_FragColor = texture2D(tex5, TexCoord);
82    else if(tex_point<6.5)gl_FragColor = texture2D(tex6, TexCoord);
83    else if(tex_point<7.5)gl_FragColor = texture2D(tex7, TexCoord);
84    else if(tex_point<8.5)gl_FragColor = texture2D(tex8, TexCoord);
85    else if(tex_point<9.5)gl_FragColor = texture2D(tex9, TexCoord);
86    else if(tex_point<10.5)gl_FragColor = texture2D(tex10, TexCoord);
87    else if(tex_point<11.5)gl_FragColor = texture2D(tex11, TexCoord);
88    else if(tex_point<12.5)gl_FragColor = texture2D(tex12, TexCoord);
89    else if(tex_point<13.5)gl_FragColor = texture2D(tex13, TexCoord);
90    else if(tex_point<14.5)gl_FragColor = texture2D(tex14, TexCoord);
91    else if(tex_point<15.5)gl_FragColor = texture2D(tex15, TexCoord);
92    gl_FragColor=gl_FragColor * clr_filter;
93}`;
94
95module.exports = {
96  shaderFastVs,
97  shaderFastFs,
98};
99