23: Phong Ambient Shading With Swift And Metal

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ต.ค. 2024

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

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

    I've never known so much about ambient lighting! Geat video!

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

    I had some time to think about the problem of knowing how many items are in an array passed to the shader without separately passing in the count... You could pass a sentinel value to mark the end of the array. It could be another boolean flag in LightData or some combination of values for existing fields that otherwise wouldn't make sense (like brightness 1 but color (0,0,0)). Actually I'm kind of embarrassed I didn't think of it right away... I actually spent some time working out this really nice array replacement that stores the count in the same memory block as the data itself, before it occurred to me that complication isn't necessary. You don't need to know how many items are in the light array except just to know when to stop looping through them. It would be different if you needed to randomly index all over the place in it, but for just one after the other, you only need a marker for last one.

  • @michaelbarber2818
    @michaelbarber2818 5 ปีที่แล้ว +1

    Ambient sounds like amphibian and both are colors. Wild bro.

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

      I’m glad you put that correlation together! I wasn’t sure if people would understand.

  • @boydandrews2690
    @boydandrews2690 5 ปีที่แล้ว

    Regarding your query would something like : int lightcount = sizeof(lightdatas)/sizeof(lightdata); work

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

      I tried that. No cigar :(

    • @boydandrews2690
      @boydandrews2690 5 ปีที่แล้ว

      Your light data on your CPU does not match your GPUs light data. On the CPU you reference game object instead of a matching lightobject

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

      @@boydandrews2690 On the CPU I have the function 'gatherLightData'. That puts all of the LightData structs from the LightObjects into one singular array. Both LightData structs (GPU & CPU) match. What CPU reference are you talking about? I appreciate all of the feedback btw :)

    • @boydandrews2690
      @boydandrews2690 5 ปีที่แล้ว

      2etime sorry I am working through your logic, should your lightmanager when it sets the fragment byte length set it to length of lightdata x number of lights

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

      @@boydandrews2690 No Problem Mr. Andrews! Why don't you head over to discord :) I can help you through this logical issue and all others you might come across! But... If you look at where the extension I add for Int32 in types, you will notice that the sizeable struct does just that! It multiplies the MemoryLayout.stride * count. Here is my discord channel link :) discord.gg/hKPBTbC

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

    For anyone struggling with why lighting doesn't work properly on custom meshes... The answer to your not normals is in the mip mapping tutorial! 🤦‍♂

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

      Ya sorry about that :(

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

      @@2etime All good, I appreciate the effort that has gone into this series. just wanted to shortcut future me's (who spend a little long debugging something that is solved by watching 15 minute video).