Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Danielmelody opened this issue Mar 3, 2017 · 6 comments
Closed

Comments

@Danielmelody
Copy link

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?

@Danielmelody Danielmelody changed the title How to correctly sample light index from the light index texture How to correctly sample light index from the light index texture? Mar 3, 2017
@tiansijie
Copy link
Owner

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

@Danielmelody
Copy link
Author

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

@tiansijie
Copy link
Owner

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

@Danielmelody
Copy link
Author

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

@Danielmelody
Copy link
Author

Anyway, thanks for your reply.

1 similar comment
@Danielmelody
Copy link
Author

Anyway, thanks for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants