Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

J3MLoader Fix for default textures for j3md #1052

Merged
merged 1 commit into from Mar 27, 2019

Conversation

@riccardobl
Copy link
Member

commented Mar 21, 2019

In j3md you should be allowed to define default textures like this

Texture2D Texture -LINEAR: MinTrilinear MagBilinear /path/to/my/texture.dds

But the j3md loaded actually didn't set the default value for texture params.
This pr fixes that.

@riccardobl riccardobl changed the title j3md Fix for default textures J3MLoader Fix for default textures for j3md Mar 21, 2019

@stephengold

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2019

Is there a test case or example?

@riccardobl

This comment has been minimized.

Copy link
Member Author

commented Mar 27, 2019

TestDefaultTex.java

package tests;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;

public class TestDefaultTex extends SimpleApplication {


    public static void main(String[] args){
        new TestDefaultTex().start();
    }

    @Override
    public void simpleInitApp() {
        Quad quadMesh = new Quad(512,512);
        Geometry quad = new Geometry("Quad", quadMesh);
        quad.setQueueBucket(Bucket.Gui);
        quad.setMaterial(new Material(assetManager, "TestMaterials/TestDefaultTexture.j3md"));  
        guiNode.attachChild(quad);

        quad = quad.clone();
        quad.setMaterial(new Material(assetManager, "TestMaterials/TestMissingTexture.j3md"));
        guiNode.attachChild(quad);
        quad.setLocalTranslation(522,0,0);
    }

    @Override
    public void simpleUpdate(float tpf){
    
    }
}

TestMaterials/TestDefaultTexture.j3md

MaterialDef TestDefaultTexture {

    MaterialParameters {
        Texture2D ColorMap: Flip Textures/ColoredTex/Monkey.png
    }

    Technique {
        VertexShader GLSL100 GLSL150:   Common/MatDefs/Misc/Unshaded.vert
        FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag

        WorldParameters {
            WorldViewProjectionMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            HAS_COLORMAP : ColorMap
        }
    }
}

TestMaterials/TestMissingTexture.j3md

MaterialDef TestMissingDefaultTexture {

    MaterialParameters {
        Texture2D ColorMap: Texture/that/doesnt/exist.png
    }

    Technique {
        VertexShader GLSL100 GLSL150:   Common/MatDefs/Misc/Unshaded.vert
        FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag

        WorldParameters {
            WorldViewProjectionMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            HAS_COLORMAP : ColorMap
        }
    }
}

Expected output
missingtex

@stephengold stephengold merged commit cf7b15b into jMonkeyEngine:master Mar 27, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@stephengold stephengold added this to the v3.2.4 milestone Jul 8, 2019

stephengold added a commit that referenced this pull request Jul 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.