Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#Actualunbird

Posted 26 August 2013 - 02:33 PM

Hmmm, "voronoi" in barycentric coordinates with the corners as points:
 

    float ulen = length(pin.DomainLocation.xyz - float3(1,0,0));
    float vlen = length(pin.DomainLocation.xyz - float3(0,1,0));
    float wlen = length(pin.DomainLocation.xyz - float3(0,0,1));
    float3 color = float3(1,0,0);
    if(vlen < ulen)
    {
        if(wlen < vlen)
            color = float3(0,0,1);
        else
            color = float3(0,1,0);
    }
    else
        if(wlen < ulen)
            color = float3(0,0,1);
        
    return float4(color, 1);
Edit: There should have been a question mark, but it looks fine to me wink.png

9b27cf272452549.jpg

Code could probably be compacted with some tricks I guess.

PS: I like your puzzles.

#2unbird

Posted 26 August 2013 - 02:32 PM

Hmmm, "voronoi" in barycentric coordinates with the corners as points:
 
    float ulen = length(pin.DomainLocation.xyz - float3(1,0,0));
    float vlen = length(pin.DomainLocation.xyz - float3(0,1,0));
    float wlen = length(pin.DomainLocation.xyz - float3(0,0,1));
    float3 color = float3(1,0,0);
    if(vlen < ulen)
    {
        if(wlen < vlen)
            color = float3(0,0,1);
        else
            color = float3(0,1,0);
    }
    else
        if(wlen < ulen)
            color = float3(0,0,1);
        
    return float4(color, 1);

Edit: There should have been a question mark, but it looks fine to me wink.png

9b27cf272452549.jpg

Code could probably be compacted with some tricks I guess.

#1unbird

Posted 26 August 2013 - 02:22 PM

Hmmm, "voronoi" in barycentric coordinates with the corners as points:
 
    float ulen = length(pin.DomainLocation.xyz - float3(1,0,0));
    float vlen = length(pin.DomainLocation.xyz - float3(0,1,0));
    float wlen = length(pin.DomainLocation.xyz - float3(0,0,1));
    float3 color = float3(1,0,0);
    if(vlen < ulen)
    {
        if(wlen < vlen)
            color = float3(0,0,1);
        else
            color = float3(0,1,0);
    }
    else
        if(wlen < ulen)
            color = float3(0,0,1);
        
    return float4(color, 1);

PARTNERS