22: Phong Shading Math Concepts

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ค. 2024
  • Before I jump into the phong shading implementation, we need to first get fundamental understanding of more technical math surrounding lighting. In this video I cover vectors normals, dot products, vector subtraction, normalizing, and summation.
    Swift Game Engine Tutorial With Metal Playlist
    • Swift Game Engine Tuto...
    Become A Patron:
    / 2etime
    I really do appreciate everyone in this community! Thank you all!
    Full Engine Code:
    github.com/twohyjr/Metal-Game...
    Keynote Presentation:
    github.com/twohyjr/Metal-Game...
    Awesome Lighting Explanations:
    buildnewgames.com/lighting/
    learnopengl.com/Lighting/Ligh...
    Metal Specification Documentation:
    developer.apple.com/metal/Met...
    Discord:
    Join me on Discord for discussions about Metal. I am always open to talk code :)
    / discord
    Affiliate Links:
    Sweet Standing Desks: bit.ly/2XxH13m

ความคิดเห็น • 34

  • @iamlordstarbuilder5595
    @iamlordstarbuilder5595 4 ปีที่แล้ว +12

    This is exactly what I was looking for when I typed in “Phong shading math”

  • @Daniel-Murphy951
    @Daniel-Murphy951 3 หลายเดือนก่อน

    Back in college when I took graphics the phong algorithm for fragment shaders was just kinda there, so I'd often forget and have to look back. Now that I'm getting into Opengl on my own time, I should learn it lol. This tutorial explained everything perfectly! I can finally understand the code for it and why we write what we write in it!

  • @CyrusPellet
    @CyrusPellet 5 ปีที่แล้ว +8

    Amazing! Your channel is so underrated!

    • @2etime
      @2etime  5 ปีที่แล้ว

      Thank You :)

  • @erich_l4644
    @erich_l4644 4 ปีที่แล้ว +4

    wth less than 1k views? This video is worth millions.

  • @LennartDoering
    @LennartDoering 2 ปีที่แล้ว +1

    very helpful! thanks so much

  • @leyao929
    @leyao929 4 หลายเดือนก่อน

    Thank you so much, this video is very helpful!!

  • @Lynkor
    @Lynkor 4 ปีที่แล้ว +3

    awesome, great explanation. one day the algorithm will hit you if you keep it up :)

  • @tsuntakcheung8243
    @tsuntakcheung8243 5 ปีที่แล้ว +2

    Yeah new episode

  • @z4gon
    @z4gon ปีที่แล้ว

    Very clear and informative

  • @iamlordstarbuilder5595
    @iamlordstarbuilder5595 4 ปีที่แล้ว +4

    Furthermore, this explains lighting a billion times better than the OpenGL tutorial I was reading that did this lighting method, resulting in a horrendous, disorganized plane crash that brought me to this video. So I’ll make sure to pass on this video to other aspiring programmers.

    • @2etime
      @2etime  4 ปีที่แล้ว

      Thank you ;)

  • @michaeldamolsen
    @michaeldamolsen 3 ปีที่แล้ว

    Apart from the fact that the summation "epsilon" is of course called sigma (greek S, for sum), the rest of the information is completely accurate. A nice video, very well illustrated and planned, and very engaging narration! Thanks!!

    • @2etime
      @2etime  3 ปีที่แล้ว +1

      Haha! Wish I could edit that :) thanks though my guy!

  • @jevonmahoney
    @jevonmahoney ปีที่แล้ว

    Amazing content mate genuinely, well delivered, interesting and really top shit keep it going man!!

  • @pkoechkirui3797
    @pkoechkirui3797 3 ปีที่แล้ว

    perfect explanation

  • @chipjarred
    @chipjarred 4 ปีที่แล้ว

    It's great that you've done these videos, but there's a minor clarification so people who aren't familiar with the summation notation and look at other sources don't get confused. The summation symbol is a capital sigma (Greek "S"), standing for "sum"'. It does look kind of like a capital "E", but it's not epsilon. There is an epsilon in the notation though, the lower case "e" looking symbol under the sigma. It stands for "element of", and in this context indicates that the sum of all the elements in the set is being calculated. It's actually a good shorthand for a Swift for...in loop. The more frequent notation is to put "i = a" under the sigma instead of the epsilon thing, with "b" above the sigma to indicate that the sum is done over the integers in the range a...b, which is a good shorthand for a C-style for loop.

    • @2etime
      @2etime  4 ปีที่แล้ว +1

      Lol! Thank you :) sometimes I just say things, then can never update the TH-cam video again! You are awesome for this!

  • @tsuntakcheung8243
    @tsuntakcheung8243 4 ปีที่แล้ว +1

    Hey man, if you have to pls make another video, that will be great!

    • @2etime
      @2etime  4 ปีที่แล้ว

      Will do!

  • @yangyangcui9150
    @yangyangcui9150 4 ปีที่แล้ว +2

    👍🏻

  • @hampusekedahl7309
    @hampusekedahl7309 2 ปีที่แล้ว +2

    what is im, s?, is it the angle betwen eye and refleciton?

  • @daleowens7695
    @daleowens7695 4 ปีที่แล้ว +1

    You're using the "hat" so, A hat = (0,1,0) Typically when dealing with vectors, the hat symbol represents the basis vectors for a coordinate system. In your example A hat == Y hat. The cartesian system has basis vectors (1,0,0),(0,1,0),and(0,0,1). People may get confused if they use this symbol expecting it to represent an arbitrary vector. 5:55

    • @2etime
      @2etime  4 ปีที่แล้ว

      True! I normalize these vectors in the code at least! Thanks for the clarification :)

  • @PeterFlash
    @PeterFlash 3 ปีที่แล้ว +2

    I'm still learning how all of this works so this is great.
    I have a question though. I know that Phong shading (or shading algorithms in general) uses linear interpolation.
    I'm currently researching on the subject of fast interpolation, and I have found a very fast way to interpolate, but it's based solely on integer math. So the input points and the interpolated points are integers.
    Would it be possible to use this integer based interpolation in any shading algorithm and still get a decent result? Or in a more general sense, is there any use in shading for an interpolation algorithm based on integers?

    • @2etime
      @2etime  3 ปีที่แล้ว

      The interpolation occurs between the vertex shader and the fragment shader. Unfortunately this stage is a part of the “Fixed Function Pipeline” meaning that it is not programmable. At least in the metal shading language. However this does sound really cool! Are you able to share?

  • @commentvigilante
    @commentvigilante 3 ปีที่แล้ว

    06:00 The magnitude of B is not 0.5, it is sqrt(0.5). Or so I think :/
    Never the less, pretty good Video. Im reading alot about BRD-Functions right now for my Bachelors Thesis and it is super overwhelming... Your video helped, thanks :)

    • @2etime
      @2etime  3 ปีที่แล้ว

      Thanks man. Ya math is hard lol. Let me know if you need anything!

  • @JamesKorcc
    @JamesKorcc 3 ปีที่แล้ว +1

    "we wont say tangent", *says it a minute later* lmao

  • @chrischoir3594
    @chrischoir3594 4 ปีที่แล้ว +1

    why isn't 22 in your github pr+oject?

    • @2etime
      @2etime  4 ปีที่แล้ว +1

      Hey there Chris! Ep 22 has a keynote but there is no code additions in this tutorial :)

    • @chrischoir3594
      @chrischoir3594 4 ปีที่แล้ว +2

      @@2etime got it. thanks for the video

  • @kaltwarraith5172
    @kaltwarraith5172 4 ปีที่แล้ว +1

    that greek letter in a sum is a sigma not an epsilon

    • @2etime
      @2etime  4 ปีที่แล้ว

      Already addressed but thanks
      :)