Here is a shader:
cbuffer ConstantBufferMatrices : register(b0) { float4x4 World: packoffset(c0); float4x4 View: packoffset(c4); float4x4 Projection: packoffset(c8); } struct VS_INPUT { float3 Pos : POSITION; float2 Tex : TEXCOORD0; float3 Norm : TEXCOORD1; }; struct VS_OUTPUT { float4 Pos : SV_POSITION; float3 Norm : TEXCOORD0; }; VS_OUTPUT main(VS_INPUT input) { VS_OUTPUT output = (VS_OUTPUT)0; float4 Pos1 = float4(input.Pos.x, input.Pos.y, input.Pos.z, 1); float4x4 FinalMatrix = mul(Projection, mul(View,World)); output.Pos = mul(FinalMatrix, Pos1); float4 Normal_4 = float4(input.Norm, 0); float4 Normal_4_b = mul(Normal_4,World); output.Norm = normalize(float3(Normal_4_b.xyz)); return output; } I study his third hour in a row. It is necessary to translate the normals into the world coordinate system, so that when you rotate the teapot, the normals apparently glide over it. A world matrix is put (only rotation along the Y axis), a specific matrix (once at the start of the program, the PerspectiveLookAt function), the projection matrix can be disregarded. Normal translate to float4 with w=0 (since this is the direction), normalize and in the pixel shader I simply output as a color (with alpha 1.0f). I get the result: the normals rotate with the teapot. When they swim a little at the very beginning and freeze, it probably does not mean anything. The teapot is green-red, the bottom is blue. All this is intended for lighting tied to the camera, but for now I’m doing normals. Why do the normals rotate with the teapot? The only thing that changes is the matrix of the world, but I multiply it into it!