-
Tutorial 21: Specular Mapping 연습문제Directx 11 with rastertek 2022. 9. 20. 15:02
To Do Exercises
1. Recompile the code and ensure you get a rotating cube with specular highlighting on the bump mapped surface. Press escape when done.
2. Create you own different specular maps to see how it changes the effect.
3. Change the pixel shader to return just the specular result.
4. Change the shininess of the light object in the GraphicsClass to see the change in effect.
1. 코드를 다시 컴파일하고 범프 매핑 표면에 specular highlighting이 적용된 회전하는 큐브를 얻었는지 확인합니다. 완료되면 ESC를 누릅니다.
2. 다른 specular map을 만들어 효과를 어떻게 변화시키는지 확인합니다.
생략
3. 픽셀 셰이더를 변경하여 특정 결과만 반환합니다.
float4 SpecMapPixelShader(PixelInputType input) : SV_TARGET { ..................................생략.................................. if (lightIntensity > 0.0f) { // Sample the pixel from the specular map texture. specularIntensity = shaderTextures[2].Sample(SampleType, input.tex); // Calculate the reflection vector based on the light intensity, normal vector, and light direction. reflection = normalize(2 * lightIntensity * bumpNormal - lightDir); // Determine the amount of specular light based on the reflection vector, viewing direction, and specular power. specular = pow(saturate(dot(reflection, input.viewDirection)), specularPower); // Use the specular map to determine the intensity of specular light at this pixel. specular = specular * specularIntensity; // Add the specular component last to the output color. color = saturate(specular); } ..................................생략.................................. }
specular만 적용 float4 SpecMapPixelShader(PixelInputType input) : SV_TARGET { ..................................생략.................................. if (lightIntensity > 0.0f) { // Sample the pixel from the specular map texture. specularIntensity = shaderTextures[2].Sample(SampleType, input.tex); // Calculate the reflection vector based on the light intensity, normal vector, and light direction. reflection = normalize(2 * lightIntensity * bumpNormal - lightDir); // Determine the amount of specular light based on the reflection vector, viewing direction, and specular power. specular = pow(saturate(dot(reflection, input.viewDirection)), specularPower); // Use the specular map to determine the intensity of specular light at this pixel. specular = specular * specularIntensity; // Add the specular component last to the output color. color = saturate(color); } ..................................생략.................................. }
specular 생략 4. Graphics Class에서 light 객체의 광택을 변경하여 변경 내용을 확인합니다.
graphicsclass.cpp
bool GraphicsClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) { ....................................생략.................................... // Initialize the light object. m_Light->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); m_Light->SetDirection(0.0f, 0.0f, 1.0f); m_Light->SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f); m_Light->SetSpecularPower(1.0f); }
SetSpecularPower를 16.0f -> 1.0f으로 변경
m_Light->SetSpecularPower(1.0f) 'Directx 11 with rastertek' 카테고리의 다른 글
Tutorial 23: Fog 연습문제 (1) 2022.09.21 Tutorial 22: Render to Texture 연습문제 (1) 2022.09.21 Tutorial 20: Bump Mapping 연습문제 (0) 2022.09.20 Tutorial 19: Alpha Mapping 연습문제 (0) 2022.09.20 Tutorial 18: Light Maps 연습문제 (0) 2022.09.19