1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
package org.sunflow.core.shader;
import org.sunflow.SunflowAPI;
import org.sunflow.core.ParameterList;
import org.sunflow.core.Shader;
import org.sunflow.core.ShadingState;
import org.sunflow.image.Color;
import org.sunflow.math.Vector3;
public class PrimIDShader implements Shader {
private static final Color[] BORDERS = { Color.RED, Color.GREEN,
Color.BLUE, Color.YELLOW, Color.CYAN, Color.MAGENTA };
public boolean update(ParameterList pl, SunflowAPI api) {
return true;
}
public Color getRadiance(ShadingState state) {
Vector3 n = state.getNormal();
float f = n == null ? 1.0f : Math.abs(state.getRay().dot(n));
return BORDERS[state.getPrimitiveID() % BORDERS.length].copy().mul(f);
}
public void scatterPhoton(ShadingState state, Color power) {
}
// EP : Added transparency management
public boolean isOpaque() {
return true;
}
public Color getOpacity(ShadingState state) {
return null;
}
// EP : End of modification
}
|