ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Tutorial 20: Bump Mapping 연습문제
    Directx 11 with rastertek 2022. 9. 20. 13:52

    To Do Exercises

    1. Recompile and run the program. You should see a bump mapped rotating cube. Press escape to quit.

    2. Change the bump map effect from 2.5 to something smaller (like 1.0) and larger (like 5.0) in the shader to see the change in the bump depth.

    3. Comment out the color = color * textureColor; line in the pixel shader to see just the bump lighting effect.

    4. Move the camera and light position around to see the effect from different angles.

     

    1. 프로그램을 다시 컴파일하여 실행합니다. 범프 매핑된 회전 큐브가 표시됩니다. 종료하려면 ESC를 누르십시오.

     

    2. 범프 맵 효과를 2.5에서 셰이더에서 더 작게(예: 1.0) 또는 더 크게(예: 5.0) 변경하여 범프 깊이의 변화를 확인합니다.

    ??

     

    3. 픽셀 셰이더의 color = color * textureColor; 라인을 주석 처리하여 범프 조명 효과만 확인합니다.

    bumpmap.ps

    float4 BumpMapPixelShader(PixelInputType input) : SV_TARGET
    {
        float4 textureColor;
        float4 bumpMap;
        float3 bumpNormal;
        float3 lightDir;
        float lightIntensity;
        float4 color;
    
    
        // Sample the texture pixel at this location.
        textureColor = shaderTextures[0].Sample(SampleType, input.tex);
    
        // Sample the pixel in the bump map.
        bumpMap = shaderTextures[1].Sample(SampleType, input.tex);
    
        // Expand the range of the normal value from (0, +1) to (-1, +1).
        bumpMap = (bumpMap * 2.0f) - 1.0f;
    
        // Calculate the normal from the data in the bump map.
        bumpNormal = (bumpMap.x * input.tangent) + (bumpMap.y * input.binormal) + (bumpMap.z * input.normal);
    
        // Normalize the resulting bump normal.
        bumpNormal = normalize(bumpNormal);
    
        // Invert the light direction for calculations.
        lightDir = -lightDirection;
    
        // Calculate the amount of light on this pixel based on the bump map normal value.
        lightIntensity = saturate(dot(bumpNormal, lightDir));
    
        // Determine the final diffuse color based on the diffuse color and the amount of light intensity.
        color = saturate(diffuseColor * lightIntensity);
    
        // Combine the final bump light color with the texture color.
        //color = color * textureColor;
    
        return color;
    }


    4. 카메라와 조명 위치를 이리저리 움직여 다른 각도에서 효과를 봅니다.

Designed by Tistory.