Fix Vulkan unlit single-source HLSL compilation
This commit is contained in:
@@ -11,19 +11,56 @@ Shader "Builtin Unlit"
|
||||
{
|
||||
Name "Unlit"
|
||||
Tags { "LightMode" = "Unlit" }
|
||||
Resources
|
||||
{
|
||||
PerObjectConstants (ConstantBuffer, 0, 0) [Semantic(PerObject)]
|
||||
MaterialConstants (ConstantBuffer, 1, 0) [Semantic(Material)]
|
||||
BaseColorTexture (Texture2D, 2, 0) [Semantic(BaseColorTexture)]
|
||||
LinearClampSampler (Sampler, 3, 0) [Semantic(LinearClampSampler)]
|
||||
}
|
||||
Cull Back
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex MainVS
|
||||
#pragma fragment MainPS
|
||||
#pragma backend D3D12 HLSL "unlit.vs.hlsl" "unlit.ps.hlsl" vs_5_0 ps_5_0
|
||||
#pragma backend OpenGL GLSL "unlit.vert.glsl" "unlit.frag.glsl"
|
||||
#pragma backend Vulkan GLSL "unlit.vert.vk.glsl" "unlit.frag.vk.glsl"
|
||||
cbuffer PerObjectConstants : register(b0)
|
||||
{
|
||||
float4x4 gProjectionMatrix;
|
||||
float4x4 gViewMatrix;
|
||||
float4x4 gModelMatrix;
|
||||
float4x4 gNormalMatrix;
|
||||
};
|
||||
|
||||
cbuffer MaterialConstants : register(b1)
|
||||
{
|
||||
float4 gBaseColorFactor;
|
||||
};
|
||||
|
||||
Texture2D BaseColorTexture : register(t0);
|
||||
SamplerState LinearClampSampler : register(s0);
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PSInput
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
PSInput MainVS(VSInput input)
|
||||
{
|
||||
PSInput output;
|
||||
const float4 positionWS = mul(gModelMatrix, float4(input.position, 1.0f));
|
||||
const float4 positionVS = mul(gViewMatrix, positionWS);
|
||||
output.position = mul(gProjectionMatrix, positionVS);
|
||||
output.texcoord = input.texcoord;
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 MainPS(PSInput input) : SV_TARGET
|
||||
{
|
||||
return BaseColorTexture.Sample(LinearClampSampler, input.texcoord) * gBaseColorFactor;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user