Shaders Case Study - Spelunky Ice Cave Crystals

Поділитися
Вставка
  • Опубліковано 20 жов 2024
  • In this Visual Case Study, we explore a subtle yet enchanting effect from the Ice Caves of Spelunky!
    Web Demo on itch.io:
    broxxar.itch.i...
    Support me on Patreon:
    / danmoran
    Get the Assets for this Video here:
    danjohnmoran.co...
    Music:
    Spelunky OST - 2012
    Eirik Suhrke
    Yeti Caves (It Smells Like Wet Fur In Here!)

КОМЕНТАРІ • 112

  • @copuntv3432
    @copuntv3432 8 років тому +92

    Dude how are you're not as big on UA-cam as you should be? Never seen such top quality Unity tutorials!

    • @SinanAkkoyun
      @SinanAkkoyun 8 років тому +5

      Yes I think so too

    • @sharp7j
      @sharp7j 8 років тому +13

      Ya seriously! Most Unity tutorials are "how to get your FIRST EVER UNITY CHARACTER TO MOVE RIGHT OMG!" and other basic stuff. These tutorials are awesome and are really advanced!

    • @chinhlequang6410
      @chinhlequang6410 7 років тому

      Sharp Most paid course is like that too smh. And i CANT even find one advance shader tutorial .
      I wish he could make a full shader course on udemy or something , gonna throw 300$ at him instantly lol .

    • @Ali-hq5kr
      @Ali-hq5kr 5 років тому

      hello, its a year later and I too would throw $300 at him. Is there anything else close to this out there?

  • @mattishii
    @mattishii 8 років тому +23

    that's some 80s ass smooth jazz there dan

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому +11

      +mattishii It's music from the game yo

    • @mattishii
      @mattishii 8 років тому +2

      +Makin' Stuff Look Good woow i suck.

  • @colossusjak2
    @colossusjak2 5 років тому +5

    hey, just wanna say to this date ( I watched this a few years ago) you're the only channel that helped me understand shaders. Thank you!

  • @Tharky
    @Tharky 7 років тому

    Just found this channel and it is one of the highest quality Unity tutorials out there. Especially about shaders. I always wantes to learn how to code my own shaders, this helps a lot! Thanks man.

  • @josephzabriskie8554
    @josephzabriskie8554 6 років тому +1

    This series is incredible!

  • @spider853
    @spider853 7 років тому

    Funny thing, as soon as I found these tutorials I wanted to suggest this effect, but it's already here. Nice!

  • @LeeoooGGGG
    @LeeoooGGGG 8 років тому +1

    These case studies are so good, thank you very much

  • @alexandreasen333
    @alexandreasen333 8 років тому +10

    The quality of the content you present is really nice :-).
    Would you consider doing a beginner friendly tutorial series for shaders and particles, where you from scratch make a small game that is based graphically around shaders, particles and the player?
    If you did it, it would be really interesting to follow!

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому +13

      I would love to do a mini-series that covers a small game from beginning to end! I'm currently swamped IRL due to a new job and moving to a new country but this is definitely something I want to do :D

    • @alexandreasen333
      @alexandreasen333 8 років тому

      :-D I already look forward to seeing it.

  • @xR0G3R
    @xR0G3R 7 років тому +1

    Dude, your content is simply fanstatic :)

  • @barnaskater93
    @barnaskater93 8 років тому

    I really love all your videos, you explain everything so in depth. Thank you so much.

  • @scorpion666lair
    @scorpion666lair 8 років тому +2

    Don't be afraid to do longer vids that explain things in more detail hey, great vids and awesome presentation but I feel they may be too short in turn not giving enough explanation. Thanks again, looking forward to more!

  • @Shrubsy
    @Shrubsy 8 років тому +1

    Dude thank you so much for these videos. Awesome work!

  • @cocoa-pf4fh
    @cocoa-pf4fh 8 років тому

    Really enjoying your videos. Great information with entertaining and concise presentation. Keep up the good work.

  • @Tzirrit
    @Tzirrit 8 років тому

    Simply brilliant. Keep up the awesome work! Very helpful indeed.

  • @ogramp
    @ogramp 8 років тому

    This episode is impressive.

  • @Stalkie
    @Stalkie 3 роки тому

    That is some incredible stuff!

  • @Galbix007
    @Galbix007 8 років тому

    Impressive channel.
    I'm really interesting in Graphics Programming and Unity, please keep making this awesome videos!

  • @BenHayward110194
    @BenHayward110194 8 років тому

    These tutorials are fantastic! Love them

  • @DanMorose
    @DanMorose 8 років тому +17

    No idea what any of that means. But I'm pretty sure I just got a little smarter!

    • @bip901
      @bip901 6 років тому

      To The Hopeless lol

  • @liccoweeee
    @liccoweeee 7 років тому

    Impress by your every video in youtube! I wish you could have a online teaching lesson class and I will definitely pay for it! lol

  • @krux02
    @krux02 6 років тому

    I don't know how it is done in unity, but in OpenGL you make the uniform you use to correct the normals to be an attribute with divisor 1. This will allow that each object will have correct normals and you won't suffer on draw calls.

  • @Scylez
    @Scylez 8 років тому

    Keep up the good work. I'm loving your videos.

  • @jsvandenjsvanden7447
    @jsvandenjsvanden7447 8 років тому

    Love this series. Great job!

  • @AzgariusPWI
    @AzgariusPWI 8 років тому

    Man.. you're awesome.. you got my subscription. Keep up the great work!!

  • @renatusdev
    @renatusdev 5 років тому

    Aight man listen up. You're a wizard.

  • @nomadcrossfire
    @nomadcrossfire 8 років тому

    i just found your channel and love it, keep it up

  • @TheDormantPsycho
    @TheDormantPsycho 7 років тому

    Hey, I'm having an issue implementing this. For some reason the alpha value on the render texture where all of the snow particles are just comes out to be zero. I don't really understand why. It works if I set the material of the particles to sprite default, but not with the default "particles/alpha blended" shader. Why is this?

  • @ucanhle3092
    @ucanhle3092 6 років тому

    omg this guy is fucking shader god... let's digging this up guys !!

  • @bartekkalemba8281
    @bartekkalemba8281 7 років тому

    Man! It's amazing! Thank You

  • @cornstarch4575
    @cornstarch4575 8 років тому +1

    Hey - I'm currently playing with the asset and all my sprites appear to be turning white? I'm no expert at this so I can't work out what I'm getting wrong. Could you think of any common mistakes that would cause this? Normal map is working fine with reflection.
    Thanks for the great tutorial either way :)

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому +2

      +CornStarch This occurs if the Ambient texture is not set in the material! Either set a texture there, or remove the ambient line and it's includion in the following line from the shader :)

    • @cornstarch4575
      @cornstarch4575 8 років тому

      That was it :) I just removed all references in the shader and it was worked! Thanks so much.

    • @felixliu1161
      @felixliu1161 6 років тому

      You can set the default color to black. --> _AmbientTex("Ambient Reflections", 2D) = "black" {}

  • @antonisdanas6064
    @antonisdanas6064 7 років тому

    Man you are the best!!! really nice tutorial!!

  • @hempshark
    @hempshark 7 років тому +1

    Great tutorials man
    ! But in my case material with this shader just made a texture pure with and little bit of reflection (unity 5.5 and 5.6) seems I miss something. And I'm new to unity.

  • @maguxzs
    @maguxzs 7 років тому +1

    hey im trying to make a mirror on my game and this was really helpfull but im getting my reflection flipped upside down, any idea how to fix it? thanks for your great tutorials btw.

    • @DanMoranGameDev
      @DanMoranGameDev  7 років тому +1

      See this page: docs.unity3d.com/Manual/SL-PlatformDifferences.html
      This issue is very much related to your quality settings, Unity version, project settings etc. So it's hard to include a version that works for everyone.

    • @felixliu1161
      @felixliu1161 6 років тому +1

      #if UNITY_UV_STARTS_AT_TOP
      o.screenuv.y = 1 - o.screenuv.y;
      #endif
      it's worked for me.

    • @coclv2591
      @coclv2591 3 роки тому

      @@felixliu1161 yes!it is!

  • @fl0yd13
    @fl0yd13 8 років тому

    Amazing, thank you!

  • @WuppertalerWanderWade
    @WuppertalerWanderWade 8 років тому

    Nice Video. It's time for me to take a look into shaders. Currently working with Lights and perspective camera in a 2D environment and it doesn't work as expected

  • @skabba
    @skabba 8 років тому

    This video was impressive. Congratulations on the good work!! This is becoming one of my favourite channels :)
    I have got a question for you: is it possible to achieve this effect with Unity's uGUI Image instead of Sprite Renderer? I have draggable pieces of GUI (it is the game's main control) and it would be awesome to create an scenario that would react like this.
    Thanks a lot!

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      Yeah it is possible! You can assign a Material for a uGUI Image in the inspector. It might be a good idea to edit a copy of the default UI shader that supports stencil buffer masking and other fancy stuff. You can download the built in shaders from the Unity website.

    • @skabba
      @skabba 8 років тому

      +Makin' Stuff Look Good Ok I have been trying more and there must be something I'm missing. What I want to achieve: 2D scenario pieces (can be either Sprite Renderer or uGUI Image) that simulate ice blocks, and uGUI Images (strictly) that get reflected in those ice blocks. The scenario does not move, and the uGUI does (they are card that are dragged with the mouse).
      I got the sample you explained working. I have also achieve to get both uGUI Image and Sprite Renderers ice blocks to reflect Sprite Renderers, but I cannot get it to reflect the uGUI Images, which is my goal. What can I do?
      Thanks a lot!!

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      +skabba ahhhh okay. You'll probably need to make the Canvas object be World Space as opposed to screen or camera space.
      Then you'll need a camera that captures the world space UI and dumps it to a render texture.

  • @Jazuhero
    @Jazuhero 8 років тому

    This stuff is awesome!

  • @Turanification
    @Turanification 8 років тому +3

    Great tutorial :) Would wish to see something like this for 3D too :)

  • @TijmenvandenHeuvel
    @TijmenvandenHeuvel 8 років тому

    Isnt there some built in function to convert from clip to screen space? Also, if performance is tight, perhaps you dont need a second camera. You can sample everything within a depth-range, with a deferred setup you already have the depth buffer for free. Does save rendering most objects twice.

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      +Tijmen van den Heuvel Not that I know of, but maybe! There is a lot hidden in the cginc file and I admittedly have combed through it in a while.
      That depth buffer technique is interesting. I might try that in the future. It wouldn't have worked here because I used Sprite Sorting so the whole scene is flat, but it wouldn't be too big a change to use z values.

    • @TijmenvandenHeuvel
      @TijmenvandenHeuvel 8 років тому

      Dont they write to the z-buffer anyway? Anyway, this approach is way simpler, so if performance isnt such a big problem i'd just go with this.

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      +Tijmen van den Heuvel Wait a minute, transparent geo never writes to the z-buffer >.< so no go on this idea unfortunately. Could work for opaque stuff though!

    • @TijmenvandenHeuvel
      @TijmenvandenHeuvel 8 років тому

      Yeah but what, in this scene, is opaque?

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      Nope, SpriteRenderer's default shader is alpha blended.

  • @asenzhechev3898
    @asenzhechev3898 8 років тому

    What software do you use to generate those UV maps?

  • @chrishudson8196
    @chrishudson8196 8 років тому

    Never subbed to any channel... but you sir.... ill make an exception

  • @0ptimiza
    @0ptimiza 8 років тому

    Very nice m8, very very nice

  • @ananttheant
    @ananttheant 4 роки тому

    I need u to come back!! come on it's been 1yr

  • @MrRattaspi
    @MrRattaspi 6 років тому

    Do it only works for sprites? im trying to do that with 3D models and im getting issues

    • @DanMoranGameDev
      @DanMoranGameDev  6 років тому

      This technique is not physically plausible and 3D reflections are much more difficult. That said, there's no reason a 3D model couldn't use it's normals/normal map with a screen space position to sample from a render texture to fake some reflections.

  • @alrightmarty
    @alrightmarty 6 років тому +1

    How would you flip the render texture so that the player (reflectable) is rendered upside down?
    I'm trying to use this as a water shader!

  • @rubpty
    @rubpty Рік тому

    A new version of this would be assome. Is not working anymore for new versions of Unity.

  • @andrewamundrud800
    @andrewamundrud800 8 років тому

    I can't wrap my brain around multiplying the texture by _Object2World and I am unable to get the same result when returning (offset.r,0,-offset.r,1). For me the red and blue are sticking to the uv coordinates a i would expect them to. What am I missing here?

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      _Object2World is a 4x4 matrix that contains the transformation from object space to world for the given object. The offset values are in object space, so we multiply (using the mul() function) by the matrix to get values in the world coordinate system.
      Did you miss the importance of not dynamically batching sprites relying on this matrix? When sprites are dynamically batched, they're vert positions are pre-transformed to world space and lumped together with other sprites in the batch. The _Object2World value for these batched sprites will always be the identity matrix, and multiplying any vector by the identity matrix leaves the vector unchanged. So you have to disable dynamic batching for things relying on on that object2world matrix having useful values.

    • @andrewamundrud800
      @andrewamundrud800 8 років тому

      I think it might be that you are rotating on the z axis and this technique only works if the UV corresponds with the xy axis of the object space. I have it working now but only after fussing with the rotation of the quad a bit in Blender. Great channel/info by the way.

    • @andrewamundrud800
      @andrewamundrud800 8 років тому

      Can I say that your little helper function to multiply a vector2 is very nice.

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      Ahhh I see, yes if you're using different planes , you would have to change the encoding of the image. Where I use red and green for X and Y offsets, you might have to use Green and Blue for Y and Z or whatever.

    • @andrewamundrud800
      @andrewamundrud800 8 років тому

      You can batch the results by encoding rotation amount into a vertex color.

  • @pkeod
    @pkeod 7 років тому +3

    This is what the actual Spelunky normal textures look like for the ice i.imgur.com/y8yEhuZ.png

    • @DanMoranGameDev
      @DanMoranGameDev  7 років тому +1

      Oh snap. Hahah I definitely went overboard on detail with mine. I bet they actually modeled a jagged surface in 3D and baked these out. Thanks for sharing!

    • @pkeod
      @pkeod 7 років тому

      I'm pretty sure these normals were hand painted overlaying the original textures. You can tell sort of because of the limited colors, and somewhat sloppiness / lack of machine precision of the color blobs. The rest of the normals Spelunky uses appear to have been auto generated based on the parent texture with a normal map from texture generation tool.

  • @thefunnyexperience6931
    @thefunnyexperience6931 8 років тому

    Great video thanks :)

  • @bhbaykus
    @bhbaykus 7 років тому

    first thanks for all, i used assets but my reflection is upside down . i tried to scale camera or size to -1 but i could not do it work correctly i sent a mail to you . Thanks again

    • @DanMoranGameDev
      @DanMoranGameDev  7 років тому

      See this page: docs.unity3d.com/Manual/SL-PlatformDifferences.html
      Different platforms and Unity versions will react different so it's hard for me to debug this in your particular setup. Try your best to work out the solution for yours.
      Note that you cannot scale cameras, they only use translation and rotation and scale is ignored when building their transformation matrix.

    • @bhbaykus
      @bhbaykus 7 років тому

      Thanks for quick answer and thanks for videos again

  • @CrisDavidF7
    @CrisDavidF7 8 років тому

    thanks a lot

  • @P0P357UR3
    @P0P357UR3 8 років тому

    Wow, great tutorial and channel! Sub'd!

  • @isaachayes6163
    @isaachayes6163 8 років тому

    Any opinion on shaderforge?

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому +1

      +Isaac Hayes I haven't used it, but I've used a node based material editor before (the 3Ds max one). Whether you know how to write the effect yourself or compose it using nodes, it's always gonna require shader knowledge. If it works, it works! I'll always prefer to understand and write shaders myself.
      It's probably easier to hack together something nodes, but also easier to create something inefficient (redundant nodes, doing something per fragment that could be done in the vert program, etc).
      If you've got $90 to spare, it looks like it's a decent product. But if you're willing to put in the work learning shaders, you can save some money and be able to create anything shader forge can do and so much more!

    • @isaachayes6163
      @isaachayes6163 8 років тому

      +Makin' Stuff Look Good Thanks for the feedback!

  • @random_precision_software
    @random_precision_software 5 років тому

    The link is broke..i just get garbage text

  • @Siausalas
    @Siausalas 8 років тому

    Idea for case study: Contra Hard Corps bosses and some minor enemies have effect that is shown in video.
    ua-cam.com/video/-9YFtbCb3y0/v-deo.html
    Is it something harder to do or just simple shader that changes something with colors based on passed time?

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      +Siausalas I think simple! But still cool. I've been planning some content for shorter videos so I'm not always doing 10 minute ones and this might be perfect for that so thanks! :D

  • @nuckm
    @nuckm 8 років тому +2

    Haven't watched the video yet but I think it would be a great direction to be going for this serie (that is, recreating shader effects from other games and stuff)
    I've been curious about some of the stuff that can be seen in this video actually ua-cam.com/video/qQ1jDR_DMhM/v-deo.html it's not from any game or whatever but the are some really interesting visuals that have had me wondering how they could be recreated with shaders and whatnot.

  • @danielaguirre5078
    @danielaguirre5078 8 років тому

    Wow *v*, can you make a Godot engine version of this shader? :)

  • @MichaelPohoreski
    @MichaelPohoreski 8 років тому

    @4:55 4D space is NOT a hack for 3D, it is a **unification** of 3D Rotation, Scaling, and Tranlsation. See Page 49 of my _"WebGL Theory"_ github.com/Michaelangel007/game_dev_pdfs/raw/master/graphics/opengl/WebGL_Theory.pdf

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому

      +Michael Pohoreski I called it a hack, but it's actually quite clever to represent translations as a shear in a higher dimension. Sorry for the word choice! Thanks for sharing additional resources. The section on "Affine Transformations" is an excellent read for the stuff I glossed over.

    • @MichaelPohoreski
      @MichaelPohoreski 8 років тому

      Makin' Stuff Look Good Fair enough -- I guess I wouldn't have been offended if you had called it a _"clever hack."_ ;-) Thanks for the compliment.

  • @cjmxp
    @cjmxp 7 років тому

    不错

  • @WuppertalerWanderWade
    @WuppertalerWanderWade 8 років тому

    The link to the assets gives me a 404

    • @DanMoranGameDev
      @DanMoranGameDev  8 років тому +1

      +Nalincah Whoops! Forgot to upload it to my server. Should work now, thanks for letting me know!

  • @notsoren665
    @notsoren665 8 років тому

    Playing the intro on repeat.
    www.yourepeat.com/watch/?v=7fMCTVhEzmU&start_at=0&end_at=3

  • @irgendjemand8221
    @irgendjemand8221 7 років тому

    I hate your intro... but the content is great :D