Texture sampling

This commit is contained in:
2025-12-20 23:45:54 +00:00
parent 893a0e5452
commit 717a8f1869
4 changed files with 2299 additions and 10 deletions

1113
25_sampler.cpp Normal file

File diff suppressed because it is too large Load Diff

1142
26_texture_mapping.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -242,16 +242,16 @@ add_chapter (24_texture_image
TEXTURES images/texture.jpg
LIBS glm::glm)
# add_chapter (25_sampler
# SHADER 22_shader_ubo
# TEXTURES images/texture.jpg
# LIBS glm::glm)
#
# add_chapter (26_texture_mapping
# SHADER 26_shader_textures
# TEXTURES images/texture.jpg
# LIBS glm::glm)
#
add_chapter (25_sampler
SHADER 22_shader_ubo
TEXTURES images/texture.jpg
LIBS glm::glm)
add_chapter (26_texture_mapping
SHADER 26_shader_textures
TEXTURES images/texture.jpg
LIBS glm::glm)
# add_chapter (27_depth_buffering
# SHADER 27_shader_depth
# TEXTURES images/texture.jpg

View File

@@ -0,0 +1,34 @@
struct VSInput {
float2 inPosition;
float3 inColor;
float2 inTexCoord;
};
struct UniformBuffer {
float4x4 model;
float4x4 view;
float4x4 proj;
};
ConstantBuffer<UniformBuffer> ubo;
struct VSOutput {
float4 pos : SV_Position;
float3 color;
float2 fragTexCoord;
};
[shader("vertex")]
VSOutput vertMain(VSInput input) {
VSOutput output;
output.color = input.inColor;
output.pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(input.inPosition, 0.0, 1.0))));
output.fragTexCoord = input.inTexCoord;
return output;
}
Sampler2D texture;
[shader("fragment")]
float4 fragMain(VSOutput vertIn) : SV_Target {
return texture.Sample(vertIn.fragTexCoord);
}