SP / MP Lighting: render ambient color if no lights or only ambient lights

- Prevents "invisible model" bug if there are no lights
experimental
shadowislord 10 years ago
parent 32e56351df
commit 4c69cc00a6
  1. 17
      jme3-core/src/main/java/com/jme3/material/Material.java

@ -935,9 +935,9 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
renderMeshFromGeometry(r, g);
}
if (isFirstLight && lightList.size() > 0) {
// There are only ambient lights in the scene. Render
// a dummy "normal light" so we can see the ambient
if (isFirstLight) {
// Either there are no lights at all, or only ambient lights.
// Render a dummy "normal light" so we can see the ambient color.
ambientColor.setValue(VarType.Vector4, getAmbientColor(lightList, false));
lightColor.setValue(VarType.Vector4, ColorRGBA.BlackNoAlpha);
lightPos.setValue(VarType.Vector4, nullDirLight);
@ -1152,11 +1152,6 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
TechniqueDef techDef = technique.getDef();
if (techDef.getLightMode() == LightMode.MultiPass
&& lights.size() == 0) {
return;
}
if (rm.getForcedRenderState() != null) {
r.applyRenderState(rm.getForcedRenderState());
} else {
@ -1191,11 +1186,17 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
case SinglePass:
int nbRenderedLights = 0;
resetUniformsNotSetByCurrent(shader);
if (lights.size() == 0) {
nbRenderedLights = updateLightListUniforms(shader, geom, lights, rm.getSinglePassLightBatchSize(), rm, 0);
r.setShader(shader);
renderMeshFromGeometry(r, geom);
} else {
while (nbRenderedLights < lights.size()) {
nbRenderedLights = updateLightListUniforms(shader, geom, lights, rm.getSinglePassLightBatchSize(), rm, nbRenderedLights);
r.setShader(shader);
renderMeshFromGeometry(r, geom);
}
}
return;
case FixedPipeline:
throw new IllegalArgumentException("OpenGL1 is not supported");

Loading…
Cancel
Save