slang
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
cbuffer Uniforms {
|
||||
float4x4 u_Projection;
|
||||
float4x4 u_View;
|
||||
float4x4 u_Model;
|
||||
struct MVP {
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
float4x4 model;
|
||||
}
|
||||
|
||||
struct Uniforms {
|
||||
MVP mvp;
|
||||
float4 u_Color;
|
||||
bool u_HasTexture;
|
||||
uniform Sampler2D u_Texture;
|
||||
Sampler2D u_Texture;
|
||||
};
|
||||
|
||||
struct AssembledVertex {
|
||||
@ -26,7 +30,10 @@ float4 someFunction(float4 color) {
|
||||
}
|
||||
|
||||
[shader("vertex")]
|
||||
VertexStageOutput vertexMain(AssembledVertex assembledVertex) {
|
||||
VertexStageOutput vertexMain(
|
||||
uniform ParameterBlock<Uniforms> uniforms,
|
||||
AssembledVertex assembledVertex
|
||||
) {
|
||||
VertexStageOutput output;
|
||||
|
||||
float3 position = assembledVertex.position;
|
||||
@ -35,19 +42,22 @@ VertexStageOutput vertexMain(AssembledVertex assembledVertex) {
|
||||
|
||||
output.sv_position = mul(
|
||||
float4(position, 1.0),
|
||||
mul(u_Model, mul(u_View, u_Projection))
|
||||
mul(uniforms.mvp.model, mul(uniforms.mvp.view, uniforms.mvp.projection))
|
||||
);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
Fragment fragmentMain(float2 uv: UV) : SV_Target {
|
||||
Fragment fragmentMain(
|
||||
uniform ParameterBlock<Uniforms> uniforms,
|
||||
float2 uv: UV
|
||||
) : SV_Target {
|
||||
Fragment output;
|
||||
if(u_HasTexture) {
|
||||
output.color = u_Texture.Sample(uv) * u_Color;
|
||||
if(uniforms.u_HasTexture) {
|
||||
output.color = uniforms.u_Texture.Sample(uv) * uniforms.u_Color;
|
||||
} else {
|
||||
output.color = someFunction(u_Color);
|
||||
output.color = someFunction(uniforms.u_Color);
|
||||
}
|
||||
return output;
|
||||
}
|
Reference in New Issue
Block a user