Colors are now always Vec4, ARGB ints are only wrappers
This commit is contained in:
parent
a6c1b914c1
commit
d197c0a73e
@ -2,11 +2,11 @@ package ru.windcorp.progressia.client;
|
||||
|
||||
import ru.windcorp.progressia.client.comms.localhost.LocalServerCommsChannel;
|
||||
import ru.windcorp.progressia.client.graphics.GUI;
|
||||
import ru.windcorp.progressia.client.graphics.flat.LayerTestUI;
|
||||
import ru.windcorp.progressia.client.graphics.world.LayerWorld;
|
||||
import ru.windcorp.progressia.common.world.WorldData;
|
||||
import ru.windcorp.progressia.server.ServerState;
|
||||
import ru.windcorp.progressia.test.LayerTestGUI;
|
||||
import ru.windcorp.progressia.test.LayerTestUI;
|
||||
import ru.windcorp.progressia.test.TestContent;
|
||||
|
||||
public class ClientState {
|
||||
@ -31,8 +31,6 @@ public class ClientState {
|
||||
|
||||
Client client = new Client(world, channel);
|
||||
|
||||
// world.tmp_generate();
|
||||
|
||||
channel.connect(TestContent.PLAYER_LOGIN);
|
||||
|
||||
setInstance(client);
|
||||
|
@ -17,34 +17,43 @@
|
||||
*******************************************************************************/
|
||||
package ru.windcorp.progressia.client.graphics;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._4.Vec4;
|
||||
|
||||
public class Colors {
|
||||
|
||||
public static final int
|
||||
WHITE = 0xFFFFFF,
|
||||
BLACK = 0x000000,
|
||||
public static final Vec4
|
||||
WHITE = toVector(0xFFFFFFFF),
|
||||
BLACK = toVector(0xFF000000),
|
||||
|
||||
GRAY_4 = 0x444444,
|
||||
GRAY = 0x888888,
|
||||
GRAY_A = 0xAAAAAA,
|
||||
GRAY_4 = toVector(0xFF444444),
|
||||
GRAY = toVector(0xFF888888),
|
||||
GRAY_A = toVector(0xFFAAAAAA),
|
||||
|
||||
DEBUG_RED = 0xFF0000,
|
||||
DEBUG_GREEN = 0x00FF00,
|
||||
DEBUG_BLUE = 0x0000FF,
|
||||
DEBUG_RED = toVector(0xFFFF0000),
|
||||
DEBUG_GREEN = toVector(0xFF00FF00),
|
||||
DEBUG_BLUE = toVector(0xFF0000FF),
|
||||
DEBUG_CYAN = toVector(0xFF00FFFF),
|
||||
DEBUG_MAGENTA = toVector(0xFFFF00FF),
|
||||
DEBUG_YELLOW = toVector(0xFFFFFF00);
|
||||
|
||||
DEBUG_CYAN = 0x00FFFF,
|
||||
DEBUG_MAGENTA = 0xFF00FF,
|
||||
DEBUG_YELLOW = 0xFFFF00;
|
||||
|
||||
public static Vec3 toVector(int rgb) {
|
||||
return toVector(rgb, new Vec3());
|
||||
public static Vec4 toVector(int argb) {
|
||||
return toVector(argb, new Vec4());
|
||||
}
|
||||
|
||||
public static Vec3 toVector(int rgb, Vec3 output) {
|
||||
output.x = ((rgb & 0xFF0000) >> 16) / 256f;
|
||||
output.y = ((rgb & 0x00FF00) >> 8 ) / 256f;
|
||||
output.z = ((rgb & 0x0000FF) ) / 256f;
|
||||
public static Vec4 multiplyRGB(Vec4 color, float multiplier) {
|
||||
return color.mul(multiplier, multiplier, multiplier, 1);
|
||||
}
|
||||
|
||||
public static Vec4 multiplyRGB(Vec4 color, float multiplier, Vec4 output) {
|
||||
if (output == null) output = new Vec4();
|
||||
return color.mul(multiplier, multiplier, multiplier, 1, output);
|
||||
}
|
||||
|
||||
public static Vec4 toVector(int argb, Vec4 output) {
|
||||
output.w = ((argb & 0xFF000000) >>> 24) / 256f; // Alpha
|
||||
output.x = ((argb & 0x00FF0000) >>> 16) / 256f; // Red
|
||||
output.y = ((argb & 0x0000FF00) >>> 8) / 256f; // Green
|
||||
output.z = ((argb & 0x000000FF) ) / 256f; // Blue
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import java.util.Objects;
|
||||
|
||||
import glm.mat._4.Mat4;
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.backend.Usage;
|
||||
import ru.windcorp.progressia.client.graphics.model.Face;
|
||||
@ -190,13 +191,20 @@ public class RenderTarget {
|
||||
|
||||
public void drawTexture(
|
||||
int x, int y, int width, int height,
|
||||
int color, Texture texture
|
||||
Vec4 color, Texture texture
|
||||
) {
|
||||
addFaceToCurrentClip(
|
||||
createRectagleFace(x, y, width, height, color, texture)
|
||||
);
|
||||
}
|
||||
|
||||
public void drawTexture(
|
||||
int x, int y, int width, int height,
|
||||
int color, Texture texture
|
||||
) {
|
||||
drawTexture(x, y, width, height, Colors.toVector(color), texture);
|
||||
}
|
||||
|
||||
public void drawTexture(
|
||||
int x, int y, int width, int height,
|
||||
Texture texture
|
||||
@ -206,12 +214,19 @@ public class RenderTarget {
|
||||
|
||||
public void fill(
|
||||
int x, int y, int width, int height,
|
||||
int color
|
||||
Vec4 color
|
||||
) {
|
||||
drawTexture(x, y, width, height, color, null);
|
||||
}
|
||||
|
||||
public void fill(int color) {
|
||||
public void fill(
|
||||
int x, int y, int width, int height,
|
||||
int color
|
||||
) {
|
||||
fill(x, y, width, height, Colors.toVector(color));
|
||||
}
|
||||
|
||||
public void fill(Vec4 color) {
|
||||
fill(
|
||||
Integer.MIN_VALUE / 2, Integer.MIN_VALUE / 2,
|
||||
Integer.MAX_VALUE, Integer.MAX_VALUE,
|
||||
@ -219,15 +234,19 @@ public class RenderTarget {
|
||||
);
|
||||
}
|
||||
|
||||
public void fill(int color) {
|
||||
fill(Colors.toVector(color));
|
||||
}
|
||||
|
||||
public Face createRectagleFace(
|
||||
int x, int y, int width, int height, int color, Texture texture
|
||||
int x, int y, int width, int height, Vec4 color, Texture texture
|
||||
) {
|
||||
float depth = this.depth--;
|
||||
|
||||
return Faces.createRectangle(
|
||||
FlatRenderProgram.getDefault(),
|
||||
texture,
|
||||
Colors.toVector(color),
|
||||
color,
|
||||
new Vec3(x, y, depth),
|
||||
new Vec3(width, 0, 0),
|
||||
new Vec3(0, height, 0),
|
||||
@ -235,8 +254,14 @@ public class RenderTarget {
|
||||
);
|
||||
}
|
||||
|
||||
public Shape createRectagle(
|
||||
public Face createRectagleFace(
|
||||
int x, int y, int width, int height, int color, Texture texture
|
||||
) {
|
||||
return createRectagleFace(x, y, width, height, Colors.toVector(color), texture);
|
||||
}
|
||||
|
||||
public Shape createRectagle(
|
||||
int x, int y, int width, int height, Vec4 color, Texture texture
|
||||
) {
|
||||
return new Shape(
|
||||
Usage.STATIC, FlatRenderProgram.getDefault(),
|
||||
@ -244,4 +269,10 @@ public class RenderTarget {
|
||||
);
|
||||
}
|
||||
|
||||
public Shape createRectagle(
|
||||
int x, int y, int width, int height, int color, Texture texture
|
||||
) {
|
||||
return createRectagle(x, y, width, height, Colors.toVector(color), texture);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package ru.windcorp.progressia.client.graphics.font;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import glm.vec._2.i.Vec2i;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.model.Renderable;
|
||||
|
||||
@ -12,15 +13,19 @@ public class Font {
|
||||
|
||||
private final int style;
|
||||
private final float align;
|
||||
private final int color;
|
||||
private final Vec4 color;
|
||||
|
||||
public Font(Typeface typeface, int style, float align, int color) {
|
||||
public Font(Typeface typeface, int style, float align, Vec4 color) {
|
||||
this.typeface = typeface;
|
||||
this.style = style;
|
||||
this.align = align;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Font(Typeface typeface, int style, float align, int color) {
|
||||
this(typeface, style, align, Colors.toVector(color));
|
||||
}
|
||||
|
||||
public Font(Typeface typeface) {
|
||||
this(typeface, Typeface.Style.PLAIN, Typeface.ALIGN_LEFT, Colors.WHITE);
|
||||
}
|
||||
@ -41,14 +46,14 @@ public class Font {
|
||||
return align;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
public Vec4 getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Renderable assemble(
|
||||
CharSequence chars, float maxWidth
|
||||
) {
|
||||
return typeface.assemble(chars, style, align, maxWidth, color);
|
||||
return typeface.assembleStatic(chars, style, align, maxWidth, color);
|
||||
}
|
||||
|
||||
public Renderable assembleDynamic(
|
||||
@ -127,6 +132,10 @@ public class Font {
|
||||
return new Font(getTypeface(), getStyle(), align, getColor());
|
||||
}
|
||||
|
||||
public Font withColor(Vec4 color) {
|
||||
return new Font(getTypeface(), getStyle(), getAlign(), color);
|
||||
}
|
||||
|
||||
public Font withColor(int color) {
|
||||
return new Font(getTypeface(), getStyle(), getAlign(), color);
|
||||
}
|
||||
|
@ -8,10 +8,12 @@ import glm.mat._4.Mat4;
|
||||
import glm.vec._2.Vec2;
|
||||
import glm.vec._2.i.Vec2i;
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._4.Vec4;
|
||||
import gnu.trove.map.TCharObjectMap;
|
||||
import gnu.trove.map.hash.TCharObjectHashMap;
|
||||
import gnu.trove.stack.TIntStack;
|
||||
import gnu.trove.stack.array.TIntArrayStack;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.backend.Usage;
|
||||
import ru.windcorp.progressia.client.graphics.model.Face;
|
||||
import ru.windcorp.progressia.client.graphics.model.Faces;
|
||||
@ -115,7 +117,7 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
return output.set(resultWidth, height);
|
||||
}
|
||||
|
||||
private Shape createCharShape(char c, Vec3 color) {
|
||||
private Shape createCharShape(char c, Vec4 color) {
|
||||
return new Shape(
|
||||
Usage.STATIC, getProgram(),
|
||||
Faces.createRectangle(
|
||||
@ -130,25 +132,16 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO remove
|
||||
private static Vec3 createVectorFromRGBInt(int rgb) {
|
||||
int r = (rgb & 0xFF0000) >> 16;
|
||||
int g = (rgb & 0x00FF00) >> 8;
|
||||
int b = (rgb & 0x0000FF);
|
||||
|
||||
return new Vec3(r / 256f, g / 256f, b / 256f);
|
||||
}
|
||||
|
||||
private class DynamicText implements Renderable, Drawer {
|
||||
|
||||
private final Supplier<CharSequence> supplier;
|
||||
private final int style;
|
||||
private final float align;
|
||||
private final float maxWidth;
|
||||
private final Vec3 color;
|
||||
private final Vec4 color;
|
||||
|
||||
private final Renderable unitLine = new Shape(Usage.STATIC, getProgram(), Faces.createRectangle(
|
||||
getProgram(), null, Vectors.UNIT_3, Vectors.ZERO_3, new Vec3(1, 0, 0), new Vec3(0, 1, 0), false
|
||||
getProgram(), null, Vectors.UNIT_4, Vectors.ZERO_3, new Vec3(1, 0, 0), new Vec3(0, 1, 0), false
|
||||
));
|
||||
|
||||
private class DynamicWorkspace extends Workspace {
|
||||
@ -165,7 +158,7 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
|
||||
public DynamicText(
|
||||
Supplier<CharSequence> supplier,
|
||||
int style, float align, float maxWidth, Vec3 color
|
||||
int style, float align, float maxWidth, Vec4 color
|
||||
) {
|
||||
this.supplier = supplier;
|
||||
this.style = style;
|
||||
@ -200,14 +193,14 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void drawChar(char c, Vec3 color, Mat4 transform) {
|
||||
public void drawChar(char c, Vec4 color, Mat4 transform) {
|
||||
workspace.renderer.pushTransform().mul(transform);
|
||||
getShape(c).render(workspace.renderer);
|
||||
workspace.renderer.popTransform();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRectangle(Vec2 size, Vec3 color, Mat4 transform) {
|
||||
public void drawRectangle(Vec2 size, Vec4 color, Mat4 transform) {
|
||||
workspace.renderer.pushTransform().mul(transform).scale(size.x, size.y, 1);
|
||||
unitLine.render(workspace.renderer);
|
||||
workspace.renderer.popTransform();
|
||||
@ -234,7 +227,7 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
public final SDWorkspace workspace = new SDWorkspace();
|
||||
|
||||
@Override
|
||||
public void drawChar(char c, Vec3 color, Mat4 transform) {
|
||||
public void drawChar(char c, Vec4 color, Mat4 transform) {
|
||||
workspace.origin.set(0, 0, 0);
|
||||
workspace.width.set(getWidth(c), 0, 0);
|
||||
workspace.height.set(0, getHeight(), 0);
|
||||
@ -243,7 +236,7 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRectangle(Vec2 size, Vec3 color, Mat4 transform) {
|
||||
public void drawRectangle(Vec2 size, Vec4 color, Mat4 transform) {
|
||||
workspace.origin.set(0, 0, 0);
|
||||
workspace.width.set(size.x, 0, 0);
|
||||
workspace.height.set(0, size.y, 0);
|
||||
@ -251,7 +244,7 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
drawFace(null, color, transform);
|
||||
}
|
||||
|
||||
private void drawFace(Texture texture, Vec3 color, Mat4 transform) {
|
||||
private void drawFace(Texture texture, Vec4 color, Mat4 transform) {
|
||||
|
||||
workspace.width.add(workspace.origin);
|
||||
workspace.height.add(workspace.origin);
|
||||
@ -281,15 +274,15 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderable assemble(CharSequence chars, int style, float align, float maxWidth, int color) {
|
||||
public Renderable assembleStatic(CharSequence text, int style, float align, float maxWidth, Vec4 color) {
|
||||
StaticDrawer drawer = new StaticDrawer();
|
||||
draw(chars, drawer, drawer.workspace, style, align, maxWidth, createVectorFromRGBInt(color));
|
||||
draw(text, drawer, drawer.workspace, style, align, maxWidth, color);
|
||||
return drawer.assemble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderable assembleDynamic(Supplier<CharSequence> supplier, int style, float align, float maxWidth, int color) {
|
||||
return new DynamicText(supplier, style, align, maxWidth, createVectorFromRGBInt(color));
|
||||
public Renderable assembleDynamic(Supplier<CharSequence> supplier, int style, float align, float maxWidth, Vec4 color) {
|
||||
return new DynamicText(supplier, style, align, maxWidth, color);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -309,7 +302,7 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
private float maxWidth;
|
||||
|
||||
private final TIntStack styles = new TIntArrayStack(16);
|
||||
private final StashingStack<Vec3> colors = new StashingStack<>(16, Vec3::new);
|
||||
private final StashingStack<Vec4> colors = new StashingStack<>(16, Vec4::new);
|
||||
|
||||
private final Vec2 pos = new Vec2();
|
||||
|
||||
@ -332,10 +325,10 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
return current;
|
||||
}
|
||||
|
||||
private Vec3 pushColor() {
|
||||
private Vec4 pushColor() {
|
||||
if (colors.isEmpty()) return colors.push();
|
||||
|
||||
Vec3 previous = colors.peek();
|
||||
Vec4 previous = colors.peek();
|
||||
return colors.push().set(previous);
|
||||
}
|
||||
|
||||
@ -371,13 +364,13 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
}
|
||||
|
||||
protected interface Drawer {
|
||||
void drawChar(char c, Vec3 color, Mat4 transform);
|
||||
void drawRectangle(Vec2 size, Vec3 color, Mat4 transform);
|
||||
void drawChar(char c, Vec4 color, Mat4 transform);
|
||||
void drawRectangle(Vec2 size, Vec4 color, Mat4 transform);
|
||||
}
|
||||
|
||||
protected void draw(
|
||||
CharSequence text, Drawer drawer, Workspace workspace,
|
||||
int style, float align, float maxWidth, Vec3 color
|
||||
int style, float align, float maxWidth, Vec4 color
|
||||
) {
|
||||
workspace.text = text;
|
||||
workspace.toIndex = text.length();
|
||||
@ -387,7 +380,7 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
getSize(text, style, align, maxWidth, workspace.totalSize);
|
||||
|
||||
workspace.styles.push(style);
|
||||
workspace.colors.push().set(color.x, color.y, color.z);
|
||||
workspace.colors.push().set(color);
|
||||
|
||||
drawSpan(drawer, workspace);
|
||||
|
||||
@ -447,15 +440,15 @@ public abstract class SpriteTypeface extends Typeface {
|
||||
|
||||
workspace.pushStyle(~Style.SHADOW);
|
||||
|
||||
workspace.pushColor().mul(getShadowColorMultiplier());
|
||||
drawLine(drawer, workspace); // TODO figure out why placing this line after drawing shadow reverses order of display (should be the opposite)
|
||||
workspace.pos.x = xToRestore;
|
||||
|
||||
Colors.multiplyRGB(workspace.pushColor(), getShadowColorMultiplier());
|
||||
workspace.pushTransform().translate(getShadowOffset());
|
||||
drawLine(drawer, workspace);
|
||||
workspace.pos.x = xToRestore;
|
||||
workspace.colors.pop();
|
||||
workspace.transforms.pop();
|
||||
|
||||
drawLine(drawer, workspace);
|
||||
|
||||
workspace.styles.pop();
|
||||
|
||||
} else if (Style.isBold(style)) {
|
||||
|
@ -3,6 +3,7 @@ package ru.windcorp.progressia.client.graphics.font;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import glm.vec._2.i.Vec2i;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.graphics.model.Renderable;
|
||||
import ru.windcorp.progressia.common.util.Named;
|
||||
import ru.windcorp.progressia.common.util.Vectors;
|
||||
@ -48,13 +49,15 @@ public abstract class Typeface extends Named {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public abstract Renderable assemble(
|
||||
CharSequence chars, int style,
|
||||
float align, float maxWidth,
|
||||
int color
|
||||
public abstract Renderable assembleStatic(
|
||||
CharSequence chars,
|
||||
int style, float align, float maxWidth, Vec4 color
|
||||
);
|
||||
|
||||
public abstract Renderable assembleDynamic(Supplier<CharSequence> supplier, int style, float align, float maxWidth, int color);
|
||||
public abstract Renderable assembleDynamic(
|
||||
Supplier<CharSequence> supplier,
|
||||
int style, float align, float maxWidth, Vec4 color
|
||||
);
|
||||
|
||||
public int getWidth(
|
||||
CharSequence chars, int style,
|
||||
|
@ -21,6 +21,7 @@ import java.nio.ShortBuffer;
|
||||
|
||||
import glm.vec._2.Vec2;
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.graphics.model.ShapeRenderProgram.VertexBuilder;
|
||||
import ru.windcorp.progressia.client.graphics.texture.Texture;
|
||||
import ru.windcorp.progressia.common.world.block.BlockFace;
|
||||
@ -32,7 +33,7 @@ public class Faces {
|
||||
public static Face createRectangle(
|
||||
ShapeRenderProgram program,
|
||||
Texture texture,
|
||||
Vec3 colorMultiplier,
|
||||
Vec4 colorMultiplier,
|
||||
Vec3 origin,
|
||||
Vec3 width,
|
||||
Vec3 height,
|
||||
@ -76,7 +77,7 @@ public class Faces {
|
||||
public static Face createBlockFace(
|
||||
ShapeRenderProgram program,
|
||||
Texture texture,
|
||||
Vec3 colorMultiplier,
|
||||
Vec4 colorMultiplier,
|
||||
Vec3 blockCenter,
|
||||
BlockFace face,
|
||||
boolean inner
|
||||
|
@ -28,6 +28,7 @@ import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import glm.vec._2.Vec2;
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.graphics.backend.VertexBufferObject;
|
||||
import ru.windcorp.progressia.client.graphics.backend.VertexBufferObject.BindTarget;
|
||||
import ru.windcorp.progressia.client.graphics.backend.shaders.CombinedShader;
|
||||
@ -42,7 +43,7 @@ public class ShapeRenderProgram extends Program {
|
||||
|
||||
private static final int DEFAULT_BYTES_PER_VERTEX =
|
||||
3 * Float.BYTES + // Position
|
||||
3 * Float.BYTES + // Color multiplier
|
||||
4 * Float.BYTES + // Color multiplier
|
||||
2 * Float.BYTES; // Texture coordinates
|
||||
|
||||
private static final String SHAPE_VERTEX_SHADER_RESOURCE =
|
||||
@ -152,10 +153,10 @@ public class ShapeRenderProgram extends Program {
|
||||
offset += 3 * Float.BYTES;
|
||||
|
||||
colorsAttribute.set(
|
||||
3, GL11.GL_FLOAT, false, vertexStride, vertices,
|
||||
4, GL11.GL_FLOAT, false, vertexStride, vertices,
|
||||
offset
|
||||
);
|
||||
offset += 3 * Float.BYTES;
|
||||
offset += 4 * Float.BYTES;
|
||||
|
||||
textureCoordsAttribute.set(
|
||||
2, GL11.GL_FLOAT, false, vertexStride, vertices,
|
||||
@ -209,7 +210,7 @@ public class ShapeRenderProgram extends Program {
|
||||
for (int i = 0; i < face.getVertexCount(); i++) {
|
||||
int offset = vertices.position() + i * getBytesPerVertex() + (
|
||||
3 * Float.BYTES +
|
||||
3 * Float.BYTES
|
||||
4 * Float.BYTES
|
||||
);
|
||||
|
||||
v.set(
|
||||
@ -239,9 +240,15 @@ public class ShapeRenderProgram extends Program {
|
||||
float tx, float ty
|
||||
);
|
||||
|
||||
VertexBuilder addVertex(
|
||||
float x, float y, float z,
|
||||
float r, float g, float b, float a,
|
||||
float tx, float ty
|
||||
);
|
||||
|
||||
VertexBuilder addVertex(
|
||||
Vec3 position,
|
||||
Vec3 colorMultiplier,
|
||||
Vec4 colorMultiplier,
|
||||
Vec2 textureCoords
|
||||
);
|
||||
|
||||
@ -252,10 +259,10 @@ public class ShapeRenderProgram extends Program {
|
||||
|
||||
private static class Vertex {
|
||||
final Vec3 position;
|
||||
final Vec3 colorMultiplier;
|
||||
final Vec4 colorMultiplier;
|
||||
final Vec2 textureCoords;
|
||||
|
||||
Vertex(Vec3 position, Vec3 colorMultiplier, Vec2 textureCoords) {
|
||||
Vertex(Vec3 position, Vec4 colorMultiplier, Vec2 textureCoords) {
|
||||
this.position = position;
|
||||
this.colorMultiplier = colorMultiplier;
|
||||
this.textureCoords = textureCoords;
|
||||
@ -264,6 +271,21 @@ public class ShapeRenderProgram extends Program {
|
||||
|
||||
private final List<Vertex> vertices = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public VertexBuilder addVertex(
|
||||
float x, float y, float z,
|
||||
float r, float g, float b, float a,
|
||||
float tx, float ty
|
||||
) {
|
||||
vertices.add(new Vertex(
|
||||
new Vec3(x, y, z),
|
||||
new Vec4(r, g, b, a),
|
||||
new Vec2(tx, ty)
|
||||
));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexBuilder addVertex(
|
||||
float x, float y, float z,
|
||||
@ -272,7 +294,7 @@ public class ShapeRenderProgram extends Program {
|
||||
) {
|
||||
vertices.add(new Vertex(
|
||||
new Vec3(x, y, z),
|
||||
new Vec3(r, g, b),
|
||||
new Vec4(r, g, b, 1f),
|
||||
new Vec2(tx, ty)
|
||||
));
|
||||
|
||||
@ -282,12 +304,12 @@ public class ShapeRenderProgram extends Program {
|
||||
@Override
|
||||
public VertexBuilder addVertex(
|
||||
Vec3 position,
|
||||
Vec3 colorMultiplier,
|
||||
Vec4 colorMultiplier,
|
||||
Vec2 textureCoords
|
||||
) {
|
||||
vertices.add(new Vertex(
|
||||
new Vec3(position),
|
||||
new Vec3(colorMultiplier),
|
||||
new Vec4(colorMultiplier),
|
||||
new Vec2(textureCoords)
|
||||
));
|
||||
|
||||
@ -308,6 +330,7 @@ public class ShapeRenderProgram extends Program {
|
||||
.putFloat(v.colorMultiplier.x)
|
||||
.putFloat(v.colorMultiplier.y)
|
||||
.putFloat(v.colorMultiplier.z)
|
||||
.putFloat(v.colorMultiplier.w)
|
||||
.putFloat(v.textureCoords.x)
|
||||
.putFloat(v.textureCoords.y);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package ru.windcorp.progressia.client.graphics.model;
|
||||
import java.util.Map;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.graphics.backend.Usage;
|
||||
import ru.windcorp.progressia.client.graphics.texture.Texture;
|
||||
import ru.windcorp.progressia.common.world.block.BlockFace;
|
||||
@ -35,7 +36,7 @@ public class Shapes {
|
||||
Vec3 height,
|
||||
Vec3 depth,
|
||||
|
||||
Vec3 colorMultiplier,
|
||||
Vec4 colorMultiplier,
|
||||
|
||||
Texture topTexture,
|
||||
Texture bottomTexture,
|
||||
@ -120,7 +121,7 @@ public class Shapes {
|
||||
private final Vec3 width = new Vec3(0, 1, 0);
|
||||
private final Vec3 height = new Vec3(0, 0, 1);
|
||||
|
||||
private final Vec3 colorMultiplier = new Vec3(1, 1, 1);
|
||||
private final Vec4 colorMultiplier = new Vec4(1, 1, 1, 1);
|
||||
|
||||
private final Texture topTexture;
|
||||
private final Texture bottomTexture;
|
||||
@ -178,13 +179,18 @@ public class Shapes {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PppBuilder setColorMultiplier(Vec3 colorMultiplier) {
|
||||
public PppBuilder setColorMultiplier(Vec4 colorMultiplier) {
|
||||
this.colorMultiplier.set(colorMultiplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PppBuilder setColorMultiplier(float r, float g, float b) {
|
||||
this.colorMultiplier.set(r, g, b);
|
||||
this.colorMultiplier.set(r, g, b, 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PppBuilder setColorMultiplier(float r, float g, float b, float a) {
|
||||
this.colorMultiplier.set(r, g, b, a);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||
import glm.mat._4.Mat4;
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._3.i.Vec3i;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.Client;
|
||||
import ru.windcorp.progressia.client.ClientState;
|
||||
import ru.windcorp.progressia.client.comms.controls.InputBasedControls;
|
||||
@ -157,7 +158,7 @@ public class LayerWorld extends Layer {
|
||||
|
||||
final float f = 1e-2f;
|
||||
final float scale = 1 - f/2;
|
||||
final Vec3 color = new Vec3(1, 1, 1).mul(0);
|
||||
final Vec4 color = new Vec4(1, 1, 1, 1).mul(0);
|
||||
|
||||
for (float phi = 0; phi < 2*FloatMathUtils.PI_F; phi += FloatMathUtils.PI_F/2) {
|
||||
Mat4 rot = new Mat4().identity().rotateZ(phi).scale(scale);
|
||||
|
@ -28,6 +28,7 @@ import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import glm.vec._2.Vec2;
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.graphics.backend.VertexBufferObject;
|
||||
import ru.windcorp.progressia.client.graphics.backend.shaders.attributes.*;
|
||||
import ru.windcorp.progressia.client.graphics.backend.shaders.uniforms.*;
|
||||
@ -54,7 +55,7 @@ public class WorldRenderProgram extends ShapeRenderProgram {
|
||||
|
||||
private static final int DEFAULT_BYTES_PER_VERTEX =
|
||||
3 * Float.BYTES + // Position
|
||||
3 * Float.BYTES + // Color multiplier
|
||||
4 * Float.BYTES + // Color multiplier
|
||||
2 * Float.BYTES + // Texture coordinates
|
||||
3 * Float.BYTES; // Normals
|
||||
|
||||
@ -194,7 +195,7 @@ public class WorldRenderProgram extends ShapeRenderProgram {
|
||||
ByteBuffer vertices = face.getVertices();
|
||||
int offset = vertices.position() + index * getBytesPerVertex() + (
|
||||
3 * Float.BYTES +
|
||||
3 * Float.BYTES +
|
||||
4 * Float.BYTES +
|
||||
2 * Float.BYTES
|
||||
);
|
||||
|
||||
@ -216,10 +217,10 @@ public class WorldRenderProgram extends ShapeRenderProgram {
|
||||
|
||||
private static class Vertex {
|
||||
final Vec3 position;
|
||||
final Vec3 colorMultiplier;
|
||||
final Vec4 colorMultiplier;
|
||||
final Vec2 textureCoords;
|
||||
|
||||
Vertex(Vec3 position, Vec3 colorMultiplier, Vec2 textureCoords) {
|
||||
Vertex(Vec3 position, Vec4 colorMultiplier, Vec2 textureCoords) {
|
||||
this.position = position;
|
||||
this.colorMultiplier = colorMultiplier;
|
||||
this.textureCoords = textureCoords;
|
||||
@ -236,7 +237,22 @@ public class WorldRenderProgram extends ShapeRenderProgram {
|
||||
) {
|
||||
vertices.add(new Vertex(
|
||||
new Vec3(x, y, z),
|
||||
new Vec3(r, g, b),
|
||||
new Vec4(r, g, b, 1),
|
||||
new Vec2(tx, ty)
|
||||
));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexBuilder addVertex(
|
||||
float x, float y, float z,
|
||||
float r, float g, float b, float a,
|
||||
float tx, float ty
|
||||
) {
|
||||
vertices.add(new Vertex(
|
||||
new Vec3(x, y, z),
|
||||
new Vec4(r, g, b, a),
|
||||
new Vec2(tx, ty)
|
||||
));
|
||||
|
||||
@ -246,12 +262,12 @@ public class WorldRenderProgram extends ShapeRenderProgram {
|
||||
@Override
|
||||
public VertexBuilder addVertex(
|
||||
Vec3 position,
|
||||
Vec3 colorMultiplier,
|
||||
Vec4 colorMultiplier,
|
||||
Vec2 textureCoords
|
||||
) {
|
||||
vertices.add(new Vertex(
|
||||
new Vec3(position),
|
||||
new Vec3(colorMultiplier),
|
||||
new Vec4(colorMultiplier),
|
||||
new Vec2(textureCoords)
|
||||
));
|
||||
|
||||
@ -272,6 +288,7 @@ public class WorldRenderProgram extends ShapeRenderProgram {
|
||||
.putFloat(v.colorMultiplier.x)
|
||||
.putFloat(v.colorMultiplier.y)
|
||||
.putFloat(v.colorMultiplier.z)
|
||||
.putFloat(v.colorMultiplier.w)
|
||||
.putFloat(v.textureCoords.x)
|
||||
.putFloat(v.textureCoords.y)
|
||||
.putFloat(Float.NaN)
|
||||
|
@ -27,6 +27,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._3.i.Vec3i;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.backend.Usage;
|
||||
import ru.windcorp.progressia.client.graphics.model.Face;
|
||||
import ru.windcorp.progressia.client.graphics.model.Faces;
|
||||
@ -70,8 +71,6 @@ public class ChunkRenderOptimizerCube extends ChunkRenderOptimizer {
|
||||
int tileCount = 0;
|
||||
}
|
||||
|
||||
private static final Vec3 COLOR_MULTIPLIER = new Vec3(1, 1, 1);
|
||||
|
||||
private final BlockInfo[][][] data =
|
||||
new BlockInfo[BLOCKS_PER_CHUNK]
|
||||
[BLOCKS_PER_CHUNK]
|
||||
@ -209,7 +208,7 @@ public class ChunkRenderOptimizerCube extends ChunkRenderOptimizer {
|
||||
output.accept(Faces.createBlockFace(
|
||||
WorldRenderProgram.getDefault(),
|
||||
texture,
|
||||
COLOR_MULTIPLIER,
|
||||
Colors.WHITE,
|
||||
new Vec3(cursor),
|
||||
face,
|
||||
false
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.windcorp.progressia.client.world.tile;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.backend.Usage;
|
||||
import ru.windcorp.progressia.client.graphics.model.Faces;
|
||||
import ru.windcorp.progressia.client.graphics.model.Shape;
|
||||
@ -42,7 +43,7 @@ public class TileRenderGrass extends TileRender implements OpaqueTile {
|
||||
return new Shape(
|
||||
Usage.STATIC, WorldRenderProgram.getDefault(),
|
||||
Faces.createBlockFace(
|
||||
program, getTexture(face), new Vec3(1, 1, 1),
|
||||
program, getTexture(face), Colors.WHITE,
|
||||
new Vec3(0, 0, 0), face, false
|
||||
)
|
||||
);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.windcorp.progressia.client.world.tile;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.backend.Usage;
|
||||
import ru.windcorp.progressia.client.graphics.model.Faces;
|
||||
import ru.windcorp.progressia.client.graphics.model.Shape;
|
||||
@ -43,7 +44,7 @@ public class TileRenderSimple extends TileRender implements OpaqueTile {
|
||||
return new Shape(
|
||||
Usage.STATIC, WorldRenderProgram.getDefault(),
|
||||
Faces.createBlockFace(
|
||||
program, getTexture(face), new Vec3(1, 1, 1),
|
||||
program, getTexture(face), Colors.WHITE,
|
||||
new Vec3(0, 0, 0), face, false
|
||||
)
|
||||
);
|
||||
|
@ -46,45 +46,45 @@ public class LayerTestGUI extends GUILayer {
|
||||
Collection<Label> labels = new ArrayList<>();
|
||||
|
||||
panel.addChild(new Label(
|
||||
"IsFlyingDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"IsFlyingDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
() -> String.format("Flying: %5s (Space bar x2)", TestPlayerControls.getInstance().isFlying())
|
||||
));
|
||||
|
||||
panel.addChild(new Label(
|
||||
"IsMouseCapturedDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"IsMouseCapturedDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
() -> String.format("Mouse captured: %5s (esc)", TestPlayerControls.getInstance().isMouseCaptured())
|
||||
));
|
||||
|
||||
panel.addChild(new Label(
|
||||
"CameraModeDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"CameraModeDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
() -> String.format("Camera mode: %5d (F5)", ClientState.getInstance().getCamera().getCurrentModeIndex())
|
||||
));
|
||||
|
||||
panel.addChild(new Label(
|
||||
"GravityModeDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"GravityModeDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
() -> String.format("Gravity: %9s (G)", TestPlayerControls.getInstance().useMinecraftGravity() ? "Minecraft" : "Realistic")
|
||||
));
|
||||
|
||||
panel.addChild(new DynamicLabel(
|
||||
"FPSDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"FPSDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
LayerTestGUI::getFPS,
|
||||
128
|
||||
));
|
||||
|
||||
panel.addChild(new DynamicLabel(
|
||||
"TPSDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"TPSDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
LayerTestGUI::getTPS,
|
||||
128
|
||||
));
|
||||
|
||||
panel.addChild(new DynamicLabel(
|
||||
"ChunkUpdatesDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"ChunkUpdatesDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
() -> "Pending updates: " + Integer.toString(ClientState.getInstance().getWorld().getPendingChunkUpdates()),
|
||||
128
|
||||
));
|
||||
|
||||
panel.addChild(new DynamicLabel(
|
||||
"PosDisplay", new Font().withColor(0x37A3E6).deriveShadow(),
|
||||
"PosDisplay", new Font().withColor(0xFF37A3E6).deriveShadow(),
|
||||
LayerTestGUI::getPos,
|
||||
128
|
||||
));
|
||||
|
@ -15,16 +15,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*******************************************************************************/
|
||||
package ru.windcorp.progressia.client.graphics.flat;
|
||||
package ru.windcorp.progressia.test;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import glm.mat._4.Mat4;
|
||||
import glm.vec._4.Vec4;
|
||||
import ru.windcorp.progressia.client.ClientState;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.backend.GraphicsInterface;
|
||||
import ru.windcorp.progressia.client.graphics.flat.AssembledFlatLayer;
|
||||
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
||||
import ru.windcorp.progressia.client.graphics.input.KeyEvent;
|
||||
import ru.windcorp.progressia.client.graphics.input.bus.Input;
|
||||
import ru.windcorp.progressia.client.graphics.model.LambdaModel;
|
||||
@ -48,9 +51,9 @@ public class LayerTestUI extends AssembledFlatLayer {
|
||||
|
||||
@Override
|
||||
protected void assemble(RenderTarget target) {
|
||||
final int boxColor = flag ? 0xEE8888 : 0xEEEE88;
|
||||
final int borderColor = flag ? 0xAA4444 : 0xAAAA44;
|
||||
final int boxShadowColor = flag ? 0x440000 : 0x444400;
|
||||
final int boxColor = flag ? 0xFFEE8888 : 0xFFEEEE88;
|
||||
final int borderColor = flag ? 0xFFAA4444 : 0xFFAAAA44;
|
||||
final int boxShadowColor = flag ? 0xFF440000 : 0xFF444400;
|
||||
|
||||
int x = (getWidth() - WIDTH) / 2;
|
||||
int y = 2*BORDER;
|
||||
@ -73,7 +76,7 @@ public class LayerTestUI extends AssembledFlatLayer {
|
||||
|
||||
target.addCustomRenderer(new LambdaModel(LambdaModel.lambdaBuilder()
|
||||
.addDynamicPart(
|
||||
target.createRectagle(0, 0, texSize, texSize, 0xFFFFFF, compassFg),
|
||||
target.createRectagle(0, 0, texSize, texSize, Colors.WHITE, compassFg),
|
||||
mat ->
|
||||
mat.translate(texSize/2, texSize/2, 0)
|
||||
.rotateZ(getCompassRotation())
|
||||
@ -101,8 +104,8 @@ public class LayerTestUI extends AssembledFlatLayer {
|
||||
final int length = 15;
|
||||
final int thickness = 5;
|
||||
final int borderSize = 1;
|
||||
final int borderColor = Colors.BLACK;
|
||||
final int fillColor = Colors.WHITE;
|
||||
final Vec4 borderColor = Colors.BLACK;
|
||||
final Vec4 fillColor = Colors.WHITE;
|
||||
|
||||
target.fill(
|
||||
cx - length - thickness / 2,
|
||||
@ -139,7 +142,6 @@ public class LayerTestUI extends AssembledFlatLayer {
|
||||
|
||||
@Override
|
||||
protected void handleInput(Input input) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.backend.GraphicsInterface;
|
||||
import ru.windcorp.progressia.client.graphics.backend.Usage;
|
||||
import ru.windcorp.progressia.client.graphics.model.Face;
|
||||
@ -99,11 +100,9 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
WorldRenderProgram program = WorldRenderProgram.getDefault();
|
||||
List<Face> faces = new ArrayList<>();
|
||||
|
||||
final Vec3 color = new Vec3(1, 1, 1);
|
||||
|
||||
// F BODY
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(80, 16, 32, 32), color,
|
||||
program, texture.get(80, 16, 32, 32), Colors.WHITE,
|
||||
new Vec3(+16, -16, -16),
|
||||
new Vec3(0, +32, 0), new Vec3(0, 0, +32),
|
||||
false
|
||||
@ -111,7 +110,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// NECK BASE
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(80, 48, 32, 16), color,
|
||||
program, texture.get(80, 48, 32, 16), Colors.WHITE,
|
||||
new Vec3(+16, -16, +16),
|
||||
new Vec3(0, +32, 0), new Vec3(-16, 0, 0),
|
||||
false
|
||||
@ -119,7 +118,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// T BODY (BACK)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(128, 0, 32, 48), color,
|
||||
program, texture.get(128, 0, 32, 48), Colors.WHITE,
|
||||
new Vec3(0, -16, +16),
|
||||
new Vec3(0, +32, 0), new Vec3(-48, 0, 0),
|
||||
false
|
||||
@ -127,7 +126,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BOTTOM B (upper)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(144, 48, 32, 16), color,
|
||||
program, texture.get(144, 48, 32, 16), Colors.WHITE,
|
||||
new Vec3(-48, -16, 0),
|
||||
new Vec3(0, 32, 0), new Vec3(0, 0, 16),
|
||||
true
|
||||
@ -135,7 +134,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BOTTOM B (lower)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(144, 48, 32, 16), color,
|
||||
program, texture.get(144, 48, 32, 16), Colors.WHITE,
|
||||
new Vec3(-48, -16, -16),
|
||||
new Vec3(0, 32, 0), new Vec3(0, 0, 16),
|
||||
true
|
||||
@ -143,7 +142,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BOTTOM B (stomach)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(144, 48, 32, 16), color,
|
||||
program, texture.get(144, 48, 32, 16), Colors.WHITE,
|
||||
new Vec3(-48, -16, -16),
|
||||
new Vec3(0, 32, 0), new Vec3(16, 0, 0),
|
||||
false
|
||||
@ -151,7 +150,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// STOMACH
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(224, 96, 32, 32), color,
|
||||
program, texture.get(224, 96, 32, 32), Colors.WHITE,
|
||||
new Vec3(-32, -16, -16),
|
||||
new Vec3(0, 32, 0), new Vec3(32, 0, 0),
|
||||
false
|
||||
@ -159,7 +158,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BOTTOM F
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(112, 48, 32, 16), color,
|
||||
program, texture.get(112, 48, 32, 16), Colors.WHITE,
|
||||
new Vec3(+16, -16, -16),
|
||||
new Vec3(0, 32, 0), new Vec3(-16, 0, 0),
|
||||
true
|
||||
@ -167,7 +166,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BODY L
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(112, 16, 16, 32), color,
|
||||
program, texture.get(112, 16, 16, 32), Colors.WHITE,
|
||||
new Vec3(+16, +16, -16),
|
||||
new Vec3(-16, 0, 0), new Vec3(0, 0, +32),
|
||||
false
|
||||
@ -175,7 +174,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BODY SIDES (left)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(96, 96, 32, 32), color,
|
||||
program, texture.get(96, 96, 32, 32), Colors.WHITE,
|
||||
new Vec3(0, +16, -16),
|
||||
new Vec3(-32, 0, 0), new Vec3(0, 0, +32),
|
||||
false
|
||||
@ -183,7 +182,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// QT MARK (left)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(16, 96, 16, 32), color,
|
||||
program, texture.get(16, 96, 16, 32), Colors.WHITE,
|
||||
new Vec3(-32, +16, -16),
|
||||
new Vec3(-16, 0, 0), new Vec3(0, 0, +32),
|
||||
false
|
||||
@ -191,7 +190,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BODY R
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(64, 16, 16, 32), color,
|
||||
program, texture.get(64, 16, 16, 32), Colors.WHITE,
|
||||
new Vec3(0, -16, -16),
|
||||
new Vec3(+16, 0, 0), new Vec3(0, 0, +32),
|
||||
false
|
||||
@ -199,7 +198,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// BODY SIDES (right)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(96, 96, 32, 32), color,
|
||||
program, texture.get(96, 96, 32, 32), Colors.WHITE,
|
||||
new Vec3(0, -16, -16),
|
||||
new Vec3(-32, 0, 0), new Vec3(0, 0, +32),
|
||||
true
|
||||
@ -207,7 +206,7 @@ public class TestEntityRenderJavapony extends EntityRender {
|
||||
|
||||
// QT MARK (right)
|
||||
faces.add(Faces.createRectangle(
|
||||
program, texture.get(16, 96, 16, 32), color,
|
||||
program, texture.get(16, 96, 16, 32), Colors.WHITE,
|
||||
new Vec3(-32, -16, -16),
|
||||
new Vec3(-16, 0, 0), new Vec3(0, 0, +32),
|
||||
true
|
||||
|
@ -1,6 +1,6 @@
|
||||
#version 120
|
||||
|
||||
varying vec3 varyingColorMultiplier;
|
||||
varying vec4 varyingColorMultiplier;
|
||||
varying vec2 varyingTextureCoords;
|
||||
|
||||
uniform sampler2D textureSlot;
|
||||
@ -16,11 +16,11 @@ void applyTexture() {
|
||||
}
|
||||
|
||||
void applyColorMultiplier() {
|
||||
gl_FragColor *= vec4(varyingColorMultiplier, 1.0);
|
||||
gl_FragColor *= varyingColorMultiplier;
|
||||
}
|
||||
|
||||
void applyAlpha() {
|
||||
if (gl_FragColor.w < 0.01) {
|
||||
if (gl_FragColor.w < (1 / 256.0)) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
attribute vec3 inputPositions;
|
||||
|
||||
attribute vec3 inputColorMultiplier;
|
||||
varying vec3 varyingColorMultiplier;
|
||||
attribute vec4 inputColorMultiplier;
|
||||
varying vec4 varyingColorMultiplier;
|
||||
|
||||
attribute vec2 inputTextureCoords;
|
||||
varying vec2 varyingTextureCoords;
|
||||
|
Reference in New Issue
Block a user