Search in sources :

Example 1 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class OpaqueComparatorTest method testSortByAll.

@Test
public void testSortByAll() {
    Material matBase1 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material matBase2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    Texture texBase = createTexture("BASE");
    texBase.getImage().setId(1);
    Texture tex1 = createTexture("1");
    tex1.getImage().setId(2);
    Texture tex2 = createTexture("2");
    tex2.getImage().setId(3);
    matBase1.setName("BASE");
    matBase1.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
    matBase1.setBoolean("UseVertexColor", true);
    matBase1.setTexture("DiffuseMap", texBase);
    Material mat1100 = matBase1.clone();
    mat1100.setName("1100");
    mat1100.selectTechnique("PreShadow", renderManager);
    Material mat1101 = matBase1.clone();
    mat1101.setName("1101");
    mat1101.selectTechnique("PreShadow", renderManager);
    mat1101.setTexture("DiffuseMap", tex1);
    Material mat1102 = matBase1.clone();
    mat1102.setName("1102");
    mat1102.selectTechnique("PreShadow", renderManager);
    mat1102.setTexture("DiffuseMap", tex2);
    Material mat1110 = matBase1.clone();
    mat1110.setName("1110");
    mat1110.selectTechnique("PreShadow", renderManager);
    mat1110.setFloat("AlphaDiscardThreshold", 2f);
    Material mat1120 = matBase1.clone();
    mat1120.setName("1120");
    mat1120.selectTechnique("PreShadow", renderManager);
    mat1120.setBoolean("UseInstancing", true);
    Material mat1121 = matBase1.clone();
    mat1121.setName("1121");
    mat1121.selectTechnique("PreShadow", renderManager);
    mat1121.setBoolean("UseInstancing", true);
    mat1121.setTexture("DiffuseMap", tex1);
    Material mat1122 = matBase1.clone();
    mat1122.setName("1122");
    mat1122.selectTechnique("PreShadow", renderManager);
    mat1122.setBoolean("UseInstancing", true);
    mat1122.setTexture("DiffuseMap", tex2);
    Material mat1140 = matBase1.clone();
    mat1140.setName("1140");
    mat1140.selectTechnique("PreShadow", renderManager);
    mat1140.setFloat("AlphaDiscardThreshold", 2f);
    mat1140.setBoolean("UseInstancing", true);
    Material mat1200 = matBase1.clone();
    mat1200.setName("1200");
    mat1200.selectTechnique("PostShadow", renderManager);
    Material mat1210 = matBase1.clone();
    mat1210.setName("1210");
    mat1210.selectTechnique("PostShadow", renderManager);
    mat1210.setFloat("AlphaDiscardThreshold", 2f);
    Material mat1220 = matBase1.clone();
    mat1220.setName("1220");
    mat1220.selectTechnique("PostShadow", renderManager);
    mat1220.setBoolean("UseInstancing", true);
    Material mat2000 = matBase2.clone();
    mat2000.setName("2000");
    testSort(mat1100, mat1101, mat1102, mat1110, mat1120, mat1121, mat1122, mat1140, mat1200, mat1210, mat1220, mat2000);
}
Also used : Material(com.jme3.material.Material) Texture(com.jme3.texture.Texture) Test(org.junit.Test)

Example 2 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class OpaqueComparatorTest method testSortByShaderDefines.

@Test
public void testSortByShaderDefines() {
    Material lightingMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatVColor = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatVLight = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatTC = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatVColorLight = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatTCVColorLight = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    lightingMat.setName("DefNone");
    lightingMatVColor.setName("DefVC");
    lightingMatVColor.setBoolean("UseVertexColor", true);
    lightingMatVLight.setName("DefVL");
    lightingMatVLight.setBoolean("VertexLighting", true);
    lightingMatTC.setName("DefTC");
    lightingMatTC.setBoolean("SeparateTexCoord", true);
    lightingMatVColorLight.setName("DefVCVL");
    lightingMatVColorLight.setBoolean("UseVertexColor", true);
    lightingMatVColorLight.setBoolean("VertexLighting", true);
    lightingMatTCVColorLight.setName("DefVCVLTC");
    lightingMatTCVColorLight.setBoolean("UseVertexColor", true);
    lightingMatTCVColorLight.setBoolean("VertexLighting", true);
    lightingMatTCVColorLight.setBoolean("SeparateTexCoord", true);
    testSort(lightingMat, lightingMatVColor, lightingMatVLight, lightingMatVColorLight, lightingMatTC, lightingMatTCVColorLight);
}
Also used : Material(com.jme3.material.Material) Test(org.junit.Test)

