Skip to content

Commit

Permalink
Added dynamic cubemap texture init
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocelot5836 committed Nov 1, 2024
1 parent 3e21c32 commit 931bfe3
Show file tree
Hide file tree
Showing 41 changed files with 42 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package foundry.veil.api.client.color;

import net.minecraft.util.Mth;

import com.mojang.serialization.Codec;
import net.minecraft.util.Mth;

/**
* A simple color class that can be used to represent a color in RGBA format with utility functions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import foundry.veil.api.client.color.theme.IThemeProperty;
import foundry.veil.api.client.tooltip.Tooltippable;
import net.minecraft.Util;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;

/**
* A color theme is a collection of colors. The colors can be accessed by name. Themes are intended to be used for color schemes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package foundry.veil.api.client.editor;

import foundry.veil.api.client.render.VeilRenderSystem;
import imgui.ImGui;
import imgui.type.ImBoolean;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.lwjgl.system.NativeResource;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package foundry.veil.api.client.editor;

import foundry.veil.Veil;
import foundry.veil.api.client.imgui.VeilImGuiUtil;
import foundry.veil.api.client.registry.VeilResourceEditorRegistry;
import foundry.veil.api.resource.editor.ResourceFileEditor;
import foundry.veil.api.util.CompositeReloadListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package foundry.veil.api.client.necromancer;

import com.mojang.blaze3d.vertex.PoseStack;
import foundry.veil.api.client.graveyard.skeleton.InterpolatedSkeleton;
import foundry.veil.api.client.graveyard.skeleton.InterpolatedSkeletonParent;
import net.minecraft.client.renderer.MultiBufferSource;

// W.I.P. replacement for graveyard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import foundry.veil.Veil;
import foundry.veil.api.client.render.VeilRenderSystem;
import foundry.veil.api.client.render.VeilVertexFormat;
import foundry.veil.api.client.render.shader.VeilShaders;
import foundry.veil.ext.VertexBufferExtension;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;

import java.util.Map;
import java.util.Set;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.jetbrains.annotations.NotNull;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,33 @@
import java.io.IOException;

import static org.lwjgl.opengl.GL11C.*;
import static org.lwjgl.opengl.GL13C.GL_TEXTURE_CUBE_MAP_POSITIVE_X;

public class DynamicCubemapTexture extends CubemapTexture {

public void init(int width, int height) {
try (NativeImage image = new NativeImage(width, height, true)) {
this.upload(image);
}
}

public void upload(NativeImage image) {
this.bind();

int width = image.getWidth();
int height = image.getHeight();
RenderSystem.assertOnRenderThreadOrInit();
NativeImageAccessor accessor = (NativeImageAccessor) (Object) image;
accessor.invokeCheckAllocated();
GlStateManager._pixelStore(GL_UNPACK_ROW_LENGTH, 0);
GlStateManager._pixelStore(GL_UNPACK_SKIP_ROWS, 0);
GlStateManager._pixelStore(GL_UNPACK_SKIP_PIXELS, 0);
image.format().setUnpackPixelStoreState();
for (int i = 0; i < 6; i++) {
GlStateManager._texSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, width, height, image.format().glFormat(), GL_UNSIGNED_BYTE, accessor.getPixels());
}
}

public void upload(Direction face, NativeImage image) {
this.upload(getGlFace(face), image);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package foundry.veil.api.client.ui.util;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.util.Mth;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.util.Mth;

/**
* A utility class to manage and apply animations to a {@link PoseStack}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import foundry.veil.api.client.render.MatrixStack;
import foundry.veil.api.client.render.VeilRenderBridge;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;
import foundry.veil.api.util.CodecUtil;
import net.minecraft.core.Holder;
import net.minecraft.util.ExtraCodecs;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import foundry.veil.api.util.CodecUtil;
import net.minecraft.core.Holder;
import net.minecraft.resources.RegistryFileCodec;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
* @param maxLifetime
* @param loop Whether the emitter will loop. If <code>true</code>, the emitter will reset after maxLifetime ticks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package foundry.veil.api.quasar.data;

import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import foundry.veil.Veil;
import foundry.veil.api.quasar.data.module.ModuleType;
import foundry.veil.api.quasar.data.module.ParticleModuleData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;
import foundry.veil.api.quasar.data.module.ParticleModuleData;
import foundry.veil.api.quasar.particle.QuasarParticle;
import foundry.veil.api.quasar.particle.RenderData;
import foundry.veil.api.quasar.particle.RenderStyle;
import foundry.veil.api.quasar.particle.SpriteData;
import foundry.veil.api.quasar.registry.RenderStyleRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import foundry.veil.api.quasar.emitters.module.UpdateParticleModule;
import foundry.veil.api.quasar.particle.QuasarParticle;
import foundry.veil.api.quasar.particle.RenderData;
import foundry.veil.api.quasar.registry.RenderStyleRegistry;
import net.minecraft.util.Mth;
import org.joml.Vector3d;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import foundry.veil.Veil;
import foundry.veil.api.quasar.registry.EmitterShapeRegistry;
import foundry.veil.api.util.CodecUtil;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import org.joml.Vector3d;
import org.joml.Vector3dc;
import org.joml.Vector3fc;

import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;

public interface EmitterShape {

Vector3d getPoint(RandomSource randomSource, Vector3fc dimensions, Vector3fc rotation, Vector3dc position, boolean fromSurface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.joml.*;

import java.lang.Math;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.List;

public class RenderData {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import foundry.veil.api.quasar.data.QuasarParticleData;
import foundry.veil.api.quasar.registry.RenderStyleRegistry;
import foundry.veil.api.util.CodecUtil;
Expand All @@ -13,8 +12,6 @@
import org.joml.Vector3f;
import org.joml.Vector3fc;

import java.util.Locale;

public interface RenderStyle {
Codec<RenderStyle> CODEC = CodecUtil.registryOrLegacyCodec(RenderStyleRegistry.REGISTRY);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package foundry.veil.api.quasar.registry;

import com.mojang.serialization.Codec;
import foundry.veil.Veil;
import foundry.veil.api.client.render.post.PostPipeline;
import foundry.veil.api.client.render.post.stage.BlitPostStage;
import foundry.veil.api.client.render.post.stage.CopyPostStage;
import foundry.veil.api.client.render.post.stage.DepthFunctionPostStage;
import foundry.veil.api.client.render.post.stage.MaskPostStage;
import foundry.veil.api.quasar.emitters.shape.*;
import foundry.veil.platform.registry.RegistrationProvider;
import net.minecraft.core.Registry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package foundry.veil.api.quasar.registry;

import foundry.veil.Veil;
import foundry.veil.api.quasar.emitters.shape.*;
import foundry.veil.api.quasar.particle.RenderData;
import foundry.veil.api.quasar.particle.RenderStyle;
import foundry.veil.platform.registry.RegistrationProvider;
import net.minecraft.core.Registry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package foundry.veil.api.resource.type;

import foundry.veil.api.resource.VeilResourceInfo;
import foundry.veil.api.resource.VeilResource;
import foundry.veil.api.resource.VeilResourceAction;
import foundry.veil.api.resource.VeilResourceInfo;
import net.minecraft.server.packs.resources.ResourceMetadata;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package foundry.veil.api.resource.type;

import foundry.veil.api.client.imgui.VeilImGuiUtil;
import foundry.veil.api.resource.VeilResourceInfo;
import foundry.veil.api.resource.VeilResource;
import foundry.veil.api.resource.VeilResourceAction;
import foundry.veil.api.resource.VeilResourceInfo;
import imgui.ImGui;
import imgui.flag.ImGuiCol;
import imgui.flag.ImGuiStyleVar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package foundry.veil.api.resource.type;

import foundry.veil.api.resource.VeilResourceInfo;
import foundry.veil.api.resource.VeilResource;
import foundry.veil.api.resource.VeilResourceAction;
import foundry.veil.api.resource.VeilResourceInfo;

import java.util.List;

Expand Down
7 changes: 2 additions & 5 deletions common/src/main/java/foundry/veil/api/util/CodecUtil.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package foundry.veil.api.util;

import com.mojang.datafixers.util.Either;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.*;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import foundry.veil.Veil;
import foundry.veil.api.quasar.emitters.shape.EmitterShape;
import foundry.veil.api.quasar.registry.EmitterShapeRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -16,7 +14,6 @@
import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;

public class CodecUtil {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import imgui.type.ImBoolean;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

@ApiStatus.Internal
public class DemoEditor implements Editor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import imgui.ImGui;
import imgui.flag.ImGuiDataType;
import imgui.type.ImInt;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.util.HashSet;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package foundry.veil.impl.client.imgui;

import foundry.veil.api.client.imgui.VeilImGui;
import imgui.ImFont;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.util.function.ObjIntConsumer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import imgui.flag.ImGuiCol;
import imgui.flag.ImGuiDir;

import java.io.IOException;

public class VeilImGuiStylesheet {

public static void initStyles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.jetbrains.annotations.ApiStatus;

import java.io.IOException;
import java.util.function.Supplier;
import java.util.regex.Matcher;

@ApiStatus.Internal
public class InputShaderModification implements ShaderModification {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.Objects;
import java.util.regex.Matcher;

@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package foundry.veil.impl.compat;

import foundry.veil.Veil;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.ints.IntSets;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;

import java.util.Collections;
import java.util.Set;
import java.util.function.Supplier;

@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import foundry.veil.api.resource.type.FramebufferResource;
import net.minecraft.network.chat.Component;

import java.util.Comparator;
import java.util.OptionalInt;

public class FramebufferEditAction implements VeilResourceAction<FramebufferResource> {
Expand Down
Loading

0 comments on commit 931bfe3

Please sign in to comment.