mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Underlay
- Clamp overlay from 0 to 10 rather than 3 to 10 to fix everything appearing washed out - Fix normalized short backed float vectors being unpacked incorrectly - Set overlay in shadow instance component to fix shadows appearing red - Indicative of the ivec issue being present for divisor 0 vertex attributes
This commit is contained in:
parent
1dee5db9a1
commit
17130e22ea
3 changed files with 33 additions and 8 deletions
|
@ -207,7 +207,7 @@ public class IndirectComponent implements SourceComponent {
|
|||
return unpackUnsignedVector(fieldName, unsignedIntegerRepr, packed, size);
|
||||
} else if (repr instanceof FloatRepr floatRepr) {
|
||||
return unpackFloatVector(fieldName, floatRepr, packed, size);
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unknown repr " + repr);
|
||||
}
|
||||
|
@ -230,10 +230,10 @@ public class IndirectComponent implements SourceComponent {
|
|||
|
||||
private static GlslExpr unpackFloatVector(String fieldName, FloatRepr floatRepr, GlslStruct packed, int size) {
|
||||
return switch (floatRepr) {
|
||||
case NORMALIZED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackSnorm4x8");
|
||||
case NORMALIZED_UNSIGNED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackUnorm4x8");
|
||||
case NORMALIZED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackSnorm2x16");
|
||||
case NORMALIZED_UNSIGNED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackUnorm2x16");
|
||||
case NORMALIZED_BYTE -> unpackByteBuiltin(fieldName, packed, size, "unpackSnorm4x8");
|
||||
case NORMALIZED_UNSIGNED_BYTE -> unpackByteBuiltin(fieldName, packed, size, "unpackUnorm4x8");
|
||||
case NORMALIZED_SHORT -> unpackShortBuiltin(fieldName, packed, size, "unpackSnorm2x16");
|
||||
case NORMALIZED_UNSIGNED_SHORT -> unpackShortBuiltin(fieldName, packed, size, "unpackUnorm2x16");
|
||||
case NORMALIZED_INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.div(2147483647f)
|
||||
.clamp(-1, 1));
|
||||
case NORMALIZED_UNSIGNED_INT ->
|
||||
|
@ -260,7 +260,7 @@ public class IndirectComponent implements SourceComponent {
|
|||
.rsh(bitPos);
|
||||
args.add(perElement.apply(element));
|
||||
}
|
||||
return GlslExpr.call(outType + size, args);
|
||||
return GlslExpr.call(outType, args);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackShortBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
|
||||
|
@ -296,7 +296,7 @@ public class IndirectComponent implements SourceComponent {
|
|||
return GlslExpr.call(outType, args);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackBuiltin(String fieldName, GlslStruct packed, int size, String func) {
|
||||
private static GlslExpr unpackByteBuiltin(String fieldName, GlslStruct packed, int size, String func) {
|
||||
packed.addField("uint", fieldName);
|
||||
GlslExpr expr = UNPACKING_VARIABLE.access(fieldName)
|
||||
.callFunction(func);
|
||||
|
@ -308,6 +308,30 @@ public class IndirectComponent implements SourceComponent {
|
|||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackShortBuiltin(String fieldName, GlslStruct packed, int size, String func) {
|
||||
if (size == 2) {
|
||||
packed.addField("uint", fieldName);
|
||||
return UNPACKING_VARIABLE.access(fieldName)
|
||||
.callFunction(func);
|
||||
} else {
|
||||
var name0 = fieldName + "_" + 0;
|
||||
var name1 = fieldName + "_" + 1;
|
||||
packed.addField("uint", name0);
|
||||
packed.addField("uint", name1);
|
||||
GlslExpr xy = UNPACKING_VARIABLE.access(name0)
|
||||
.callFunction(func);
|
||||
|
||||
GlslExpr zw = UNPACKING_VARIABLE.access(name1)
|
||||
.callFunction(func);
|
||||
|
||||
if (size == 3) {
|
||||
return GlslExpr.call("vec3", List.of(xy.swizzle("xy"), zw.swizzle("x")));
|
||||
} else {
|
||||
return GlslExpr.call("vec4", List.of(xy, zw));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static GlslExpr unpackMatrix(String name, GlslStruct packed, MatrixElementType matrix) {
|
||||
var repr = matrix.repr();
|
||||
|
||||
|
|
|
@ -7,4 +7,5 @@ void flw_instanceVertex(in FlwInstance i) {
|
|||
flw_vertexTexCoord = (flw_vertexPos.xz - i.entityPosXZ) * 0.5 / i.radius + 0.5;
|
||||
|
||||
flw_vertexColor.a = i.alpha;
|
||||
flw_vertexOverlay = ivec2(0, 10);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void _flw_main() {
|
|||
// This can be removed once instancing uses sampler buffers, though
|
||||
// we may need a solution for the internal vertex format. Perhaps
|
||||
// pass as floats and convert to integers in the shader?
|
||||
ivec2 actualCoord = clamp(flw_fragOverlay, ivec2(3), ivec2(10));
|
||||
ivec2 actualCoord = clamp(flw_fragOverlay, 0, 10);
|
||||
|
||||
vec4 overlayColor = texelFetch(_flw_overlayTex, actualCoord, 0);
|
||||
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
|
||||
|
|
Loading…
Reference in a new issue