morph a sphere to a cube and a a cube to a sphere with GLSL

Posted by nkint on Game Development See other posts from Game Development or by nkint
Published on 2011-01-08T17:19:36Z Indexed on 2011/01/08 18:00 UTC
Read the original article Hit count: 437

Filed under:
|

hi i'm getting started with glsl with quartz composer. i have a patch with a particle system in which each particle is mapped into a sphere with a blend value. with blend=0 particles are in random positions, blend=1 particles are in the sphere. the code is here:

    vec3 sphere(vec2 domain)
{
    vec3 range;
    range.x = radius * cos(domain.y) * sin(domain.x);
    range.y = radius * sin(domain.y) * sin(domain.x);
    range.z = radius * cos(domain.x);
    return range;
}

// in main:

    normal = sphere(p0); * blend + gl_Normal * (1.0 - blend);

i'd like the particle to be on a cube if blend=0

i've tried to find but i can't figure out some parametric equation for the cube. mayebe it is not the right way?

© Game Development or respective owner

Related posts about glsl

Related posts about geometry