Reflective Metaballs

22 views
Skip to first unread message

ashgavs

unread,
Nov 21, 2011, 9:52:26 AM11/21/11
to PhiloGL
Hello,
Can anyone explain the code behind animating the change of textures in
this example
http://senchalabs.github.com/philogl/PhiloGL/examples/metaballs/
I am looking to do something similar, and I don't quite understand how
it works.
--Ashley

Guang Han

unread,
Nov 21, 2011, 10:34:35 AM11/21/11
to phi...@googlegroups.com
I think it's done use the fx, (by chaning the delta value of the planes. )

  var fx = new Fx({
    duration: 2000,
    transition: Fx.Transition.Quint.easeOut,
    onCompute: function(delta) {
      for (var i = 0; i < 5; ++i) {
        planes[i].uniforms = { delta: delta };
      }
      if (model) {
        model.uniforms = { delta: delta };
      }
    }
  });


thanks,
--pangwa--

ashgavs

unread,
Nov 21, 2011, 12:07:52 PM11/21/11
to PhiloGL
I understood that part, I just didnt understand the smooth transition
between the textures. What is delta in this case? Is it literally
moving planes in and out of view, or is it physically changing the
texture?
--Ashley

Guang Han

unread,
Nov 21, 2011, 8:41:35 PM11/21/11
to phi...@googlegroups.com
Hi Ashley,

The delta value was used in the frag-shader and it's used like the fade in/out factor. You can frag-shader code at:

http://senchalabs.github.com/philogl/PhiloGL/examples/metaballs/box.fs.glsl

 if (hasTextureCube2) {
      vec4 cubeColor2 = textureCube(samplerCube2, vec3(-reflectionValue.x, -reflectionValue.y, reflectionValue.z));
      endColor = cubeColor + delta * (cubeColor2 - cubeColor);
    } else {
      endColor = cubeColor;
    }

thanks,
--pangwa--

ashgavs

unread,
Nov 22, 2011, 5:32:09 PM11/22/11
to PhiloGL
Ah thank you very much, not very familiar with shaders. This helped a
lot.

On Nov 21, 8:41 pm, Guang Han <pan...@gmail.com> wrote:
> Hi Ashley,
>
> The delta value was used in the frag-shader and it's used like the fade
> in/out factor. You can frag-shader code at:
>

> http://senchalabs.github.com/philogl/PhiloGL/examples/metaballs/box.f...


>
>  if (hasTextureCube2) {
>       vec4 cubeColor2 = textureCube(samplerCube2, vec3(-reflectionValue.x,
> -reflectionValue.y, reflectionValue.z));

>       *endColor = cubeColor + delta * (cubeColor2 - cubeColor);*

Reply all
Reply to author
Forward
0 new messages