Merge branch 'SaschaWillems:master' into master
This commit is contained in:
commit
a867ca2809
109 changed files with 2298 additions and 642 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#version 450
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
layout (binding = 0) uniform sampler2D samplerColor;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -17,7 +17,7 @@ void main()
|
|||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(inLightVec);
|
||||
vec3 V = normalize(inViewVec);
|
||||
vec3 R = reflect(-L, N);
|
||||
vec3 R = reflect(L, N);
|
||||
vec3 diffuse = max(dot(N, L), 0.15) * inColor;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 16.0) * vec3(0.75);
|
||||
outFragColor = vec4(diffuse * color.rgb + specular, 1.0);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -10,6 +10,7 @@ layout (set = 0, binding = 0) uniform UBOScene
|
|||
mat4 projection;
|
||||
mat4 view;
|
||||
vec4 lightPos;
|
||||
vec4 viewPos;
|
||||
} uboScene;
|
||||
|
||||
layout(push_constant) uniform PushConsts {
|
||||
|
|
@ -32,6 +33,6 @@ void main()
|
|||
vec4 pos = uboScene.view * vec4(inPos, 1.0);
|
||||
outNormal = mat3(uboScene.view) * inNormal;
|
||||
vec3 lPos = mat3(uboScene.view) * uboScene.lightPos.xyz;
|
||||
outLightVec = lPos - pos.xyz;
|
||||
outViewVec = -pos.xyz;
|
||||
outLightVec = uboScene.lightPos.xyz - pos.xyz;
|
||||
outViewVec = uboScene.viewPos.xyz - pos.xyz;
|
||||
}
|
||||
Binary file not shown.
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in vec4 inPos;
|
||||
layout (location = 0) in vec4 inPos;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,7 +1,6 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec2 inUV;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
|
|
@ -10,12 +9,10 @@ layout (binding = 0) uniform UBO
|
|||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
layout (location = 1) out vec4 outPos;
|
||||
layout (location = 0) out vec4 outPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV;
|
||||
outPos = ubo.projection * ubo.view * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
gl_Position = outPos;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5,16 +5,25 @@ layout (set = 0, binding = 2) uniform sampler samplers[3];
|
|||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in float inLodBias;
|
||||
layout (location = 2) flat in int inSamplerIndex;
|
||||
layout (location = 3) in vec3 inNormal;
|
||||
layout (location = 4) in vec3 inViewVec;
|
||||
layout (location = 5) in vec3 inLightVec;
|
||||
layout (location = 2) in vec3 inNormal;
|
||||
layout (location = 3) in vec3 inViewVec;
|
||||
layout (location = 4) in vec3 inLightVec;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
vec4 viewPos;
|
||||
float lodBias;
|
||||
int samplerIndex;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(sampler2D(textureColor, samplers[inSamplerIndex]), inUV, inLodBias);
|
||||
vec4 color = texture(sampler2D(textureColor, samplers[uniform.samplerIndex]), inUV, inLodBias);
|
||||
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(inLightVec);
|
||||
|
|
|
|||
|
|
@ -16,21 +16,14 @@ layout (binding = 0) uniform UBO
|
|||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
layout (location = 1) out float outLodBias;
|
||||
layout (location = 2) flat out int outSamplerIndex;
|
||||
layout (location = 3) out vec3 outNormal;
|
||||
layout (location = 4) out vec3 outViewVec;
|
||||
layout (location = 5) out vec3 outLightVec;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
layout (location = 2) out vec3 outNormal;
|
||||
layout (location = 3) out vec3 outViewVec;
|
||||
layout (location = 4) out vec3 outLightVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV * vec2(2.0, 1.0);
|
||||
outLodBias = ubo.lodBias;
|
||||
outSamplerIndex = ubo.samplerIndex;
|
||||
|
||||
vec3 worldPos = vec3(ubo.model * vec4(inPos, 1.0));
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ float4 main(VSOutput input) : SV_TARGET
|
|||
float3 N = normalize(input.Normal);
|
||||
float3 L = normalize(input.LightVec);
|
||||
float3 V = normalize(input.ViewVec);
|
||||
float3 R = reflect(-L, N);
|
||||
float3 R = reflect(L, N);
|
||||
float3 diffuse = max(dot(N, L), 0.0) * input.Color;
|
||||
float3 specular = pow(max(dot(R, V), 0.0), 16.0) * float3(0.75, 0.75, 0.75);
|
||||
return float4(diffuse * color.rgb + specular, 1.0);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -13,6 +13,7 @@ struct UBO
|
|||
float4x4 projection;
|
||||
float4x4 view;
|
||||
float4 lightPos;
|
||||
float4 viewPos;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
|
@ -42,8 +43,7 @@ VSOutput main(VSInput input)
|
|||
|
||||
float4 pos = mul(ubo.view, float4(input.Pos, 1.0));
|
||||
output.Normal = mul((float3x3)ubo.view, input.Normal);
|
||||
float3 lPos = mul((float3x3)ubo.view, ubo.lightPos.xyz);
|
||||
output.LightVec = lPos - pos.xyz;
|
||||
output.ViewVec = -pos.xyz;
|
||||
output.LightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
output.ViewVec = ubo.viewPos.xyz - pos.xyz;
|
||||
return output;
|
||||
}
|
||||
Binary file not shown.
|
|
@ -5,8 +5,7 @@ SamplerState samplerColor : register(s1);
|
|||
|
||||
struct VSOutput
|
||||
{
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]] float4 ProjCoord : POSITION0;
|
||||
[[vk::location(0)]] float4 ProjCoord : POSITION0;
|
||||
};
|
||||
|
||||
float4 main(VSOutput input, bool FrontFacing : SV_IsFrontFace) : SV_TARGET
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -3,7 +3,6 @@
|
|||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float3 Pos : POSITION0;
|
||||
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct UBO
|
||||
|
|
@ -18,14 +17,12 @@ cbuffer ubo : register(b0) { UBO ubo; }
|
|||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]] float4 ProjCoord : POSITION0;
|
||||
[[vk::location(0)]] float4 ProjCoord : POSITION0;
|
||||
};
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.UV = input.UV;
|
||||
output.ProjCoord = mul(ubo.projection, mul(ubo.view, mul(ubo.model, float4(input.Pos.xyz, 1.0))));
|
||||
output.Pos = output.ProjCoord;
|
||||
return output;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -3,19 +3,30 @@
|
|||
Texture2D textureColor : register(t1);
|
||||
SamplerState samplers[3] : register(s2);
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
float4x4 model;
|
||||
float4 viewPos;
|
||||
float lodBias;
|
||||
int samplerIndex;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]] float LodBias : TEXCOORD3;
|
||||
[[vk::location(2)]] int SamplerIndex : TEXCOORD4;
|
||||
[[vk::location(3)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(4)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(5)]] float3 LightVec : TEXCOORD2;
|
||||
[[vk::location(2)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(3)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(4)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
float4 main(VSOutput input) : SV_TARGET
|
||||
{
|
||||
float4 color = textureColor.Sample(samplers[input.SamplerIndex], input.UV, int2(0, 0), input.LodBias);
|
||||
float4 color = textureColor.Sample(samplers[ubo.samplerIndex], input.UV, int2(0, 0), input.LodBias);
|
||||
|
||||
float3 N = normalize(input.Normal);
|
||||
float3 L = normalize(input.LightVec);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -24,10 +24,9 @@ struct VSOutput
|
|||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]] float LodBias : TEXCOORD3;
|
||||
[[vk::location(2)]] int SamplerIndex : TEXCOORD4;
|
||||
[[vk::location(3)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(4)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(5)]] float3 LightVec : TEXCOORD2;
|
||||
[[vk::location(2)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(3)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(4)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
|
|
@ -35,7 +34,6 @@ VSOutput main(VSInput input)
|
|||
VSOutput output = (VSOutput)0;
|
||||
output.UV = input.UV * float2(2.0, 1.0);
|
||||
output.LodBias = ubo.lodBias;
|
||||
output.SamplerIndex = ubo.samplerIndex;
|
||||
|
||||
float3 worldPos = mul(ubo.model, float4(input.Pos, 1.0)).xyz;
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue