• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
42    int tt1=tt-tt/64*64;
43    clr_filter.b=0.015873015873*float(tt1);
44    tt=tt/64;
45
46    int tt2=tt-tt/64*64;
47    clr_filter.g=0.015873015873*float(tt2);
48    tt=tt/64;
49
50    int tt3=tt-tt/64*64;
51    clr_filter.r=0.015873015873*float(tt3);
52    tt=tt/64;
53
54    clr_filter.a=0.015873015873*float(tt-tt/64*64);
55}
56`;
57
58var shaderFastFs = `
59precision mediump float;
60
61varying vec2 TexCoord;
62varying float tex_point;
63varying vec4 clr_filter;
64uniform sampler2D tex0;
65uniform sampler2D tex1;
66uniform sampler2D tex2;
67uniform sampler2D tex3;
68uniform sampler2D tex4;
69uniform sampler2D tex5;
70uniform sampler2D tex6;
71uniform sampler2D tex7;
72uniform sampler2D tex8;
73uniform sampler2D tex9;
74uniform sampler2D tex10;
75uniform sampler2D tex11;
76uniform sampler2D tex12;
77uniform sampler2D tex13;
78uniform sampler2D tex14;
79uniform sampler2D tex15;
80
81void main()
82{
83    if(tex_point<0.5)gl_FragColor = texture2D(tex0, TexCoord);
84    else if(tex_point<1.5)gl_FragColor = texture2D(tex1, TexCoord);
85    else if(tex_point<2.5)gl_FragColor = texture2D(tex2, TexCoord);
86    else if(tex_point<3.5)gl_FragColor = texture2D(tex3, TexCoord);
87    else if(tex_point<4.5)gl_FragColor = texture2D(tex4, TexCoord);
88    else if(tex_point<5.5)gl_FragColor = texture2D(tex5, TexCoord);
89    else if(tex_point<6.5)gl_FragColor = texture2D(tex6, TexCoord);
90    else if(tex_point<7.5)gl_FragColor = texture2D(tex7, TexCoord);
91    else if(tex_point<8.5)gl_FragColor = texture2D(tex8, TexCoord);
92    else if(tex_point<9.5)gl_FragColor = texture2D(tex9, TexCoord);
93    else if(tex_point<10.5)gl_FragColor = texture2D(tex10, TexCoord);
94    else if(tex_point<11.5)gl_FragColor = texture2D(tex11, TexCoord);
95    else if(tex_point<12.5)gl_FragColor = texture2D(tex12, TexCoord);
96    else if(tex_point<13.5)gl_FragColor = texture2D(tex13, TexCoord);
97    else if(tex_point<14.5)gl_FragColor = texture2D(tex14, TexCoord);
98    else if(tex_point<15.5)gl_FragColor = texture2D(tex15, TexCoord);
99    gl_FragColor=gl_FragColor * clr_filter;
100}`;
101
102module.exports = {
103  shaderFastVs,
104  shaderFastFs,
105};
106