Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import foundry.veil.impl.client.render.pipeline.VeilShaderBufferCache;
import foundry.veil.impl.client.render.profiler.VeilRenderProfilerImpl;
import foundry.veil.impl.client.render.shader.program.ShaderProgramImpl;
import foundry.veil.impl.client.render.light.VoxelShadowGrid;
import foundry.veil.mixin.pipeline.accessor.PipelineBufferSourceAccessor;
import foundry.veil.platform.VeilEventPlatform;
import net.minecraft.Util;
Expand Down Expand Up @@ -1241,6 +1242,7 @@ public static void close() {
if (renderer != null) {
renderer.free();
}
VoxelShadowGrid.close();
glDeleteVertexArrays(screenQuadVao);
MemoryUtil.memFree(emptySamplers);
SHADER_BUFFER_CACHE.free();
Expand Down Expand Up @@ -1277,6 +1279,8 @@ public static boolean drawLights(ProfilerFiller profiler, CullFrustum cullFrustu
return false;
}

VoxelShadowGrid.beforeRenderLights();

VeilDebug debug = VeilDebug.get();
debug.pushDebugGroup("Veil Draw Lights");

Expand Down Expand Up @@ -1322,5 +1326,6 @@ public static void compositeLights(ProfilerFiller profiler) {
@ApiStatus.Internal
public static void clearLevel() {
NecromancerRenderDispatcher.delete();
VoxelShadowGrid.clearLevel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public void bindSamplers(int first, int... samplers) {
.expireAfterAccess(10, TimeUnit.SECONDS)
.build();

private static final Cache<Integer, Integer> TEXTURE_TARGET_CACHE = CacheBuilder.newBuilder()
.maximumSize(100)
.expireAfterAccess(10, TimeUnit.SECONDS)
.build();

private static int getTarget(int texture) {
Integer cached = TEXTURE_TARGET_CACHE.getIfPresent(texture);
if (cached != null) {
Expand Down Expand Up @@ -238,4 +243,5 @@ public static VeilMultiBind get() {
}
return multiBind;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AreaLightData extends LightData implements InstancedLightData, Edit

protected float angle;
protected float distance;
protected boolean occluded;

public AreaLightData() {
this.matrix = new Matrix4d();
Expand All @@ -41,6 +42,16 @@ public AreaLightData() {

this.angle = (float) Math.toRadians(45);
this.distance = 1.0F;
this.occluded = false;
}

public boolean isOccluded() {
return this.occluded;
}

public AreaLightData setOccluded(boolean occluded) {
this.occluded = occluded;
return this;
}

protected void updateMatrix() {
Expand Down Expand Up @@ -163,6 +174,7 @@ public void store(ByteBuffer buffer) {

buffer.putShort((short) Mth.clamp((int) (this.angle * MAX_ANGLE_SIZE), 0, 65535));
buffer.putFloat(this.distance);
buffer.putFloat(this.occluded ? 1.0F : 0.0F);
}

@Override
Expand Down Expand Up @@ -201,6 +213,7 @@ public void renderImGuiAttributes() {

float[] editAngle = new float[]{this.angle};
float[] editDistance = new float[]{this.distance};
imgui.type.ImBoolean editOccluded = new imgui.type.ImBoolean(this.occluded);

if (ImGui.dragFloat2("size", editSize, 0.02F, 0.0001F)) {
this.setSize(editSize[0], editSize[1]);
Expand Down Expand Up @@ -250,5 +263,9 @@ public void renderImGuiAttributes() {
if (ImGui.dragScalar("distance", editDistance, 0.02F, 0.0F)) {
this.setDistance(editDistance[0]);
}

if (ImGui.checkbox("Occluded", editOccluded)) {
this.occluded = editOccluded.get();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ public class PointLightData extends LightData implements IndirectLightData, Edit

protected final Vector3d position;
protected float radius;
protected boolean occluded;

public PointLightData() {
this.position = new Vector3d();
this.radius = 1.0F;
this.occluded = false;
}

public boolean isOccluded() {
return this.occluded;
}

public PointLightData setOccluded(boolean occluded) {
this.occluded = occluded;
return this;
}

@Override
Expand Down Expand Up @@ -97,6 +108,7 @@ public void store(ByteBuffer buffer) {
buffer.putFloat(this.color.green() * this.brightness);
buffer.putFloat(this.color.blue() * this.brightness);
buffer.putFloat(this.radius);
buffer.putFloat(this.occluded ? 1.0F : 0.0F);
}

@Override
Expand All @@ -118,6 +130,7 @@ public void renderImGuiAttributes() {
double[] editZ = new double[]{this.position.z()};

float[] editRadius = new float[]{this.radius};
imgui.type.ImBoolean editOccluded = new imgui.type.ImBoolean(this.occluded);

float totalWidth = ImGui.calcItemWidth();
ImGui.pushItemWidth(totalWidth / 3.0F - (ImGui.getStyle().getItemInnerSpacingX() * 0.58F));
Expand All @@ -140,5 +153,9 @@ public void renderImGuiAttributes() {
if (ImGui.dragScalar("radius", editRadius, 0.02F, 0.0F)) {
this.setRadius(editRadius[0]);
}

if (ImGui.checkbox("Occluded", editOccluded)) {
this.occluded = editOccluded.get();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class AreaLightRenderer extends InstancedLightRenderer<AreaLightData> {
private static final ResourceLocation RENDER_TYPE = Veil.veilPath("light/area");

public AreaLightRenderer() {
super(Float.BYTES * 22 + 2);
super(Float.BYTES * 23 + 2);
}

@Override
Expand All @@ -45,6 +45,7 @@ protected void setupBufferState(VertexArrayBuilder builder) {
builder.setVertexAttribute(6, 2, 2, VertexArrayBuilder.DataType.FLOAT, false, Float.BYTES * 19); // size
builder.setVertexAttribute(7, 2, 1, VertexArrayBuilder.DataType.UNSIGNED_SHORT, true, Float.BYTES * 21); // angle
builder.setVertexAttribute(8, 2, 1, VertexArrayBuilder.DataType.FLOAT, false, Float.BYTES * 21 + 2); // distance
builder.setVertexAttribute(9, 2, 1, VertexArrayBuilder.DataType.FLOAT, false, Float.BYTES * 21 + 2 + Float.BYTES);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class InstancedPointLightRenderer extends InstancedLightRenderer<PointLig
private static final ResourceLocation RENDER_TYPE = Veil.veilPath("light/point");

public InstancedPointLightRenderer() {
super(Float.BYTES * 7);
super(Float.BYTES * 8);
}

@Override
Expand All @@ -40,6 +40,7 @@ protected void setupBufferState(VertexArrayBuilder builder) {
builder.setVertexAttribute(1, 2, 3, VertexArrayBuilder.DataType.FLOAT, false, 0);
builder.setVertexAttribute(2, 2, 3, VertexArrayBuilder.DataType.FLOAT, false, Float.BYTES * 3);
builder.setVertexAttribute(3, 2, 1, VertexArrayBuilder.DataType.FLOAT, false, Float.BYTES * 6);
builder.setVertexAttribute(4, 2, 1, VertexArrayBuilder.DataType.FLOAT, false, Float.BYTES * 7);
}

@Override
Expand Down
Loading
Loading