* Prevent UnsupportedOperationException when using LightMode SinglePass
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7491 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
bfe76ba56a
commit
3430cd93d1
@ -560,10 +560,15 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
lightColor.setVector4Length(numLights);
|
lightColor.setVector4Length(numLights);
|
||||||
lightPos.setVector4Length(numLights);
|
lightPos.setVector4Length(numLights);
|
||||||
|
|
||||||
|
Uniform ambientColor = shader.getUniform("g_AmbientLightColor");
|
||||||
|
ambientColor.setValue(VarType.Vector4, getAmbientColor(lightList));
|
||||||
|
|
||||||
|
int lightIndex = 0;
|
||||||
|
|
||||||
for (int i = 0; i < numLights; i++) {
|
for (int i = 0; i < numLights; i++) {
|
||||||
if (lightList.size() <= i) {
|
if (lightList.size() <= i) {
|
||||||
lightColor.setVector4InArray(0f, 0f, 0f, 0f, i);
|
lightColor.setVector4InArray(0f, 0f, 0f, 0f, lightIndex);
|
||||||
lightPos.setVector4InArray(0f, 0f, 0f, 0f, i);
|
lightPos.setVector4InArray(0f, 0f, 0f, 0f, lightIndex);
|
||||||
} else {
|
} else {
|
||||||
Light l = lightList.get(i);
|
Light l = lightList.get(i);
|
||||||
ColorRGBA color = l.getColor();
|
ColorRGBA color = l.getColor();
|
||||||
@ -577,7 +582,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
case Directional:
|
case Directional:
|
||||||
DirectionalLight dl = (DirectionalLight) l;
|
DirectionalLight dl = (DirectionalLight) l;
|
||||||
Vector3f dir = dl.getDirection();
|
Vector3f dir = dl.getDirection();
|
||||||
lightPos.setVector4InArray(dir.getX(), dir.getY(), dir.getZ(), -1, i);
|
lightPos.setVector4InArray(dir.getX(), dir.getY(), dir.getZ(), -1, lightIndex);
|
||||||
break;
|
break;
|
||||||
case Point:
|
case Point:
|
||||||
PointLight pl = (PointLight) l;
|
PointLight pl = (PointLight) l;
|
||||||
@ -586,12 +591,24 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
if (invRadius != 0) {
|
if (invRadius != 0) {
|
||||||
invRadius = 1f / invRadius;
|
invRadius = 1f / invRadius;
|
||||||
}
|
}
|
||||||
lightPos.setVector4InArray(pos.getX(), pos.getY(), pos.getZ(), invRadius, i);
|
lightPos.setVector4InArray(pos.getX(), pos.getY(), pos.getZ(), invRadius, lightIndex);
|
||||||
break;
|
break;
|
||||||
|
case Ambient:
|
||||||
|
// skip this light. Does not increase lightIndex
|
||||||
|
continue;
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Unknown type of light: " + l.getType());
|
throw new UnsupportedOperationException("Unknown type of light: " + l.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lightIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (lightIndex < numLights){
|
||||||
|
lightColor.setVector4InArray(0f, 0f, 0f, 0f, lightIndex);
|
||||||
|
lightPos.setVector4InArray(0f, 0f, 0f, 0f, lightIndex);
|
||||||
|
|
||||||
|
lightIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user