Is there a way in Quartz Composer to draw a (right) triangle of size X that is
Gouraud or Smooth shaded between the 3 specified corner values. Actually, I
will want to draw an entire "sheet" of them, but I'll start with just one.
I can do so with a CI Kernel program, but it involves a silly amount of math
interpolating the coloration between the vertices, especially when I am sure
this can be done in hardware...
As an FYI, here's the CI Kernel code - feeding it an image with the RGB values
pre-plugged at size intervals. It's not efficient to be doing 4 texture reads
for each pixel, then interpolating to determine the color...
Any thoughts? thanks,
Patrick
kernel vec4 triangle(sampler image, float size)
{
vec2 uv = samplerCoord(image);
vec2 auv = floor(uv/size) * size;
vec2 duv = auv + size;
vec2 buv = vec2(duv.x,auv.y);
vec2 cuv = vec2(auv.x,duv.y);
vec2 s = mod(uv, size);
vec3 a = sample(image, auv).rgb;
vec3 b = sample(image, buv).rgb;
vec3 c = sample(image, cuv).rgb;
vec3 d = sample(image, duv).rgb;
vec3 pix = (s.x + s.y) < size ?
mix(mix(a, b, s.x/(size-s.y)), c, s.y/size)
:
mix(b, mix(c, d, (s.x-(size-s.y))/(size-(size-s.y))), s.y/size);
return vec4(pix,1.0);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]