Skip to content

Commit

Permalink
Add proper lsd effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Dec 14, 2024
1 parent d83b66f commit 9a858d7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ public void addUniforms(ShaderProgramSetupView program, Consumer<GlUniform> regi
register.accept(new BoundUniform("PS_FractalFractureStrength", GlUniform.getTypeIndex("float"), 1, program, uniform -> {
uniform.set(isWorld() ? ShaderContext.hallucinations().get(Drug.SHATTERING_WAVES) : 0F);
}));
register.accept(new BoundUniform("PS_lsdBlendRatio", GlUniform.getTypeIndex("float"), 1, program, uniform -> {
uniform.set(isWorld() && RenderPhase.current() != RenderPhase.CLOUDS
? ShaderContext.modifier(Drug.RAINBOW_WAVES)
: RenderPhase.current() == RenderPhase.SKY ? ShaderContext.modifier(Drug.RAINBOW_WAVES) * 1.1F
: 0F);
}));
}

public Map<String, Supplier<Integer>> getSamplers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public interface Drug extends NbtSerialisable {
Attribute BUBBLING_WAVES = new Attribute("bubbling_waves", 0, Combiner.SUM);
Attribute SHATTERING_WAVES = new Attribute("shattering_waves", 0, Combiner.SUM);
Attribute FRACTALS = new Attribute("fractals", 0, Combiner.SUM);
Attribute RAINBOW_WAVES = new Attribute("rainbow_waves", 0, Combiner.SUM);

Function<DrugProperties, Vector4f> CONTRAST_COLORIZATION = Attribute.createColorModification(Drug::applyContrastColorization);
Function<DrugProperties, Vector4f> BLOOM = Attribute.createColorModification(Drug::applyColorBloom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public BlockState getFractalAppearance() {
}

public Vector4f getPulseColor(float tickDelta, boolean sky) {
if (sky) {
return MathUtils.TEMP_VECTOR.set(pulseColor.getColor(tickDelta), ShaderContext.modifier(Drug.RAINBOW_WAVES));
}
float alpha = MathHelper.clamp(visualisations.getMultiplier(HallucinationTypes.PULSES), 0, 1);
if (alpha == 0) {
return MathUtils.ZERO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class LsdDrug extends SimpleDrug {
+ Math.abs(MathHelper.sin(ShaderContext.ticks() / 30F) * 0.02F * MathUtils.project(f, 0, 0.3F))
+ Math.abs(MathHelper.cos((ShaderContext.ticks() + 15) / 30F) * 0.02F * MathUtils.project(f, 0, 0.3F))
)
.put(RAINBOW_WAVES, 1)
.build();

public LsdDrug(DrugType<LsdDrug> type, double decSpeed, double decSpeedPlus) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

uniform float PS_WorldTicks;
uniform vec4 PS_Pulses;
uniform float PS_lsdBlendRatio;

ps_in float vertexDistance;
ps_in vec4 vertexColor;

ps_in float psyColorMultiplier;
ps_in float lsdBlendRatio;

ps_out vec4 fragColor;

void main() {
Expand All @@ -13,6 +17,7 @@ void main() {
i_parent_shaders_main();

float worldTicks = PS_WorldTicks;
float lsdBlendRatio = PS_lsdBlendRatio;

float fogFragCoord = vertexDistance;
float unusedbecausemacisgarbage = vertexColor.r;
Expand All @@ -29,4 +34,15 @@ void main() {

fragColor = vec4(outcolor, fragColor.a);
}

if (lsdBlendRatio > 0) {
lsdBlendRatio *= (vertexDistance <= 0 ? 1 : vertexDistance / 9) * (sin(worldTicks / 100) * 0.5);
fragColor = vec4(
vec3(
fragColor.r * (sin((psyColorMultiplier + 90) * 1.18)),
fragColor.g * (cos(psyColorMultiplier * 1.18)),
fragColor.b * (sin(psyColorMultiplier * 1.18))
) * lsdBlendRatio + (fragColor.rgb * (1 - lsdBlendRatio))
, fragColor.a);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ ps_out vec4 vertexColor;

ps_out float vertexDistance;

ps_out float psyColorMultiplier;

float PHI = 1.61803398874989484820459;
float TAU = 6.283185307;

Expand Down Expand Up @@ -56,8 +58,8 @@ void main() {
if (smallWaves > 0.0) {
float w1 = 8.0;

gl_Position[1] += sin((vertexPosition.x + worldTicks / 5.0) / w1 * TAU) * sin((vertexPosition.z + worldTicks / 5.0) / w1 * TAU) * smallWaves * 1.5;
gl_Position[1] -= sin((playerPos.x + worldTicks / 5.0) / w1 * TAU) * sin((playerPos.z + worldTicks / 5.0) / w1 * TAU) * smallWaves * 1.5;
gl_Position.y += sin((vertexPosition.x + worldTicks / 5.0) / w1 * TAU) * sin((vertexPosition.z + worldTicks / 5.0) / w1 * TAU) * smallWaves * 1.5;
gl_Position.y -= sin((playerPos.x + worldTicks / 5.0) / w1 * TAU) * sin((playerPos.z + worldTicks / 5.0) / w1 * TAU) * smallWaves * 1.5;

float w2 = 16.0;

Expand Down Expand Up @@ -133,4 +135,6 @@ void main() {
gl_Position.w += sin(gl_Position.x * 0.124 * sin(worldTicks * 0.00184298) + worldTicks * 0.018394082) * 0.05 * inf6 * pMul;
}
}

psyColorMultiplier = (vertexPosition.x + vertexPosition.y + vertexPosition.z) + worldTicks * 0.1 + sin(gl_Position.x + worldTicks * 0.1);
}

0 comments on commit 9a858d7

Please sign in to comment.