Comments (2)
@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
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
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.
Transitioning to space is intact.
I would like to hear your thoughts on this.
from gpu-planetary-rendering.
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)
- Skybox support? HOT 6
- Is it possible to get this to work in unity urp? HOT 5
- What is the suggested way for editing inscatter, irradiance, and transmittance textures? HOT 2
- VR Support HOT 9
- Physics not working in Unity 2021? HOT 4
- How to define the sea level? HOT 9
- Elevation based mesh colors HOT 2
- How to create continent? HOT 7
- Creating an earth sized planet HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpu-planetary-rendering.