[prev in list] [next in list] [prev in thread] [next in thread]
List: mesa3d-dev
Subject: Re: [Mesa3d-dev] Color Interpolation
From: Brian Paul <brian.paul () tungstengraphics ! com>
Date: 2005-04-25 15:56:06
Message-ID: 426D1316.8030201 () tungstengraphics ! com
[Download RAW message or body]
³¯¥¿õ(Murphy Chen) wrote:
> In Mesa, color interpolation is calculated as follows:
>
> /* Y(vMin)<=Y(vMid)<=Y(vMax) */
>
> const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
> GLfloat oneOverArea = 1.0F / area;
> GLfloat eMaj_dr = (GLfloat) ((ColorTemp) vMax->color[RCOMP] - (ColorTemp) vMin->color[RCOMP]);
> GLfloat eBot_dr = (GLfloat) ((ColorTemp) vMid->color[RCOMP] - (ColorTemp) vMin->color[RCOMP]);
> span.drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
> span.drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
>
> I'd like to know how drdx and drdy is deduced?
They're the partial derivatives of color with respect to x and y.
If you consider Z instead of color, think of a triangle in 3-space.
If you want to determine the change in Z over X and Y you'd plug in X
and X+1 into the plane equation for some Y to get the change in Z. If
you simplify that arithmetic you'll eventually arrive at expressions
like you see above.
I haven't worked through that arithmetic in a while. But the cross
product of two edge vectors, normalized according to the area of the
triangle is directly related to the dz/dx and dz/dy terms.
-Brian
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&opÌk
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic