floooh / sokol-samples

Sample code for https://github.com/floooh/sokol
MIT License
615 stars 79 forks source link

Shadow contact issue in sample shadow-sapp.c #114

Open lazalong opened 1 year ago

lazalong commented 1 year ago

Hi

There is a shadow contact issue in the sample shadow-sapp.c. You see it when the cube is near the floor. Compiled with gcc & VSCode

To show the issue just added a float variable cy to the state struct and the following lines at 218:

    state.cy += 0.01 * t;
    float fff = sin(state.cy) * 2 + 0.95;
    const hmm_mat4 translate = HMM_Translate(HMM_Vec3(0,fff,0));

c-shadows-sapp

lazalong commented 1 year ago

In fact it can be 'fixed' by adding 0.001 to the depth at line 154 of shadow-sapp.glsl

float depth = lightPos.z+0.001;

But that is purely by trying instead of understanding what I am doing ahaha