generated from jaredlll08/MultiLoader-Template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dynamic shader buffer swapping
- Loading branch information
1 parent
77d2351
commit fcdcc37
Showing
25 changed files
with
573 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
common/src/main/java/foundry/veil/api/client/render/dynamicbuffer/DynamicBufferType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package foundry.veil.api.client.render.dynamicbuffer; | ||
|
||
public enum DynamicBufferType { | ||
ALBEDO("albedo", "Albedo", false, 4), | ||
NORMAL("normal", "Normal", false, 3), | ||
LIGHT_COLOR("light_color", "LightColor", false, 4), | ||
LIGHT_UV("light_uv", "LightUv", true, 2), | ||
DEBUG("debug", "Debug", false, 4); | ||
|
||
private final String name; | ||
private final String sourceName; | ||
private final boolean integer; | ||
private final int components; | ||
private final int mask; | ||
|
||
DynamicBufferType(String name, String sourceName, boolean integer, int components) { | ||
this.name = name; | ||
this.sourceName = "VeilDynamic"+sourceName; | ||
this.integer = integer; | ||
this.components = components; | ||
this.mask = 1 << this.ordinal(); | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public String getSourceName() { | ||
return this.sourceName; | ||
} | ||
|
||
public String getType() { | ||
if (this.components == 1) { | ||
return this.isInteger() ? "int" : "float"; | ||
} | ||
return (this.isInteger() ? "u" : "") + "vec" + this.components; | ||
} | ||
|
||
public boolean isInteger() { | ||
return this.integer; | ||
} | ||
|
||
public int getComponents() { | ||
return this.components; | ||
} | ||
|
||
public int getMask() { | ||
return this.mask; | ||
} | ||
|
||
public static int encode(DynamicBufferType... types) { | ||
int mask = 0; | ||
for (DynamicBufferType type : types) { | ||
mask |= type.mask; | ||
} | ||
return mask; | ||
} | ||
|
||
public static DynamicBufferType[] decode(int mask) { | ||
int next = 0; | ||
DynamicBufferType[] types = new DynamicBufferType[Integer.bitCount(mask)]; | ||
for (DynamicBufferType value : values()) { | ||
if ((value.mask & mask) != 0) { | ||
types[next++] = value; | ||
} | ||
} | ||
return types; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.