@Override public void begin(Camera camera, RenderContext context) { this.camera = camera; context.setCullFace(GL20.GL_BACK); context.setDepthTest(GL20.GL_LEQUAL); context.setDepthMask(true); //Gdx.gl.glViewport(0, 0, (int) camera.viewportWidth, (int) camera.viewportHeight); lightGrid.setFrustums(((PerspectiveCamera) camera)); makeLightTexture(); super.begin(camera, context); program.setUniform3fv("u_lightPositions", getLightPositions(), 0, lights.size * 3); program.setUniform3fv("u_lightDirections", getLightDirections(), 0, lights.size * 3); }
@Override public void begin(Camera camera, RenderContext context) { program.begin(); viewProjTrans.set(camera.combined); program.setUniformf(u_cameraPosition, camera.position.x, camera.position.y, camera.position.z, 1); program.setUniformf(u_worldLightDir, lightDirection.x, lightDirection.y, lightDirection.z, 0); context.setDepthTest(GL20.GL_LEQUAL); context.setCullFace(GL20.GL_BACK); context.setBlending(shouldFadeEnds ? true : false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); texture.bind(0); program.setUniformi(u_texture, 0); specLUT.getTexture().bind(1); program.setUniformi(u_specularPowerLUTTexture, 1); }
@Override public void begin(Camera camera, RenderContext context) { context.setDepthTest(GL20.GL_NONE); program.begin(); viewProjTrans.set(camera.combined); context.setCullFace(GL20.GL_BACK); context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); texture.bind(0); program.setUniformi(u_texture, 0); program.setUniformf(u_color, color.r, color.g, color.b); program.setUniformf(u_ambient, MainRenderer.AMBIENT_BRIGHTNESS); }
@Override protected void onInitialize() { if (removeOld) { clearOld(); } ForgE.blocks.loadAtlasAndUvsIfNull(); this.levelEnv = new LevelEnv(); this.shader = (TerrainShader)ForgE.shaders.get("block-preview"); this.renderContext = new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1)); this.camera = new PerspectiveCamera(40, PREVIEW_SIZE/2, PREVIEW_SIZE/2); //this.buffer = new FrameBuffer(Pixmap.Format.RGBA8888, PREVIEW_SIZE, PREVIEW_SIZE, true); camera.near = 0.01f; camera.far = 5f; camera.position.set(0f, 2.5f, 0f); camera.lookAt(new Vector3(0.2f,2.35f,0.2f)); camera.update(); this.blocks = ForgE.blocks.list(); this.i = 1; }
public void renderFB(RenderContext renderContext, LevelEnv env, String outputFrameBufferId, String shaderName) { BaseShader baseShader = ForgE.shaders.get(shaderName); if (FrameBufferShader.class.isInstance(baseShader)) { FrameBufferShader shader = (FrameBufferShader)baseShader; renderContext.begin(); { begin(outputFrameBufferId); { ForgE.graphics.clearAll(Color.CLEAR); shader.begin(screenCamera, renderContext, env); { shader.render(screenQuad, GL30.GL_TRIANGLE_STRIP); } shader.end(); } end(); } renderContext.end(); } else { throw new GdxRuntimeException(shaderName + " is not FrameBufferShader"); } }
public Level(LevelState state, TerrainGeometryProvider geometryProvider) { this.colorShaderProvider = new ShaderProvider(); this.depthShaderProvider = new DepthShaderProvider(); this.env = state.env; this.state = state; this.terrainMap = state.terrainMap; this.terrainGeometryProvider = geometryProvider; this.postProcessing = new PostProcessingManager(ForgE.files.internal("postprocessing:default.json")); this.renderContext = new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1)); this.octree = OctreeNode.root(); this.batch = new VoxelBatch(renderContext, colorShaderProvider); this.camera = env.mainCamera; this.frustrumDebugger = new FrustrumDebugAndRenderer(); frustrumDebugger.add(camera); frustrumDebugger.add(env.mainLight.getShadowCamera()); this.terrainEngine = new TerrainEngine(this); this.entities = new EntitySystemsManager(this); octree.setBounds(terrainMap.getBounds(ChunkMap.TERRAIN_TILE_SIZE)); }
@Override protected void initialize() { displayableCollections = new Array<Array<? extends Displayable>>(); modelDisplayables = new Array<ModelDisplayable>(); displayableCollections.add(modelDisplayables); decalDisplayables = new Array<DecalDisplayable>(); displayableCollections.add(decalDisplayables); renderContext = new RenderContext( new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED)); renderContext.setCullFace(GL20.GL_BACK); modelBatch = new ModelBatch(renderContext, new DefaultShaderProvider(), new HelixRenderableSorter()); decalBatch = new DecalBatch(new CameraGroupStrategy(camera)); spriteBatch = new SpriteBatch(); }
public void render(RenderContext context, PerspectiveCamera camera) { invView.set(camera.view); invView.val[Matrix4.M03] = 0; invView.val[Matrix4.M13] = 0; invView.val[Matrix4.M23] = 0; invView.inv().tra(); mvp.set(camera.projection); mvp.mul(invView); context.begin(); context.setCullFace(GL20.GL_FRONT); context.setDepthMask(false); shader.begin(); shader.setUniformMatrix(u_mvpMatrix, mvp); shader.setUniformi(s_cubemap, context.textureBinder.bind(cubeMap)); mesh.render(shader, GL20.GL_TRIANGLE_STRIP); shader.end(); context.end(); }
@Override public boolean setup() { modelBatch = new ModelBatch(new DefaultShaderProvider()); lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 1.0f, 1.0f, 1.0f, 1.f)); lights.add(new DirectionalLight().set(0.3f, 0.3f, 0.3f, 0, 1, -0.2f)); cam = new MapCamera(mMap); renderContext = new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1)); // shader = new DefaultShader(renderable.material, // renderable.mesh.getVertexAttributes(), true, false, 1, 0, 0, 0); // shader.init(); return true; }
@Override public void begin(Camera camera, RenderContext context) { super.begin(camera, context); if (Cubes.getClient() == null) { program.setUniformf(u_sunlight, 1f); } else { program.setUniformf(u_sunlight, Cubes.getClient().world.getWorldSunlight()); } program.setUniformf(u_lightoverride, -1f); }
@Override public void begin(Camera camera, RenderContext context) { super.begin(camera, context); for (Feature feature : features) { feature.begin(program, camera, context); } }
@Override public void begin(ShaderProgram program, Camera camera, RenderContext context) { WorldClient worldClient = ((WorldClient) Cubes.getClient().world); float distance = Settings.getIntegerSettingValue(Settings.GRAPHICS_VIEW_DISTANCE) * Area.SIZE_BLOCKS; float fogDistance = MathUtils.clamp(distance * 0.1f, 8f, 16f); program.setUniformf(u_cameraposition, Cubes.getClient().player.position); program.setUniformf(u_skycolor, worldClient.getSkyColour()); program.setUniformf(u_fogdistance, fogDistance); program.setUniformf(u_minfogdistance, distance - fogDistance); }
@Override public void begin(ShaderProgram program, Camera camera, RenderContext context) { TextureAttribute textureAttribute = AmbientOcclusion.getTextureAttribute(); ao_unit = context.textureBinder.bind(textureAttribute.textureDescription); program.setUniformi(u_aoTexture, ao_unit); program.setUniformf(u_aoUVTransform, textureAttribute.offsetU, textureAttribute.offsetV, textureAttribute.scaleU, textureAttribute.scaleV); }
@Override public void begin(final Camera camera, final RenderContext context) { super.begin(camera, context); //context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); //context.setDepthTest(GL20.GL_LEQUAL); //context.setDepthMask(true); }
@Override public void begin(Camera camera, RenderContext context) { this.camera=camera; this.context=context; program.begin(); program.setUniformMatrix(u_projTrans, camera.combined); context.setDepthTest(GL20.GL_LEQUAL); /* context.setDepthTest(0) per disabilitare */ context.setCullFace(GL20.GL_BACK); }
@Override public void begin (Camera camera, RenderContext context) { super.begin(camera, context); program.setUniformf("invDistFog", InGame.invDistFog); program.setUniformf("u_fogColor", InGame.solFog); // Gdx.gl20.glEnable(GL20.GL_POLYGON_OFFSET_FILL); // Gdx.gl20.glPolygonOffset(2.f, 100.f); }
@Override public void begin (Camera camera, RenderContext context) { super.begin(camera, context); // program.setUniformf("invDistFog", InGame.invDistFog); // program.setUniformf("u_fogColor", InGame.solFog); // Gdx.gl20.glEnable(GL20.GL_POLYGON_OFFSET_FILL); // Gdx.gl20.glPolygonOffset(2.f, 100.f); }
@Override public void begin(final Camera camera, final RenderContext context) { super.begin(camera, context); context.setDepthTest(GL20.GL_LEQUAL); context.setCullFace(GL20.GL_BACK); }
@Override public void begin(Camera camera, RenderContext context) { context.setDepthTest(GL20.GL_NONE); program.begin(); viewProjTrans.set(camera.combined); context.setDepthTest(GL20.GL_LEQUAL); context.setCullFace(GL20.GL_BACK); context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); texture.bind(0); program.setUniformi(u_texture, 0); }
@Override public void begin(Camera camera, RenderContext context) { context.setDepthTest(GL20.GL_NONE); program.begin(); viewProjTrans.set(camera.combined); context.setCullFace(GL20.GL_BACK); context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); }
@Override public void begin(Camera camera, RenderContext context) { this.context = context; context.begin(); program.begin(); set(UNIFORM_PROJ_VIEW_MATRIX, camera.combined); transform.idt(); transform.translate(camera.position); set(UNIFORM_TRANS_MATRIX, transform); }
@Override public void begin(Camera camera, RenderContext context) { this.context = context; context.begin(); context.setCullFace(GL20.GL_BACK); this.context.setDepthTest(GL20.GL_LEQUAL, 0f, 1f); this.context.setDepthMask(true); program.begin(); set(UNIFORM_PROJ_VIEW_MATRIX, camera.combined); set(UNIFORM_CAM_POS, camera.position); }
@Override public void begin(Camera camera, RenderContext context) { this.context = context; context.begin(); this.context.setCullFace(GL20.GL_BACK); this.context.setDepthTest(GL20.GL_LEQUAL, 0f, 1f); this.context.setDepthMask(true); program.begin(); set(UNIFORM_PROJ_VIEW_MATRIX, camera.combined); set(UNIFORM_CAM_POS, camera.position); }
@Override public void begin(Camera camera, RenderContext context) { this.context = context; this.context.setCullFace(GL20.GL_BACK); this.context.setDepthTest(GL20.GL_LEQUAL, 0f, 1f); this.context.setDepthMask(true); program.begin(); set(UNIFORM_PROJ_VIEW_MATRIX, camera.combined); }
/** * Setup uniforms and begin new render context * @param camera * @param context */ public void begin(Camera camera, RenderContext context, LevelEnv env) { this.camera = camera; this.context = context; this.env = env; if (isValid()) { shader.begin(); context.begin(); bindGlobalUniforms(camera, context, env); afterBegin(); } }
@Override public void bind(ShaderProgram shader, LevelEnv env, RenderContext context, Camera camera) { shader.setUniformf(UNIFORM_WATER_COLOR, env.water.color); shader.setUniformf(UNIFORM_WATER_WAVE_STRENGTH, env.water.waveStrength); shader.setUniformf(UNIFORM_WATER_DISPLACEMENT_TILING, env.water.displacementTiling); shader.setUniformf(UNIFORM_WATER_SPEED, env.water.waterSpeed); shader.setUniformf(UNIFORM_WATER_COLOR_TINT, env.water.colorTint); shader.setUniformf(UNIFORM_WATER_REFRACTION_FACTOR, env.water.refractiveFactor); shader.setUniformf(UNIFORM_WATER_REFLECTIVITY, env.water.reflectivity); shader.setUniformf(UNIFORM_WATER_SHINE_DAMPER, env.water.shineDamper); }
@Override public void bind(ShaderProgram shader, LevelEnv env, RenderContext context, Camera camera) { Camera shadowCamera = env.mainLight.getCamera(); shader.setUniformi(UNIFORM_SHADOW_FAR_MAP_TEXTURE, context.textureBinder.bind(ForgE.fb.get(Fbo.FRAMEBUFFER_SUN_FAR_DEPTH).getColorBufferTexture())); shader.setUniformi(UNIFORM_SHADOW_NEAR_MAP_TEXTURE, context.textureBinder.bind(ForgE.fb.get(Fbo.FRAMEBUFFER_SUN_NEAR_DEPTH).getColorBufferTexture())); shader.setUniformMatrix(UNIFORM_SHADOW_MAP_FAR_TRANSFORM, env.mainLight.farMatrix); shader.setUniformMatrix(UNIFORM_SHADOW_MAP_NEAR_TRANSFORM, env.mainLight.nearMatrix); shader.setUniformf(UNIFORM_SHADOW_MAP_POSITION, shadowCamera.position.x, shadowCamera.position.y, shadowCamera.position.z, UniformEyePosition.CONST / (shadowCamera.far * shadowCamera.far)); shader.setUniformf(UNIFORM_SHADOW_MAP_FAR, shadowCamera.far); shader.setUniformf(UNIFORM_SHADOW_MAP_NEAR, shadowCamera.near); }
@Override public void bind(ShaderProgram shader, LevelEnv env, RenderContext context, Camera camera) { if (ForgE.time.isDay()) { shader.setUniformf( UNIFORM_DOT_DIR_VIEW_NAME, tempVec.set(env.mainLight.direction).dot(env.mainCamera.direction) ); } else { shader.setUniformf( UNIFORM_DOT_DIR_VIEW_NAME, 1 ); } if (DayNightSkybox.class.isInstance(env.skybox)) { DayNightSkybox dayNightSkybox = (DayNightSkybox)env.skybox; dayNightSkybox.getLightPosition(tempVec); env.mainCamera.project(tempVec); /*tempVec.x /= env.mainCamera.far; tempVec.y /= env.mainCamera.far; tempVec.x = (tempVec.x + 1.0f) / 2.0f; tempVec.y = (tempVec.y + 1.0f) / 2.0f; //tempVec.z /= camera.far; */ shader.setUniformf( UNIFORM_POS_ON_SCREEN, tempVec.x / env.mainCamera.viewportWidth, tempVec.y / env.mainCamera.viewportHeight ); } }
@Override public void bind(ShaderProgram shader, LevelEnv env, RenderContext context, Camera camera) { FrameBuffer frameBuffer = ForgE.fb.get(fbName); if (frameBuffer == null) { throw new GdxRuntimeException("Could not find framebuffer: " + fbName); } else { shader.setUniformi(uniformName, context.textureBinder.bind(frameBuffer.getColorBufferTexture())); } }
@Override public void bind(ShaderProgram shader, LevelEnv env, RenderContext context, Camera camera) { if (env.getWindDisplacementTextureAsset() != null) { shader.setUniformi(UNIFORM_WIND_DISPLACEMENT_TEXTURE, context.textureBinder.bind(env.getWindDisplacementTexture())); shader.setUniformf(UNIFORM_WIND_DIR, env.windDirection); } }
@Override public void bind(ShaderProgram shader, LevelEnv env, RenderContext context, Camera camera) { shader.setUniformf(UNIFORM_CLIP_ELEVATION, env.water.getElevationWithWaterBlockHeight()); switch (env.water.clipMode) { case Reflection: shader.setUniformf(UNIFORM_CLIP_NORMAL, reflectionNormal); break; case Refraction: shader.setUniformf(UNIFORM_CLIP_NORMAL, refractionNormal); break; default: shader.setUniformf(UNIFORM_CLIP_ELEVATION, DISABLED_ELEVATION); } }