Directx 11 with rastertek

Tutorial 25: Texture Translation 연습문제

코다람쥐 2022. 9. 23. 13:56

To Do Exercises

1. Recompile the code and ensure you get a texture translating across the polygon surface.

2. Change the pixel shader to affect the Y axis instead of the X axis.

3. Change the pixel shader to affect both the Y axis and then X axis by the same translation value.

 

1. 코드를 다시 컴파일하고 도형 표면을 가로지르는 변환된 텍스처가 있는지를 확인합니다.

2. X축 대신 Y축에 영향을 미치도록 픽셀 셰이더를 변경해주세요.

translate.ps

float4 TranslatePixelShader(PixelInputType input) : SV_TARGET
{
    // Translate the position where we sample the pixel from.
    input.tex.y += textureTranslation;

    return shaderTexture.Sample(SampleType, input.tex);
}

 

3. 픽셀 셰이더를 변경하여 동일한 변환 값으로 Y축과 X축 모두에 영향을 주세요.

translate.ps

float4 TranslatePixelShader(PixelInputType input) : SV_TARGET
{
    // Translate the position where we sample the pixel from.
    input.tex.x += textureTranslation;
    input.tex.y += textureTranslation;


    return shaderTexture.Sample(SampleType, input.tex);
}