Java 类com.badlogic.gdx.graphics.g3d.shaders.DepthShader 实例源码

项目:Argent    文件:ShaderForm.java   
public void init() {
        vertexShaderArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS);
        vertexShaderArea.setCodeFoldingEnabled(true);

        fragmentShaderArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS);
        fragmentShaderArea.setCodeFoldingEnabled(true);

        shaderInfo = new ArrayList();

        newShaderBtn.addActionListener(e -> add());
        shaderCompileBtn.addActionListener(e -> {
            displayDetectedUniforms();
            save();
        });
        applyShaderBtn.addActionListener(e -> apply());
        deleteShaderBtn.addActionListener(e -> delete());

        uniformList.setModel(new DefaultListModel<>());

        // TREE

        DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Editor");

//        collectionTree.setModel(new DefaultTreeModel(rootNode));

        collectionTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        collectionTree.addTreeSelectionListener(e -> select());

        DefaultMutableTreeNode autoWireNode = new DefaultMutableTreeNode("Autowired Uniforms");
        UNIFORMS().keySet().stream().sorted((o1, o2) -> o1.alias.compareToIgnoreCase(o2.alias)).forEach(k -> {
            autoWireNode.add(new DefaultMutableTreeNode(k.alias));
        });

        shaderNode = new DroppableTreeNode("Shaders");
        DefaultTreeModel model = new DefaultTreeModel(rootNode);

        collectionTree.setModel(model);

        premadeNode = new DefaultMutableTreeNode("Native Shaders");
        // Uber Shader
        DynamicShader.Info uberShaderInfo = new DynamicShader.Info(false);
        uberShaderInfo.name = "Uber Shader";
        uberShaderInfo.desc = "The default LibGdx shader";
        uberShaderInfo.vertex = DefaultShader.getDefaultVertexShader();
        uberShaderInfo.fragment = DefaultShader.getDefaultFragmentShader();
        premadeNode.add(new DefaultMutableTreeNode(uberShaderInfo));
        DynamicShader.Info uberDepthShaderInfo = new DynamicShader.Info(false);
        uberDepthShaderInfo.name = "Uber Depth Shader";
        uberDepthShaderInfo.desc = "The default LibGdx Depth Shader";
        uberDepthShaderInfo.vertex = DepthShader.getDefaultVertexShader();
        uberDepthShaderInfo.fragment = DepthShader.getDefaultFragmentShader();
        premadeNode.add(new DefaultMutableTreeNode(uberDepthShaderInfo));

        rootNode.add(autoWireNode);
        rootNode.add(premadeNode);
        rootNode.add(shaderNode);

        DefaultComboBoxModel<DynamicShader.GLPrimitiveType> primitiveModel = new DefaultComboBoxModel<>();
        for (DynamicShader.GLPrimitiveType type : DynamicShader.GLPrimitiveType.values())
            primitiveModel.addElement(type);
        shaderPrimitiveSelect.setModel(primitiveModel);

//        readFromDisk();



        finalRendererText.setText(getFinalShader() != null ? getFinalShader().name : "");

        collectionTree.addTreeSelectionListener(e -> {
            DynamicShader.Info info = getFinalShader();
            finalRendererText.setText(info != null ? info.name : "Error");
            if (realtime)
                if (info != null)
                    Gdx.app.postRunnable(editorController::compile);
        });
    }
项目:libgdxcn    文件:DepthShaderProvider.java   
public DepthShaderProvider (final DepthShader.Config config) {
    this.config = (config == null) ? new DepthShader.Config() : config;
}
项目:libgdxcn    文件:DepthShaderProvider.java   
public DepthShaderProvider (final String vertexShader, final String fragmentShader) {
    this(new DepthShader.Config(vertexShader, fragmentShader));
}
项目:libgdxcn    文件:DepthShaderProvider.java   
@Override
protected Shader createShader (final Renderable renderable) {
    return new DepthShader(renderable, config);
}
项目:BotLogic    文件:GameLevelScreen.java   
public GameLevelScreen(LevelFile levelDef) {
  this.gameObjectsTweenManager = new TweenManager();
  this.uiTweenManager          = new TweenManager();
  this.renderContext      = new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1));
  this.entities           = new ArrayList<Entity>();
  this.perspectiveCamera  = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

  levelDefinition         = levelDef;

  this.map                = new Map(levelDefinition.geometryFile());
  perspectiveCamera.position.set(0, 0, 0);
  perspectiveCamera.near = 0.1f;
  perspectiveCamera.far = 50f;
  perspectiveCamera.update(true);

  this.cameraController = new RTSCameraController();
  cameraController.setCamera(perspectiveCamera);
  cameraController.setCenter(0, 0);
  cameraController.setEnabled(true);

  environment = new Environment();
  environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1f));

  this.cellShadingCompositor = new LevelCompositor(renderContext);

  this.robot = BotLogic.entities.robot();
  this.robot.led = BotLogic.entities.led();

  addEntity(this.robot);
  addEntity(this.robot.led);

  colorModelBatch = new ModelBatch(renderContext);
  decalBatch      = new DecalBatch();

  decalBatch.setGroupStrategy(new CameraGroupStrategy(perspectiveCamera));

  DepthShader.Config depthConfig     = new DepthShader.Config(Gdx.files.internal("shaders/depth.vertex").readString(), Gdx.files.internal("shaders/depth.frag").readString());
  depthConfig.defaultCullFace        = GL20.GL_BACK;
  depthConfig.depthBufferOnly        = false;
  depthModelBatch = new ModelBatch(renderContext, new DepthShaderProvider(depthConfig));

  map.environment = environment;
  this.controller = new GameController(this);
  reset();

  environment.set(new ColorAttribute(ColorAttribute.Fog, 0f, 0f, 0f, 1f));
  environment.add(new DirectionalLight().set(new Color(.4f,.4f, .4f, 0.1f), new Vector3(1,-1,0)));
  BotLogic.audio.mainMenuMusic.play();
}