Coder Social home page Coder Social logo

Comments (2)

AustinSmith13 avatar AustinSmith13 commented on June 14, 2024

@simeonradivoev I have a solution to this problem now. I'm not sure if this is the correct way to go about realistic rendering, but works for what I need. I'll explain how I arrived to this solution.

The Solution

Attenuation_Broken

before we calculated the attenuation if it was below the horizon, the original function for Transmittance handled the bottom and top half of the atmosphere.

I removed the function Transmittance and created a new function called Transmittance_Bottom

float3 Transmittance_Bottom(float r, float mu, float d) 
{
    float r1 = sqrt(r * r + d * d + 2.0 * r * mu * d);
    float mu1 = (r * mu + d) / r1;
    return min (Transmittance(r, -mu1), 1.0);
}

Transmittance use to take into account both sides of the horizon, but now this is split up into separate functions.

Instead of pathLength < maxPathLength I check to see if anything is in-front of the atmosphere.

if (pathLength < (Rg - atmosOffset))
{
    // reduce total in-scattered light when surface hit 
    // within atmosphere
    // fíx described in chapter 5.1.1 
    attenuation = Transmittance_Bottom(startPosHeight, muStartPos, pathLength);
 
    float muEndPos = dot(surfacePos, viewDir) / surfacePosHeight; 
    inscatterSurface = Texture4D(_Inscatter, surfacePosHeight, muEndPos, musEndPos, nuStartPos);

    // Inscatter for objects infront of the sky
    inscatter = max(inscatter - attenuation.rgbr * inscatterSurface, 0.0f) * pathLength/ (Rg  -  fogDensity); 

    irradianceFactor = 1.0f;
} 

I then removed all of the code for the if block because we do not need to blend the artifact.
if (abs(muStartPos - muHorizon) < EPSILON_INSCATTER)

After Changes

Attenuation_Better_Assume_Unit_Sphere
After applying the changes to the attenuation calculations we no longer have the strange artifact from division. It looks much better, but is still incorrect, I need to find out how to take the height into consideration when calculating mu (still figuring that out).

Inscatter will also look better because we are changing the intensity of the fog depending on how close the geometry is to us.

DayNight.mp4

From the ground you can not discern any visual distortions.

Fog_change.mp4

You can change the fog intensity.

space

Transitioning to space is intact.

I would like to hear your thoughts on this.

from gpu-planetary-rendering.

simeonradivoev avatar simeonradivoev commented on June 14, 2024

I remember something about this issue, and it is caused because the precomputed texture is for a perfect sphere. You can get away with blending some of it when you have a huge planet but it doesn't work if your mountains are super huge or your planet is small.
Not sure what you can do, except tricks as you did to minimize it. Or maybe investigate how others have solved it.

from gpu-planetary-rendering.

Related Issues (10)

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.