Real-time 2D shadows | HUGE improvements!

37,895
8
Published 2024-04-21
40% off CodeCrafters membership: app.codecrafters.io/join?via=BarneyCodes

Become a member: youtube.com/channel/UCrzKp7Z7PuuuAPXfQnDTdpQ/join

Join the discord: discord.gg/Qnc3jWTeEW

Code from the video: editor.p5js.org/BarneyCodes/sketches/oZaRiBI5j

Wishlist Star Mining Co. on Steam and join the play test: s.team/a/2584800/

Original reddit post:
www.reddit.com/r/generative/comments/xz7tlf/compar…

Basic lighting calculations: learnopengl.com/Lighting/Basic-Lighting

Voronoi Noise: openprocessing.org/sketch/564686

Chapters:
0:00 What is this project?
0:28 Fixing the speckles (for real this time)
2:30 Colour banding
2:50 Softer shadows
3:49 CodeCrafters.io
4:50 New lighting model
6:18 Specular highlights
6:50 Waves
7:31 Water improvements
8:08 Star Mining Co.
8:22 Next steps

Thanks again to your great suggestions, I've made some massive improvements to my real-time height map shadow shader.
This video focusses on the visuals, fixing up some artefacts, changing the lighting model, and improving the water rendering.

Follow me:
Twitter: twitter.com/barney_codes
Reddit: www.reddit.com/user/BarneyCodes/

#shaders #glsl #gamedev

All Comments (21)
  • @BarneyCodes
    Help support the channel AND get 40% off CodeCrafters membership: app.codecrafters.io/join?via=BarneyCodes Check out the original reddit post that inspired this project: www.reddit.com/r/generative/comments/xz7tlf/compar… Become a member: youtube.com/@BarneyCodes/join Join the discord: discord.gg/Qnc3jWTeEW Thanks everyone for the support on this project, I'm still amazed by how much traction it's gotten! As always, if you've got any suggestions, please let me know in the comments so we can make this as cool as possible!
  • @Kagayaki74
    The ambient light should be the same color as the sky! :D If you try shifting it towards sky blue, the shadows get a more natural look. Really cool project!
  • @NostraDavid2
    Holy smokes, BarneyCodes, Acerola AND Sebastian Lague videos, all in a week!? You guys spoil me! I love these kind of technical videos relating to graphics. I used to learn gamedev (went to school for it and all that), but after learning that working for 80 hours can be "normal" in gamedev I noped out of that field. I now do "boring" data engineering, but still love to learn about graphics, etc.
  • @aeyedeyen
    if you expand it in the future, sailing around through a big map on a little wooden ship would be what I would want. Getting into little scuffles with pirates, maybe trading with villages on islands, maybe even being a pirate! I can imagine it as a really cute title.
  • @Godot-Game-Dev
    I don't know if anyone else has said it before but I think it would be cool to have some sort of cloud simulation going on over the island where the clouds float around and change shape over time, maybe even casting a soft shadow as well.
  • @ohnoitsaninja
    In processing which p5 is based off, you can use different texture modes like R32F, which gives each pixel a single 32 bit float instead of 4 8bit ints. Perhaps this works in p5
  • @sivadfa
    Not sure if you can simulate it but I thought it was worth mentioning that the cove that gives the impression of a smaller island being eaten by your main island would be surprisingly smooth most of the time. I live in a cove with a similar make up and it's often as smooth as a lake when there aren't any boats on the water.
  • I can slowly see this evolving into a game/simulation after you realize that you put good effort into what started as a test
  • @jtmcdole
    You can start with the cozy fishing village and then gradually deal with OilCo buying up rights to the island, and the villagers having to fight back (with wind/solar/malicious interference)
  • @Rynstick
    Happy i could Help . Great work !
  • @hjewkes
    What about some game about triggering underwater volcanos to make islands. I realize thats harder than modifying the water level, but playing with the texture map could be an interesting exercise. Say you control the elements - fire builds up to trigger eruptions and clear grass/trees, water adjusts water level and causes rain for errosion, wind also does a different kind of errosion and blows seeds into new areas. Goal is to terraform certain characteristics of into the island to attract different kinds of wild life or create different resources
  • @jupiterbjy
    amazing work, looks drastically better!
  • @ruolbu
    since height is a core element to this game-to-be I was thinking of a Worms style shooter. You bomb each other which rips craters into the landscapes and transforms what the island looks like and where shadows land. You could have an additional 2D view, a vertical plane that you rotate around your currently active unit and align it with your target unit.
  • @thatperson9478
    Simple game idea here: When I saw you change the water level, the first thing I thought of was volcanic activity forming islands. I don't have a solid idea about how this could be gamified, but I think a game about stoking volcanos in order to grow an island into a continent has potential. Perhaps you could have other factors influencing the water level, such as pollution caused by the ash from eruptions, or you could simulate tectonic plates shifting and changing the world. Regardless, I think this is an idea worth looking into!
  • @loaf414
    2:50 It might be possible to create a blur by creating multiple, more transparent shadows then offsetting the angle of each shadow slightly. That way, the shadows would be more solid near the origin of the shadow (since the shadows would overlap more), and more blurred near the end of it.
  • @realalphas
    I would make distance blur detection with taking 2 additional shadows (+ and - angles, gives additional parameter of blur) and getting inverse intersections and blur those. Good video!
  • @blaholtzen
    An old game idea that I had (I will never make this myself) was a city/town builder type thing taking place on an island where the water level is slowly lowering as part of the progression, giving you gradually more island to work with as well as revealing more resources to use, maybe that could work for this.
  • The game this makes me think of would be something like this: The player triggers a volcano to raise a new island, then plays a very simple ecological sim game, maybe just tile placment or something, to establish plants on the island. After some time animals arrive, migrating birds or turtles looking for nesting sites or maybe even humans in canoes, and if the player has set up the island well enough to be inhabitable they get points and can move on to raise a new island in the archipelago and set it up in turn.
  • @VesaKo
    It'd be cool if it was a management sim where your islands become flooded periodically, sinking your structures under the waves. Once the flooding ends and the structures re-emerge, you'd need to fix them. To prevent frustration, the first island could be larger than the rest and more resistant to flooding. This island could be used as a base to launch repair operations to other islands which hold precious resources needed to progress. With the procedural generation, you could theoretically find the exact type of island you're looking for to advance your resource network.
  • @lakoderdritte994
    The first game Idea I had would be some kind of "city" building with the special difficulty of extreme tides.