ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Tutorial 29: Water 연습문제
    Directx 11 with rastertek 2022. 9. 27. 14:30

    To Do Exercises

    1. Recompile and run the program. You should get animated reflective/refractive water.

    2. Modify how the reflection and refraction are coming by changing the 0.6f value in: color = lerp(reflectionColor, refractionColor, 0.6f)

    3. Modify reflectRefractScale value (its the last value sent into the m_WaterShader->Render function).

    4. Create your own normal map and see the difference it makes in the water effect.

    5. Change the clip plane to be the exact height of the water in the RenderRefractionToTexture() function.

     

    1. 프로그램을 다시 컴파일하여 실행합니다. 당신은 반사/굴절이 적용된 움직이는 물을 얻어야 합니다.

     

    2. color = lerp (reflectionColor, refractionColor, 0.6f)의 0.6f 값을 변경하여 반사 및 굴절이 오는 방식을 수정하세요.

    0.1f
    0.9f

    값이 낮을수록 반사가 선명해지고 물의 색깔이 어두워졌다.

     

    3. reflectRefractScale 값(m_WaterShader->Render 함수로 전송된 마지막 인자값)을 수정합니다.

    graphicsclass.cpp

    bool GraphicsClass::RenderScene()
    {
    ................................생략................................
    	result = m_WaterShader->Render(m_D3D->GetDeviceContext(), m_WaterModel->GetIndexCount(), worldMatrix, viewMatrix,
    		projectionMatrix, reflectionMatrix, m_ReflectionTexture->GetShaderResourceView(),
    		m_RefractionTexture->GetShaderResourceView(), m_WaterModel->GetTexture(),
    		m_waterTranslation, 0.05f);
    ................................생략................................
    }

     

    0.01f -> 0.05f

    물 속에 투영된 모델의 굴절이 심해졌다.

     

    4. 나만의 노말맵(normal map)을 만들고 그것이 물 효과에 어떤 차이를 만드는지 보세요.

    bool GraphicsClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
    {
    ................................생략................................
    	result = m_WaterModel->Initialize(m_D3D->GetDevice(),
        	L"../rastertek/data/water02.dds",
            "../rastertek/data/water.txt");
    ................................생략................................
    }

    water02.dds

    뚜렷한 차이를 보기 위해서 3번의 0.05f값을 유지하였음.

    water02.dds
    0.15MB

     

    5.RenderRefractionToTexture() 함수에서 정확한 물의 높이가 되도록 클립 평면을 수정합니다.

    graphicsclass.cpp

    bool GraphicsClass::RenderRefractionToTexture()
    {
    ..............................생략..............................
    	clipPlane = D3DXVECTOR4(0.0f, -1.0f, 0.0f, m_waterHeight);
    ..............................생략..............................
    }

    자세히보면 물의 테두리 쪽에 검은색으로 렌더된 부분이 보인다. 이러한 검은색을 방지하기 위해 물의 높이에 0.1f를 더한 것으로 추측된다.

Designed by Tistory.