mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Don't indent shader code to minify better.
This commit is contained in:
parent
55c2bd9ed4
commit
d5cd7f67b1
@ -194,106 +194,106 @@ export class Shader implements Disposable, Restorable {
|
|||||||
|
|
||||||
public static newColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
public static newColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
||||||
let vs = `
|
let vs = `
|
||||||
attribute vec4 ${Shader.POSITION};
|
attribute vec4 ${Shader.POSITION};
|
||||||
attribute vec4 ${Shader.COLOR};
|
attribute vec4 ${Shader.COLOR};
|
||||||
attribute vec2 ${Shader.TEXCOORDS};
|
attribute vec2 ${Shader.TEXCOORDS};
|
||||||
uniform mat4 ${Shader.MVP_MATRIX};
|
uniform mat4 ${Shader.MVP_MATRIX};
|
||||||
varying vec4 v_color;
|
varying vec4 v_color;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
v_color = ${Shader.COLOR};
|
v_color = ${Shader.COLOR};
|
||||||
v_texCoords = ${Shader.TEXCOORDS};
|
v_texCoords = ${Shader.TEXCOORDS};
|
||||||
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let fs = `
|
let fs = `
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
#define LOWP lowp
|
#define LOWP lowp
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#else
|
#else
|
||||||
#define LOWP
|
#define LOWP
|
||||||
#endif
|
#endif
|
||||||
varying LOWP vec4 v_color;
|
varying LOWP vec4 v_color;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
return new Shader(context, vs, fs);
|
return new Shader(context, vs, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static newTwoColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
public static newTwoColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
||||||
let vs = `
|
let vs = `
|
||||||
attribute vec4 ${Shader.POSITION};
|
attribute vec4 ${Shader.POSITION};
|
||||||
attribute vec4 ${Shader.COLOR};
|
attribute vec4 ${Shader.COLOR};
|
||||||
attribute vec4 ${Shader.COLOR2};
|
attribute vec4 ${Shader.COLOR2};
|
||||||
attribute vec2 ${Shader.TEXCOORDS};
|
attribute vec2 ${Shader.TEXCOORDS};
|
||||||
uniform mat4 ${Shader.MVP_MATRIX};
|
uniform mat4 ${Shader.MVP_MATRIX};
|
||||||
varying vec4 v_light;
|
varying vec4 v_light;
|
||||||
varying vec4 v_dark;
|
varying vec4 v_dark;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
v_light = ${Shader.COLOR};
|
v_light = ${Shader.COLOR};
|
||||||
v_dark = ${Shader.COLOR2};
|
v_dark = ${Shader.COLOR2};
|
||||||
v_texCoords = ${Shader.TEXCOORDS};
|
v_texCoords = ${Shader.TEXCOORDS};
|
||||||
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let fs = `
|
let fs = `
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
#define LOWP lowp
|
#define LOWP lowp
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#else
|
#else
|
||||||
#define LOWP
|
#define LOWP
|
||||||
#endif
|
#endif
|
||||||
varying LOWP vec4 v_light;
|
varying LOWP vec4 v_light;
|
||||||
varying LOWP vec4 v_dark;
|
varying LOWP vec4 v_dark;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
vec4 texColor = texture2D(u_texture, v_texCoords);
|
vec4 texColor = texture2D(u_texture, v_texCoords);
|
||||||
gl_FragColor.a = texColor.a * v_light.a;
|
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;
|
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);
|
return new Shader(context, vs, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static newColored (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
public static newColored (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
||||||
let vs = `
|
let vs = `
|
||||||
attribute vec4 ${Shader.POSITION};
|
attribute vec4 ${Shader.POSITION};
|
||||||
attribute vec4 ${Shader.COLOR};
|
attribute vec4 ${Shader.COLOR};
|
||||||
uniform mat4 ${Shader.MVP_MATRIX};
|
uniform mat4 ${Shader.MVP_MATRIX};
|
||||||
varying vec4 v_color;
|
varying vec4 v_color;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
v_color = ${Shader.COLOR};
|
v_color = ${Shader.COLOR};
|
||||||
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let fs = `
|
let fs = `
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
#define LOWP lowp
|
#define LOWP lowp
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#else
|
#else
|
||||||
#define LOWP
|
#define LOWP
|
||||||
#endif
|
#endif
|
||||||
varying LOWP vec4 v_color;
|
varying LOWP vec4 v_color;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
gl_FragColor = v_color;
|
gl_FragColor = v_color;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
return new Shader(context, vs, fs);
|
return new Shader(context, vs, fs);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user