Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Dull texture with same lighting #88

Closed
ManishJu opened this issue May 4, 2020 · 11 comments
Closed

Dull texture with same lighting #88

ManishJu opened this issue May 4, 2020 · 11 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@ManishJu
Copy link

ManishJu commented May 4, 2020

It feels like texture contrast takes heavy hit when we change from threejs's WebGL2 to raytracing-renderer. What could be the issue ? The following textures have same lighting conditions but the dull one is from the raytracing-renderer. I even waited for the renderer to go on for 10 minutes so that the texture might clear out but the results are almost same.

I checked the texture encoding when shifting from threejs's renderer to raytracing renderer, they are same. Is that taken into account in raytracing renderer as srgb-encoding should be default for pictures on web
.

Screenshot from 2020-05-04 18-03-32
Screenshot from 2020-05-04 18-04-08

Thanks!

@jaxry
Copy link
Contributor

jaxry commented May 4, 2020

I'm not sure what's going on here. For starters, both renderers do srgb gamma correction so that isn't the issue directly. Are both renderers using the same tone mapping? What about lighting?

@ManishJu
Copy link
Author

ManishJu commented May 4, 2020

Yes both of them have same lighting and both of them are using ACES filmic tone mapping.

@ManishJu
Copy link
Author

ManishJu commented May 4, 2020

Could it be the texture minification/magnification filter ?

@ManishJu
Copy link
Author

ManishJu commented May 4, 2020

Sorry I did not provide the original texture for you guys to test . Here you go :
Casa Catillo

There was only one directional light and one environment light in the scene

@jaxry
Copy link
Contributor

jaxry commented May 5, 2020

This is a really tricky one to debug since it's difficult to control the differences between Three.js and this renderer. I have a few ideas:

  • Dir lights are not normalized between Three.js and this renderer. The brightnesses are different, and that could be one looks lighter than the other. This is a limitation that needs to be addressed outside of this issue, but it could be contributing to it. Do the brightnesses "look" the same elsewhere in the scene?

  • The renderer's BRDF is slightly different than Three.js's. Three.js simply adds the diffuse and specular light components together, while this renderer implements Disney's Principled BRDF. This could be making the surface reflect more light. To debug this, temporarily changing the BRDF to the one Three.js uses could confirm the issue.

Texture filtering could maybe be an issue but I don't understand how that would happen. If you could replicate the bug with a simple test scene that you could share, I could look into it and help out. Does that sound possible?

@ManishJu
Copy link
Author

ManishJu commented May 5, 2020

Thanks for replying !. I will definitely post a piece of code to replicate the bug here soon.

@ManishJu
Copy link
Author

I think I need to get clear of this issue before I can proceed : #95

@ManishJu
Copy link
Author

ManishJu commented May 12, 2020

Screenshot from 2020-05-12 08-32-40

There is difference in the original image and when the image is used as a texure on cube inside the ray tracer. I did not change any lighting setting here , this is the default test file.

The original image is same when rendered in realtime.

I also tested forcing the image to have LinearEncoding and the results are same!? Again, could texture encoding be the issue ?

PS: the webgl-comparison scene inside the scenes folder is also broken . Should I make a separate issue for this ?

Thanks for your support ! :)

@jaxry
Copy link
Contributor

jaxry commented May 12, 2020

This is most unusual. Does the texture look darker on my machine to you? It looks as black to me as the source image.
Screenshot from 2020-05-12 12-35-12

I think this could be a driver bug on your machine related to gamma correction. Would you be able to try this out:

  1. https://github.com/hoverinc/ray-tracing-renderer/blob/master/src/renderer/MaterialBuffer.js#L31
    Set the third argument from true to false. This will disable sRGB gamma correction

  2. https://github.com/hoverinc/ray-tracing-renderer/blob/master/src/renderer/glsl/chunks/materialBuffer.glsl#L42
    And replace this line with these two lines to do gamma correction manually.

      vec3 texColor = texture(diffuseMap, vec3(uv * materials.diffuseNormalMapSize[diffuseMapIndex].xy, diffuseMapIndex)).rgb;
      color *= pow(texColor, vec3(2.2));

Does that solve the issue?

PS: the webgl-comparison scene inside the scenes folder is also broken . Should I make a separate issue for this ?

Did you try localhost:8080/scenes/webgl-comparison/dev.html? dev.html (instead of index.html) is needed for local viewing.

@elfrank elfrank added help wanted Extra attention is needed question Further information is requested labels May 17, 2020
@ManishJu
Copy link
Author

ManishJu commented May 27, 2020

Hello @jaxry !,
Thanks for answering my questions. I tried the above with multiple operating systems(Ubuntu,Windows) & multiple nvidia driver versions namely 330,335 and 340. I even got a chance to get the results from a Mac running on integrated card. The results were all same ! Your results are quite different as compared to ours. Now I doubt which one is correct. What more can be done ? What kind of system and drivers are you running on ?

For webgl-comparison. I tried with your suggestion and it worked . Thanks !

@ManishJu
Copy link
Author

I guess the GGX model of Disney has a heavy influence(lobe) of diffuse lighting. That being said I was able to get to good texture while reducing my texture metalness from 0.2 to 0.0 which is not a big leap in realtime but affects the ray-tracer a lot. Thanks for your time guys . :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants