Package com.jme3.shader

Examples of com.jme3.shader.ShaderNodeVariable


        try {
            mapping = parseMapping(statement1, new boolean[]{false, true});
        } catch (Exception e) {
            throw new MatParseException("Unexpected mapping format", statement1, e);
        }
        ShaderNodeVariable left = mapping.getLeftVariable();
        ShaderNodeVariable right = mapping.getRightVariable();
        if (!updateVariableFromList(left, shaderNode.getDefinition().getInputs())) {
            throw new MatParseException(left.getName() + " is not an input variable of " + shaderNode.getDefinition().getName(), statement1);
        }

        if (left.getType().startsWith("sampler") && !right.getNameSpace().equals("MatParam")) {
            throw new MatParseException("Samplers can only be assigned to MatParams", statement1);
        }

        if (right.getNameSpace().equals("Global")) {
            right.setType("vec4");//Globals are all vec4 for now (maybe forever...)
            //        updateCondition(right, mapping);
            storeGlobal(right, statement1);

        } else if (right.getNameSpace().equals("Attr")) {
            if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) {
                throw new MatParseException("Cannot have an attribute as input in a fragment shader" + right.getName(), statement1);
            }
            updateVarFromAttributes(mapping.getRightVariable(), mapping);
            //          updateCondition(mapping.getRightVariable(), mapping);
            storeAttribute(mapping.getRightVariable());
        } else if (right.getNameSpace().equals("MatParam")) {
            MatParam param = findMatParam(right.getName());
            if (param == null) {
                throw new MatParseException("Could not find a Material Parameter named " + right.getName(), statement1);
            }
            if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) {
                if (updateRightFromUniforms(param, mapping, vertexDeclaredUniforms, statement1)) {                 
                    storeVertexUniform(mapping.getRightVariable());
                }
            } else {
                if (updateRightFromUniforms(param, mapping, fragmentDeclaredUniforms, statement1)) {
                    if (mapping.getRightVariable().getType().contains("|")) {
                        String type = fixSamplerType(left.getType(), mapping.getRightVariable().getType());
                        if (type != null) {
                            mapping.getRightVariable().setType(type);
                        } else {
                            throw new MatParseException(param.getVarType().toString() + " can only be matched to one of " + param.getVarType().getGlslType().replaceAll("\\|", ",") + " found " + left.getType(), statement1);
                        }
                    }               
                    storeFragmentUniform(mapping.getRightVariable());
                }
            }

        } else if (right.getNameSpace().equals("WorldParam")) {
            UniformBinding worldParam = findWorldParam(right.getName());
            if (worldParam == null) {
                throw new MatParseException("Could not find a World Parameter named " + right.getName(), statement1);
            }
            if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) {
                if (updateRightFromUniforms(worldParam, mapping, vertexDeclaredUniforms)) {                   
                    storeVertexUniform(mapping.getRightVariable());
                }
            } else {
                if (updateRightFromUniforms(worldParam, mapping, fragmentDeclaredUniforms)) {                   
                    storeFragmentUniform(mapping.getRightVariable());
                }
            }

        } else {
            ShaderNode node = nodes.get(right.getNameSpace());
            if (node == null) {
                throw new MatParseException("Undeclared node" + right.getNameSpace() + ". Make sure this node is declared before the current node", statement1);
            }
            ShaderNodeVariable var = findNodeOutput(node.getDefinition().getOutputs(), right.getName());
            if (var == null) {
                throw new MatParseException("Cannot find output variable" + right.getName() + " form ShaderNode " + node.getName(), statement1);
            }
            right.setNameSpace(node.getName());
            right.setType(var.getType());
            mapping.setRightVariable(right);           
            storeVaryings(node, mapping.getRightVariable());

        }
View Full Code Here


        try {
            mapping = parseMapping(statement1, new boolean[]{true, false});
        } catch (Exception e) {
            throw new MatParseException("Unexpected mapping format", statement1, e);
        }
        ShaderNodeVariable left = mapping.getLeftVariable();
        ShaderNodeVariable right = mapping.getRightVariable();


        if (left.getType().startsWith("sampler") || right.getType().startsWith("sampler")) {
            throw new MatParseException("Samplers can only be inputs", statement1);
        }

        if (left.getNameSpace().equals("Global")) {
            left.setType("vec4");//Globals are all vec4 for now (maybe forever...)
            storeGlobal(left, statement1);
        } else {
            throw new MatParseException("Only Global nameSpace is allowed for outputMapping, got" + left.getNameSpace(), statement1);
        }

        if (!updateVariableFromList(right, shaderNode.getDefinition().getOutputs())) {
            throw new MatParseException(right.getName() + " is not an output variable of " + shaderNode.getDefinition().getName(), statement1);
        }

        checkTypes(mapping, statement1);

        return mapping;
