Throwing shade

- Actually register instance types.
- Update instance shaders to compile with new flywheel.
- Add cull shaders.
- Update flywheel dep in mods.toml.
- Bump flywheel build.
This commit is contained in:
Jozufozu 2024-01-15 16:25:15 -08:00
parent 45c9e2c87a
commit e892003eb5
11 changed files with 118 additions and 73 deletions

View file

@ -23,7 +23,7 @@ use_parchment = true
# dependency versions
registrate_version = MC1.20-1.3.3
flywheel_minecraft_version = 1.20.1
flywheel_version = 1.0.0-alpha-11
flywheel_version = 1.0.0-alpha-14
jei_minecraft_version = 1.20.1
jei_version = 15.2.0.22
curios_minecraft_version = 1.20.1

View file

@ -18,6 +18,7 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsClient;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.outliner.Outliner;
import com.simibubi.create.foundation.ponder.element.WorldSectionElement;
import com.simibubi.create.foundation.render.AllInstanceTypes;
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.CreateContexts;
import com.simibubi.create.foundation.render.SuperByteBufferCache;
@ -63,6 +64,8 @@ public class CreateClient {
modEventBus.addListener(CreateClient::clientInit);
modEventBus.addListener(AllParticleTypes::registerFactories);
AllInstanceTypes.init();
MODEL_SWAPPER.registerListeners(modEventBus);
ZAPPER_RENDER_HANDLER.registerListeners(forgeEventBus);

View file

@ -5,7 +5,7 @@ license="MIT"
[[mods]]
modId="create"
# The Implementation-Version property in the jar's MANIFEST.MF file will be used as the mod version at runtime
# The Implementation-Version property in the jar's MANIFEST.MF file will be used as the mod version at runtime
version="${file.jarVersion}"
displayName="Create"
#updateJSONURL=""
@ -33,6 +33,6 @@ Technology that empowers the player.'''
[[dependencies.create]]
modId="flywheel"
mandatory=true
versionRange="[0.6.10,0.6.11)"
versionRange="[1.0.0-alpha,2.0)"
ordering="AFTER"
side="CLIENT"

View file

@ -1,33 +1,23 @@
#define PI 3.1415926538
#include "flywheel:core/quaternion.glsl"
#include "flywheel:core/matutils.glsl"
#include "flywheel:util/quaternion.glsl"
#include "flywheel:util/matrix.glsl"
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
const float uTime = 0.;
void vertex(inout Vertex v, Belt instance) {
v.pos = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
void flw_instanceVertex(in FlwInstance instance) {
flw_vertexPos = vec4(rotateVertexByQuat(flw_vertexPos.xyz - .5, instance.rotation) + instance.pos + .5, 1.);
v.normal = rotateVertexByQuat(v.normal, instance.rotation);
flw_vertexNormal = rotateVertexByQuat(flw_vertexNormal, instance.rotation);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
v.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
v.light = instance.light;
flw_vertexTexCoord = flw_vertexTexCoord - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
flw_vertexLight = instance.light;
#if defined(DEBUG_RAINBOW)
v.color = instance.color;
flw_vertexColor = instance.color;
#endif
}

View file

@ -1,26 +1,15 @@
#define PI 3.1415926538
#include "flywheel:util/matrix.glsl"
#include "flywheel:util/quaternion.glsl"
#include "flywheel:core/matutils.glsl"
#include "flywheel:core/quaternion.glsl"
const float uTime = 0.;
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
void vertex(inout Vertex v, Actor instance) {
void flw_instanceVertex(in FlwInstance instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec3 rotated = rotateVertexByQuat(flw_vertexPos.xyz - instance.rotationCenter, kineticRot) + instance.rotationCenter;
v.pos = rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5;
v.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
v.light = instance.light;
flw_vertexPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
flw_vertexNormal = rotateVertexByQuat(rotateVertexByQuat(flw_vertexNormal, kineticRot), instance.rotation);
flw_vertexLight = instance.light;
}

View file

@ -0,0 +1,11 @@
#define PI 3.1415926538
#include "flywheel:util/quaternion.glsl"
#include "flywheel:util/matrix.glsl"
const float uTime = 0.;
void flw_transformBoundingSphere(in FlwInstance instance, inout vec3 center, inout float radius) {
// FIXME: this is incorrect, but it compiles
center = rotateVertexByQuat(center - .5, instance.rotation) + instance.pos + .5;
}

View file

@ -0,0 +1,14 @@
#include "flywheel:util/matrix.glsl"
#include "flywheel:util/quaternion.glsl"
const float uTime = 0.;
void flw_transformBoundingSphere(in FlwInstance instance, inout vec3 center, inout float radius) {
// FIXME: this is incorrect, but it compiles
float degrees = instance.offset + uTime * instance.speed / 20.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(center - instance.rotationCenter, kineticRot) + instance.rotationCenter;
center = rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5;
}

View file

@ -0,0 +1,34 @@
#define PI 3.1415926538
const float uTime = 0.;
#include "flywheel:util/matrix.glsl"
#include "flywheel:util/quaternion.glsl"
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
void flw_transformBoundingSphere(in FlwInstance flap, inout vec3 center, inout float radius) {
// FIXME: this is incorrect, but it compiles
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(center - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
center = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
}

View file

@ -0,0 +1,20 @@
#define PI 3.1415926538
#include "flywheel:util/matrix.glsl"
const float uTime = 0.;
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
void flw_transformBoundingSphere(in FlwInstance instance, inout vec3 center, inout float radius) {
// FIXME: this is incorrect, but it compiles
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(center - .5, 1.);
center = worldPos.xyz + instance.pos + .5;
}

View file

@ -1,18 +1,9 @@
#define PI 3.1415926538
#include "flywheel:core/matutils.glsl"
#include "flywheel:core/quaternion.glsl"
const float uTime = 0.;
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#include "flywheel:util/matrix.glsl"
#include "flywheel:util/quaternion.glsl"
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
@ -31,16 +22,16 @@ float getFlapAngle(float flapness, float intensity, float scale) {
return degrees;
}
void vertex(inout Vertex v, Flap flap) {
void flw_instanceVertex(in FlwInstance flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
vec3 rotated = rotateVertexByQuat(flw_vertexPos.xyz - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
v.pos = rotated;
v.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
v.light = flap.light;
flw_vertexPos = vec4(rotated, 1.);
flw_vertexNormal = rotateVertexByQuat(rotateVertexByQuat(flw_vertexNormal, flapRotation), orientation);
flw_vertexLight = flap.light;
}

View file

@ -1,15 +1,8 @@
#define PI 3.1415926538
#include "flywheel:core/matutils.glsl"
#include "flywheel:util/matrix.glsl"
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
const float uTime = 0.;
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
@ -18,16 +11,16 @@ mat4 kineticRotation(float offset, float speed, vec3 axis) {
return rotate(axis, angle);
}
void vertex(inout Vertex v, Rotating instance) {
void flw_instanceVertex(in FlwInstance instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
v.pos = worldPos.xyz + instance.pos + .5;
vec4 worldPos = spin * vec4(flw_vertexPos.xyz - .5, 1.);
flw_vertexPos = vec4(worldPos.xyz + instance.pos + .5, 1.);
v.normal = modelToNormal(spin) * v.normal;
v.light = instance.light;
flw_vertexNormal = modelToNormal(spin) * flw_vertexNormal;
flw_vertexLight = instance.light;
#if defined(DEBUG_RAINBOW)
v.color = instance.color;
flw_vertexColor = instance.color;
#endif
}