Shader cleanup
This commit is contained in:
@@ -9,12 +9,43 @@ import io.anuke.arc.graphics.glutils.Shader;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.Matrix3;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
import io.anuke.arc.util.Strings;
|
||||
|
||||
//TODO this class is a trainwreck, remove it
|
||||
public class IndexedRenderer implements Disposable{
|
||||
private final static int vsize = 5;
|
||||
|
||||
private Shader program = BatchShader.create();
|
||||
private Shader program = new Shader(
|
||||
Strings.join("\n",
|
||||
"attribute vec4 " + Shader.POSITION_ATTRIBUTE + ";",
|
||||
"attribute vec4 " + Shader.COLOR_ATTRIBUTE + ";",
|
||||
"attribute vec2 " + Shader.TEXCOORD_ATTRIBUTE + "0;",
|
||||
"uniform mat4 u_projTrans;",
|
||||
"varying vec4 v_color;",
|
||||
"varying vec2 v_texCoords;",
|
||||
"",
|
||||
"void main(){",
|
||||
" v_color = " + Shader.COLOR_ATTRIBUTE + ";",
|
||||
" v_color.a = v_color.a * (255.0/254.0);",
|
||||
" v_texCoords = " + Shader.TEXCOORD_ATTRIBUTE + "0;",
|
||||
" gl_Position = u_projTrans * " + Shader.POSITION_ATTRIBUTE + ";",
|
||||
"}"),
|
||||
Strings.join("\n",
|
||||
"#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);",
|
||||
"}"
|
||||
));
|
||||
private Mesh mesh;
|
||||
private float[] tmpVerts = new float[vsize * 6];
|
||||
private float[] vertices;
|
||||
|
||||
@@ -10,23 +10,17 @@ import io.anuke.arc.util.Time;
|
||||
public class Shaders{
|
||||
public static Shadow shadow;
|
||||
public static BlockBuild blockbuild;
|
||||
public static BlockPreview blockpreview;
|
||||
public static Shield shield;
|
||||
public static UnitBuild build;
|
||||
public static MixShader mix;
|
||||
public static Shader fullMix;
|
||||
public static FogShader fog;
|
||||
public static MenuShader menu;
|
||||
|
||||
public static void init(){
|
||||
shadow = new Shadow();
|
||||
blockbuild = new BlockBuild();
|
||||
blockpreview = new BlockPreview();
|
||||
shield = new Shield();
|
||||
build = new UnitBuild();
|
||||
mix = new MixShader();
|
||||
fog = new FogShader();
|
||||
fullMix = new LoadShader("fullmix", "default");
|
||||
menu = new MenuShader();
|
||||
}
|
||||
|
||||
@@ -55,27 +49,13 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class MixShader extends LoadShader{
|
||||
public Color color = new Color(Color.WHITE);
|
||||
|
||||
public MixShader(){
|
||||
super("mix", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
super.apply();
|
||||
setUniformf("u_color", color);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnitBuild extends LoadShader{
|
||||
public float progress, time;
|
||||
public Color color = new Color();
|
||||
public TextureRegion region;
|
||||
|
||||
public UnitBuild(){
|
||||
super("build", "default");
|
||||
super("unitbuild", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,23 +106,6 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockPreview extends LoadShader{
|
||||
public Color color = new Color();
|
||||
public TextureRegion region = new TextureRegion();
|
||||
|
||||
public BlockPreview(){
|
||||
super("blockpreview", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
setUniformf("u_color", color);
|
||||
setUniformf("u_uv", region.getU(), region.getV());
|
||||
setUniformf("u_uv2", region.getU2(), region.getV2());
|
||||
setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Shield extends LoadShader{
|
||||
|
||||
public Shield(){
|
||||
|
||||
Reference in New Issue
Block a user