Last active
September 9, 2019 17:59
-
-
Save milcktoast/6eef45a288e2348e850474a172cc992f to your computer and use it in GitHub Desktop.
Color Transform Effect – https://github.com/vanruesc/postprocessing/issues/124
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
#define LUT_FLIP_Y | |
#pragma glslify: applyTransform = require('glsl-lut') | |
uniform sampler2D colorTransformLookup; | |
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) { | |
outputColor = applyTransform(inputColor, colorTransformLookup); | |
} |
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
import { | |
NearestFilter, | |
RGBAFormat, | |
Uniform | |
} from 'three' | |
import { | |
BlendFunction, | |
Effect | |
} from 'postprocessing' | |
import fragment from 'color_transform.frag' | |
export class ColorTransformEffect extends Effect { | |
constructor ({ lutTexture }) { | |
super('ColorTransformEffect', fragment, { | |
blendFunction: BlendFunction.NORMAL, | |
uniforms: new Map([ | |
['colorTransformLookup', new Uniform(lutTexture)] | |
]) | |
}) | |
lutTexture.magFilter = NearestFilter | |
lutTexture.minFilter = NearestFilter | |
lutTexture.format = RGBAFormat | |
lutTexture.generateMipmaps = false | |
lutTexture.needsUpdate = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment