Add shaders re-implemented in HLSL
These were written against the shaders at revision eddd724e7.
There have been changes made since then, which will need to be mirrored.
See `data/hlsl/README.md` for the current status of each sample.
This commit is contained in:
parent
10a1ecaf7b
commit
cce75f1859
287 changed files with 11263 additions and 0 deletions
60
data/hlsl/particlefire/normalmap.vert
Normal file
60
data/hlsl/particlefire/normalmap.vert
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float3 Pos : POSITION0;
|
||||
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(2)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(3)]] float3 Tangent : TEXCOORD1;
|
||||
[[vk::location(4)]] float3 BiTangent : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 model;
|
||||
float4x4 normal;
|
||||
float4 lightPos;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]] float3 LightVec : TEXCOORD2;
|
||||
[[vk::location(2)]] float3 LightVecB : TEXCOORD3;
|
||||
[[vk::location(3)]] float3 LightDir : TEXCOORD4;
|
||||
[[vk::location(4)]] float3 ViewVec : TEXCOORD1;
|
||||
};
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
float3 vertexPosition = mul(ubo.model, float4(input.Pos, 1.0)).xyz;
|
||||
output.LightDir = normalize(ubo.lightPos.xyz - vertexPosition);
|
||||
|
||||
// Setup (t)angent-(b)inormal-(n)ormal matrix for converting
|
||||
// object coordinates into tangent space
|
||||
float3x3 tbnMatrix;
|
||||
tbnMatrix[0] = mul((float3x3)ubo.normal, input.Tangent);
|
||||
tbnMatrix[1] = mul((float3x3)ubo.normal, input.BiTangent);
|
||||
tbnMatrix[2] = mul((float3x3)ubo.normal, input.Normal);
|
||||
|
||||
output.LightVec.xyz = mul(float3(ubo.lightPos.xyz - vertexPosition), tbnMatrix);
|
||||
|
||||
float3 lightDist = ubo.lightPos.xyz - input.Pos;
|
||||
output.LightVecB.x = dot(input.Tangent, lightDist);
|
||||
output.LightVecB.y = dot(input.BiTangent, lightDist);
|
||||
output.LightVecB.z = dot(input.Normal, lightDist);
|
||||
|
||||
output.ViewVec.x = dot(input.Tangent, input.Pos);
|
||||
output.ViewVec.y = dot(input.BiTangent, input.Pos);
|
||||
output.ViewVec.z = dot(input.Normal, input.Pos);
|
||||
|
||||
output.UV = input.UV;
|
||||
|
||||
output.Pos = mul(ubo.projection, mul(ubo.model, float4(input.Pos, 1.0)));
|
||||
return output;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue