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

项目:GdxDemo3D    文件:UberShader.java   
public UberShader(Renderable renderable, Config config) {
    super(renderable, config);

    String prefix = DefaultShader.createPrefix(renderable, config);

    if (renderable.material.has(VertexColorTextureBlend.Red)) {
        prefix += "#define redVertexColorBlendFlag\n";
    }
    if (renderable.material.has(VertexColorTextureBlend.Green)) {
        prefix += "#define greenVertexColorBlendFlag\n";
    }
    if (renderable.material.has(VertexColorTextureBlend.Blue)) {
        prefix += "#define blueVertexColorBlendFlag\n";
    }

    program = new ShaderProgram(prefix + config.vertexShader, prefix + config.fragmentShader);
    if (!program.isCompiled()) {
        Gdx.app.debug(TAG, program.getLog());
    }
}
项目:libgdxcn    文件:ParticleShader.java   
public ParticleShader(final Renderable renderable, final Config config, final ShaderProgram shaderProgram) {
    this.config = config;
    this.program = shaderProgram;
    this.renderable = renderable;
    materialMask = renderable.material.getMask() | optionalAttributes;
    vertexMask = renderable.mesh.getVertexAttributes().getMask();

    if (!config.ignoreUnimplemented && (implementedFlags & materialMask) != materialMask)
        throw new GdxRuntimeException("Some attributes not implemented yet ("+materialMask+")");

    // Global uniforms
    register(DefaultShader.Inputs.viewTrans, DefaultShader.Setters.viewTrans);
    register(DefaultShader.Inputs.projViewTrans, DefaultShader.Setters.projViewTrans);
    register(DefaultShader.Inputs.projTrans, DefaultShader.Setters.projTrans);
    register(Inputs.screenWidth, Setters.screenWidth);
    register(DefaultShader.Inputs.cameraUp, Setters.cameraUp);
    register(Inputs.cameraRight, Setters.cameraRight);
    register(Inputs.cameraInvDirection, Setters.cameraInvDirection);
    register(DefaultShader.Inputs.cameraPosition, Setters.cameraPosition);

    // Object uniforms
    register(DefaultShader.Inputs.diffuseTexture, DefaultShader.Setters.diffuseTexture);
}
项目:gdx-vr    文件:SimpleRoom.java   
@Override
public void create() {
    assets = new AssetManager();
    String model = "Bambo_House.g3db";
    assets.load(model, Model.class);
    assets.finishLoading();
    modelInstance = new ModelInstance(assets.get(model, Model.class), new Matrix4().setToScaling(0.6f, 0.6f, 0.6f));

    DefaultShader.Config config = new Config();
    config.defaultCullFace = GL20.GL_NONE;
    ShaderProvider shaderProvider = new DefaultShaderProvider(config);
    modelBatch = new ModelBatch(shaderProvider);

    ModelBuilder builder = new ModelBuilder();
    float groundSize = 1000f;
    ground = new ModelInstance(builder.createRect(-groundSize, 0, groundSize, groundSize, 0, groundSize, groundSize, 0, -groundSize, -groundSize, 0, -groundSize, 0,
            1, 0, new Material(), Usage.Position | Usage.Normal), new Matrix4().setToTranslation(0, -0.01f, 0));
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

    VirtualReality.renderer.listeners.add(this);
    // VirtualReality.head.setCyclops(true);
}
项目:Argent    文件:VolumetricDepthShader.java   
public VolumetricDepthShader(final Renderable renderable, final ShaderProgram shaderProgramModelBorder, List<VolumetricLight> lights) {
    this.renderable = renderable;
    this.program = shaderProgramModelBorder;
    this.lights = lights;

    register(DefaultShader.Inputs.worldTrans, DefaultShader.Setters.worldTrans);
    register(DefaultShader.Inputs.projViewTrans, DefaultShader.Setters.projViewTrans);
    register(DefaultShader.Inputs.normalMatrix, DefaultShader.Setters.normalMatrix);
}
项目:TheEndlessCastle    文件:ShaderLoader.java   
/** Loads the asset.
 * @param file the resolved file to load
 * @param parameter */
