yomotsu / gl-slideshow

A JavaScript library for advanced 2D slideshow with WebGL, that provides variety of beautiful effects
83 stars 12 forks source link

My own "displacementMap" Image #8

Closed cimt closed 3 years ago

cimt commented 4 years ago

Hello,

I use the slideshow with this transition (and it works): https://gl-transitions.com/editor/displacement

But how can I create my own "displacementMap" image for this transition

like this: texture: 'images/displacement-image.png'

My goal is a slideshow like this: https://tympanus.net/Development/webGLImageTransitions/index6.html

Be happy about any answer

yomotsu commented 4 years ago

Currently, the lib allows only float and vectors in uniforms. https://github.com/yomotsu/gl-slideshow/blob/846b554c7667327d63bfbd205297d2b669480168/src/GLSlideshow.ts#L432-L453

Add sampler2D above, then images can be uploaded as uniform. (feel free to submit pull requests)

cimt commented 4 years ago

Thank you for your answer. I am not a developer and i don't understand what you mean... Sorry

My starting point is the "shader.html" template.

with the script: `const uniforms = { texture2D: 'localhost/test/assets/images/displacement.png', strength: 0.2, }; const shader = [
'uniform sampler2D displacementMap;', 'uniform float strength; // = 0.2',

'vec4 transition (vec2 uv) {', ' float displacement = texture2D(displacementMap, uv).r * strength;',

' vec2 uvFrom = vec2(uv.x + progress displacement, uv.y);', ' vec2 uvTo = vec2(uv.x - (1.0 - progress) displacement, uv.y);',

' return mix(', ' getFromColor(uvFrom),', ' getToColor(uvTo),', ' progress', ' );', '}',`

yomotsu commented 4 years ago

I'm sorry, I don't have much time... Please ask your developer team.

cimt commented 4 years ago

Thank you for your answer. I was hoping it wouldn't be complicated.

I would be glad if you could build it in in the future!?

Great work so far

yomotsu commented 3 years ago

Custom-texture was just supported. http://yomotsu.github.io/gl-slideshow/examples/shader-image.html

closing this issue.