Program: 92366
Project: 92366
Buggy source:
public void renderEffects(DrawContext dc,DeferredRendererImpl dr){
  GL gl=dc.getGL();
  if (!dc.isSunLightEnabled())   return;
  if (!atmosphere.isTexturesDone()) {
    atmosphere.precompute(dc);
  }
  if (!atmosphere.isTexturesDone()) {
    return;
  }
  if (viewport == null || !viewport.equals(dr.getViewport())) {
    viewport=new Rectangle(dr.getDrawableWidth(),dr.getDrawableHeight());
    createResizeFbo(gl);
    createResizeScreenTexture(dc,usageTexture);
    if (enablePosEffects) {
      createResizeScreenTextureHDR(dc,finalTextureHDR);
      createResizeScreenTexture(dc,finalTexture);
    }
  }
  if (dc.isAerialPerspectiveEnabled() && useShadowVolume) {
    shadowVolumeTexture[0]=ShadowMapFactory.getWorldShadowVolumeInstance().render(dc,dr,false);
  }
  Layer layer=supportLayers.getMaterialLayer(dc);
  if (layer != null) {
    layer.preRender(dc);
  }
  bindFbo(dc,dr.getDepthTexture());
  renderLayerToFbo(dc,supportLayers.getMaterialLayer(dc),usageTexture[0],true);
  releaseFbo(dc);
  gl.glActiveTexture(GL.GL_TEXTURE0);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getColorTexture());
  gl.glActiveTexture(GL.GL_TEXTURE1);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getNormalTexture());
  gl.glActiveTexture(GL.GL_TEXTURE2);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getDepthTexture());
  gl.glTexParameteri(GL.GL_TEXTURE_2D,GL2.GL_TEXTURE_COMPARE_MODE,GL.GL_NONE);
  if (dc.isShadowsEnabled()) {
    gl.glActiveTexture(GL.GL_TEXTURE3);
    ShadowMapFactory.getWorldShadowMapInstance(dc).setShadowTerrain(!this.useShadowVolume);
    ShadowMapFactory.getWorldShadowMapInstance(dc).bindTexture(gl);
  }
  if (dc.isAtmosphereEnabled()) {
    gl.glActiveTexture(GL.GL_TEXTURE4);
    gl.glBindTexture(GL.GL_TEXTURE_2D,atmosphere.getTransmittanceTexture());
    gl.glActiveTexture(GL.GL_TEXTURE5);
    gl.glBindTexture(GL.GL_TEXTURE_2D,atmosphere.getIrradianceTexture());
    gl.glActiveTexture(GL.GL_TEXTURE6);
    gl.glBindTexture(GL2.GL_TEXTURE_3D,atmosphere.getInscatterTexture());
    if (dc.isAerialPerspectiveEnabled()) {
      gl.glActiveTexture(GL.GL_TEXTURE7);
      gl.glBindTexture(GL.GL_TEXTURE_2D,usageTexture[0]);
      if (useShadowVolume) {
        gl.glActiveTexture(GL.GL_TEXTURE8);
        gl.glBindTexture(GL.GL_TEXTURE_2D,shadowVolumeTexture[0]);
      }
    }
  }
  gl.glActiveTexture(GL.GL_TEXTURE9);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getMaterialTexture());
  gl.glActiveTexture(GL.GL_TEXTURE0);
  gl.glDepthFunc(GL.GL_ALWAYS);
  if (enablePosEffects) {
    dc.getFramebufferController().push();
    frambuffer.bind(dc);
    frambuffer.releaseTextures(dc);
    frambuffer.attachTexture2D(dc,GL.GL_COLOR_ATTACHMENT0,finalTextureHDR[0],GL.GL_TEXTURE_2D);
    frambuffer.setDrawBuffers(dc,new int[]{GL.GL_COLOR_ATTACHMENT0});
    frambuffer.setReadBuffers(dc,GL.GL_COLOR_ATTACHMENT0);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    frambuffer.isComplete(dc,false);
    gl.glDisable(GL.GL_BLEND);
    gl.glDisable(GL2.GL_ALPHA_TEST);
    if (dc.isAerialPerspectiveEnabled()) {
      renderTerrainArialPerspective(dc);
    }
 else {
      renderTerrain(dc);
    }
    if (dc.isAtmosphereEnabled()) {
      renderAtmosphere(dc);
    }
    gl.glActiveTexture(GL.GL_TEXTURE0);
    gl.glBindTexture(GL.GL_TEXTURE_2D,finalTextureHDR[0]);
    float[] intensity=getIntensity(dc);
    postProcessing.setBloom(this.enableBloom);
    postProcessing.setBlureDistance(this.enableBloom);
    postProcessing.setDepthTexture(dr.getDepthTexture());
    postProcessing.setIntensity(intensity);
    postProcessing.setTexture(finalTextureHDR[0],GL.GL_RGBA32F,GL.GL_BGRA,GL.GL_FLOAT,viewport.width,viewport.height);
    postProcessing.renderEffect(dc);
    dc.getFramebufferController().pop();
    postProcessing.renderTonemap(dc);
  }
 else {
    if (dc.isAerialPerspectiveEnabled()) {
      renderTerrainArialPerspective(dc);
    }
 else {
      renderTerrain(dc);
    }
    if (dc.isAtmosphereEnabled()) {
      renderAtmosphere(dc);
    }
  }
  gl.glDepthFunc(GL.GL_LEQUAL);
}

Fixed version (ground truth):
public void renderEffects(DrawContext dc,DeferredRendererImpl dr){
  GL gl=dc.getGL();
  if (!dc.isSunLightEnabled())   return;
  if (!atmosphere.isTexturesDone()) {
    atmosphere.precompute(dc);
  }
  if (!atmosphere.isTexturesDone()) {
    return;
  }
  if (viewport == null || !viewport.equals(dr.getViewport())) {
    viewport=new Rectangle(dr.getDrawableWidth(),dr.getDrawableHeight());
    createResizeFbo(gl);
    createResizeScreenTexture(dc,usageTexture);
    createResizeScreenTextureHDR(dc,finalTextureHDR);
    createResizeScreenTexture(dc,finalTexture);
  }
  if (dc.isAerialPerspectiveEnabled() && useShadowVolume) {
    shadowVolumeTexture[0]=ShadowMapFactory.getWorldShadowVolumeInstance().render(dc,dr,false);
  }
  Layer layer=supportLayers.getMaterialLayer(dc);
  if (layer != null) {
    layer.preRender(dc);
  }
  bindFbo(dc,dr.getDepthTexture());
  renderLayerToFbo(dc,supportLayers.getMaterialLayer(dc),usageTexture[0],true);
  releaseFbo(dc);
  gl.glActiveTexture(GL.GL_TEXTURE0);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getColorTexture());
  gl.glActiveTexture(GL.GL_TEXTURE1);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getNormalTexture());
  gl.glActiveTexture(GL.GL_TEXTURE2);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getDepthTexture());
  gl.glTexParameteri(GL.GL_TEXTURE_2D,GL2.GL_TEXTURE_COMPARE_MODE,GL.GL_NONE);
  if (dc.isShadowsEnabled()) {
    gl.glActiveTexture(GL.GL_TEXTURE3);
    ShadowMapFactory.getWorldShadowMapInstance(dc).setShadowTerrain(!this.useShadowVolume);
    ShadowMapFactory.getWorldShadowMapInstance(dc).bindTexture(gl);
  }
  if (dc.isAtmosphereEnabled()) {
    gl.glActiveTexture(GL.GL_TEXTURE4);
    gl.glBindTexture(GL.GL_TEXTURE_2D,atmosphere.getTransmittanceTexture());
    gl.glActiveTexture(GL.GL_TEXTURE5);
    gl.glBindTexture(GL.GL_TEXTURE_2D,atmosphere.getIrradianceTexture());
    gl.glActiveTexture(GL.GL_TEXTURE6);
    gl.glBindTexture(GL2.GL_TEXTURE_3D,atmosphere.getInscatterTexture());
    if (dc.isAerialPerspectiveEnabled()) {
      gl.glActiveTexture(GL.GL_TEXTURE7);
      gl.glBindTexture(GL.GL_TEXTURE_2D,usageTexture[0]);
      if (useShadowVolume) {
        gl.glActiveTexture(GL.GL_TEXTURE8);
        gl.glBindTexture(GL.GL_TEXTURE_2D,shadowVolumeTexture[0]);
      }
    }
  }
  gl.glActiveTexture(GL.GL_TEXTURE9);
  gl.glBindTexture(GL.GL_TEXTURE_2D,dr.getMaterialTexture());
  gl.glActiveTexture(GL.GL_TEXTURE0);
  gl.glDepthFunc(GL.GL_ALWAYS);
  if (dc.isPosEffectsEnabled()) {
    dc.getFramebufferController().push();
    frambuffer.bind(dc);
    frambuffer.releaseTextures(dc);
    frambuffer.attachTexture2D(dc,GL.GL_COLOR_ATTACHMENT0,finalTextureHDR[0],GL.GL_TEXTURE_2D);
    frambuffer.setDrawBuffers(dc,new int[]{GL.GL_COLOR_ATTACHMENT0});
    frambuffer.setReadBuffers(dc,GL.GL_COLOR_ATTACHMENT0);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    frambuffer.isComplete(dc,false);
    gl.glDisable(GL.GL_BLEND);
    gl.glDisable(GL2.GL_ALPHA_TEST);
    if (dc.isAerialPerspectiveEnabled()) {
      renderTerrainArialPerspective(dc);
    }
 else {
      renderTerrain(dc);
    }
    if (dc.isAtmosphereEnabled()) {
      renderAtmosphere(dc);
    }
    gl.glActiveTexture(GL.GL_TEXTURE0);
    gl.glBindTexture(GL.GL_TEXTURE_2D,finalTextureHDR[0]);
    float[] intensity=getIntensity(dc);
    postProcessing.setBloom(this.enableBloom);
    postProcessing.setBlureDistance(this.enableBlureDistance);
    postProcessing.setDepthTexture(dr.getDepthTexture());
    postProcessing.setIntensity(intensity);
    postProcessing.setTexture(finalTextureHDR[0],GL.GL_RGBA32F,GL.GL_BGRA,GL.GL_FLOAT,viewport.width,viewport.height);
    postProcessing.renderEffect(dc);
    dc.getFramebufferController().pop();
    postProcessing.renderTonemap(dc);
  }
 else {
    if (dc.isAerialPerspectiveEnabled()) {
      renderTerrainArialPerspective(dc);
    }
 else {
      renderTerrain(dc);
    }
    if (dc.isAtmosphereEnabled()) {
      renderAtmosphere(dc);
    }
  }
  gl.glDepthFunc(GL.GL_LEQUAL);
}