|
|
|
@ -46,6 +46,7 @@ import org.junit.Assert; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
import static com.jme3.scene.MPOTestUtils.*; |
|
|
|
|
import com.jme3.scene.Node; |
|
|
|
|
import com.jme3.shader.DefineList; |
|
|
|
|
import com.jme3.system.NullRenderer; |
|
|
|
|
import com.jme3.system.TestUtil; |
|
|
|
@ -54,6 +55,7 @@ import com.jme3.texture.Texture; |
|
|
|
|
import com.jme3.texture.Texture2D; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import org.junit.Before; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Validates how {@link MatParamOverride MPOs} work on the material level. |
|
|
|
@ -124,6 +126,18 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
outUniforms(uniform("AlphaDiscardThreshold", VarType.Float, 2.79f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Test |
|
|
|
|
public void testChildOverridesParent() { |
|
|
|
|
material("Common/MatDefs/Light/Lighting.j3md"); |
|
|
|
|
|
|
|
|
|
inputParentMpo(mpoFloat("AlphaDiscardThreshold", 3.12f)); |
|
|
|
|
inputMpo(mpoFloat("AlphaDiscardThreshold", 2.79f)); |
|
|
|
|
|
|
|
|
|
outUniforms(uniform("AlphaDiscardThreshold", VarType.Float, 2.79f)); |
|
|
|
|
outDefines(def("DISCARD_ALPHA", VarType.Float, 2.79f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testMpoDisable() { |
|
|
|
|
material("Common/MatDefs/Light/Lighting.j3md"); |
|
|
|
@ -222,7 +236,7 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
|
|
|
|
|
reset(); |
|
|
|
|
geometry.clearMatParamOverrides(); |
|
|
|
|
geometry.updateGeometricState(); |
|
|
|
|
root.updateGeometricState(); |
|
|
|
|
outDefines(def("NUM_BONES", VarType.Int, 1234)); |
|
|
|
|
outUniforms(uniform("NumberOfBones", VarType.Int, 1234)); |
|
|
|
|
|
|
|
|
@ -272,7 +286,7 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
|
|
|
|
|
reset(); |
|
|
|
|
geometry.clearMatParamOverrides(); |
|
|
|
|
geometry.updateGeometricState(); |
|
|
|
|
root.updateGeometricState(); |
|
|
|
|
outDefines(); |
|
|
|
|
outUniforms(); |
|
|
|
|
} |
|
|
|
@ -315,7 +329,7 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
|
|
|
|
|
reset(); |
|
|
|
|
geometry.clearMatParamOverrides(); |
|
|
|
|
geometry.updateGeometricState(); |
|
|
|
|
root.updateGeometricState(); |
|
|
|
|
outDefines(); |
|
|
|
|
outUniforms(); |
|
|
|
|
outTextures(); |
|
|
|
@ -341,7 +355,7 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
|
|
|
|
|
reset(); |
|
|
|
|
geometry.clearMatParamOverrides(); |
|
|
|
|
geometry.updateGeometricState(); |
|
|
|
|
root.updateGeometricState(); |
|
|
|
|
outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex1)); |
|
|
|
|
outUniforms(uniform("DiffuseMap", VarType.Int, 0)); |
|
|
|
|
outTextures(tex1); |
|
|
|
@ -369,9 +383,15 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private final Geometry geometry = new Geometry("geometry", new Box(1, 1, 1)); |
|
|
|
|
private final Geometry geometry = new Geometry("Geometry", new Box(1, 1, 1)); |
|
|
|
|
private final Node root = new Node("Root Node"); |
|
|
|
|
private final LightList lightList = new LightList(geometry); |
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
public void setUp() { |
|
|
|
|
root.attachChild(geometry); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private final NullRenderer renderer = new NullRenderer() { |
|
|
|
|
@Override |
|
|
|
|
public void setShader(Shader shader) { |
|
|
|
@ -407,7 +427,17 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
for (MatParamOverride override : overrides) { |
|
|
|
|
geometry.addMatParamOverride(override); |
|
|
|
|
} |
|
|
|
|
geometry.updateGeometricState(); |
|
|
|
|
root.updateGeometricState(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void inputParentMpo(MatParamOverride... overrides) { |
|
|
|
|
if (evaluated) { |
|
|
|
|
throw new IllegalStateException(); |
|
|
|
|
} |
|
|
|
|
for (MatParamOverride override : overrides) { |
|
|
|
|
root.addMatParamOverride(override); |
|
|
|
|
} |
|
|
|
|
root.updateGeometricState(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void reset() { |
|
|
|
@ -520,6 +550,10 @@ public class MaterialMatParamOverrideTest { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void outUniforms(Uniform... uniforms) { |
|
|
|
|
if (!evaluated) { |
|
|
|
|
evaluateTechniqueDef(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HashSet<Uniform> actualUniforms = new HashSet<>(); |
|
|
|
|
|
|
|
|
|
for (Uniform uniform : usedShader.getUniformMap().values()) { |
|
|
|
|