@Override
public ShaderProgram load(AssetManager assetManager, String fileName, FileHandle file, ShaderParameter parameter) {
    // TODO: verifier _testShader.getLog() et _testShader.isCompiled();
    if(parameter != null)
        _shader = new ShaderProgram(Gdx.files.internal(parameter.VertexShaderPath), Gdx.files.internal(fileName));
    else
        _shader = new ShaderProgram(DefaultShader.getDefaultVertexShader(), Gdx.files.internal(fileName).readString());

    return _shader;
}
项目:libgdxcn    文件:ShaderCollectionTest.java   
@Override
protected Shader createShader (Renderable renderable) {
    if (config.vertexShader != null && config.fragmentShader != null && tempFolder != null
        && Gdx.app.getType() == ApplicationType.Desktop) {
        String prefix = DefaultShader.createPrefix(renderable, config);
        Gdx.files.absolute(tempFolder).child(name + ".vertex.glsl").writeString(prefix + config.vertexShader, false);
        Gdx.files.absolute(tempFolder).child(name + ".fragment.glsl").writeString(prefix + config.fragmentShader, false);
    }
    BaseShader result = new MultiPassShader(renderable, config);
    if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop)
        Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(result.program.getLog(), false);
    return result;
}
项目:libgdxcn    文件:VoxelTest.java   
@Override
public void create () {
    spriteBatch = new SpriteBatch();
    font = new BitmapFont();
    modelBatch = new ModelBatch();
    DefaultShader.defaultCullFace = GL20.GL_FRONT;
    camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.near = 0.5f;
    camera.far = 1000;
    controller = new FirstPersonCameraController(camera);
    Gdx.input.setInputProcessor(controller);

    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    lights.add(new DirectionalLight().set(1, 1, 1, 0, -1, 0));

    Texture texture = new Texture(Gdx.files.internal("data/g3d/tiles.png"));
    TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32);

    MathUtils.random.setSeed(0);
    voxelWorld = new VoxelWorld(tiles[0], 20, 4, 20);
    PerlinNoiseGenerator.generateVoxels(voxelWorld, 0, 63, 10);
    float camX = voxelWorld.voxelsX / 2f;
    float camZ = voxelWorld.voxelsZ / 2f;
    float camY = voxelWorld.getHighest(camX, camZ) + 1.5f;
    camera.position.set(camX, camY, camZ);
}
项目:gaiasky    文件:GroundShader.java   
public static String createPrefix(final Renderable renderable, final Config config) {
    String prefix = DefaultShader.createPrefix(renderable, config);
    final long mask = renderable.material.getMask();
    // Atmosphere ground only if camera height is set
    if ((mask & AtmosphereAttribute.CameraHeight) == AtmosphereAttribute.CameraHeight)
        prefix += "#define atmosphereGround\n";
    return prefix;
}
项目:amatsukaze    文件:ShaderCollectionTest.java   
@Override
protected Shader createShader (Renderable renderable) {
    if (config.vertexShader != null && config.fragmentShader != null && tempFolder != null
        && Gdx.app.getType() == ApplicationType.Desktop) {
        String prefix = DefaultShader.createPrefix(renderable, config);
        Gdx.files.absolute(tempFolder).child(name + ".vertex.glsl").writeString(prefix + config.vertexShader, false);
        Gdx.files.absolute(tempFolder).child(name + ".fragment.glsl").writeString(prefix + config.fragmentShader, false);
    }
    BaseShader result = new MultiPassShader(renderable, config);
    if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop)
        Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(result.program.getLog(), false);
    return result;
}
项目: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);
        });
    }
项目:origin    文件:ModelShaderProvider.java   
public ModelShaderProvider()
{
    _config = new DefaultShader.Config(
            Gdx.files.internal(SHADER_DIR + VERTEX).readString(),
            Gdx.files.internal(SHADER_DIR + FRAGMENT).readString());
}
项目:origin    文件:DepthShader.java   
public static String createPrefix(final Renderable renderable, final Config config)
{
    String prefix = DefaultShader.createPrefix(renderable, config);
    if (!config.depthBufferOnly) prefix += "#define PackedDepthFlag\n";
    return prefix;
}
项目:libgdxcn    文件:DefaultShaderProvider.java   
public DefaultShaderProvider (final DefaultShader.Config config) {
    this.config = (config == null) ? new DefaultShader.Config() : config;
}
项目:libgdxcn    文件:DefaultShaderProvider.java   
public DefaultShaderProvider (final String vertexShader, final String fragmentShader) {
    this(new DefaultShader.Config(vertexShader, fragmentShader));
}
项目:libgdxcn    文件:DefaultShaderProvider.java   
@Override
protected Shader createShader (final Renderable renderable) {
    return new DefaultShader(renderable, config);
}
项目:libgdxcn    文件:BillboardParticleBatch.java   
private Shader getShader (Renderable renderable) {
    Shader shader = useGPU  ?   new ParticleShader(renderable, new ParticleShader.Config(mode)) :
                            new DefaultShader(renderable);
    shader.init();
    return shader;
}