Planet atmospheres, ray-sphere intersections.

  Рет қаралды 28,243

Martin Donald

Martin Donald

Күн бұрын

Пікірлер: 60
@GmZorZ
@GmZorZ 4 жыл бұрын
excellent video, it reminded me of coding adventure at first but your explanation of the ray-sphere intersection is really clear! thanks!
@MartinDonald
@MartinDonald 4 жыл бұрын
Thanks! I love Sebastian's videos. Full of great info.
@GmZorZ
@GmZorZ 4 жыл бұрын
@@MartinDonald not sure if it would be in your interest, but i am currently struggling with cone/cylinder intersections for my ray tracer, so if you ever get ideas for videos about rays and intersections i have your bell turned on ;-)
@davidmurphy563
@davidmurphy563 4 жыл бұрын
I'm currently programming a procedural solar system and was looking for approaches for the atmo. And instead I find this. In Godot no less. Just bought you a pint on patreon. Thank you man.
@MartinDonald
@MartinDonald 4 жыл бұрын
Thank you very much! Really appreciated :)
@davidmurphy563
@davidmurphy563 4 жыл бұрын
I implemented this and had an odd issue. When looking directly down toward the planet there's a completely unshaded square front and centre between the camera and the planet. When looking side on I've got a nice atmo so I'm not far from the answer hopefully. I've literally just copied the shader so far and haven't gone through it properly yet but I was wondering if you have any ideas where I'm going wrong? EDIT: missed your reply, oh you're very welcome! I'm grateful to you for doing this, it's exactly what I needed explained in beautiful detail.
@davidmurphy563
@davidmurphy563 4 жыл бұрын
@@MartinDonald This is bizarre. I thought it might be the camera as mine has gimbals and zooms and all sorts so I added a new vanilla one and made that current. Same bug. Thought it might be my implementation of the shader (I'm instancing the meshes procedurally in code including the CubeMesh), so I did it that way on a fresh scene and that worked perfectly, no weird box, just not on my actual project... So it's not the shader code and it's not the camera. Grr. It's the same whether you're above the atmo or below, so it's not the neg culling. It's just like there's a "so not shade here" plane a metre from the camera... What else could it possibly be?
@MartinDonald
@MartinDonald 4 жыл бұрын
@@davidmurphy563 hmm sorry, I'm not sure what the problem could be, if you're rendering to a mesh cube as I do in the video then perhaps your sphere radius is too large and it's clipping with the cube? Since you're a patron you can also download my project files for this video and see if there are any clues in there 🔍
@davidmurphy563
@davidmurphy563 4 жыл бұрын
@@MartinDonald Yeah, I'm baffled by it too. Like I say, I got it going perfectly on another quick mockup project, just not my game... My radius is 10k but the CubeMesh is bigger and anyway, it's the opposite of that: the unshaded diamond shaped region is on the local -y axis between the camera and the world. Just like if there were an unshading plane as a child of the camera positioned on a tangent in the direction of the world removing the shade. There isn't such a plane obvs, that's just how it looks. Very frustrating. Anyway, sorry to pester, I'll keep plugging away. I'll try deleting the shader and making a new one, see if that fixes it.
@ZiplawDev
@ZiplawDev 2 жыл бұрын
brother this is amazing, I remember watching Sebastian lague's atmosphere video and having no idea where to start, this seems like a much more manageable approach, and you explained it wonderfully
@Polygarden
@Polygarden Жыл бұрын
Great video! Good to see more people doing shaders for Godot. From there it's not a big step towards clouds and atmospherics. I went this entire pathway inside of shadertoy. ^^
@WilcoVerhoef
@WilcoVerhoef 2 жыл бұрын
It looks like the atmosphere has the same density at all heights, until it cuts off at some point. Maybe the easiest hacky way of making it look like the atmosphere thins out at higher altitudes; is to not just look at the thickness ΔT, but first raise it to some power. So thickness = c * ΔT ^ e.
@stayroh
@stayroh 2 жыл бұрын
Realy Realy good tutorial tysm. I will use this to try to find the position where the second buggy of a train wagon should be on a path (the train tracks in this case)
@danieldrew2356
@danieldrew2356 4 жыл бұрын
Really good, high-quality video!
@tissuepaper9962
@tissuepaper9962 2 жыл бұрын
These videos are really helping me study for the graphics exam I'm trying to procrastinate on. Damn you Martin!
@finsflexin
@finsflexin 2 жыл бұрын
Outer Wilds was the best game I’ve ever played. Whatever you are doing, I need to stay updated!
@Rossilaz58
@Rossilaz58 2 жыл бұрын
This is really good, but something that would make it even better is casting the shadow of the planet onto the atmosphere.
@pokonomo
@pokonomo 3 жыл бұрын
That was an amazing explanation, thank you!
@isaackershnerART
@isaackershnerART 11 ай бұрын
i know it has been a while but I am stuck in UE4 trying to decipher what the is equivalent to this line: vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0); specifically, what is INV_PROJECTION_MATRIX for hlsl or in ue4 nodes. Great tutorial btw!!!!
@brodakarat6340
@brodakarat6340 2 ай бұрын
im doing a assignment where i gotta write a research on something in games and i chose atmospheres after seeing sebastian lagues one. my specific research is how are modern techniques optimising for realtime apps compared to raw ray marching
@n41sd
@n41sd 3 жыл бұрын
Amazing channel!! this is really necessary for godot!! Sugestion put some tags on video.
@jamesb9120
@jamesb9120 4 жыл бұрын
I think I have found where Sebastian Lague gets his ideas from...
@LeoninMinecraft
@LeoninMinecraft 2 жыл бұрын
this looks like a lot of fun to impliment. Im going to try making it with Unity
@ciberman
@ciberman 3 жыл бұрын
So... Are you telling me you are the new Sebastian League?
@jpsilver3510
@jpsilver3510 3 жыл бұрын
100%
@faimenDev
@faimenDev 2 жыл бұрын
Man, it's excellent video, thx!
@monsoonsheep
@monsoonsheep 2 жыл бұрын
Brilliant work!
@mimisaiko
@mimisaiko Жыл бұрын
This is exactly what I'm thinking about lately after watching those video that put GoPro camera on a balloon and let it fly to space.
@VladgavligGapchich
@VladgavligGapchich 4 жыл бұрын
Great video, as usual! Can't wait to leave the same comment again and again :)
@imbw267
@imbw267 2 жыл бұрын
Adding a sigmoid curve modifier from r=sr to r=2*sr would allow the atmosphere to blend into space
@Grytix5567
@Grytix5567 Жыл бұрын
how can you use this im so lost
@HarryLarsson-b2n
@HarryLarsson-b2n 4 күн бұрын
you should decrease the density with altitude
@feffo9908
@feffo9908 4 жыл бұрын
hei man, amazing work both at explaining and coding! just a question: while calculating the light interaction, i noticed that using a global vector for light direction is not working as I should use the relative direction to camera (otherwise the illuminated area always face the same direction of the screen) I would do some math to calculate the relative light direction starting from the global, but i'm a noob with shader and dont know the code the extrapolate the camera direction. Since you havent mentioned it in the video, how did you solve it?
@MartinDonald
@MartinDonald 4 жыл бұрын
Thanks! You're absolutely right, you just need to multiply it by your cam matrix like so: vec4(light_dir.xyz, 1.0) * CAMERA_MATRIX;
@feffo9908
@feffo9908 4 жыл бұрын
@@MartinDonald works wonderfully! thanks a lot!
@Sandmule
@Sandmule Жыл бұрын
Works great, only have one issue (kzbin.info/www/bejne/hXS9hYmmm7KGr9U): for whatever reason: float t2 = min(t+x, max_depth*1.8); //gives accurate looking results float t2 = min(t+x, max_depth); //planet still shows up in front
@samwelwalter907
@samwelwalter907 2 жыл бұрын
Having trouble when the atmosphere is scaled to large radius values like 600k and above
@gordon1201
@gordon1201 3 жыл бұрын
Anyone know what is the equivalent of VIEW in unity?
@syuta9317
@syuta9317 3 жыл бұрын
that worked for me: struct v2f { float2 uv : TEXCOORD0; float3 view : TEXCOORD1; float4 vertex : SV_POSITION; }; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.uv; o.view = mul(unity_ObjectToWorld, v.vertex); return o; } in fragment shader: float3 VIEW= normalize(i.view - _WorldSpaceCameraPos);
@jpsilver3510
@jpsilver3510 3 жыл бұрын
@@syuta9317 thank you
@addmix
@addmix 2 жыл бұрын
Godot brand Sebastian Lague
@sntghujkkbbbgtttttuuoppp
@sntghujkkbbbgtttttuuoppp Жыл бұрын
Fantastic video - you really helped me grasp this concept so much better than I otherwise would've. I'll give your channel a shout in the credits of our indie game, if it ever releases :)
@tux_the_astronaut
@tux_the_astronaut 4 жыл бұрын
How did you get the atmosphere to render really far away when I do the atmosphere has black rings
@MartinDonald
@MartinDonald 4 жыл бұрын
This is probably due to the depth buffer becoming less accurate at really long distances. You can try offsetting the depth test in the shader when the planet is really far away? Or maybe you could look into swapping your planet for a simple sprite for seriously long distances.
@Pracedru
@Pracedru 4 жыл бұрын
I suggest increasing the camera near plane when you are far away.
@jpsilver3510
@jpsilver3510 3 жыл бұрын
Does anyone know how to sample the depth texture in unity using hdrp?
@nicks4727
@nicks4727 4 жыл бұрын
How do you get the sun to light all the planets? I've been having troubles with that in Unity URP because they don't support real time point lights. Is there a better way to make the sun the main light source?
@toupocallen7572
@toupocallen7572 4 жыл бұрын
I'm sure you don't have time to answer such a dumb question but I was wondering how did you keep the player upright when on the planet. I've tried a bunch of stuff but once the planet starts moving I cant get anything to work.
@MartinDonald
@MartinDonald 4 жыл бұрын
Not a dumb question at all! 3D transforms are a nightmare. Check out this page in the godot docs, particularly the part about quaternion rotations at the end: docs.godotengine.org/en/stable/tutorials/3d/using_transforms.html
@jpsilver3510
@jpsilver3510 3 жыл бұрын
Can you please do this in unity as well?
@MartinDonald
@MartinDonald 3 жыл бұрын
I probably can't, but I can recommend Sebastian Lague's video on planet atmospheres, which is done in Unity: kzbin.info/www/bejne/eqnJdpWrod55mbs
@jpsilver3510
@jpsilver3510 3 жыл бұрын
@@MartinDonald thank you! I have seen it but he doesn't really go in too much depth, as far as i know he only mentions the rsi, but thank you for this video. Im really close to getting it in unity hdrp, just having issues with sampling the depth texture. For some reason the screen position does not get interpolated so only the bottom left corner gets all the depth of the entire depth map. Please do keep on keeping on, im loving your videos. I understood this the first time you explained it.
@thelifeoftheepie7643
@thelifeoftheepie7643 3 жыл бұрын
How did u get the lit side to properly render? In my case the lit side disappears completely when looking at the unlit side and looks like the color/light is only hitting the very top/surface of the atmosphere and not the inside. How can I fix this?
@jpsilver3510
@jpsilver3510 3 жыл бұрын
I had the same issue when i tried to render the atmosphere with a sphere, you need to use a cube like he said
@jackisgoofingoff5510
@jackisgoofingoff5510 2 жыл бұрын
right, I am trying to understand, just trying...
@JackabeeT
@JackabeeT 2 жыл бұрын
WHY ARE CIRCLES AND SPHERES SO HARD.
@finsflexin
@finsflexin 2 жыл бұрын
You need some work with your variable names. Nobody’s gonna know what “r”, “y”, “ndc”, “depth” (of what?), and “so”
Superpositions, Sudoku, the Wave Function Collapse algorithm.
14:28
Martin Donald
Рет қаралды 706 М.
[Godot] Procedural Planets (E01 the sphere)
19:07
Ombarus
Рет қаралды 25 М.
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
It Takes Two, lava lamps, Raymarching in Godot 4.1.
12:42
Martin Donald
Рет қаралды 53 М.
Calculating Ray-Sphere Intersections
12:15
The Art of Code
Рет қаралды 41 М.
Flowmaps, gradient maps, gas giants.
6:19
Martin Donald
Рет қаралды 50 М.
Ocean waves simulation with Fast Fourier transform
14:26
Jump Trajectory
Рет қаралды 374 М.
Animal Crossing, wobbly leaves, pivot caching.
8:06
Martin Donald
Рет қаралды 113 М.
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
How Big Budget AAA Games Render Clouds
10:45
SimonDev
Рет қаралды 282 М.
Coding Adventure: Solar System
12:12
Sebastian Lague
Рет қаралды 870 М.
Color Quantization and Dithering
11:55
Acerola
Рет қаралды 449 М.
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН