|
From: <kin...@us...> - 2003-11-06 14:47:29
|
Update of /cvsroot/teem/teem/src/mite
In directory sc8-pr-cvs1:/tmp/cvs-serv23681/mite
Modified Files:
mite.h ray.c
Log Message:
added two-sided lighting to miter, accessible via miter -ns
Index: mite.h
===================================================================
RCS file: /cvsroot/teem/teem/src/mite/mite.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** mite.h 2 Oct 2003 03:35:24 -0000 1.21
--- mite.h 6 Nov 2003 14:47:25 -0000 1.22
***************
*** 128,135 ****
int normalSide, /* determines direction of gradient that is used
as normal for shading:
! 1 for normal pointing to lower values (higher
! values are more "inside"); -1 for normal
! pointing to higher values (low values more
! "inside") */
justSum, /* don't use opacity: just sum colors */
noDirLight; /* forget directional phong lighting, using only
--- 128,136 ----
int normalSide, /* determines direction of gradient that is used
as normal for shading:
! 1: normal points to lower values
! (higher values are more "inside");
! 0: "two-sided": dot-products are abs()'d
! -1: normal points to higher values
! (lower values more "inside") */
justSum, /* don't use opacity: just sum colors */
noDirLight; /* forget directional phong lighting, using only
Index: ray.c
===================================================================
RCS file: /cvsroot/teem/teem/src/mite/ray.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ray.c 2 Sep 2003 01:48:17 -0000 1.14
--- ray.c 6 Nov 2003 14:47:25 -0000 1.15
***************
*** 63,69 ****
ELL_3V_SCALE(ad, ka, muu->lit->amb);
if (!muu->noDirLight && (kd || ks)) {
! ELL_3V_SCALE(N, -muu->normalSide, mtt->norm);
if (kd) {
LdotN = ELL_3V_DOT(muu->lit->dir[0], N);
if (LdotN > 0) {
ELL_3V_SCALE_ADD2(ad, 1.0, ad, LdotN*kd, muu->lit->col[0]);
--- 63,76 ----
ELL_3V_SCALE(ad, ka, muu->lit->amb);
if (!muu->noDirLight && (kd || ks)) {
! if (muu->normalSide) {
! ELL_3V_SCALE(N, -muu->normalSide, mtt->norm);
! } else {
! ELL_3V_COPY(N, mtt->norm);
! }
if (kd) {
LdotN = ELL_3V_DOT(muu->lit->dir[0], N);
+ if (!muu->normalSide) {
+ LdotN = AIR_ABS(LdotN);
+ }
if (LdotN > 0) {
ELL_3V_SCALE_ADD2(ad, 1.0, ad, LdotN*kd, muu->lit->col[0]);
***************
*** 75,78 ****
--- 82,88 ----
ELL_3V_NORM(H, H, tmp);
HdotN = ELL_3V_DOT(H, N);
+ if (!muu->normalSide) {
+ HdotN = AIR_ABS(HdotN);
+ }
if (HdotN > 0) {
HdotN = pow(HdotN, sp);
***************
*** 134,137 ****
--- 144,151 ----
mtt->mscl[miteSclNdotL] = -muu->normalSide*ELL_3V_DOT(mtt->norm,
muu->lit->dir[0]);
+ if (!muu->normalSide) {
+ mtt->mscl[miteSclNdotV] = AIR_ABS(mtt->mscl[miteSclNdotV]);
+ mtt->mscl[miteSclNdotL] = AIR_ABS(mtt->mscl[miteSclNdotL]);
+ }
ELL_3MV_MUL(kn, mtt->nPerp, mtt->V);
ELL_3V_NORM(kn, kn, len);
|