use of io.github.voidzombie.nhglib.graphics.lights.NhgLightsAttribute in project nhglib by VoidZombie.
the class TiledForwardShader method createPrefix.
private String createPrefix(Renderable renderable) {
String prefix = "";
if (params.useBones) {
prefix += "#define numBones " + 12 + "\n";
final int n = renderable.meshPart.mesh.getVertexAttributes().size();
for (int i = 0; i < n; i++) {
final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i);
if (attr.usage == VertexAttributes.Usage.BoneWeight) {
prefix += "#define boneWeight" + attr.unit + "Flag\n";
}
}
}
if (params.albedo) {
prefix += "#define defAlbedo\n";
}
if (params.metalness) {
prefix += "#define defMetalness\n";
}
if (params.roughness) {
prefix += "#define defRoughness\n";
}
if (params.normal) {
prefix += "#define defNormal\n";
}
if (params.ambientOcclusion) {
prefix += "#define defAmbientOcclusion\n";
}
if (params.gammaCorrection) {
prefix += "#define defGammaCorrection\n";
}
if (params.lit) {
NhgLightsAttribute lightsAttribute = (NhgLightsAttribute) environment.get(NhgLightsAttribute.Type);
prefix += "#define lights " + lightsAttribute.lights.size + "\n";
}
return prefix;
}
use of io.github.voidzombie.nhglib.graphics.lights.NhgLightsAttribute in project nhglib by VoidZombie.
the class LightComponentJson method parse.
@Override
public void parse(JsonValue jsonValue) {
GraphicsSystem graphicsSystem = entities.getEntitySystem(GraphicsSystem.class);
LightComponent lightComponent = entities.createComponent(entity, LightComponent.class);
LightType lightType = LightType.fromString(jsonValue.getString("lightType"));
float range = jsonValue.getFloat("range", 1f);
float intensity = jsonValue.getFloat("intensity", 1f);
float innerAngle = jsonValue.getFloat("innerAngle", 0f);
float outerAngle = jsonValue.getFloat("outerAngle", 0f);
if (innerAngle > outerAngle) {
innerAngle = outerAngle;
}
if (range < 1.0f) {
range = 1.0f;
}
JsonValue colorJson = jsonValue.get("color");
Color color = new Color(colorJson.getFloat("r"), colorJson.getFloat("g"), colorJson.getFloat("b"), colorJson.getFloat("a"));
/*JsonValue directionJson = jsonValue.get("direction");
Vector3 direction = VectorPool.getVector3();
if (directionJson != null) {
direction.set(
directionJson.getFloat("x"),
directionJson.getFloat("y"),
directionJson.getFloat("z"));
}*/
NhgLight light = null;
switch(lightType) {
case DIRECTIONAL_LIGHT:
light = NhgLight.directional(intensity, color);
break;
case POINT_LIGHT:
light = NhgLight.point(intensity, range, color);
break;
case SPOT_LIGHT:
light = NhgLight.spot(intensity, range, innerAngle, outerAngle, color);
break;
}
if (light == null)
return;
Environment environment = graphicsSystem.getEnvironment();
NhgLightsAttribute attribute = (NhgLightsAttribute) environment.get(NhgLightsAttribute.Type);
if (attribute == null) {
attribute = new NhgLightsAttribute();
environment.set(attribute);
}
attribute.lights.add(light);
lightComponent.light = light;
lightComponent.type = lightType;
output = lightComponent;
}
Aggregations