mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-17 02:55:10 +00:00
Seperate colour and lighting a bit. Made baking colours easier and the distinction between dynamic and static rendering easier to manage.
Fixed invalid u coords in generateBlock
This commit is contained in:
1 parent
97cb16586a
commit
09bf91715b
7 files changed
+93
-41
No files matched your search
@@ -180,6 +180,32 @@ public class CCRenderState
|
||||
setColour(baseColour);
|
||||
}
|
||||
};
|
||||
public static VertexAttribute<int[]> lightingAttrib = new VertexAttribute<int[]>() {
|
||||
private int[] colourRef;
|
||||
|
||||
@Override
|
||||
public int[] newArray(int length) {
|
||||
return new int[length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load() {
|
||||
if(!computeLighting || !hasColour || !model.hasAttribute(this))
|
||||
return false;
|
||||
|
||||
colourRef = model.getAttributes(this);
|
||||
if(colourRef != null) {
|
||||
pipeline.addDependency(colourAttrib);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operate() {
|
||||
setColour(ColourRGBA.multiply(colour, colourRef[vertexIndex]));
|
||||
}
|
||||
};
|
||||
public static VertexAttribute<int[]> sideAttrib = new VertexAttribute<int[]>() {
|
||||
private int[] sideRef;
|
||||
|
||||
@@ -251,6 +277,8 @@ public class CCRenderState
|
||||
public static int baseColour;
|
||||
public static int alphaOverride;
|
||||
public static boolean useNormals;
|
||||
public static boolean computeLighting;
|
||||
public static boolean useColour;
|
||||
public static LightMatrix lightMatrix = new LightMatrix();
|
||||
|
||||
//vertex outputs
|
||||
@@ -269,8 +297,8 @@ public class CCRenderState
|
||||
public static void reset() {
|
||||
model = null;
|
||||
pipeline.reset();
|
||||
hasNormal = hasBrightness = false;
|
||||
hasColour = true;
|
||||
useNormals = hasNormal = hasBrightness = hasColour = false;
|
||||
useColour = computeLighting = true;
|
||||
baseColour = alphaOverride = -1;
|
||||
}
|
||||
|
||||
@@ -362,6 +390,14 @@ public class CCRenderState
|
||||
setBrightness((int)OpenGlHelper.lastBrightnessY << 16 | (int)OpenGlHelper.lastBrightnessX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compact helper for setting dynamic rendering context. Uses normals and doesn't compute lighting
|
||||
*/
|
||||
public static void setDynamic() {
|
||||
useNormals = true;
|
||||
computeLighting = false;
|
||||
}
|
||||
|
||||
public static void changeTexture(String texture) {
|
||||
changeTexture(new ResourceLocation(texture));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user