Technically working shaders.

This commit is contained in:
2024-12-29 17:58:49 -06:00
parent 7c3225fe10
commit bfd1ac6953
24 changed files with 281 additions and 134 deletions

View File

@ -0,0 +1,8 @@
{
"assets": {
"simpleTexturedShader": {
"type": "shader",
"path": "shaders/simple-textured.shader"
}
}
}

View File

@ -13,6 +13,10 @@
"rosatext": {
"type": "texture",
"path": "rosa.texture"
},
"simpleTexturedShader": {
"type": "shader",
"path": "shaders/simple-textured.slang"
}
},

View File

@ -1,13 +1,9 @@
struct Uniforms {
float4x4 projection;
float4x4 view;
float4x4 model;
float4 color;
bool hasTexture;
Sampler2D texture;
}
uniform Uniforms uniforms;
uniform float4x4 projection;
uniform float4x4 view;
uniform float4x4 model;
uniform float4 color;
uniform bool hasTexture;
uniform Sampler2D texture;
struct AssembledVertex {
float3 position : POSITION;
@ -35,7 +31,7 @@ VertexStageOutput vertexMain(
output.sv_position = mul(
float4(position, 1.0),
mul(uniforms.model, mul(uniforms.view, uniforms.projection))
mul(model, mul(view, projection))
);
return output;
@ -46,10 +42,11 @@ Fragment fragmentMain(
float2 uv: UV
) : SV_Target {
Fragment output;
if (uniforms.hasTexture) {
output.color = uniforms.texture.Sample(uv) * uniforms.color;
if (hasTexture) {
output.color = texture.Sample(uv) * color;
} else {
output.color = uniforms.color;
output.color = color;
}
return output;