View Full Code Here

     * @throws IOException
     */
    public void storeGlobal(ShaderNodeVariable var, Statement statement1) throws IOException {
        var.setShaderOutput(true);
        if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) {
            ShaderNodeVariable global = techniqueDef.getShaderGenerationInfo().getVertexGlobal();
            if (global != null) {
//                global.setCondition(mergeConditions(global.getCondition(), var.getCondition(), "||"));
//                var.setCondition(global.getCondition());
                if (!global.getName().equals(var.getName())) {
                    throw new MatParseException("A global output is already defined for the vertex shader: " + global.getName() + ". vertex shader can only have one global output", statement1);
                }
            } else {
                techniqueDef.getShaderGenerationInfo().setVertexGlobal(var);
            }
        } else if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) {
View Full Code Here

     * Starts the application. Creating a display and running the main loop.
     */
    public void start(){

        if (settings == null){
            settings = new AppSettings(true);
        }
       
        context = JmeSystem.newContext(settings, JmeContext.Type.OffscreenSurface);
        context.setSystemListener(this);
        context.create(false);
View Full Code Here

      new ModelInfo(activeModel, app.getAssetLogger().getKeys(activeModel.getRelPath(workspace)));
    } catch (Exception e) {}
  }

  public static void createCanvas(){
    AppSettings settings = new AppSettings(true);
    settings.setWidth( Math.max(640, frame.getContentPane().getWidth()) );
    settings.setHeight( Math.max(480, frame.getContentPane().getHeight()) );

    app = new EditorApp();

    app.setPauseOnLostFocus(false);
    app.setSettings(settings);
    app.createCanvas();

    context = (JmeCanvasContext) app.getContext();
    canvas = context.getCanvas();
    canvas.setSize(settings.getWidth(), settings.getHeight());
  }
View Full Code Here

   * main for testing
   *
   * @param args
   */
  public static void main(String[] args) {
        AppSettings settings = new AppSettings(true);
        PolluxSettingsDialog.show(settings);
        System.out.println(settings.toString());
        System.exit(0);
  }
View Full Code Here

    }

    @Override
    public void start() {
     
        setSettings(new AppSettings(true));
        PolluxSettingsDialog.show(settings);
       
        super.start();
    }
View Full Code Here

    */
    Geometry g = new Geometry("Bubble", b);
    g.rotate(FastMath.HALF_PI, 0, FastMath.HALF_PI);
    //g.scale(1, 1, -1);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    Texture tex = assetManager.loadTexture("Textures/test3.png");
    mat.setTexture("ColorMap", tex);
    //mat.setColor("Color", ColorRGBA.Blue);
    //mat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
    g.setMaterial(mat);
   
View Full Code Here

    sphere.setQueueBucket(Bucket.Sky);
    Material sky = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
    TextureKey key = new TextureKey("Textures/Sky/Stars.dds", true);
    key.setGenerateMips(true);
    key.setAsCube(true);
    Texture tex = assetManager.loadTexture(key);
    sky.setTexture("m_Texture", tex);
    sky.setVector3("m_NormalScale", Vector3f.UNIT_XYZ);
    sphere.setMaterial(sky);
    sphere.setCullHint(Spatial.CullHint.Never);
    bgNode.attachChild(sphere);
View Full Code Here

  public void initialize(AppStateManager stateManager, Application app){
    super.initialize(stateManager, app);
    assetManager = app.getAssetManager();
    settings = app.getContext().getSettings();
   
    Picture pic = new Picture("HUD Picture");
    pic.setImage(assetManager, "Hud/InfoBox2.png", true);
    pic.setHeight(settings.getHeight());
    pic.setWidth(settings.getHeight()/2);
    pic.setPosition(settings.getWidth()-settings.getHeight()/2, 0);
    menuNode.attachChild(pic);
   
   
    /*Quad q = new Quad(6, 3);
        Geometry g = new Geometry("quad", q);
View Full Code Here

TOP

Related Classes of com.jme3.shader.ShaderNodeVariable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.