com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkyboxShader.java    From Mundus with Apache License 2.0 6 votes vote down vote up
@Override
public void render(Renderable renderable) {

    // texture uniform
    CubemapAttribute cubemapAttribute = ((CubemapAttribute) (renderable.material
            .get(CubemapAttribute.EnvironmentMap)));
    if (cubemapAttribute != null) {
        set(UNIFORM_TEXTURE, cubemapAttribute.textureDescription);
    }

    // Fog
    Fog fog = ((MundusEnvironment) renderable.environment).getFog();
    if (fog == null) {
        set(UNIFORM_FOG, 0);
    } else {
        set(UNIFORM_FOG, 1);
        set(UNIFORM_FOG_COLOR, fog.color);
    }

    renderable.meshPart.render(program);
}
 
Example #2
Source File: SceneSkybox.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public SceneSkybox(Cubemap cubemap){
	super();
	
	// create shader provider
	Config shaderConfig = new Config();
	String basePathName = "net/mgsx/gltf/shaders/skybox";
	shaderConfig.vertexShader = Gdx.files.classpath(basePathName + ".vs.glsl").readString();
	shaderConfig.fragmentShader = Gdx.files.classpath(basePathName + ".fs.glsl").readString();
	shaderProvider =  new DefaultShaderProvider(shaderConfig);
	
	// create box
	float boxScale = (float)(1.0 / Math.sqrt(2.0));
	boxModel = new ModelBuilder().createBox(boxScale, boxScale, boxScale, new Material(), VertexAttributes.Usage.Position);
	box = boxModel.nodes.first().parts.first().setRenderable(new Renderable());
	
	// assign environment
	Environment env = new Environment();
	env.set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap));
	env.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));
	box.environment = env;
	
	// set hint to render last but before transparent ones
	box.userData = SceneRenderableSorter.Hints.OPAQUE_LAST;
	
	// set material options : preserve background depth
	box.material = new Material(ColorAttribute.createDiffuse(Color.WHITE));
	box.material.set(new DepthTestAttribute(false));
	
	
	// assign shader
	box.shader = shaderProvider.getShader(box);
}
 
Example #3
Source File: Skybox.java    From Mundus with Apache License 2.0 5 votes vote down vote up
private Model createModel() {
    ModelBuilder modelBuilder = new ModelBuilder();
    Model model = modelBuilder.createBox(1, 1, 1,
            new Material(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap)),
            VertexAttributes.Usage.Position);
    return model;
}
 
Example #4
Source File: SceneSkybox.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
public SceneSkybox set(Cubemap cubemap){
	box.environment.set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap));
	return this;
}