|
@@ -194,106 +194,106 @@ export class Shader implements Disposable, Restorable {
|
|
|
|
|
|
public static newColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
|
|
let vs = `
|
|
|
- attribute vec4 ${Shader.POSITION};
|
|
|
- attribute vec4 ${Shader.COLOR};
|
|
|
- attribute vec2 ${Shader.TEXCOORDS};
|
|
|
- uniform mat4 ${Shader.MVP_MATRIX};
|
|
|
- varying vec4 v_color;
|
|
|
- varying vec2 v_texCoords;
|
|
|
-
|
|
|
- void main () {
|
|
|
- v_color = ${Shader.COLOR};
|
|
|
- v_texCoords = ${Shader.TEXCOORDS};
|
|
|
- gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
|
|
- }
|
|
|
- `;
|
|
|
+attribute vec4 ${Shader.POSITION};
|
|
|
+attribute vec4 ${Shader.COLOR};
|
|
|
+attribute vec2 ${Shader.TEXCOORDS};
|
|
|
+uniform mat4 ${Shader.MVP_MATRIX};
|
|
|
+varying vec4 v_color;
|
|
|
+varying vec2 v_texCoords;
|
|
|
+
|
|
|
+void main () {
|
|
|
+ v_color = ${Shader.COLOR};
|
|
|
+ v_texCoords = ${Shader.TEXCOORDS};
|
|
|
+ gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
|
|
+}
|
|
|
+`;
|
|
|
|
|
|
let fs = `
|
|
|
- #ifdef GL_ES
|
|
|
- #define LOWP lowp
|
|
|
- precision mediump float;
|
|
|
- #else
|
|
|
- #define LOWP
|
|
|
- #endif
|
|
|
- varying LOWP vec4 v_color;
|
|
|
- varying vec2 v_texCoords;
|
|
|
- uniform sampler2D u_texture;
|
|
|
-
|
|
|
- void main () {
|
|
|
- gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
|
|
- }
|
|
|
- `;
|
|
|
+#ifdef GL_ES
|
|
|
+ #define LOWP lowp
|
|
|
+ precision mediump float;
|
|
|
+#else
|
|
|
+ #define LOWP
|
|
|
+#endif
|
|
|
+varying LOWP vec4 v_color;
|
|
|
+varying vec2 v_texCoords;
|
|
|
+uniform sampler2D u_texture;
|
|
|
+
|
|
|
+void main () {
|
|
|
+ gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
|
|
+}
|
|
|
+`;
|
|
|
|
|
|
return new Shader(context, vs, fs);
|
|
|
}
|
|
|
|
|
|
public static newTwoColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
|
|
let vs = `
|
|
|
- attribute vec4 ${Shader.POSITION};
|
|
|
- attribute vec4 ${Shader.COLOR};
|
|
|
- attribute vec4 ${Shader.COLOR2};
|
|
|
- attribute vec2 ${Shader.TEXCOORDS};
|
|
|
- uniform mat4 ${Shader.MVP_MATRIX};
|
|
|
- varying vec4 v_light;
|
|
|
- varying vec4 v_dark;
|
|
|
- varying vec2 v_texCoords;
|
|
|
-
|
|
|
- void main () {
|
|
|
- v_light = ${Shader.COLOR};
|
|
|
- v_dark = ${Shader.COLOR2};
|
|
|
- v_texCoords = ${Shader.TEXCOORDS};
|
|
|
- gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
|
|
- }
|
|
|
- `;
|
|
|
+attribute vec4 ${Shader.POSITION};
|
|
|
+attribute vec4 ${Shader.COLOR};
|
|
|
+attribute vec4 ${Shader.COLOR2};
|
|
|
+attribute vec2 ${Shader.TEXCOORDS};
|
|
|
+uniform mat4 ${Shader.MVP_MATRIX};
|
|
|
+varying vec4 v_light;
|
|
|
+varying vec4 v_dark;
|
|
|
+varying vec2 v_texCoords;
|
|
|
+
|
|
|
+void main () {
|
|
|
+ v_light = ${Shader.COLOR};
|
|
|
+ v_dark = ${Shader.COLOR2};
|
|
|
+ v_texCoords = ${Shader.TEXCOORDS};
|
|
|
+ gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
|
|
+}
|
|
|
+`;
|
|
|
|
|
|
let fs = `
|
|
|
- #ifdef GL_ES
|
|
|
- #define LOWP lowp
|
|
|
- precision mediump float;
|
|
|
- #else
|
|
|
- #define LOWP
|
|
|
- #endif
|
|
|
- varying LOWP vec4 v_light;
|
|
|
- varying LOWP vec4 v_dark;
|
|
|
- varying vec2 v_texCoords;
|
|
|
- uniform sampler2D u_texture;
|
|
|
-
|
|
|
- void main () {
|
|
|
- vec4 texColor = texture2D(u_texture, v_texCoords);
|
|
|
- gl_FragColor.a = texColor.a * v_light.a;
|
|
|
- gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
|
|
- }
|
|
|
- `;
|
|
|
+#ifdef GL_ES
|
|
|
+ #define LOWP lowp
|
|
|
+ precision mediump float;
|
|
|
+#else
|
|
|
+ #define LOWP
|
|
|
+#endif
|
|
|
+varying LOWP vec4 v_light;
|
|
|
+varying LOWP vec4 v_dark;
|
|
|
+varying vec2 v_texCoords;
|
|
|
+uniform sampler2D u_texture;
|
|
|
+
|
|
|
+void main () {
|
|
|
+ vec4 texColor = texture2D(u_texture, v_texCoords);
|
|
|
+ gl_FragColor.a = texColor.a * v_light.a;
|
|
|
+ gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
|
|
+}
|
|
|
+`;
|
|
|
|
|
|
return new Shader(context, vs, fs);
|
|
|
}
|
|
|
|
|
|
public static newColored (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
|
|
let vs = `
|
|
|
- attribute vec4 ${Shader.POSITION};
|
|
|
- attribute vec4 ${Shader.COLOR};
|
|
|
- uniform mat4 ${Shader.MVP_MATRIX};
|
|
|
- varying vec4 v_color;
|
|
|
-
|
|
|
- void main () {
|
|
|
- v_color = ${Shader.COLOR};
|
|
|
- gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
|
|
- }
|
|
|
- `;
|
|
|
+attribute vec4 ${Shader.POSITION};
|
|
|
+attribute vec4 ${Shader.COLOR};
|
|
|
+uniform mat4 ${Shader.MVP_MATRIX};
|
|
|
+varying vec4 v_color;
|
|
|
+
|
|
|
+void main () {
|
|
|
+ v_color = ${Shader.COLOR};
|
|
|
+ gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
|
|
+}
|
|
|
+`;
|
|
|
|
|
|
let fs = `
|
|
|
- #ifdef GL_ES
|
|
|
- #define LOWP lowp
|
|
|
- precision mediump float;
|
|
|
- #else
|
|
|
- #define LOWP
|
|
|
- #endif
|
|
|
- varying LOWP vec4 v_color;
|
|
|
-
|
|
|
- void main () {
|
|
|
- gl_FragColor = v_color;
|
|
|
- }
|
|
|
- `;
|
|
|
+#ifdef GL_ES
|
|
|
+ #define LOWP lowp
|
|
|
+ precision mediump float;
|
|
|
+#else
|
|
|
+ #define LOWP
|
|
|
+#endif
|
|
|
+varying LOWP vec4 v_color;
|
|
|
+
|
|
|
+void main () {
|
|
|
+ gl_FragColor = v_color;
|
|
|
+}
|
|
|
+`;
|
|
|
|
|
|
return new Shader(context, vs, fs);
|
|
|
}
|