Search in sources :

Example 11 with Uniform

use of com.jme3.shader.Uniform in project jmonkeyengine by jMonkeyEngine.

the class ShaderGenerationInfo method clone.

@Override
protected ShaderGenerationInfo clone() throws CloneNotSupportedException {
    ShaderGenerationInfo clone = (ShaderGenerationInfo) super.clone();
    for (ShaderNodeVariable attribute : attributes) {
        clone.attributes.add(attribute.clone());
    }
    for (ShaderNodeVariable uniform : vertexUniforms) {
        clone.vertexUniforms.add(uniform.clone());
    }
    clone.vertexGlobal = vertexGlobal.clone();
    for (ShaderNodeVariable varying : varyings) {
        clone.varyings.add(varying.clone());
    }
    for (ShaderNodeVariable uniform : fragmentUniforms) {
        clone.fragmentUniforms.add(uniform.clone());
    }
    for (ShaderNodeVariable globals : fragmentGlobals) {
        clone.fragmentGlobals.add(globals.clone());
    }
    clone.unusedNodes.addAll(unusedNodes);
    return clone;
}
Also used : ShaderNodeVariable(com.jme3.shader.ShaderNodeVariable)

Example 12 with Uniform

use of com.jme3.shader.Uniform in project jmonkeyengine by jMonkeyEngine.

the class ShaderNodeLoaderDelegate method updateRightFromUniforms.

/**
     * updates the right variable of the given mapping from a UniformBinding (a
     * WorldParam) it checks if the uniform hasn't already been loaded, add it
     * to the maps if not.
     *
     * @param param the WorldParam UniformBinding
     * @param mapping the mapping
     * @param map the map of uniforms to search into
     * @return true if the param was added to the map
     */
protected boolean updateRightFromUniforms(UniformBinding param, VariableMapping mapping, Map<String, DeclaredVariable> map) {
    ShaderNodeVariable right = mapping.getRightVariable();
    String name = "g_" + param.toString();
    DeclaredVariable dv = map.get(name);
    if (dv == null) {
        right.setType(param.getGlslType());
        right.setName(name);
        dv = new DeclaredVariable(right);
        map.put(right.getName(), dv);
        dv.addNode(shaderNode);
        mapping.setRightVariable(right);
        return true;
    }
    dv.addNode(shaderNode);
    mapping.setRightVariable(dv.var);
    return false;
}
Also used : ShaderNodeVariable(com.jme3.shader.ShaderNodeVariable)

Example 13 with Uniform

use of com.jme3.shader.Uniform in project jmonkeyengine by jMonkeyEngine.

the class MaterialMatParamTest method testTextureMpoOnly.

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

Example 14 with Uniform

use of com.jme3.shader.Uniform in project jmonkeyengine by jMonkeyEngine.

the class MaterialMatParamTest method uniform.

private Uniform uniform(String name, VarType type, Object value) {
    Uniform u = new Uniform();
    u.setName("m_" + name);
    u.setValue(type, value);
    return u;
}
Also used : Uniform(com.jme3.shader.Uniform)

Example 15 with Uniform

use of com.jme3.shader.Uniform in project jmonkeyengine by jMonkeyEngine.

the class MaterialMatParamTest method testTextureOverride.

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

Aggregations

Uniform (com.jme3.shader.Uniform)10 Vector3f (com.jme3.math.Vector3f)4 Texture2D (com.jme3.texture.Texture2D)4 Test (org.junit.Test)4 DirectionalLight (com.jme3.light.DirectionalLight)3 PointLight (com.jme3.light.PointLight)3 SpotLight (com.jme3.light.SpotLight)3 ColorRGBA (com.jme3.math.ColorRGBA)3 ShaderNodeVariable (com.jme3.shader.ShaderNodeVariable)3 TempVars (com.jme3.util.TempVars)3 Light (com.jme3.light.Light)2 Vector4f (com.jme3.math.Vector4f)2 Renderer (com.jme3.renderer.Renderer)2 VarType (com.jme3.shader.VarType)2 BoundingSphere (com.jme3.bounding.BoundingSphere)1 AmbientLight (com.jme3.light.AmbientLight)1 MatParam (com.jme3.material.MatParam)1 Quaternion (com.jme3.math.Quaternion)1 Caps (com.jme3.renderer.Caps)1 Mesh (com.jme3.scene.Mesh)1