Beispiel #1
0
// --- Methods inherited from Texmap ---
RGBA Smoke::EvalColor(ShadeContext& sc) {
	float d;
	Point3 p, dp;

	if (gbufID) 
		sc.SetGBufferID(gbufID);

	xyzGen->GetXYZ(sc, p, dp);

	if (size == 0.0f) 
		size = 1.0f;

	d = SmokeFunc(p/size, iter);

	// If we have sub-texmaps and they are enabled, get the colors from 
	// the sub-texmaps, otherwise get them from the color swatch
	RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0];
	RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1];

	Col24 c;
	Col24 col1 = Col24FromColor(c0);
	Col24 col2 = Col24FromColor(c1);

	lerp_color(&c, &col1, &col2, d);
	return ColorFromCol24(c);
}
Beispiel #2
0
// --- Methods inherited from Texmap ---
RGBA Speckle::EvalColor(ShadeContext& sc) {
	// After being evaluated, if a map or material has a non-zero gbufID, 
	// it should call ShadeContext::SetGBuffer() to store it into 
	// the shade context.
	if (gbufID) 
		sc.SetGBufferID(gbufID);

	// Use the XYZGen instance to get a transformed point from the
	// ShadeContext.
	Point3 p, dp;
	xyzGen->GetXYZ(sc, p, dp);
	if (size == 0.0f) 
		size = 0.0001f;
	p *= SCALE_FACTOR/size;

	float d = SpeckleFunc(p);
	if (d>1.0f) d = 1.0f;

	// If we have sub-texmaps and they are enabled, get the colors from 
	// the sub-texmaps, otherwise get them from the color swatch
	RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0];
	RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1];

	// Composite the colors together and return the result.
	return (1.0f-d)*c0 + d*c1;
}
Beispiel #3
0
// --- Methods inherited from Texmap ---
RGBA Water::EvalColor(ShadeContext& sc) {
	float d;
	float q[3];
	Point3 p, dp;

	if (gbufID) 
		sc.SetGBufferID(gbufID);

	xyzGen->GetXYZ(sc, p, dp);

	q[0] = p.x;
	q[1] = p.y;
	q[2] = p.z;
	d = ScalarWave(q);
	if (d>1.0f) d = 1.0f;

	// If we have sub-texmaps and they are enabled, get the colors from 
	// the sub-texmaps, otherwise get them from the color swatch
	RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0];
	RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1];

	Col24 c;
	Col24 col1 = Col24FromColor(c0);
	Col24 col2 = Col24FromColor(c1);

	lerp_color(&c, &col1, &col2, d);
	return ColorFromCol24(c);
	}
Beispiel #4
0
// --- Methods inherited from Texmap ---
RGBA Stucco::EvalColor(ShadeContext& sc) {
	float f;
	Point3 p, dp;

	if (gbufID) 
		sc.SetGBufferID(gbufID);

	xyzGen->GetXYZ(sc, p, dp);

	if (size == 0.0f) 
		size = 0.0001f;
	p /= size;

	float scl = compscl(dp, size);
	f = Func(p, scl);

	// If we have sub-texmaps and they are enabled, get the colors from 
	// the sub-texmaps, otherwise get them from the color swatch
	RGBA c0 = (mapOn[0]&&subTex[0]) ? subTex[0]->EvalColor(sc): col[0];
	RGBA c1 = (mapOn[1]&&subTex[1]) ? subTex[1]->EvalColor(sc): col[1];

	Col24 c;
	Col24 col1 = Col24FromColor(c0);
	Col24 col2 = Col24FromColor(c1);

	lerp_color(&c, &col1, &col2, f);
	return ColorFromCol24(c);
}
Beispiel #5
0
RGBA Noise::EvalColor(ShadeContext& sc) {
	Point3 p,dp;
	if (!sc.doMaps) return black;

	AColor c;
	if (sc.GetCache(this,c)) 
		return c; 

	if (gbufID) sc.SetGBufferID(gbufID);

	//IPoint2 ps = sc.ScreenCoord();
  	UpdateCache(sc.CurTime());  // DS 10/3/00
	xyzGen->GetXYZ(sc,p,dp);
	p /= size;	   
	filter = sc.filterMaps;
	
	float smw;
	float limlev = LimitLevel(dp,smw);
    float d = NoiseFunction(p,limlev,smw);

	RGBA c0 = mapOn[0]&&subTex[0] ? subTex[0]->EvalColor(sc): col[0];
	RGBA c1 = mapOn[1]&&subTex[1] ? subTex[1]->EvalColor(sc): col[1];
	c = texout->Filter((1.0f-d)*c0 + d*c1);
	
	sc.PutCache(this,c); 
	return c;
	}
