2013-07-16 17:58:02 +10:00
|
|
|
package codechicken.lib.lighting;
|
|
|
|
|
|
|
|
|
|
import codechicken.lib.colour.ColourRGBA;
|
|
|
|
|
import codechicken.lib.render.CCRenderState;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Faster precomputed version of LightModel that only works for axis planar sides
|
|
|
|
|
*/
|
2014-04-07 14:02:47 +10:00
|
|
|
public class PlanarLightModel implements CCRenderState.IVertexOperation
|
2013-07-16 17:58:02 +10:00
|
|
|
{
|
2013-08-23 17:30:37 +10:00
|
|
|
public static PlanarLightModel standardLightModel = LightModel.standardLightModel.reducePlanar();
|
2014-04-07 14:02:47 +10:00
|
|
|
|
|
|
|
|
public int[] colours;
|
|
|
|
|
|
|
|
|
|
public PlanarLightModel(int[] colours) {
|
|
|
|
|
this.colours = colours;
|
2013-07-16 17:58:02 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-04-07 14:02:47 +10:00
|
|
|
public boolean load() {
|
|
|
|
|
CCRenderState.pipeline.addDependency(CCRenderState.sideAttrib);
|
|
|
|
|
CCRenderState.pipeline.addDependency(CCRenderState.colourAttrib);
|
|
|
|
|
return true;
|
2013-07-16 17:58:02 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-04-07 14:02:47 +10:00
|
|
|
public void operate() {
|
|
|
|
|
CCRenderState.setColour(ColourRGBA.multiply(CCRenderState.colour, colours[CCRenderState.side]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int operationID() {
|
|
|
|
|
return LightModel.operationIndex;
|
2013-07-16 17:58:02 +10:00
|
|
|
}
|
|
|
|
|
}
|