Example 3 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class OpaqueComparatorTest method testSortByMaterialDef.

@Test
public void testSortByMaterialDef() {
    Material lightingMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material particleMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    Material unshadedMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    Material skyMat = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
    lightingMat.setName("MatLight");
    particleMat.setName("MatParticle");
    unshadedMat.setName("MatUnshaded");
    skyMat.setName("MatSky");
    testSort(skyMat, lightingMat, particleMat, unshadedMat);
}
Also used : Material(com.jme3.material.Material) Test(org.junit.Test)

Example 4 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class TextureAtlas method makeAtlasBatch.

/**
     * Creates one geometry out of the given root spatial and merges all single
     * textures into one texture of the given size.
     * @param spat The root spatial of the scene to batch
     * @param mgr An assetmanager that can be used to create the material.
     * @param atlasSize A size for the atlas texture, it has to be large enough to hold all single textures.
     * @return A new geometry that uses the generated texture atlas and merges all meshes of the root spatial, null if the atlas cannot be created because not all textures fit.
     */
public static Geometry makeAtlasBatch(Spatial spat, AssetManager mgr, int atlasSize) {
    List<Geometry> geometries = new ArrayList<Geometry>();
    GeometryBatchFactory.gatherGeoms(spat, geometries);
    TextureAtlas atlas = createAtlas(spat, atlasSize);
    if (atlas == null) {
        return null;
    }
    Geometry geom = new Geometry();
    Mesh mesh = new Mesh();
    GeometryBatchFactory.mergeGeometries(geometries, mesh);
    applyAtlasCoords(geometries, mesh, atlas);
    mesh.updateCounts();
    mesh.updateBound();
    geom.setMesh(mesh);
    Material mat = new Material(mgr, "Common/MatDefs/Light/Lighting.j3md");
    Texture diffuseMap = atlas.getAtlasTexture("DiffuseMap");
    Texture normalMap = atlas.getAtlasTexture("NormalMap");
    Texture specularMap = atlas.getAtlasTexture("SpecularMap");
    if (diffuseMap != null) {
        mat.setTexture("DiffuseMap", diffuseMap);
    }
    if (normalMap != null) {
        mat.setTexture("NormalMap", normalMap);
    }
    if (specularMap != null) {
        mat.setTexture("SpecularMap", specularMap);
    }
    mat.setFloat("Shininess", 16.0f);
    geom.setMaterial(mat);
    return geom;
}
Also used : Geometry(com.jme3.scene.Geometry) ArrayList(java.util.ArrayList) Mesh(com.jme3.scene.Mesh) Material(com.jme3.material.Material) MatParamTexture(com.jme3.material.MatParamTexture) Texture(com.jme3.texture.Texture)

Example 5 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class MaterialMatParamTest method testRemoveTexture.

@Test
public void testRemoveTexture() {
    material("Common/MatDefs/Light/Lighting.j3md");
    Texture2D tex = new Texture2D(128, 128, Format.RGBA8);
    reset();
    inputMpo(mpoTexture2D("DiffuseMap", tex));
    outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex));
    outUniforms(uniform("DiffuseMap", VarType.Int, 0));
    outTextures(tex);
    reset();
    geometry.clearMatParamOverrides();
    root.updateGeometricState();
    outDefines();
    outUniforms();
    outTextures();
}
Also used : Texture2D(com.jme3.texture.Texture2D) Test(org.junit.Test)

Aggregations

Vector3f (com.jme3.math.Vector3f)64 Material (com.jme3.material.Material)61 DirectionalLight (com.jme3.light.DirectionalLight)55 Geometry (com.jme3.scene.Geometry)52 PointLight (com.jme3.light.PointLight)27 Spatial (com.jme3.scene.Spatial)27 Box (com.jme3.scene.shape.Box)26 Sphere (com.jme3.scene.shape.Sphere)26 ColorRGBA (com.jme3.math.ColorRGBA)24 Quaternion (com.jme3.math.Quaternion)21 Node (com.jme3.scene.Node)21 AmbientLight (com.jme3.light.AmbientLight)20 Texture (com.jme3.texture.Texture)18 SpotLight (com.jme3.light.SpotLight)16 FilterPostProcessor (com.jme3.post.FilterPostProcessor)15 KeyTrigger (com.jme3.input.controls.KeyTrigger)11 Test (org.junit.Test)11 TempVars (com.jme3.util.TempVars)10 Light (com.jme3.light.Light)9 Camera (com.jme3.renderer.Camera)9