159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapackage com.jme3.scene.plugins.blender.textures.blending; 259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 359b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport java.nio.ByteBuffer; 459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport java.util.ArrayList; 559b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport java.util.logging.Level; 659b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport java.util.logging.Logger; 759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 859b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.math.FastMath; 959b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.plugins.blender.BlenderContext; 1059b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Image; 1159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture; 1259b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture2D; 1359b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture3D; 1459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Image.Format; 1559b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.util.BufferUtils; 1659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 1759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta/** 1859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * The class that is responsible for blending the following texture types: 1959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * <li> Luminance8 2059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * <li> Luminance8Alpha8 2159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Not yet supported (but will be): 2259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * <li> Luminance16: 2359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * <li> Luminance16Alpha16: 2459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * <li> Luminance16F: 2559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * <li> Luminance16FAlpha16F: 2659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * <li> Luminance32F: 2759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @author Marcin Roguski (Kaelthas) 2859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 2959b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapublic class TextureBlenderLuminance extends AbstractTextureBlender { 3059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private static final Logger LOGGER = Logger.getLogger(TextureBlenderLuminance.class.getName()); 3159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 3259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta @Override 3359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public Texture blend(float[] materialColor, Texture texture, float[] color, float affectFactor, int blendType, boolean neg, BlenderContext blenderContext) { 3459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta Format format = texture.getImage().getFormat(); 3559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta ByteBuffer data = texture.getImage().getData(0); 3659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta data.rewind(); 3759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 3859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta int width = texture.getImage().getWidth(); 3959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta int height = texture.getImage().getHeight(); 4059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta int depth = texture.getImage().getDepth(); 4159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (depth == 0) { 4259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta depth = 1; 4359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 4459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta ByteBuffer newData = BufferUtils.createByteBuffer(width * height * depth * 4); 4559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 4659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta float[] resultPixel = new float[4]; 4759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta float[] tinAndAlpha = new float[2]; 4859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta int dataIndex = 0; 4959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta while (data.hasRemaining()) { 5059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.getTinAndAlpha(data, format, neg, tinAndAlpha); 5159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.blendPixel(resultPixel, materialColor, color, tinAndAlpha[0], affectFactor, blendType, blenderContext); 5259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta newData.put(dataIndex++, (byte) (resultPixel[0] * 255.0f)); 5359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f)); 5459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f)); 5559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta newData.put(dataIndex++, (byte) (tinAndAlpha[1] * 255.0f)); 5659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 5759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (texture.getType() == Texture.Type.TwoDimensional) { 5859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return new Texture2D(new Image(Format.RGBA8, width, height, newData)); 5959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } else { 6059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta ArrayList<ByteBuffer> dataArray = new ArrayList<ByteBuffer>(1); 6159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta dataArray.add(newData); 6259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return new Texture3D(new Image(Format.RGBA8, width, height, depth, dataArray)); 6359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 6459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 6559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 6659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 6759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * This method return texture intensity and alpha value. 6859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 6959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param data 7059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the texture data 7159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param imageFormat 7259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the image format 7359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param neg 7459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * indicates if the texture is negated 7559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param result 7659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the table (2 elements) where the result is being stored 7759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 7859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected void getTinAndAlpha(ByteBuffer data, Format imageFormat, boolean neg, float[] result) { 7959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta byte pixelValue = data.get();// at least one byte is always taken 8059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta float firstPixelValue = pixelValue >= 0 ? pixelValue / 255.0f : 1.0f - (~pixelValue) / 255.0f; 8159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta switch (imageFormat) { 8259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case Luminance8: 8359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = neg ? 1.0f - firstPixelValue : firstPixelValue; 8459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = 1.0f; 8559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 8659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case Luminance8Alpha8: 8759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = neg ? 1.0f - firstPixelValue : firstPixelValue; 8859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta pixelValue = data.get(); 8959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = pixelValue >= 0 ? pixelValue / 255.0f : 1.0f - (~pixelValue) / 255.0f; 9059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 9159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case Luminance16: 9259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case Luminance16Alpha16: 9359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case Luminance16F: 9459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case Luminance16FAlpha16F: 9559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case Luminance32F: 9659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta LOGGER.log(Level.WARNING, "Image type not yet supported for blending: {0}", imageFormat); 9759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 9859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta default: 9959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta throw new IllegalStateException("Invalid image format type for DDS texture blender: " + imageFormat); 10059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 10159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 10259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 10359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 10459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * This method blends the texture with an appropriate color. 10559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 10659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param result 10759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the result color (variable 'in' in blender source code) 10859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param materialColor 10959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the texture color (variable 'out' in blender source coude) 11059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param color 11159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the previous color (variable 'tex' in blender source code) 11259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param textureIntensity 11359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * texture intensity (variable 'fact' in blender source code) 11459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param textureFactor 11559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * texture affection factor (variable 'facg' in blender source 11659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * code) 11759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param blendtype 11859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the blend type 11959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param blenderContext 12059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the blender context 12159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 12259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected void blendPixel(float[] result, float[] materialColor, float[] color, float textureIntensity, float textureFactor, int blendtype, BlenderContext blenderContext) { 12359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta float oneMinusFactor, col; 12459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta textureIntensity *= textureFactor; 12559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 12659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta switch (blendtype) { 12759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_BLEND: 12859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oneMinusFactor = 1.0f - textureIntensity; 12959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = textureIntensity * color[0] + oneMinusFactor * materialColor[0]; 13059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = textureIntensity * color[1] + oneMinusFactor * materialColor[1]; 13159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = textureIntensity * color[2] + oneMinusFactor * materialColor[2]; 13259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 13359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_MUL: 13459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oneMinusFactor = 1.0f - textureFactor; 13559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = (oneMinusFactor + textureIntensity * materialColor[0]) * color[0]; 13659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = (oneMinusFactor + textureIntensity * materialColor[1]) * color[1]; 13759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = (oneMinusFactor + textureIntensity * materialColor[2]) * color[2]; 13859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 13959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_DIV: 14059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oneMinusFactor = 1.0f - textureIntensity; 14159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (color[0] != 0.0) { 14259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = (oneMinusFactor * materialColor[0] + textureIntensity * materialColor[0] / color[0]) * 0.5f; 14359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 14459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (color[1] != 0.0) { 14559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = (oneMinusFactor * materialColor[1] + textureIntensity * materialColor[1] / color[1]) * 0.5f; 14659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 14759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (color[2] != 0.0) { 14859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = (oneMinusFactor * materialColor[2] + textureIntensity * materialColor[2] / color[2]) * 0.5f; 14959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 15059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 15159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_SCREEN: 15259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oneMinusFactor = 1.0f - textureFactor; 15359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = 1.0f - (oneMinusFactor + textureIntensity * (1.0f - materialColor[0])) * (1.0f - color[0]); 15459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = 1.0f - (oneMinusFactor + textureIntensity * (1.0f - materialColor[1])) * (1.0f - color[1]); 15559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = 1.0f - (oneMinusFactor + textureIntensity * (1.0f - materialColor[2])) * (1.0f - color[2]); 15659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 15759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_OVERLAY: 15859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oneMinusFactor = 1.0f - textureFactor; 15959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (materialColor[0] < 0.5f) { 16059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = color[0] * (oneMinusFactor + 2.0f * textureIntensity * materialColor[0]); 16159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } else { 16259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = 1.0f - (oneMinusFactor + 2.0f * textureIntensity * (1.0f - materialColor[0])) * (1.0f - color[0]); 16359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 16459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (materialColor[1] < 0.5f) { 16559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = color[1] * (oneMinusFactor + 2.0f * textureIntensity * materialColor[1]); 16659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } else { 16759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = 1.0f - (oneMinusFactor + 2.0f * textureIntensity * (1.0f - materialColor[1])) * (1.0f - color[1]); 16859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 16959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (materialColor[2] < 0.5f) { 17059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = color[2] * (oneMinusFactor + 2.0f * textureIntensity * materialColor[2]); 17159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } else { 17259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = 1.0f - (oneMinusFactor + 2.0f * textureIntensity * (1.0f - materialColor[2])) * (1.0f - color[2]); 17359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 17459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 17559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_SUB: 17659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = materialColor[0] - textureIntensity * color[0]; 17759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = materialColor[1] - textureIntensity * color[1]; 17859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = materialColor[2] - textureIntensity * color[2]; 17959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = FastMath.clamp(result[0], 0.0f, 1.0f); 18059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = FastMath.clamp(result[1], 0.0f, 1.0f); 18159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = FastMath.clamp(result[2], 0.0f, 1.0f); 18259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 18359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_ADD: 18459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = (textureIntensity * color[0] + materialColor[0]) * 0.5f; 18559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = (textureIntensity * color[1] + materialColor[1]) * 0.5f; 18659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = (textureIntensity * color[2] + materialColor[2]) * 0.5f; 18759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 18859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_DIFF: 18959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oneMinusFactor = 1.0f - textureIntensity; 19059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = oneMinusFactor * materialColor[0] + textureIntensity * Math.abs(materialColor[0] - color[0]); 19159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = oneMinusFactor * materialColor[1] + textureIntensity * Math.abs(materialColor[1] - color[1]); 19259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = oneMinusFactor * materialColor[2] + textureIntensity * Math.abs(materialColor[2] - color[2]); 19359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 19459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_DARK: 19559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta col = textureIntensity * color[0]; 19659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = col < materialColor[0] ? col : materialColor[0]; 19759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta col = textureIntensity * color[1]; 19859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = col < materialColor[1] ? col : materialColor[1]; 19959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta col = textureIntensity * color[2]; 20059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = col < materialColor[2] ? col : materialColor[2]; 20159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 20259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_LIGHT: 20359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta col = textureIntensity * color[0]; 20459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[0] = col > materialColor[0] ? col : materialColor[0]; 20559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta col = textureIntensity * color[1]; 20659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[1] = col > materialColor[1] ? col : materialColor[1]; 20759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta col = textureIntensity * color[2]; 20859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta result[2] = col > materialColor[2] ? col : materialColor[2]; 20959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 21059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_BLEND_HUE: 21159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_BLEND_SAT: 21259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_BLEND_VAL: 21359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta case MTEX_BLEND_COLOR: 21459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta System.arraycopy(materialColor, 0, result, 0, 3); 21559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.blendHSV(blendtype, result, textureIntensity, color, blenderContext); 21659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta break; 21759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta default: 21859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta throw new IllegalStateException("Unknown blend type: " + blendtype); 21959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 22059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 22159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta} 222