Beispiel #6
0
float Stucco::EvalFunc(ShadeContext &sc) {
	Point3 p, dp;
	xyzGen->GetXYZ(sc, p, dp);
	if (size == 0.0f) 
		size = 0.0001f;
	p /= size;
	float scl = compscl(dp, size);
	return Func(p, scl);
	}
Beispiel #7
0
// --- Methods inherited from Texmap ---
RGBA Planet::EvalColor(ShadeContext& sc) {
	float d, x, y, z;
	RGBA color;

	// After being evaluated, if a map or material has a non-zero gbufID, 
	// it should call ShadeContext::SetGBuffer() to store it into 
	// the shade context.
	if (gbufID) 
		sc.SetGBufferID(gbufID);

	// Use the XYZGen instance to get a transformed point from the
	// ShadeContext.
	Point3 p, dp;
	xyzGen->GetXYZ(sc, p, dp);

	if (size == 0.0f) 
		size = 0.0001f;
	x = p.x/size;
	y = p.y/size;
	z = p.z/size;
	d = NoiseFunc(x, y, z);
	if (d < land) {
		float frac;
		int index;

		d = d/land*3.0f;
		index = (int)d;
		frac = d-(float)index;
		if (index < 2)
			color = (1.0f-frac)*col[index]+frac*col[index+1];
		else {
			if (blend)
				color = (1.0f-frac)*col[2]+frac*col[3];
			else
				color = col[2];
			}
		}
	else {
		float divfac, frac;
		int index;
		
		divfac = 1.0f-land;
		if (divfac==0.0) divfac = .000001f;
		d = (d-land)/divfac*5;
		index = (int)d;
		frac = d-(float)index;
		if (index < 4)
			color = (1.0f-frac)*col[index+3]+frac*col[index+4];
		else
			color = col[7];
		}
	return color;
	}
Beispiel #8
0
Point3 Splat::EvalNormalPerturb(ShadeContext& sc) {
    float del, d, f;
    Point3 p, dp, np;

    if (gbufID)
        sc.SetGBufferID(gbufID);

    xyzGen->GetXYZ(sc, p, dp);

    d = splatter(p);
    del = 0.1f;
//	float strength = (abs((int)col[1].r-(int)col[0].r)+
//				abs((int)col[1].g-(int)col[0].g)+
//				abs((int)col[1].b-(int)col[0].b)); ///100.0f; // 756.0f

//	f = strength/del;
    f = 1.0f/del;
    Point3 M[3];
    xyzGen->GetBumpDP(sc,M);
    np.x = f*(splatter(p+del*M[0]) - d);
    np.y = f*(splatter(p+del*M[1]) - d);
    np.z = f*(splatter(p+del*M[2]) - d);

    np = sc.VectorFromNoScale(np,REF_OBJECT);
    Texmap *sub0 = mapOn[0]?subTex[0]:NULL;
    Texmap *sub1 = mapOn[1]?subTex[1]:NULL;
    if (sub0||sub1) {
        // d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da
        float a,b;
        Point3 da,db;
        if (sub0) {
            a = sub0->EvalMono(sc);
            da = sub0->EvalNormalPerturb(sc);
        }
        else {
            a = Intens(col[0]);
            da = Point3(0.0f,0.0f,0.0f);
        }
        if (sub1) {
            b = sub1->EvalMono(sc);
            db = sub1->EvalNormalPerturb(sc);
        }
        else {
            b = Intens(col[1]);
            db= Point3(0.0f,0.0f,0.0f);
        }
        np = (b-a)*np + d*(db-da) + da;
    }
    else
        np *= Intens(col[1])-Intens(col[0]);
    return np;
}
Beispiel #9
0
Point3 Water::EvalNormalPerturb(ShadeContext& sc) {
	if (gbufID) 
		sc.SetGBufferID(gbufID);

	Point3 p, dp, np;
	xyzGen->GetXYZ(sc, p, dp);

	VectorWave(p, np);
	Point3 M[3];
	xyzGen->GetBumpDP(sc,M);
	np = Point3( DotProd(np,M[0]),DotProd(np,M[1]),DotProd(np,M[2]));
	return sc.VectorFromNoScale(np,REF_OBJECT);
	}
Beispiel #10
0
AColor CellTex::EvalColor(ShadeContext& sc)
	{	
	// Get object point
	Point3 p,dp;
	if (gbufID) sc.SetGBufferID(gbufID);
	xyzGen->GetXYZ(sc,p,dp);
	p += ptOffset;
	p = p/size;
	
	// Eval maps
	Color cellC, div1C, div2C;
	if (useCellMap && subTex[0]) cellC = subTex[0]->EvalColor(sc);
	else cellC = cellCol;
	if (useDiv1Map && subTex[1]) div1C = subTex[1]->EvalColor(sc);
	else div1C = divCol1;
	if (useDiv2Map && subTex[2]) div2C = subTex[2]->EvalColor(sc);
	else div2C = divCol2;

	// Evaluate cell function
	float dist[2];
	int ids[2];
	float u;
	if (type) {
		if (fract) FractalCellFunction(p,iterations,rough,2,dist,ids);
		else CellFunction(p,2,dist,ids);
		u = 1.0f - (dist[1]-dist[0])/spread;		
	} else {
		if (fract) FractalCellFunction(p,iterations,rough,1,dist,ids);
		else CellFunction(p,1,dist,ids);
		u = dist[0]/spread;
		}

	// Vari cell color
	if (var>0.0f) {
		float vr = RandFromCellID(ids[0])*var + varOff;
		cellC.r = cellC.r*vr;
		cellC.g = cellC.g*vr;
		cellC.b = cellC.b*vr;
		cellC.ClampMinMax();		
		}

	if (u<low) return texout->Filter(RGBA(cellC));
	if (u>high) return texout->Filter(RGBA(div2C));
	if (u<mid) {
		u = (u-low)/(midMinuslow);
		return texout->Filter(RGBA(div1C*u + (1.0f-u)*cellC));
	} else {
		u = (u-mid)/(highMinusmid);
		return texout->Filter(RGBA(div2C*u + (1.0f-u)*div1C));
		}
	}
