Тёмный

Planet atmospheres, ray-sphere intersections. 

Martin Donald
Подписаться 36 тыс.
Просмотров 27 тыс.
50% 1

In this video I create a planet atmosphere effect using ray-sphere intersections.
References:
• Calculating Ray-Sphere...
gist.github.com/wwwtyro/beecc...
• Realistic atmosphere f...
docs.godotengine.org/en/stabl...
Me:
Patreon / bolddunkley
Twitter / bolddunkley
itch.io bolddunkley.itch.io/
Software used for this video:
(Content)
Blender 2.8 www.blender.org/
Godot 3.2 godotengine.org/
Krita krita.org/en/
(Recording/Editing)
OBS obsproject.com/
Kdenlive kdenlive.org/en/
Music:
Bossa Antigua by Kevin MacLeod
Link: incompetech.filmmusic.io/song...
License: creativecommons.org/licenses/b...

Опубликовано:

 

14 май 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 58   
@GmZorZ
@GmZorZ 3 года назад
excellent video, it reminded me of coding adventure at first but your explanation of the ray-sphere intersection is really clear! thanks!
@MartinDonald
@MartinDonald 3 года назад
Thanks! I love Sebastian's videos. Full of great info.
@GmZorZ
@GmZorZ 3 года назад
@@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 3 года назад
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 3 года назад
Thank you very much! Really appreciated :)
@davidmurphy563
@davidmurphy563 3 года назад
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 3 года назад
@@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 3 года назад
@@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 3 года назад
@@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. ^^
@danieldrew2356
@danieldrew2356 4 года назад
Really good, high-quality video!
@pokonomo
@pokonomo 3 года назад
That was an amazing explanation, thank you!
@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.
@monsoonsheep
@monsoonsheep 2 года назад
Brilliant work!
@jamesb9120
@jamesb9120 3 года назад
I think I have found where Sebastian Lague gets his ideas from...
@tissuepaper9962
@tissuepaper9962 2 года назад
These videos are really helping me study for the graphics exam I'm trying to procrastinate on. Damn you Martin!
@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)
@faimenDev
@faimenDev 2 года назад
Man, it's excellent video, thx!
@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 :)
@n41sd
@n41sd 3 года назад
Amazing channel!! this is really necessary for godot!! Sugestion put some tags on video.
@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.
@LeoninMinecraft
@LeoninMinecraft 2 года назад
this looks like a lot of fun to impliment. Im going to try making it with Unity
@ciberman
@ciberman 2 года назад
So... Are you telling me you are the new Sebastian League?
@jpsilver3510
@jpsilver3510 2 года назад
100%
@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 3 года назад
Great video, as usual! Can't wait to leave the same comment again and again :)
@nicks4727
@nicks4727 3 года назад
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?
@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!
@isaackershnerART
@isaackershnerART 6 месяцев назад
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!!!!
@jpsilver3510
@jpsilver3510 2 года назад
Does anyone know how to sample the depth texture in unity using hdrp?
@Grytix5567
@Grytix5567 11 месяцев назад
how can you use this im so lost
@Sandmule
@Sandmule Год назад
Works great, only have one issue (ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OCZTVpfMSys.html): 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
@imbw267
@imbw267 2 года назад
Adding a sigmoid curve modifier from r=sr to r=2*sr would allow the atmosphere to blend into space
@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.
@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 2 года назад
I had the same issue when i tried to render the atmosphere with a sphere, you need to use a cube like he said
@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
@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 2 года назад
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 2 года назад
@@syuta9317 thank you
@addmix
@addmix 2 года назад
Godot brand Sebastian Lague
@jpsilver3510
@jpsilver3510 2 года назад
Can you please do this in unity as well?
@MartinDonald
@MartinDonald 2 года назад
I probably can't, but I can recommend Sebastian Lague's video on planet atmospheres, which is done in Unity: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-DxfEbulyFcY.html
@jpsilver3510
@jpsilver3510 2 года назад
@@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.
@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”
Далее
Animal Crossing, wobbly leaves, pivot caching.
8:06
Просмотров 112 тыс.
Maybe i need to add instructions @popflexactive
00:14
Coding Adventure: Atmosphere
22:00
Просмотров 1,1 млн
It Takes Two, lava lamps, Raymarching in Godot 4.1.
12:42
Cut off geometry shader using a SDF sphere   - Godot 4
4:52
Calculating Ray-Sphere Intersections
12:15
Просмотров 40 тыс.
Christmas special, making it snow.
11:15
Просмотров 41 тыс.
Coding Adventure: Clouds
12:50
Просмотров 1,2 млн
Why do cozy games suck?
14:46
Просмотров 1,4 млн
Flowmaps, gradient maps, gas giants.
6:19
Просмотров 49 тыс.
I Made a Multiplayer Space Game
8:41
Просмотров 187 тыс.