-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 48 additions & 38 deletions
86
src/client/java/org/ladysnake/effective/core/render/particle/SoftParticleRenderType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,48 @@ | ||
//package org.ladysnake.effective.core.render.particle; | ||
// | ||
//import com.mojang.blaze3d.systems.RenderSystem; | ||
//import net.minecraft.client.MinecraftClient; | ||
//import net.minecraft.client.particle.ParticleTextureSheet; | ||
//import net.minecraft.client.render.BufferBuilder; | ||
//import net.minecraft.client.render.Tessellator; | ||
//import net.minecraft.client.texture.SpriteAtlasTexture; | ||
//import net.minecraft.client.texture.TextureManager; | ||
//import org.jetbrains.annotations.NotNull; | ||
//import org.jetbrains.annotations.Nullable; | ||
// | ||
//public class SoftParticleRenderType implements ParticleTextureSheet { | ||
// @NotNull | ||
// public static final SoftParticleRenderType SOFT_PARTICLE = new SoftParticleRenderType(); | ||
// | ||
// @Override | ||
// public @Nullable BufferBuilder begin(Tessellator tessellator, TextureManager textureManager) { | ||
// final MinecraftClient minecraft = MinecraftClient.getInstance(); | ||
// | ||
// RenderSystem.setShader(() -> softParticle); | ||
// | ||
// // Disallow soft particles from writing to the depth buffer | ||
// RenderSystem.depthMask(false); | ||
// | ||
// // Set `Sampler0` to the particle atlas | ||
// // noinspection deprecation | ||
// RenderSystem.setShaderTexture(0, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE); | ||
// | ||
// RenderSystem.enableBlend(); | ||
// RenderSystem.defaultBlendFunc(); | ||
// | ||
// // Set the sampler for the depth texture | ||
// softParticle.setSampler("DiffuseDepthSampler", minecraft.getMainRenderTarget().getDepthTextureId()); | ||
// | ||
// return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); | ||
// } | ||
//} | ||
package org.ladysnake.effective.core.render.particle; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gl.ShaderProgram; | ||
import net.minecraft.client.particle.ParticleTextureSheet; | ||
import net.minecraft.client.render.BufferBuilder; | ||
import net.minecraft.client.render.Tessellator; | ||
import net.minecraft.client.render.VertexFormat; | ||
import net.minecraft.client.render.VertexFormats; | ||
import net.minecraft.client.texture.SpriteAtlasTexture; | ||
import net.minecraft.client.texture.TextureManager; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Objects; | ||
|
||
public class SoftParticleRenderType implements ParticleTextureSheet { | ||
@NotNull | ||
public static final SoftParticleRenderType SOFT_PARTICLE = new SoftParticleRenderType(); | ||
private static ShaderProgram softParticle; | ||
|
||
@Override | ||
public @Nullable BufferBuilder begin(Tessellator tessellator, TextureManager textureManager) { | ||
final MinecraftClient minecraft = MinecraftClient.getInstance(); | ||
|
||
RenderSystem.setShader(() -> softParticle); | ||
|
||
// Disallow soft particles from writing to the depth buffer | ||
RenderSystem.depthMask(false); | ||
|
||
// Set `Sampler0` to the particle atlas | ||
// noinspection deprecation | ||
RenderSystem.setShaderTexture(0, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE); | ||
|
||
RenderSystem.enableBlend(); | ||
RenderSystem.defaultBlendFunc(); | ||
|
||
// Set the sampler for the depth texture | ||
softParticle.addSampler("DiffuseDepthSampler", minecraft.getFramebuffer().getDepthAttachment()); | ||
|
||
return tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); | ||
} | ||
|
||
public static void loadShader(@NotNull final ShaderProgram shader) { | ||
softParticle = Objects.requireNonNull(shader); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters