Skip to content

Instantly share code, notes, and snippets.

View rafaskb's full-sized avatar

Rafa Skoberg rafaskb

View GitHub Profile
@rafaskb
rafaskb / LutEffect.java
Last active April 5, 2023 22:20
Look-up Table shader for gdx-vfx. It takes an image where each line consists of a color mapping, and the shader is able to take two indices and mix them.
package com.grashers.core.utilities.vfx.effects;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.crashinvaders.vfx.VfxRenderContext;
import com.crashinvaders.vfx.effects.ChainVfxEffect;
import com.crashinvaders.vfx.effects.ShaderVfxEffect;
import com.crashinvaders.vfx.framebuffer.VfxFrameBuffer;
import com.crashinvaders.vfx.framebuffer.VfxPingPongWrapper;
import com.crashinvaders.vfx.gl.VfxGLUtils;
@rafaskb
rafaskb / ConsumableAction.java
Created June 21, 2022 17:36
Executes another action until it returns true and ensures such action is never run after its completed.
package com.grashers.core.ui.scene2d.actions;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Pool;
import com.grashers.core.app.Game;
/** Executes another action until it returns true and ensures such action is never run after its completed. */
public class ConsumableAction extends Action {
protected Action action;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.BufferUtils;
import java.nio.FloatBuffer;
public class Anisotropy {
private static boolean anisotropySupported = false;
@rafaskb
rafaskb / AddSoundToButton.java
Last active January 26, 2020 14:22
Static method that adds click and hover sounds to a Scene2D button.
/** Adds a {@link ClickListener} to the given button that plays sounds. */
public static void addSoundToButton(Actor button, Sound sound) {
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// Play click sound.
sound.play();
}
@rafaskb
rafaskb / DistortedTvEffect.java
Last active August 26, 2019 00:42
Distorted TV Effect for libGDX and libgdx-postprocessing-contribs or gdx-vfx. Example: https://www.shadertoy.com/view/Mt2XDV
package com.grashers.core.postprocessing;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.bitfire.postprocessing.PostProcessorEffect;
public final class DistortedTvEffect extends PostProcessorEffect {
private DistortedTvFilter distortion;
public DistortedTvEffect(int effectsSupport) {
distortion = new DistortedTvFilter(effectsSupport);