tiansijie/Tile_Based_WebGL_DeferredShader

How to correctly sample light index from the light index texture?

Danielmelody opened this issue · 6 comments

Hi, great works!
I 'm a student and was doing my own implementation according to this repository and the paper below.

Which keeps confusing me is that when I sample from the light index texture, I get twinkle tiles
image

The width and height of light index texture are both Math.ceil(Math.sqrt(length of index)).
Here is how I sample this texture

        float listY = ((float(lightStartIndex + i) + 0.5) / uLightListLengthSqrt);
        float listX = mod((float(lightStartIndex + i) + 0.5), uLightListLengthSqrt) / uLightListLengthSqrt;
        listY = (listY / (uLightListLengthSqrt));

The uLightListLengthSqrt is the square root of light Indices length.
listX and listY will be used as the uv coordinate of the light-index texture.

Do you know what's wrong with my code?

hmm, hard to tell, but also be careful the light texture you pass to shader need to make sure that is correct as well.

Well, it seems to be a bug of chrome(not sure). By adjusting a few code, it works. But I don't know how it works....
WebGL sucks sometimes compared to modern OpenGL

@Danielhu229 what kind of bug do you think? what did you do to fix this problem?

@tiansijie Let me got some time to clear my code and do some test, later I will post here

Anyway, thanks for your reply.

Anyway, thanks for your reply.