Java 类com.badlogic.gdx.graphics.g3d.utils.RenderContext 实例源码

项目:nhglib    文件:PBRShader.java   
@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);
}
项目:DoubleHelix    文件:SubsurfaceScatteringShader.java   
@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);

}
项目:DoubleHelix    文件:BackgroundShader.java   
@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);
}
项目:ForgE    文件:BlockPreviews.java   
@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;
}
项目:ForgE    文件:FrameBufferManager.java   
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");
  }
}
项目:ForgE    文件:Level.java   
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));
}
项目:HelixEngine    文件:RenderingSystem.java   
@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();
}
项目:BotLogic    文件:SkyBox.java   
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();
}
项目:vtm    文件:GdxModelRenderer.java   
@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;
}
项目:vtm    文件:GdxRenderer3D.java   
@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;
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@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);
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@Override
public void begin(Camera camera, RenderContext context) {
    super.begin(camera, context);
    for (Feature feature : features) {
        feature.begin(program, camera, context);
    }
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@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);
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@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);
}
项目:Cubes    文件:WorldShaderProvider.java   
@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);
}
项目:Cubes    文件:WorldShaderProvider.java   
@Override
public void begin(Camera camera, RenderContext context) {
  super.begin(camera, context);
  for (Feature feature : features) {
    feature.begin(program, camera, context);
  }
}
项目:Cubes    文件:WorldShaderProvider.java   
@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);
}
项目:Cubes    文件:WorldShaderProvider.java   
@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);
}
项目:nhglib    文件:ParticleShader.java   
@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);
}
项目:LibGDX-PBR    文件:PBRShader.java   
@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);
}
项目:LibGDX-PBR    文件:PBRSadherTexture.java   
@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);
}
项目:exterminate    文件:ModelShader.java   
@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);
}
项目:exterminate    文件:DefShader.java   
@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);
    }
项目:Argent    文件:SimpleTextureShader.java   
@Override
public void begin(final Camera camera, final RenderContext context)
{
    super.begin(camera, context);
    context.setDepthTest(GL20.GL_LEQUAL);
    context.setCullFace(GL20.GL_BACK);

}
项目:Argent    文件:ShadowMapShader.java   
@Override
public void begin(final Camera camera, final RenderContext context)
{
    super.begin(camera, context);
    context.setDepthTest(GL20.GL_LEQUAL);
    context.setCullFace(GL20.GL_BACK);

}
项目:Argent    文件:NormalTextureShader.java   
@Override
public void begin(final Camera camera, final RenderContext context)
{
    super.begin(camera, context);
    context.setDepthTest(GL20.GL_LEQUAL);
    context.setCullFace(GL20.GL_BACK);

}
项目:Argent    文件:DepthMapShader.java   
@Override
public void begin(final Camera camera, final RenderContext context)
{
    super.begin(camera, context);
    context.setDepthTest(GL20.GL_LEQUAL);
    context.setCullFace(GL20.GL_BACK);

}
项目:DoubleHelix    文件:UnlitShader.java   
@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);
}
项目:DoubleHelix    文件:BlackShader.java   
@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);

}
项目:Mundus    文件:SkyboxShader.java   
@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);
}
项目:Mundus    文件:TerrainShader.java   
@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);
}
项目:Mundus    文件:ModelShader.java   
@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);
}
项目:Mundus    文件:PickerShader.java   
@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);
}
项目:ForgE    文件:BaseShader.java   
/**
 * 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();
  }
}
项目:ForgE    文件:UniformWaterSettings.java   
@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);
}
项目:ForgE    文件:UniformShadowMap.java   
@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);
}
项目:ForgE    文件:UniformLightPositionOnScreen.java   
@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
      );
    }
  }
项目:ForgE    文件:UniformFrameBuffer.java   
@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()));
  }

}
项目:ForgE    文件:UniformWind.java   
@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);
  }
}
项目:ForgE    文件:UniformClipWaterPlane.java   
@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);
  }
}