class Shader{ String name; float scale = 1; color diffuseColor; boolean useTexture; PImage texture; int imgWidth; float glowAmount; boolean useGlowMask; String glowMaskName; Shader glowMask; boolean useGlowColor; color glowColor; //----------- Shader(){ name = "null"; useTexture = false; useGlowMask = false; useGlowColor = false; glowAmount = 0; glowColor = color(255); } //----------- void setTexture(String file){ useTexture = true; texture = loadImage("textures/"+file); imgWidth = texture.width; } //----------- void setGlowMaskName(String file){ useGlowMask = true; glowMaskName = file; } //----------- void setGlowColor(color c){ useGlowColor = true; glowColor = c; } //----------- void parse(String[] strs, int s){ for( ; s0 ? shade : 0 ); if( useTexture ){ u = (int)( pos.x/scale + imgWidth/2 ); v = (int)( pos.z/scale + imgWidth/2 ); baseColor = texture.get(u,v); } else{ baseColor = diffuseColor; } shadedColor = lerpColor( color(0,255), baseColor, shade ); glowColor = ( useGlowColor ? glowColor : baseColor ); float glow = ( useGlowMask ? brightness(glowMask.getColor(pos,normal,light))/255f : 1 ); finalColor = lerpColor( shadedColor, glowColor, glowAmount*glow ); return finalColor; } }