diff --git a/common/src/main/java/foundry/veil/api/client/property/InvertibleProperty.java b/common/src/main/java/foundry/veil/api/client/property/InvertibleProperty.java index 6c9550bb9..97bcde73b 100644 --- a/common/src/main/java/foundry/veil/api/client/property/InvertibleProperty.java +++ b/common/src/main/java/foundry/veil/api/client/property/InvertibleProperty.java @@ -4,6 +4,7 @@ import foundry.veil.api.flare.modifier.PropertyModifier; import gg.moonflower.molangcompiler.api.MolangExpression; import net.minecraft.client.renderer.ShaderInstance; +import org.jetbrains.annotations.Contract; import java.util.List; import java.util.Optional; @@ -21,16 +22,24 @@ public abstract class InvertibleProperty extends Property { public InvertibleProperty(PropertyRegistry.PropertyType type, T value) { super(type, value); - this.inverseValue = this.calculateInverse(this.cloneValue(value)); - this.overrideInverseValue = this.cloneValue(value); + this.inverseValue = this.invertAndMutate(this.cloneValue(value)); + this.overrideInverseValue = this.cloneValue(inverseValue); } - protected abstract T calculateInverse(T value); + @SuppressWarnings("UnstableApiUsage") + @Contract(mutates = "param") + protected abstract T invertAndMutate(T value); @Override public final void modify(T value, PropertyModifier.PropertyModifierMode mode, Optional> optionalMolang) { this.modifyPreInvert(value, mode, optionalMolang); - this.overrideInverseValue = this.calculateInverse(value); + + T originalOverrideValue = this.overrideValue; + this.overrideValue = overrideInverseValue; + this.modifyPreInvert(originalOverrideValue, PropertyModifier.PropertyModifierMode.REPLACE, Optional.empty()); + this.overrideValue = originalOverrideValue; + + this.invertAndMutate(this.overrideInverseValue); } public abstract void modifyPreInvert(T value, PropertyModifier.PropertyModifierMode mode, Optional> optionalMolang); @@ -44,7 +53,10 @@ public void applyInverseValue(String name, ShaderInstance shader) { @Override public void resetOverrideValue() { - super.resetOverrideValue(); - this.overrideInverseValue = this.inverseValue; + this.modifyPreInvert(this.value, PropertyModifier.PropertyModifierMode.REPLACE, Optional.empty()); + T originalOverrideValue = this.overrideValue; + this.overrideValue = overrideInverseValue; + this.modifyPreInvert(this.inverseValue, PropertyModifier.PropertyModifierMode.REPLACE, Optional.empty()); + this.overrideValue = originalOverrideValue; } } diff --git a/common/src/main/java/foundry/veil/api/client/property/Property.java b/common/src/main/java/foundry/veil/api/client/property/Property.java index 5cb7bead4..2eb301b79 100644 --- a/common/src/main/java/foundry/veil/api/client/property/Property.java +++ b/common/src/main/java/foundry/veil/api/client/property/Property.java @@ -50,7 +50,7 @@ protected void setQueries(MolangRuntime.Builder builder) { protected abstract T cloneValue(T value); public void resetOverrideValue() { - this.overrideValue = this.cloneValue(this.value); + this.modify(this.value, PropertyModifier.PropertyModifierMode.REPLACE, Optional.empty()); } public PropertyRegistry.PropertyType> getType() { diff --git a/common/src/main/java/foundry/veil/api/client/property/model/RotationModelProperty.java b/common/src/main/java/foundry/veil/api/client/property/model/RotationModelProperty.java index 604574be2..dada60252 100644 --- a/common/src/main/java/foundry/veil/api/client/property/model/RotationModelProperty.java +++ b/common/src/main/java/foundry/veil/api/client/property/model/RotationModelProperty.java @@ -21,11 +21,12 @@ @InapplicableProperty public class RotationModelProperty extends Vec3ModelProperty { private final Quaternionfc rotation; - private final Quaternionf overrideRotation = new Quaternionf(); + private final Quaternionf overrideRotation; public RotationModelProperty(Vector3f value) { super(value); - rotation = new Quaternionf().rotationXYZ(value.x() * Mth.DEG_TO_RAD, value.y() * Mth.DEG_TO_RAD, value.z() * Mth.DEG_TO_RAD); + this.rotation = new Quaternionf().rotationXYZ(value.x() * Mth.DEG_TO_RAD, value.y() * Mth.DEG_TO_RAD, value.z() * Mth.DEG_TO_RAD); + this.overrideRotation = new Quaternionf(this.rotation); } @Override diff --git a/common/src/main/java/foundry/veil/api/client/property/properties/Mat3Property.java b/common/src/main/java/foundry/veil/api/client/property/properties/Mat3Property.java index 09b6f4c2b..508583a9d 100644 --- a/common/src/main/java/foundry/veil/api/client/property/properties/Mat3Property.java +++ b/common/src/main/java/foundry/veil/api/client/property/properties/Mat3Property.java @@ -7,6 +7,7 @@ import gg.moonflower.molangcompiler.api.MolangExpression; import gg.moonflower.molangcompiler.api.MolangRuntime; import net.minecraft.client.renderer.ShaderInstance; +import org.jetbrains.annotations.Contract; import org.joml.Matrix3f; import org.joml.Matrix3fc; @@ -46,9 +47,11 @@ public void modifyPreInvert(Matrix3f value, PropertyModifier.PropertyModifierMod protected Matrix3f cloneValue(Matrix3f value) { return new Matrix3f(value); } - + + @SuppressWarnings("UnstableApiUsage") + @Contract(mutates = "param") @Override - protected Matrix3f calculateInverse(Matrix3f value) { + protected Matrix3f invertAndMutate(Matrix3f value) { return value.invert(); } } diff --git a/common/src/main/java/foundry/veil/api/client/property/properties/Mat4Property.java b/common/src/main/java/foundry/veil/api/client/property/properties/Mat4Property.java index 5704d969a..c0fec12ab 100644 --- a/common/src/main/java/foundry/veil/api/client/property/properties/Mat4Property.java +++ b/common/src/main/java/foundry/veil/api/client/property/properties/Mat4Property.java @@ -7,6 +7,7 @@ import gg.moonflower.molangcompiler.api.MolangExpression; import gg.moonflower.molangcompiler.api.MolangRuntime; import net.minecraft.client.renderer.ShaderInstance; +import org.jetbrains.annotations.Contract; import org.joml.Matrix4f; import org.joml.Matrix4fc; @@ -46,9 +47,11 @@ public void modifyPreInvert(Matrix4f value, PropertyModifier.PropertyModifierMod protected Matrix4f cloneValue(Matrix4f value) { return new Matrix4f(value); } - + + @SuppressWarnings("UnstableApiUsage") + @Contract(mutates = "param") @Override - protected Matrix4f calculateInverse(Matrix4f value) { + protected Matrix4f invertAndMutate(Matrix4f value) { return value.invert(); } } diff --git a/common/src/main/java/foundry/veil/api/client/property/properties/Sampler2DProperty.java b/common/src/main/java/foundry/veil/api/client/property/properties/Sampler2DProperty.java index f10c6a7cc..00f522105 100644 --- a/common/src/main/java/foundry/veil/api/client/property/properties/Sampler2DProperty.java +++ b/common/src/main/java/foundry/veil/api/client/property/properties/Sampler2DProperty.java @@ -20,13 +20,13 @@ public class Sampler2DProperty extends Property { public static final MapCodec CODEC = ResourceLocation.CODEC.fieldOf("value").xmap(Sampler2DProperty::new, property -> property.source); public Sampler2DProperty(ResourceLocation value) { - super(PropertyRegistry.SAMPLER2D.get(), Minecraft.getInstance().getTextureManager().getTexture(value)); + super(PropertyRegistry.SAMPLER2D.get(), null); this.source = value; } @Override public void applyValue(String name, ShaderInstance shader) { - shader.setSampler(name, this.overrideValue.getId()); + shader.setSampler(name, Minecraft.getInstance().getTextureManager().getTexture(source).getId()); // Shader must be re-applied for the sampler to take effect shader.apply(); } diff --git a/common/src/main/java/foundry/veil/api/client/property/properties/TimeProperty.java b/common/src/main/java/foundry/veil/api/client/property/properties/TimeProperty.java index 870947454..13a0bb934 100644 --- a/common/src/main/java/foundry/veil/api/client/property/properties/TimeProperty.java +++ b/common/src/main/java/foundry/veil/api/client/property/properties/TimeProperty.java @@ -34,8 +34,8 @@ private TimeProperty() { public void applyValue(String name, ShaderInstance shader) { Uniform uniform = shader.getUniform(name); if (uniform != null) { - float time = Minecraft.getInstance().getFrameTimeNs() * 1e-9f; - uniform.set(this.value.set(time / 20.0f, time, 2.0f * time, Mth.sin(time))); + float time = System.nanoTime() * 1e-9f; + uniform.set(this.value.set(time / 20.0f, time, 2.0f * time, Mth.sin(time % Mth.TWO_PI))); } } diff --git a/common/src/main/java/foundry/veil/api/client/render/rendertype/VeilRenderType.java b/common/src/main/java/foundry/veil/api/client/render/rendertype/VeilRenderType.java index 59b2ef03d..f07bfac2f 100644 --- a/common/src/main/java/foundry/veil/api/client/render/rendertype/VeilRenderType.java +++ b/common/src/main/java/foundry/veil/api/client/render/rendertype/VeilRenderType.java @@ -281,15 +281,15 @@ private LayeredRenderType(RenderType defaultValue, List layers, Stri public void draw(@NotNull MeshData meshData) { super.draw(meshData); if (BufferUploader.lastImmediateBuffer != null) { - ShaderInstance shader = RenderSystem.getShader(); - if (shader == null) { - return; - } Matrix4f modelViewMatrix = RenderSystem.getModelViewMatrix(); Matrix4f projectionMatrix = RenderSystem.getProjectionMatrix(); for (RenderType layer : this.layers) { layer.setupRenderState(); + ShaderInstance shader = RenderSystem.getShader(); + if (shader == null) { + return; + } BufferUploader.lastImmediateBuffer.drawWithShader(modelViewMatrix, projectionMatrix, shader); layer.clearRenderState(); } diff --git a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectLayer.java b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectLayer.java index 5598defc5..ea37f8c9c 100644 --- a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectLayer.java +++ b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectLayer.java @@ -77,7 +77,10 @@ public void render(EffectHost host, MatrixStack matrixStack, float partialTick, } ControllerManager controllerManager = FlareEffectManager.getInstance().getControllerManager(); - for (PropertyModifier modifier : this.originalModifiers) { + + List> size = this.originalModifiers; + for (int i = 0, propertyModifiersSize = size.size(); i < propertyModifiersSize; i++) { + PropertyModifier modifier = size.get(i); controllerManager.getOrCreateController(modifier.inputControllerName(), host).update(partialTick); } diff --git a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectTemplate.java b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectTemplate.java index 473a143f3..b41ceb56f 100644 --- a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectTemplate.java +++ b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareEffectTemplate.java @@ -33,7 +33,9 @@ public FlareEffectTemplate(List effectLayers) { } public void render(EffectHost host, MatrixStack matrixStack, float partialTick, @Nullable Map shellOverrides) { - for (FlareEffectLayer effectLayer : this.effectLayers) { + List layers = this.effectLayers; + for (int i = 0, size = layers.size(); i < size; i++) { + FlareEffectLayer effectLayer = layers.get(i); effectLayer.render(host, matrixStack, partialTick, shellOverrides); } } diff --git a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareMaterial.java b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareMaterial.java index 0265023fc..c619f4bc7 100644 --- a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareMaterial.java +++ b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareMaterial.java @@ -13,6 +13,7 @@ import foundry.veil.api.flare.modifier.PropertyModifier; import foundry.veil.api.util.CodecUtil; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; @@ -40,7 +41,8 @@ public final class FlareMaterial { private final String clazz; private final ResourceLocation renderTypeLocation; private final boolean randomizeSeed; - private final Map> properties; + private final Object2ObjectArrayMap> properties; + private final List>> propertyEntries; public FlareMaterial(String clazz, ResourceLocation renderTypeLocation, boolean randomizeSeed, Map> properties) { @@ -51,14 +53,17 @@ public FlareMaterial(String clazz, ResourceLocation renderTypeLocation, boolean this.clazz = clazz; this.renderTypeLocation = renderTypeLocation; this.randomizeSeed = randomizeSeed; - this.properties = Map.copyOf(properties); + this.properties = new Object2ObjectArrayMap<>(properties); + this.propertyEntries = this.properties.object2ObjectEntrySet().stream().toList(); } public void applyProperties(EffectHost host, @Nullable ShaderInstance shader, Map>> modifiers) { if (shader == null) { return; } - for (Map.Entry> entry : this.properties.entrySet()) { + List>> entries = this.propertyEntries; + for (int i = 0, size = entries.size(); i < size; i++) { + Map.Entry> entry = entries.get(i); Property property = entry.getValue(); Class propertyClass = property.getClass(); @@ -82,7 +87,10 @@ public void resetProperties(EffectHost host, @Nullable ShaderInstance shader) { if (shader == null) { return; } - for (Property property : this.properties.values()) { + List>> entries = this.propertyEntries; + for (int i = 0, size = entries.size(); i < size; i++) { + Object2ObjectMap.Entry> entry = entries.get(i); + Property property = entry.getValue(); if (property.getClass().getAnnotation(ModelProperty.class) != null) { continue; } diff --git a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareModel.java b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareModel.java index fa1e5427c..ca49ef4af 100644 --- a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareModel.java +++ b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareModel.java @@ -20,10 +20,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; -import org.joml.Matrix4fStack; -import org.joml.Vector3f; -import org.joml.Vector3fc; +import org.joml.*; import java.util.List; import java.util.Map; @@ -41,8 +38,9 @@ public class FlareModel { CodecUtil.VECTOR3FC_CODEC.fieldOf("scaleOffset").forGetter(FlareModel::getScaleOffset), CodecUtil.singleOrList(FlareMaterial.CODEC).fieldOf("materials").forGetter(FlareModel::getMaterials) ).apply(instance, FlareModel::new)); - - public static final Matrix4f dummyMatrix = new Matrix4f(); + + public static final Matrix4f MODEL_TO_LOCAL_MATRIX = new Matrix4f(); + public static final Matrix4f MATRIX4F = new Matrix4f(); public static final String POSITION_PROPERTY_NAME = "model::position"; public static final String ROTATION_PROPERTY_NAME = "model::rotation"; @@ -66,43 +64,47 @@ public FlareModel(ResourceLocation shell, Vector3fc position, Vector3fc rotation public void render(EffectHost host, MatrixStack matrixStack, Map>> modifiers, @Nullable Map shellOverrides) { Vector3fc positionOffset = this.positionOffset.getValue(); + Quaternionfc rotationOffset = this.rotationOffset.getRotation(); Vector3fc scaleOffset = this.scaleOffset.getValue(); - - matrixStack.matrixPush(); - matrixStack.translate(positionOffset.x(), positionOffset.y(), positionOffset.z()); - matrixStack.rotate(this.rotationOffset.getRotation()); - matrixStack.applyScale(scaleOffset.x(), scaleOffset.y(), scaleOffset.z()); + + MODEL_TO_LOCAL_MATRIX.set(matrixStack.position()); + MODEL_TO_LOCAL_MATRIX.translate(positionOffset.x(), positionOffset.y(), positionOffset.z()); + MODEL_TO_LOCAL_MATRIX.rotate(rotationOffset); + MODEL_TO_LOCAL_MATRIX.scale(scaleOffset.x(), scaleOffset.y(), scaleOffset.z()); + + BakedShell bakedShell = (shellOverrides != null && shellOverrides.containsKey(this.shell)) ? + shellOverrides.get(this.shell) : + FlareEffectManager.getInstance().getBakedShell(this.shell); + Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); - + this.modelToWorld.modify( - matrixStack.position().translateLocal((float) cameraPos.x, (float) cameraPos.y, (float) cameraPos.z, dummyMatrix), + MODEL_TO_LOCAL_MATRIX.translate((float) cameraPos.x, (float) cameraPos.y, (float) cameraPos.z, MATRIX4F), PropertyModifier.PropertyModifierMode.REPLACE, Optional.empty() ); - BakedShell bakedShell = (shellOverrides != null && shellOverrides.containsKey(this.shell)) ? - shellOverrides.get(this.shell) : - FlareEffectManager.getInstance().getBakedShell(this.shell); - - Matrix4fStack stack = RenderSystem.getModelViewStack(); - stack.pushMatrix(); - stack.mul(matrixStack.position()); + Matrix4fStack modelViewStack = RenderSystem.getModelViewStack(); + MATRIX4F.set(modelViewStack); + modelViewStack.mul(MODEL_TO_LOCAL_MATRIX); RenderSystem.applyModelViewMatrix(); - + VertexArray vertexArray = bakedShell.getVertexArray(); vertexArray.bind(); - for (FlareMaterial material : this.materials) { + + List flareMaterials = this.materials; + for (int i = 0, size = flareMaterials.size(); i < size; i++) { + FlareMaterial material = flareMaterials.get(i); RenderType renderType = VeilRenderType.get(material.renderTypeLocation()); if (renderType == null) { continue; } - + this.draw(renderType, vertexArray, host, material, modifiers); } VertexArray.unbind(); - matrixStack.matrixPop(); - - stack.popMatrix(); + + modelViewStack.set(MATRIX4F); RenderSystem.applyModelViewMatrix(); } @@ -123,7 +125,9 @@ private void draw(RenderType renderType, VertexArray vertexArray, EffectHost hos vertexArray.clear(renderType); if (renderType instanceof VeilRenderType.LayeredRenderType layeredRenderType) { - for (RenderType layer : layeredRenderType.getLayers()) { + List layers = layeredRenderType.getLayers(); + for (int i = 0, size = layers.size(); i < size; i++) { + RenderType layer = layers.get(i); vertexArray.setup(layer); currentShader = RenderSystem.getShader(); material.applyProperties(host, currentShader, modifiers); diff --git a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareSubModule.java b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareSubModule.java index a5a1a9d06..a51816313 100644 --- a/common/src/main/java/foundry/veil/api/flare/data/effect/FlareSubModule.java +++ b/common/src/main/java/foundry/veil/api/flare/data/effect/FlareSubModule.java @@ -37,7 +37,9 @@ public void render(EffectHost host, MatrixStack matrixStack, float partialTick) } public void render(EffectHost host, MatrixStack matrixStack, float partialTick, @Nullable Map shellOverrides) { - for (ResourceLocation templateLocation : this.templates) { + List resourceLocations = this.templates; + for (int i = 0, size = resourceLocations.size(); i < size; i++) { + ResourceLocation templateLocation = resourceLocations.get(i); FlareEffectTemplate template = FlareEffectManager.getTemplate(templateLocation); if (template == null) { LOGGER.error("Template {} could not be found!", templateLocation); diff --git a/common/src/main/java/foundry/veil/api/flare/model/ShellBakery.java b/common/src/main/java/foundry/veil/api/flare/model/ShellBakery.java index a0c98436b..9b1a4859c 100644 --- a/common/src/main/java/foundry/veil/api/flare/model/ShellBakery.java +++ b/common/src/main/java/foundry/veil/api/flare/model/ShellBakery.java @@ -60,7 +60,7 @@ public static FlareBakedQuad bakeQuad( } private static float[] makeVertices(ShellFaceUV uvs, Vector3f normal, Direction direction, float[] posDiv16, @Nullable ShellElementRotation rotation) { - float[] vertexData = new float[20]; + float[] vertexData = new float[32]; Matrix4f rotationMatrix = null; if (rotation != null) { float angle = rotation.angle() * Mth.DEG_TO_RAD; @@ -103,12 +103,12 @@ private static float[] setupShape(Vector3fc min, Vector3fc max) { } private static void fillVertex(float[] vertexData, int vertexIndex, Vector3f pos, Vector3f normal, ShellFaceUV shellFaceUV) { - int i = vertexIndex * 5; + int i = vertexIndex * 8; vertexData[i] = pos.x(); vertexData[i + 1] = pos.y(); vertexData[i + 2] = pos.z(); - vertexData[i + 3] = normal.z(); - vertexData[i + 4] = normal.z(); + vertexData[i + 3] = normal.x(); + vertexData[i + 4] = normal.y(); vertexData[i + 5] = normal.z(); vertexData[i + 6] = shellFaceUV.getU(vertexIndex) / 16.0F; vertexData[i + 7] = shellFaceUV.getV(vertexIndex) / 16.0F; diff --git a/common/src/main/java/foundry/veil/api/flare/modifier/PropertyModifier.java b/common/src/main/java/foundry/veil/api/flare/modifier/PropertyModifier.java index 050f0149e..e333a193c 100644 --- a/common/src/main/java/foundry/veil/api/flare/modifier/PropertyModifier.java +++ b/common/src/main/java/foundry/veil/api/flare/modifier/PropertyModifier.java @@ -128,7 +128,7 @@ public static void modifyProperty(EffectHost host, @Nullable String clazz, Prope return; } for (PropertyModifier modifier : modifiers) { - if (clazz != null && !Objects.equals(clazz, modifier.clazz)) { + if (clazz != null && modifier.clazz != null && !modifier.clazz.equals(clazz)) { continue; } modifier.apply(host, property); diff --git a/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/plume.json b/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/plume.json index b6470ea0a..0c00a59e5 100644 --- a/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/plume.json +++ b/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/plume.json @@ -3,7 +3,7 @@ "name": "plume", "model": { "path": "veil:cylinder", - "positionOffset": [0, -9, 0], + "positionOffset": [0, 0, 0], "rotationOffset": [0, 0, 0], "scaleOffset": [2, 2, 2], "materials": { @@ -106,8 +106,8 @@ ], [ {"time": 0.0, "value": 0.0, "easing": "ease_in_quad"}, - {"time": 0.05, "value": 1.8, "easing": "ease_out_quad"}, - {"time": 1.0, "value": 9.0, "easing": "linear"} + {"time": 0.05, "value": 0.0, "easing": "ease_out_quad"}, + {"time": 1.0, "value": 0.0, "easing": "linear"} ], [ {"time": 0.0, "value": 0.0, "easing": "linear"}, diff --git a/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/splash.json b/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/splash.json index 82031d464..b9c5db3f4 100644 --- a/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/splash.json +++ b/common/src/main/resources/resourcepacks/test_effects/assets/veil/flare/templates/splash.json @@ -47,9 +47,9 @@ [ {"time": 0.0, "value": 0.0, "easing": "ease_in_quad"}, {"time": 0.5, "value": 1.5, "easing": "ease_in_quad"}, - {"time": 0.75, "value": 1.25, "easing": "ease_in_quad"}, - {"time": 0.8, "value": 1.0, "easing": "ease_in_quad"}, - {"time": 1.0, "value": 0.0, "easing": "ease_in_quad"} + {"time": 0.6, "value": 1.5, "easing": "ease_in_quad"}, + {"time": 0.8, "value": 0.75, "easing": "ease_out_quad"}, + {"time": 0.9, "value": 0.0, "easing": "ease_in_quad"} ], [ {"time": 0.0, "value": 1.0, "easing": "ease_out_quad"} diff --git a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/rendertypes/flare/splash.json b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/rendertypes/flare/splash.json index 6751c7f60..c70a35b31 100644 --- a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/rendertypes/flare/splash.json +++ b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/rendertypes/flare/splash.json @@ -21,11 +21,11 @@ { "type": "minecraft:write_mask", "color": true, - "depth": false + "depth": true }, { "type": "minecraft:cull", - "face": "none" + "face": "back" } ] } diff --git a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/base.vsh b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/base.vsh index c1aa50d2c..da5239d1f 100644 --- a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/base.vsh +++ b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/base.vsh @@ -1,22 +1,28 @@ + +uniform mat4 ModelToWorld; +uniform mat4 IModelToWorld; +uniform mat4 ModelViewMat; +uniform mat4 ProjMat; + layout(location = 0) in vec3 Position; layout(location = 1) in vec4 Color; layout(location = 2) in vec2 UV0; layout(location = 3) in vec2 UV2; layout(location = 4) in vec3 Normal; -uniform mat4 ModelViewMat; -uniform mat4 ProjMat; -uniform mat3 NormalMat; - out vec2 texCoord0; out vec4 vertexColor; out vec3 vertexNormal; +out vec2 texCoord1; + void main() { - vec4 pos = ModelViewMat * vec4(Position, 1.0); - gl_Position = ProjMat * pos; + vec4 pos = vec4(Position, 1.0); + gl_Position = ProjMat * ModelViewMat * pos; vertexNormal = Normal; texCoord0 = UV0; + texCoord1 = UV0; + texCoord1.x += fract(5.0*Normal.x+3.1415926535*Normal.z); vertexColor = Color; } diff --git a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/plume.fsh b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/plume.fsh index 605ecd91e..7e6a7df58 100644 --- a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/plume.fsh +++ b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/plume.fsh @@ -10,11 +10,13 @@ in vec2 texCoord0; in vec4 vertexColor; in vec3 vertexNormal; +in vec2 texCoord1; + out vec4 fragColor; void main() { - float uvTime = _Time.x * Speed * 1000.0; + float uvTime = _Time.y * Speed; fragColor = vec4(texCoord0.y * 0.5 / (1.0 - texCoord0.y)) * ColorMultiplier; - fragColor *= texture(Noise, vec2(texCoord0.x * 0.5 * ColorMultiplier.a,texCoord0.y * 0.1 + uvTime)).a; + fragColor *= texture(Noise, vec2(texCoord1.x * 0.5 * ColorMultiplier.a, texCoord1.y * 0.041 + uvTime)).a; } diff --git a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/rainbow.fsh b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/rainbow.fsh index e456350de..4e0f5379d 100644 --- a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/rainbow.fsh +++ b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/rainbow.fsh @@ -17,6 +17,4 @@ void main() { float cosT = cos(time - 10.0 * texCoord0.y); float sinT = sin(time - 10.0 * texCoord0.y); fragColor = vec4(1+cosT, 1.0 + sinT*cosT, 1.0+sinT, texCoord0.y * 0.1 / (1.0 - texCoord0.y)) * ColorMultiplier; -// fragColor = vec4(1.0, 1.0, 1.0, 1.0) * ColorMultiplier; -// fragColor *= 1 - texCoord0.y; } diff --git a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/splash.fsh b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/splash.fsh index 57c4f6dd4..4673c502d 100644 --- a/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/splash.fsh +++ b/common/src/main/resources/resourcepacks/test_effects/assets/veil/pinwheel/shaders/program/flare/splash.fsh @@ -13,12 +13,12 @@ in vec3 vertexNormal; out vec4 fragColor; void main() { - float edginess = (1.0 - abs((texCoord0.x + Time) * 2.0 - (1.0 + Time)) / 2.0) + texCoord0.y; + float edginess = (1.0 - abs((texCoord0.x + 2.0*Time) * 2.0 - (1.0 + 2.0*Time)) / 2.0) + texCoord0.y; fragColor = texture(Sampler0, vec2(texCoord0.x, (texCoord0.y * Shift) / 32 )); fragColor *= 1.0 - fragColor.a; - fragColor *= texCoord0.y * 0.125 / (1.05 - texCoord0.y); + fragColor *= min(texCoord0.y * 0.125 / (0.525 - 0.5*texCoord0.y), 2.0); fragColor.rgb *= Blue; - fragColor *= edginess * edginess; - if (fragColor.a < 0.1) discard; + fragColor *= edginess; + if (fragColor.a < 0.01) discard; }