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