Coder Social home page Coder Social logo

Comments (5)

RealTecWare avatar RealTecWare commented on July 30, 2024 1

I have checked it out and on my android phone it thems to be like you want it.
And on my desktop it looks as good as on my phone.

Nice work.

I will study it in the afternoon.

  • Fabian

from three.js-pathtracing-renderer.

erichlof avatar erichlof commented on July 30, 2024

Hi @RealTecWare ,
Thank you for the artifact notice! I was toying around with the normals-calculation - turns out that machine precision plays a big role in how much detail you can get when finding gradient differences for normals. Too small of an epsilon like I had it, and you get the stair stepping effect. Too large, like in your first photo, and it there is not enough detail - the snow looks like it is painted on, or a decal. I don't think there is a magic perfect number for the normals epsilon - you either have lower retro-looking detail, or stair-stepping if you intersect the rock with your camera really close.
I updated the epsilon, it still has some stepping if you get REAL close to the rocks, but from most viewing distances, I like how it looks now. Please give it a try and let me know if it works better now.

Thanks again!
-Erich

from three.js-pathtracing-renderer.

RealTecWare avatar RealTecWare commented on July 30, 2024

Hi @erichlof ,
now it's much better than before your patch.
I will checkout the last revision and will study your code, maybe I can learn something and could help anywhere one day.

Have a nice day and keep it up.

  • Fabian

from three.js-pathtracing-renderer.

erichlof avatar erichlof commented on July 30, 2024

@RealTecWare
Hi Fabian,
Thank you for the update. I just realized now that although it looks better on desktop/laptop, it looks more stair-stepped on my Android mobile device (argh...). I will work on it some more and post another update.

Yes if you study the terrain_calcNormal( vec3 pos, float t ) function, that is where I calculate the normal for the terrain. I don't know how much RayMarching you know, so apologies if you already know this: The only way to find a normal for an isometric surface like a fractal terrain after intersecting it using a raymarching algo, is to take samples right around the ray-intersection spot and find the gradient. You go one unit (size of your choice, which is the issue here) in the -X direction, take a sample, then go one unit in the +X direction, take a sample. Minus the results from each other. Now do the same in the Z direction: one unit in -Z, take sample, one unit in +Z, take sample, take the difference of the two. Y is not required because Y (the terrain height) pops out of the terrain function as a result of where the X and Z coordinates are located. So we use our epsilon and multiply the Y component of the normal vector times 2.0 because we went 1 unit in negative X and one unit in positive X, which is a total sample distance of 2.0 units, same thing for Z: we moved 2.0 units to get all the samples for that direction. Now the last step as you can see from the code is normalize (unit length of 1) the resulting normal vector. If I remember correctly, this is called the central differences method of finding gradient normals. I do the same thing for the water/ocean/lakes function.

If you find anything in the future please let me know! :)

from three.js-pathtracing-renderer.

erichlof avatar erichlof commented on July 30, 2024

Hi again,
I updated the Terrain demo to switch the magic eps number between 0.2 on desktop (which you just reported looks better now) and 0.02 on mobile touch devices (which through trial and error, looks ok on my Samsung Galaxy phone). If you have a Chrome-enabled mobile device also, can you give it a try on that as well? Thanks!

from three.js-pathtracing-renderer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.