Esempio n. 1
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;
	}
Esempio n. 2
0
float Gradient::gradFunc(float u, float v) {
	float a;
	if (type==GRAD_LINEAR) {
		a = v;	
	} else {
		u-=0.5f;
		v-=0.5f;
		a = (float)sqrt(u*u+v*v)*2.0f;
		if (a>1.0f) a = 1.0f;
		}
	
	if (amount!=0.0f) {
		a += amount*NoiseFunc(Point3(u*size1+1.0f,v*size1+1.0f,phase));
		if (a<0.0f) a = 0.0f;
		if (a>1.0f) a = 1.0f;
		}
//	a = (a*a*(3-2*a));
	return a;
	}
Esempio n. 3
0
void ClassicNoise::Generate(QImage *image)
{
    double x;
    double y;
    double z = time;
    double c;
    double cmin = 1000.0;
    double cmax = -1000.0;
    uint8_t color = 0;
    uint32_t color32 = 0;

    time += 0.1;

    int width = image->width();
    int height = image->height();

    for (int iy = 0; iy < height; iy++) {
        y = static_cast<double>(iy) / 10.0;
        for (int ix = 0; ix < width; ix++) {
            x = static_cast<double>(ix) / 10.0;
            c = NoiseFunc(x, y, z);

            cmin = c < cmin ? c : cmin;
            cmax = c > cmax ? c : cmax;
            color = (((c + 1.0) / 2.0) * 255);

            color32 = 0x00000000
                      | (color << 16)
                      | (color << 8)
                      | (color);

            image->setPixel(QPoint(ix, iy), color32);
        }
    }

    // qDebug("func: %f - %f\n", cmin, cmax);
}
Esempio n. 4
0
float Planet::BumpFunc(Point3 p) {
	float f = NoiseFunc(p.x,p.y,p.z);
	return (f<land)?land:f;
	}