DentedEvaluate (Dented *inst, LWTextureAccess *ta) { /* Local stuff */ double size, result; double magnitude = 0; int i; /* Position Stuff */ double PP[3], PS[3]; // Lets work in texture space Vec3Assign(PP, ta->tPos[0], ta->tPos[1], ta->tPos[2]); size = inst->frq[0]; for (i = 0; i < inst->oct[0]; i++) { Vec3MultC(PS, PP, size); magnitude += Abs(noisey(PS, inst->fnoise)) / size; size *= 2; } result = pow(magnitude, inst->pwr[0]); /* Use value to determine new shading values. */ result *= inst->scl[0]; return result; }
HeteroTerrainEvaluate (HeteroTerrain *inst, LWTextureAccess *ta) { double turb; double PP[3]; // Lets work in texture space Vec3Assign(PP, ta->tPos[0], ta->tPos[1], ta->tPos[2]); // Use the fBm function to get some fractal turbulence turb = heteroterrain(PP, inst->inc[0], inst->lac[0], inst->oct[0], inst->off[0], inst->fnoise); return turb; }
CoriolisEvaluate (Coriolis *inst, LWTextureAccess *ta) { /* Local stuff */ double rsq, angle, value, sine, cosine, turb; /* Position Stuff */ double Pt[3], PtN[3], PP[3]; // Lets work in shader space if (ta->axis == 0) { Vec3Assign(Pt, ta->tPos[2], -ta->tPos[1], ta->tPos[0]); } else if (ta->axis == 1) { Vec3Assign(Pt, ta->tPos[0], -ta->tPos[2], ta->tPos[1]); } else { Vec3Assign(Pt, ta->tPos[0], -ta->tPos[1], ta->tPos[2]); } Vec3Copy(PtN, Pt); normalize3(PtN); rsq = xcomp(PtN) * xcomp(PtN) + ycomp(PtN) * ycomp(PtN); angle = inst->tws[0] * rsq; sine = sin( angle ); cosine = cos( angle ); PP[0] = Pt[0]*cosine - Pt[1]*sine; PP[1] = Pt[0]*sine + Pt[1]*cosine; PP[2] = Pt[2]; turb = fBm(PP, inst->inc[0], inst->lac[0], inst->oct[0], inst->fnoise); value = Abs(inst->off[0] + inst->scl[0] * turb); value = clamp(value, 0, 1); return value; }