putPixelClip() public method

public putPixelClip ( int x, int y, float v ) : void
x int
y int
v float
return void
Ejemplo n.º 1
0
		public Channel bump(Channel bumpmap, float lx, float ly, float shadow, float light, float ambient) {
			if(!(bumpmap.getWidth() == width && bumpmap.getHeight() == height))
				throw new Exception("bumpmap does not match channel size");
			Channel channel = new Channel(width, height);
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					float nx = bumpmap.getPixelWrap(x + 1, y) - bumpmap.getPixelWrap(x - 1, y);
					float ny = bumpmap.getPixelWrap(x, y + 1) - bumpmap.getPixelWrap(x, y - 1);
					float brightness = nx*lx + ny*ly;
					if (brightness >= 0) {
						channel.putPixelClip(x, y, (getPixel(x, y) + brightness*light)*(bumpmap.getPixel(x, y)*shadow + 1 - shadow));
					} else {
						channel.putPixelClip(x, y, (getPixel(x, y) + brightness*(1 - ambient))*(bumpmap.getPixel(x, y)*shadow + 1 - shadow));
					}
				}
			}
			pixels = channel.getPixels();
			return this;
		}