com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider.
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: GameRenderer.java From GdxDemo3D with Apache License 2.0 | 6 votes |
public GameRenderer(Viewport viewport, Camera camera, GameEngine engine) { this.viewport = viewport; this.camera = camera; this.engine = engine; shapeRenderer = new MyShapeRenderer(); shapeRenderer.setAutoShapeType(true); spriteBatch = new SpriteBatch(); font = new BitmapFont(); font.setColor(Color.WHITE); font.setUseIntegerPositions(false); font.getData().setScale(0.01f); shadowBatch = new ModelBatch(new DepthShaderProvider()); ShaderProgram.pedantic = false; final String vertUber = Gdx.files.internal("shaders/uber.vert").readString(); final String fragUber = Gdx.files.internal("shaders/uber.frag").readString(); modelBatch = new ModelBatch(new DefaultShaderProvider(vertUber, fragUber) { @Override protected Shader createShader(final Renderable renderable) { return new UberShader(renderable, config); } }); }
Example #2
Source File: SimpleRoom.java From gdx-vr with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: View.java From gdx-proto with Apache License 2.0 | 6 votes |
private void initShaders() { FileHandle vertexFile = Gdx.files.internal("shaders/vertex.glsl"); FileHandle fragFile = Gdx.files.internal("shaders/frag.glsl"); shaderProvider = new DefaultShaderProvider(vertexFile, fragFile); shaderProvider.config.numPointLights = 10; shaderProvider.config.numDirectionalLights = 2; // check shader compile logs /*shader = new ShaderProgram(vertexFile, fragFile); ShaderProgram.pedantic = false; String log = shader.getLog(); if (!shader.isCompiled()) throw new GdxRuntimeException(log); if (log!=null && log.length()!=0) System.out.println("Shader Log: "+log);*/ }
Example #4
Source File: SceneSkybox.java From gdx-gltf with Apache License 2.0 | 5 votes |
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 #5
Source File: Sprite3DRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public static void createBatchs() { Config modelConfigShader = new Config(Gdx.files.classpath(VERTEX_SHADER).readString(), Gdx.files.classpath(FRAGMENT_SHADER).readString()); modelConfigShader.numBones = MAX_BONES; modelConfigShader.numDirectionalLights = 0; modelConfigShader.numPointLights = 0; modelConfigShader.numSpotLights = 0; modelBatch = new ModelBatch(new DefaultShaderProvider(modelConfigShader)); shadowBatch = new ModelBatch(new DepthShaderProvider()); floorBatch = new ModelBatch(new DefaultShaderProvider(Gdx.files.classpath(VERTEX_SHADER), Gdx.files.classpath(FLOOR_FRAGMENT_SHADER))); }