lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3

Home Page:https://ahbejarano.gitbook.io/lwjglgamedev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visual glitch

parpar8090 opened this issue · comments

image
Only happens when the glitched shadow is in the "sky" (where any other object exists). Also not happens when the window is in fullscreen or maximized, only when in other states.

Hi,

Can you please state in which chapter you do experience this issue? If you can, provide camera settings. If you have modified the source code, please provide a link to the repository to try to replicate it.

Hi,

Can you please state in which chapter you do experience this issue? If you can, provide camera settings. If you have modified the source code, please provide a link to the repository to try to replicate it.

I am using chapter 28, not modified

Ok, but the objects rendered are different, this is not what is rendered in that chapter (so you should have modified at least that part). Could you share that part, specially the camera? Another question, is the glitch temporary or it is permanent?

Ok, but the objects rendered are different, this is not what is rendered in that chapter (so you should have modified at least that part). Could you share that part, specially the camera? Another question, is the glitch temporary or it is permanent?

I just changed this (in the DummyGame class):

public void init(Window window) throws Exception {
        renderer.init(window);

        scene = new Scene();

        Mesh[] houseMesh = StaticMeshesLoader.load("models/cube.obj", "models/house");
        GameItem house = new GameItem(houseMesh);

        scene.setGameItems(new GameItem[]{house});

        // Shadows
        scene.setRenderShadows(true);

        // Fog
        Vector3f fogColour = new Vector3f(0.5f, 0.5f, 0.5f);
        scene.setFog(new Fog(true, fogColour, 0.02f));

        // Setup  SkyBox
        float skyBoxScale = 100.0f;
        SkyBox skyBox = new SkyBox("models/skybox.obj", new Vector4f(0.65f, 0.65f, 0.65f, 1.0f));
        skyBox.setScale(skyBoxScale);
        scene.setSkyBox(skyBox);

        // Setup Lights
        setupLights();

        camera.getPosition().x = -17.0f;
        camera.getPosition().y =  17.0f;
        camera.getPosition().z = -30.0f;
        camera.getRotation().x = 20.0f;
        camera.getRotation().y = 140.f;
    }

Thanks, I will have a look at it.

I've just uploaed a fix. Let me me know if that works for you.

The problem was when resizing a window. The size of the buffer in the fog step was wrong. In any case, current code can be simplfied by just drawing 3 vertices and properly setting coordinates in the vertex buffer (no need to hang with screen size). Although this sample uses Vulkan, you can see how this can be done here.

I'm currentlt working with Vulkan but if I have some spare time I will update this chapter to simplify this.

Many thanks for pointing the issue.

Closing the issue. If it persists, please reopen.