Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-189818

Endermen see too dark in spectator mode when F1 game overlays are visible

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Awaiting Response
    • Affects Version/s: 1.16 Pre-release 5, 1.16.1, 1.16.2 Release Candidate 1
    • Fix Version/s: None
    • Confirmation Status:
      Unconfirmed
    • Category:
      Rendering

      Description

      When spectating an enderman in spectator mode using Fancy graphics (and probably also Fabulous graphics - can't test that as my hardware doesn't support it), its view is darkened by the lack of light when not hiding game overlays with F1.

      What I expected to happen:

      Endermen view should become lighter as the local light level becomes darker. This only happens correctly when overlays are hidden with F1.

      What actually happened:

      Endermen view becomes darker at darker places, while still seeing in negative colors. The darkening is inconsistent within color negation and should not happen as it does not happen either when hiding overlays with F1.

       

      Steps to reproduce:

      1. Find an enderman in a dark place
      2. Go into spectator mode (if not already) and spectate the enderman
      3. Make sure game overlays render properly
         Enderman view renders in negative colors but is darkened
      4. Disable game overlays with F1
         Enderman view now renders correctly

      Screenshots:

      View of an enderman in a warped forest without overlays hidden. Notice that it renders way too dark for the average view of an enderman in a warped forest. The nether is generally dark and thus endermen should be seeing light.

      View of an enderman in a warped forest with overlays hidden (F1). Notice that it now renders correctly, compared to the above screenshot.

       

      Code analysis

      The cause is the vignette filter (not fully sure why, but I can prove). The vignette filter is rendered in the net.minecraft.client.gui.Gui class and slowly adapts its brightness to the local light level (inversed: 1 - lightLevel). Now it is notable that when placing glowstone near the spectated enderman with a command, the view of the enderman slowly becomes brighter, just like the vignette would do. I'm unsure why it darkens the complete view, but that could probably be the applied blending function.

      // Class net.minecraft.client.gui.Gui
      private void updateVignetteBrightness(Entity entity) {
          if (entity == null)
              return;
          float target = Mth.clamp(1 - entity.getBrightness(), 0, 1);
      
          // Slowly let the vignette adapt the target brightness
          vignetteBrightness = (float)(vignetteBrightness + (target - vignetteBrightness) * 0.01);
      }
      

      Since the vignette filter is rendered with the GUI, it is rendered after the post shader has been rendered, and thus after the screen colors have been inverted. With the inverse shader, this brings weird effects.

       

      A probable solution would be to render the vignette before the post shader. In the net.minecraft.client.renderer.GameRenderer both the post shader and the GUI are rendered. A modification could be as simple as triggering the vignette renderer before rendering the post shader:

      // Class net.minecraft.client.gui.Gui
      
      // This method becomes public (from private)
      public void renderVignette(Entity entity) { /*...*/
      // Class net.minecraft.client.renderer.GameRenderer
      // Part of: void render(float, long, boolean)
      
      // -- Insert this --
      // First: Setup proper OpenGL configuration for vignette
      if (Minecraft.useFancyGraphics() && !this.minecraft.options.hideGui) {
          this.minecraft.gui.renderVignette(this.minecraft.getCameraEntity());
      }
      // -- End insert --
       
      // Render post effect
      if (this.postEffect != null && this.effectActive) {
          RenderSystem.disableBlend();
          RenderSystem.disableDepthTest();
          RenderSystem.disableAlphaTest();
          RenderSystem.enableTexture();
          RenderSystem.matrixMode(5890);
          RenderSystem.pushMatrix();
          RenderSystem.loadIdentity();
          this.postEffect.process(partialTick);
          RenderSystem.popMatrix();
      }
      

      (code samples remapped with official mappings, and decompiled with JD-core)

      Another solution is to disable the vignette completely when in spectator mode. This could probably have some minimal but unintended side effects though.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            RGSW Shadew
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: