|
@@ -48,8 +48,10 @@ public final class SinglePassAndImageBasedLightingLogic extends DefaultTechnique
|
|
private static final String DEFINE_SINGLE_PASS_LIGHTING = "SINGLE_PASS_LIGHTING";
|
|
private static final String DEFINE_SINGLE_PASS_LIGHTING = "SINGLE_PASS_LIGHTING";
|
|
private static final String DEFINE_NB_LIGHTS = "NB_LIGHTS";
|
|
private static final String DEFINE_NB_LIGHTS = "NB_LIGHTS";
|
|
private static final String DEFINE_NB_PROBES = "NB_PROBES";
|
|
private static final String DEFINE_NB_PROBES = "NB_PROBES";
|
|
|
|
+ private static final String DEFINE_USE_AMBIENT_LIGHT = "USE_AMBIENT_LIGHT";
|
|
private static final RenderState ADDITIVE_LIGHT = new RenderState();
|
|
private static final RenderState ADDITIVE_LIGHT = new RenderState();
|
|
|
|
|
|
|
|
+ private boolean useAmbientLight;
|
|
private final ColorRGBA ambientLightColor = new ColorRGBA(0, 0, 0, 1);
|
|
private final ColorRGBA ambientLightColor = new ColorRGBA(0, 0, 0, 1);
|
|
private List<LightProbe> lightProbes = new ArrayList<>(3);
|
|
private List<LightProbe> lightProbes = new ArrayList<>(3);
|
|
|
|
|
|
@@ -61,12 +63,14 @@ public final class SinglePassAndImageBasedLightingLogic extends DefaultTechnique
|
|
private final int singlePassLightingDefineId;
|
|
private final int singlePassLightingDefineId;
|
|
private final int nbLightsDefineId;
|
|
private final int nbLightsDefineId;
|
|
private final int nbProbesDefineId;
|
|
private final int nbProbesDefineId;
|
|
|
|
+ private final int useAmbientLightDefineId;
|
|
|
|
|
|
public SinglePassAndImageBasedLightingLogic(TechniqueDef techniqueDef) {
|
|
public SinglePassAndImageBasedLightingLogic(TechniqueDef techniqueDef) {
|
|
super(techniqueDef);
|
|
super(techniqueDef);
|
|
singlePassLightingDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_SINGLE_PASS_LIGHTING, VarType.Boolean);
|
|
singlePassLightingDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_SINGLE_PASS_LIGHTING, VarType.Boolean);
|
|
nbLightsDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_NB_LIGHTS, VarType.Int);
|
|
nbLightsDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_NB_LIGHTS, VarType.Int);
|
|
nbProbesDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_NB_PROBES, VarType.Int);
|
|
nbProbesDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_NB_PROBES, VarType.Int);
|
|
|
|
+ useAmbientLightDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_USE_AMBIENT_LIGHT, VarType.Boolean);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -83,6 +87,7 @@ public final class SinglePassAndImageBasedLightingLogic extends DefaultTechnique
|
|
lightProbes.clear();
|
|
lightProbes.clear();
|
|
extractIndirectLights(lights, false);
|
|
extractIndirectLights(lights, false);
|
|
defines.set(nbProbesDefineId, lightProbes.size());
|
|
defines.set(nbProbesDefineId, lightProbes.size());
|
|
|
|
+ defines.set(useAmbientLightDefineId, useAmbientLight);
|
|
}
|
|
}
|
|
|
|
|
|
return super.makeCurrent(assetManager, renderManager, rendererCaps, lights, defines);
|
|
return super.makeCurrent(assetManager, renderManager, rendererCaps, lights, defines);
|
|
@@ -127,7 +132,7 @@ public final class SinglePassAndImageBasedLightingLogic extends DefaultTechnique
|
|
// apply additive blending for 2nd and future passes
|
|
// apply additive blending for 2nd and future passes
|
|
rm.getRenderer().applyRenderState(ADDITIVE_LIGHT);
|
|
rm.getRenderer().applyRenderState(ADDITIVE_LIGHT);
|
|
ambientColor.setValue(VarType.Vector4, ColorRGBA.Black);
|
|
ambientColor.setValue(VarType.Vector4, ColorRGBA.Black);
|
|
- }else{
|
|
|
|
|
|
+ } else{
|
|
extractIndirectLights(lightList,true);
|
|
extractIndirectLights(lightList,true);
|
|
ambientColor.setValue(VarType.Vector4, ambientLightColor);
|
|
ambientColor.setValue(VarType.Vector4, ambientLightColor);
|
|
}
|
|
}
|
|
@@ -260,9 +265,11 @@ public final class SinglePassAndImageBasedLightingLogic extends DefaultTechnique
|
|
|
|
|
|
protected void extractIndirectLights(LightList lightList, boolean removeLights) {
|
|
protected void extractIndirectLights(LightList lightList, boolean removeLights) {
|
|
ambientLightColor.set(0, 0, 0, 1);
|
|
ambientLightColor.set(0, 0, 0, 1);
|
|
|
|
+ useAmbientLight = false;
|
|
for (int j = 0; j < lightList.size(); j++) {
|
|
for (int j = 0; j < lightList.size(); j++) {
|
|
Light l = lightList.get(j);
|
|
Light l = lightList.get(j);
|
|
if (l instanceof AmbientLight) {
|
|
if (l instanceof AmbientLight) {
|
|
|
|
+ useAmbientLight = true;
|
|
ambientLightColor.addLocal(l.getColor());
|
|
ambientLightColor.addLocal(l.getColor());
|
|
if(removeLights){
|
|
if(removeLights){
|
|
lightList.remove(l);
|
|
lightList.remove(l);
|