当前位置: 首页>>代码示例>>Java>>正文


Java DefaultShader类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.shaders.DefaultShader的典型用法代码示例。如果您正苦于以下问题:Java DefaultShader类的具体用法?Java DefaultShader怎么用?Java DefaultShader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultShader类属于com.badlogic.gdx.graphics.g3d.shaders包,在下文中一共展示了DefaultShader类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: UberShader

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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());
	}
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:21,代码来源:UberShader.java

示例2: ParticleShader

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:24,代码来源:ParticleShader.java

示例3: create

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@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);
}
 
开发者ID:nooone,项目名称:gdx-vr,代码行数:25,代码来源:SimpleRoom.java

示例4: VolumetricDepthShader

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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);
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:10,代码来源:VolumetricDepthShader.java

示例5: load

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
/** 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;
}
 
开发者ID:mitsuhirato,项目名称:TheEndlessCastle,代码行数:14,代码来源:ShaderLoader.java

示例6: createShader

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:14,代码来源:ShaderCollectionTest.java

示例7: create

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:28,代码来源:VoxelTest.java

示例8: createPrefix

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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;
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:9,代码来源:GroundShader.java

示例9: init

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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);
        });
    }
 
开发者ID:ncguy2,项目名称:Argent,代码行数:77,代码来源:ShaderForm.java

示例10: ModelShaderProvider

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public ModelShaderProvider()
{
	_config = new DefaultShader.Config(
			Gdx.files.internal(SHADER_DIR + VERTEX).readString(),
			Gdx.files.internal(SHADER_DIR + FRAGMENT).readString());
}
 
开发者ID:arksu,项目名称:origin,代码行数:7,代码来源:ModelShaderProvider.java

示例11: createPrefix

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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;
}
 
开发者ID:arksu,项目名称:origin,代码行数:7,代码来源:DepthShader.java

示例12: DefaultShaderProvider

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public DefaultShaderProvider (final DefaultShader.Config config) {
	this.config = (config == null) ? new DefaultShader.Config() : config;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:4,代码来源:DefaultShaderProvider.java

示例13: createShader

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@Override
protected Shader createShader (final Renderable renderable) {
	return new DefaultShader(renderable, config);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:5,代码来源:DefaultShaderProvider.java

示例14: getShader

import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
private Shader getShader (Renderable renderable) {
	Shader shader = useGPU 	? 	new ParticleShader(renderable, new ParticleShader.Config(mode)) :
							new DefaultShader(renderable);
	shader.init();
	return shader;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:7,代码来源:BillboardParticleBatch.java


注:本文中的com.badlogic.gdx.graphics.g3d.shaders.DefaultShader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。