Beispiel #11
0
Point3 Speckle::EvalNormalPerturb(ShadeContext& sc) {
	float del, d;
	Point3 p, dp;
	Point3 np;

	if (gbufID) 
		sc.SetGBufferID(gbufID);

	xyzGen->GetXYZ(sc, p, dp);
	if (size == 0.0f) 
		size = 0.0001f;
	p *= SCALE_FACTOR/size;

	del = 0.1f;
	d = SpeckleFunc(p);
	Point3 M[3];
	xyzGen->GetBumpDP(sc,M);
    np.x = (SpeckleFunc(p+del*M[0]) - d)/del;
	np.y = (SpeckleFunc(p+del*M[1]) - d)/del;
	np.z = (SpeckleFunc(p+del*M[2]) - d)/del;

    np = sc.VectorFromNoScale(np,REF_OBJECT);
	Texmap *sub0 = mapOn[0]?subTex[0]:NULL;
	Texmap *sub1 = mapOn[1]?subTex[1]:NULL;
	if (sub0||sub1) {
		// d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da
		float a,b;
		Point3 da,db;
		if (sub0) { 	
			a = sub0->EvalMono(sc); 	
			da = sub0->EvalNormalPerturb(sc);		
			}
		else {	 
			a = Intens(col[0]);	 
			da = Point3(0.0f,0.0f,0.0f);		 
			}
		if (sub1) {
			b = sub1->EvalMono(sc); 	
			db = sub1->EvalNormalPerturb(sc);	
			}
		else {	 
			b = Intens(col[1]);	 
			db= Point3(0.0f,0.0f,0.0f);		 
			}
		np = (b-a)*np + d*(db-da) + da;
		}
	else 
		np *= Intens(col[1])-Intens(col[0]);
	return np;
}
Beispiel #12
0
Point3 Stucco::EvalNormalPerturb(ShadeContext& sc) {
	float d,k;
	Point3 p, dp, np;

	if (gbufID) 
		sc.SetGBufferID(gbufID);

	xyzGen->GetXYZ(sc, p, dp);

	float scl = compscl(dp, size);
	p /= size;
	d = Func(p, scl);
	k = 0.25f/del;

	Point3 M[3];
	xyzGen->GetBumpDP(sc,M);
	np.x = (Func(p + del*M[0], scl) - d)*k;
	np.y = (Func(p + del*M[1], scl) - d)*k;
	np.z = (Func(p + del*M[2], scl) - d)*k;
	np = sc.VectorFromNoScale(np,REF_OBJECT);

	Texmap *sub0 = mapOn[0]?subTex[0]:NULL;
	Texmap *sub1 = mapOn[1]?subTex[1]:NULL;
	if (sub0||sub1) {
		// d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da
		float a,b;
		Point3 da,db;
		if (sub0) { 	
			a = sub0->EvalMono(sc); 	
			da = sub0->EvalNormalPerturb(sc);		
			}
		else {	 
			a = Intens(col[0]);	 
			da = Point3(0.0f,0.0f,0.0f);		 
			}
		if (sub1) {
			b = sub1->EvalMono(sc); 	
			db = sub1->EvalNormalPerturb(sc);	
			}
		else {	 
			b = Intens(col[1]);	 
			db= Point3(0.0f,0.0f,0.0f);		 
			}
		np = (b-a)*np + d*(db-da) + da;
		}
	else 
		np *= Intens(col[1])-Intens(col[0]);
	return np;
}
Beispiel #13
0
Point3 Planet::EvalNormalPerturb(ShadeContext& sc) {
	float del,d;
	Point3 p,dp;
	if (!sc.doMaps) return Point3(0,0,0);
	if (gbufID) sc.SetGBufferID(gbufID);
	xyzGen->GetXYZ(sc,p,dp);
	if (size == 0.0f) 
		size = 0.0001f;
	p /= size;
	del = 10.0f;
	d = BumpFunc(p);
	Point3 np;
	Point3 M[3];
	xyzGen->GetBumpDP(sc,M);
    np.x = (BumpFunc(p+del*M[0]) - d)/del;
	np.y = (BumpFunc(p+del*M[1]) - d)/del;
	np.z = (BumpFunc(p+del*M[2]) - d)/del;
	return sc.VectorFromNoScale(np*100.0f,REF_OBJECT);
    }
Beispiel #14
0
Point3 Noise::EvalNormalPerturb(ShadeContext& sc) {
	Point3 p,dp;
	if (!sc.doMaps) return Point3(0,0,0);
	if (gbufID) sc.SetGBufferID(gbufID);
  	UpdateCache(sc.CurTime());  // DS 10/3/00
	xyzGen->GetXYZ(sc,p,dp);
	p /= size;
	filter = sc.filterMaps;
	float smw;
	float limlev = LimitLevel(dp,smw);
	float del,d;
	d = NoiseFunction(p,limlev,smw);
	//del = (dp.x+dp.y+dp.z)/(size*3.0f);
	del = .1f;
	Point3 np;					  
	Point3 M[3];
	xyzGen->GetBumpDP(sc,M);

	np.x = (NoiseFunction(p+del*M[0],limlev,smw) - d)/del;
	np.y = (NoiseFunction(p+del*M[1],limlev,smw) - d)/del;
	np.z = (NoiseFunction(p+del*M[2],limlev,smw) - d)/del;

	np = sc.VectorFromNoScale(np, REF_OBJECT);

	Texmap *sub0 = mapOn[0]?subTex[0]:NULL;
	Texmap *sub1 = mapOn[1]?subTex[1]:NULL;
	if (sub0||sub1) {
		// d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da
		float a,b;
		Point3 da,db;
		if (sub0) { 	a = sub0->EvalMono(sc); 	da = sub0->EvalNormalPerturb(sc);		}
		else {	 a = Intens(col[0]);	 da = Point3(0.0f,0.0f,0.0f);		 }
		if (sub1) { 	b = sub1->EvalMono(sc); 	db = sub1->EvalNormalPerturb(sc);	}
		else {	 b = Intens(col[1]);	 db= Point3(0.0f,0.0f,0.0f);		 }
		np = (b-a)*np + d*(db-da) + da;
		}
	else 
		np *= Intens(col[1])-Intens(col[0]);
	return texout->Filter(np);
	}
