This commit is contained in:
Michael Tang 2019-04-23 18:26:20 -07:00
parent fdc8a6a4e2
commit e89375b39a
3 changed files with 20 additions and 14 deletions

View File

@ -34,6 +34,9 @@ mod hlsl_build {
let src_data = fs::read_to_string(&source_path).unwrap();
if vertex_destination.exists() {
fs::remove_file(vertex_destination).unwrap();
}
fs::write(
vertex_destination,
compile_shader(&src_data, &source_path, "VertexMain", "vs_4_0").unwrap_or_else(
@ -45,6 +48,9 @@ mod hlsl_build {
)
.unwrap();
if pixel_destination.exists() {
fs::remove_file(pixel_destination).unwrap();
}
fs::write(
pixel_destination,
compile_shader(&src_data, &source_path, "PixelMain", "ps_4_0").unwrap_or_else(

View File

@ -168,8 +168,8 @@ impl Shaders {
include_bytes!("shader/glsles_100.frag"),
),
HlslSm40 => (
include_bytes!("data/pixel.fx"),
include_bytes!("data/vertex.fx"),
include_bytes!("data/pixel.fx"),
),
}
}

View File

@ -1,34 +1,34 @@
cbuffer Constants : register(b0) {
float4x4 matrix_;
float4x4 matrix_;
}
Texture2D tex;
SamplerState tex_;
struct VIn {
float2 position : pos;
float2 uv : uv;
float4 color : col;
float2 position : pos;
float2 uv : uv;
float4 color : col;
};
struct VOut
{
float4 position : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
float4 position : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
VOut VertexMain(VIn vertex)
{
VOut output;
output.position = mul(matrix_, float4(vertex.position, 0.0, 1.0));
output.uv = vertex.uv;
output.color = vertex.color;
VOut output;
output.position = mul(matrix_, float4(vertex.position, 0.0, 1.0));
output.uv = vertex.uv;
output.color = vertex.color;
return output;
return output;
}
float4 PixelMain(VOut vout) : SV_TARGET
{
return vout.color * tex.Sample(tex_, vout.uv);
return vout.color * tex.Sample(tex_, vout.uv);
}