-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #349 from nudibranchrecords/feature/postprocessing…
…-per-scene Feature/postprocessing per scene
- Loading branch information
Showing
46 changed files
with
946 additions
and
564 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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
defaultTitle: 'Fragment Shader', | ||
params: [ | ||
{ | ||
key: 'distanceStep', | ||
title: 'distanceStep', | ||
defaultMax: 20, | ||
defaultValue: 0.1, | ||
}, | ||
{ | ||
key: 'yMorphAmp', | ||
title: 'Y Morph Amp', | ||
}, | ||
{ | ||
key: 'yMorphMix', | ||
title: 'Y Morph Mix', | ||
}, | ||
{ | ||
key: 'xMorphAmp', | ||
title: 'X Morph Amp', | ||
}, | ||
{ | ||
key: 'xMorphMix', | ||
title: 'X Morph Mix', | ||
}, | ||
], | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifdef GL_ES | ||
precision mediump float; | ||
#endif | ||
|
||
uniform float distanceStep; | ||
uniform float xMorphAmp; | ||
uniform float xMorphMix; | ||
uniform float yMorphAmp; | ||
uniform float yMorphMix; | ||
|
||
const vec2 center = vec2(0.5); | ||
|
||
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) { | ||
// Remap the space to -1. to 1. | ||
vec2 st = uv - center; | ||
st.x *= resolution.x/resolution.y; | ||
|
||
float xMorph = mix(1., st.x * xMorphAmp, xMorphMix); | ||
float yMorph = mix(1., st.y * yMorphAmp, yMorphMix); | ||
|
||
// Make the distance field | ||
float d = length( st * yMorph * xMorph ); | ||
|
||
// Visualize the distance field | ||
outputColor = vec4(vec3(fract(d*distanceStep)),1.0); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { postprocessing, glslify, THREE } = window.HEDRON.dependencies | ||
const { Uniform } = THREE | ||
const { EffectPass, Effect } = postprocessing | ||
|
||
const fragmentShader = glslify.file('./frag.glsl') | ||
|
||
class FragmentShader { | ||
initiatePostProcessing ({ params }) { | ||
// Define all params as uniforms | ||
const paramUniforms = Object.entries(params).map( | ||
([key, value]) => [key, new Uniform(value)] | ||
) | ||
|
||
class PatternEffect extends Effect { | ||
constructor () { | ||
super('PatternEffect', fragmentShader, { | ||
uniforms: new Map([ | ||
...paramUniforms, | ||
]), | ||
}) | ||
} | ||
} | ||
|
||
this.effect = new PatternEffect() | ||
|
||
return [ new EffectPass(null, this.effect) ] | ||
} | ||
|
||
update ({ params }) { | ||
// Update all uniforms using params | ||
for (const [key, value] of Object.entries(params)) { | ||
this.effect.uniforms.get(key).value = value | ||
} | ||
} | ||
} | ||
|
||
module.exports = FragmentShader | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.