Beispiel #15
0
float Noise::EvalMono(ShadeContext& sc) {
	Point3 p,dp;
	if (!sc.doMaps) 	return 0.0f;

	float f;
	if (sc.GetCache(this,f)) 
		return f; 

	if (gbufID) sc.SetGBufferID(gbufID);
  	UpdateCache(sc.CurTime());  // DS 10/3/00
	xyzGen->GetXYZ(sc,p,dp);
	p /= size;
	filter = sc.filterMaps;
	float smw;
	float limlev = LimitLevel(dp, smw);
    float d = NoiseFunction(p,limlev,smw);
	float c0 = mapOn[0]&&subTex[0] ? subTex[0]->EvalMono(sc): Intens(col[0]);
	float c1 = mapOn[1]&&subTex[1] ? subTex[1]->EvalMono(sc): Intens(col[1]);
	f = texout->Filter((1.0f-d)*c0 + d*c1);
	sc.PutCache(this,f); 
	return f;
	}
Beispiel #16
0
Point3 CellTex::EvalNormalPerturb(ShadeContext& sc)
	{
	Point3 p,dp;
	xyzGen->GetXYZ(sc,p,dp);	
	p += ptOffset;
	Point3 np(0.0f,0.0f,0.0f);
	float dpsq = DotProd(dp,dp);		
	float d = CellFunc(p,dpsq,np,sc.InMtlEditor());

	Texmap* sub0 = (useCellMap && subTex[0])?subTex[0]:NULL; 
	Texmap* sub1 = (useDiv1Map && subTex[1])?subTex[1]:NULL; 
	Texmap* sub2 = (useDiv2Map && subTex[2])?subTex[2]:NULL; 
	if (d<low) {
		if (sub0) 
			np  = sub0->EvalNormalPerturb(sc);
		}
	else 
	if (d>high) {
		if (sub2) 
			np  = sub2->EvalNormalPerturb(sc);
		}
	else {
		Point3 M[3];
		xyzGen->GetBumpDP(sc,M);
		np = Point3( DotProd(np,M[0]),DotProd(np,M[1]),DotProd(np,M[2]));
		if (d<mid) {
			if (sub0||sub1) {
				float a,b;
				Point3 da,db;
				// d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da
				d = (d-low)/(midMinuslow);

				// div1C*u + (1.0f-u)*cellC) ;
				if (sub0) {
					a = sub0->EvalMono(sc);
					da = sub0->EvalNormalPerturb(sc);
					}
				else {
					 a = 1.0f;
					 da = Point3(0.0f,0.0f,0.0f);
					 }
				if (sub1) {
					b = sub1->EvalMono(sc);
					db = sub1->EvalNormalPerturb(sc);
					}
				else {
					 b = 1.0f;
					 db = Point3(0.0f,0.0f,0.0f);
					 }
				np = (b-a)*np + d*(db-da) + da;
				}
			} 
		else {
			if (sub1 || sub2) {
				float a,b;
				Point3 da,db;
				// div2C*u + (1.0f-u)*div1C);
				d = (d-mid)/(highMinusmid);
				if (sub1) {
					a = sub1->EvalMono(sc);
					da = sub1->EvalNormalPerturb(sc);
					}
				else {
					 a = 1.0f;
					 da = Point3(0.0f,0.0f,0.0f);
					 }
				if (sub2) {
					b = sub2->EvalMono(sc);
					db = sub2->EvalNormalPerturb(sc);
					}
				else {
					 b = 1.0f;
					 db = Point3(0.0f,0.0f,0.0f);
					 }
				np = (b-a)*np + d*(db-da)+ da;
				}
			}
		}

//	float d = CellFunc(p,dpsq,np,sc.InMtlEditor());
//	Point3 tmp;
//	float div = type ? -0.1875f : 0.0375f;
//	Point3 DP[3];
//	xyzGen->GetBumpDP(sc,DP);
//	np.x = (CellFunc(p+DP[0],dpsq,tmp,sc.InMtlEditor()) - d)/div;
//	np.y = (CellFunc(p+DP[1],dpsq,tmp,sc.InMtlEditor()) - d)/div;
//	np.z = (CellFunc(p+DP[2],dpsq,tmp,sc.InMtlEditor()) - d)/div;

	if (type) np = np * -0.5f;	
	

	return texout->Filter(sc.VectorFromNoScale(np,REF_OBJECT));
	}