Normal Mapping Adventures // OpenGL Intermediate Series

Поделиться
HTML-код
  • Опубликовано: 24 дек 2024

Комментарии • 15

  • @OGLDEV
    @OGLDEV  5 месяцев назад

    Clone the sources:
    git clone --recurse-submodules github.com/emeiri/ogldev.git
    If you want to get the same version that was used in the video you can checkout the tag 'TUT_52_NORMAL_MAPPING'.
    Build on Windows:
    Open the Visual Studio solution: ogldev\Windows\ogldev_vs_2022\ogldev_vs_2022.sln
    Build the project 'OpenGL\Tutorials\Tutorial52_NormalMapping'

  • @CodeParticles
    @CodeParticles 5 месяцев назад +1

    @OGLDEV, just for fun Joey de Vries has a hasty function in GLSL's Fragment shader that calculates tangent normals to world space instead of bringing over tangent and bitangent attributes to the Vertex shader by using derivatives. I tried comparing both methods but I couldn't visually tell which was better; Perhaps just a smidge but he did mention this technique was more overhead than the former:
    vec3 Get_TBN()
    {
    vec3 Tangent_Normal = texture(Normal_Map, Texture_Coordinates).xyz * 2.f - 1.f;
    vec3 WderivX = dFdx(World_Position);
    vec3 WderivY = dFdy(World_Position);
    vec2 TderivX = dFdx(Texture_Coordinates);
    vec2 TderivY = dFdy(Texture_Coordinates);
    vec3 T = normalize(WderivX * TderivY.t - WderivY * TderivX.t);
    vec3 N = normalize(Normal);
    vec3 B = -normalize(cross(N, T));
    mat3 TBN = mat3(T, B, N);
    return normalize(TBN * Tangent_Normal);
    }

    • @OGLDEV
      @OGLDEV  5 месяцев назад

      Thanks. This is quite advanced. I still haven't used the derivatives in my tutorials.

  • @tanveerasif5978
    @tanveerasif5978 4 месяца назад

    Thank you so much.

    • @OGLDEV
      @OGLDEV  4 месяца назад

      You're welcome :-)

  • @alfonsomaparicio6130
    @alfonsomaparicio6130 5 месяцев назад

    Amazing explanation !!

    • @OGLDEV
      @OGLDEV  5 месяцев назад

      Thank you!

  • @frag-z3354
    @frag-z3354 5 месяцев назад

    Great explanations!

    • @OGLDEV
      @OGLDEV  5 месяцев назад

      Thanks!

  • @radueduard587
    @radueduard587 5 месяцев назад

    Great video! I implemented this technique in my renderer the other day! I did it with vec4 tangents where the w component was the direction of the bitangent in raport to the cross product between the normal and the first 3 components. It is a bit more computationally expensive but saves some space. One thing I had some trouble with was the fact that the normal texture had to be in the UNORM format. I am adding this just in case other people encounter this issue. Also I am not sure if it is an issue in OpenGL. My renderer uses Vulkan

    • @OGLDEV
      @OGLDEV  5 месяцев назад +1

      Thanks! When you sample the normal from the UNORM texture what is the range of the result components?

    • @radueduard587
      @radueduard587 4 месяца назад

      @@OGLDEV Sorry i completely forgot about the comment. It is [0, 1] so i double it and subtract one to get the actual normal

    • @OGLDEV
      @OGLDEV  4 месяца назад +1

      So it doesn't really matter if you use a UNORM texture, right? Did you get it working eventually?

  • @alejandro9609
    @alejandro9609 5 месяцев назад

    Ok..good job 👍

    • @OGLDEV
      @OGLDEV  5 месяцев назад

      Thanks 👍