Skip to content

Commit

Permalink
Added / tweaked some materials with new properties and blend modes. A…
Browse files Browse the repository at this point in the history
…dded transparent material.
  • Loading branch information
tdbe committed Feb 24, 2023
1 parent 32bfc35 commit 05f6d35
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 11 deletions.
15 changes: 9 additions & 6 deletions src/shaders/Diffuse.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#extension GL_EXT_multiview : enable

layout(binding = 0) uniform World
layout(binding = 0) uniform DynBufData
{
mat4 matrix;
} world;
mat4 worldMatrix;
vec4 colorMultiplier;
} dynBufData;

layout(binding = 1) uniform ViewProjection
{
Expand All @@ -13,14 +14,16 @@ layout(binding = 1) uniform ViewProjection
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec3 inColor;
//layout(location = 3) in vec3 colorMultiplier;

layout(location = 0) out vec3 normal; // In world space
layout(location = 1) out vec3 color;

void main()
{
gl_Position = viewProjection.matrices[gl_ViewIndex] * world.matrix * vec4(inPosition, 1.0);
gl_Position = viewProjection.matrices[gl_ViewIndex] * dynBufData.worldMatrix * vec4(inPosition, 1.0);

normal = normalize(vec3(world.matrix * vec4(inNormal, 0.0)));
color = inColor;
normal = normalize(vec3(dynBufData.worldMatrix * vec4(inNormal, 0.0)));
color = inColor
* dynBufData.colorMultiplier.xyz;
}
14 changes: 14 additions & 0 deletions src/shaders/DiffuseTransparent.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
layout(location = 0) in vec3 normal;
layout(location = 1) in vec4 color;

layout(location = 0) out vec4 outColor;

void main()
{
const vec3 lightDir = vec3(1.0, -1.0, -1.0);
const float diffuse = clamp(dot(normal, -lightDir), 0.0, 1.0);

const vec3 ambient = vec3(0.07, 0.05, 0.1);

outColor = vec4(ambient + color.xyz * diffuse, color.w);
}
30 changes: 30 additions & 0 deletions src/shaders/DiffuseTransparent.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#extension GL_EXT_multiview : enable

layout(binding = 0) uniform DynBufData
{
mat4 worldMatrix;
vec4 colorMultiplier;
} dynBufData;

layout(binding = 1) uniform ViewProjection
{
mat4 matrices[2];
} viewProjection;

layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec3 inColor;
//layout(location = 3) in vec3 colorMultiplier;

layout(location = 0) out vec3 normal; // In world space
layout(location = 1) out vec4 color;

void main()
{
gl_Position = viewProjection.matrices[gl_ViewIndex] * dynBufData.worldMatrix * vec4(inPosition, 1.0);

normal = normalize(vec3(dynBufData.worldMatrix * vec4(inNormal, 0.0)));
color.xyz = inColor
* dynBufData.colorMultiplier.xyz;
color.w = dynBufData.colorMultiplier.w;
}
13 changes: 8 additions & 5 deletions src/shaders/Grid.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#extension GL_EXT_multiview : enable

layout(binding = 0) uniform World
layout(binding = 0) uniform DynBufData
{
mat4 matrix;
} world;
mat4 worldMatrix;
vec4 colorMultiplier;
} dynBufData;

layout(binding = 1) uniform ViewProjection
{
Expand All @@ -12,15 +13,17 @@ layout(binding = 1) uniform ViewProjection

layout(location = 0) in vec3 inPosition;
layout(location = 2) in vec3 inColor;
//layout(location = 3) in vec3 colorMultiplier;

layout(location = 0) out vec3 position; // In world space
layout(location = 1) out vec3 color;

void main()
{
vec4 pos = world.matrix * vec4(inPosition, 1.0);
vec4 pos = dynBufData.worldMatrix * vec4(inPosition, 1.0);
gl_Position = viewProjection.matrices[gl_ViewIndex] * pos;
position = pos.xyz;

color = inColor;
color = inColor
*dynBufData.colorMultiplier.xyz;
}
14 changes: 14 additions & 0 deletions src/shaders/Sky.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
layout(location = 0) in vec3 normal;
layout(location = 1) in vec3 color;

layout(location = 0) out vec4 outColor;

void main()
{
const vec3 lightDir = vec3(1.0, -1.0, -1.0);
const float diffuse = clamp(dot(normal, -lightDir), 0.0, 1.0);

const vec3 ambient = vec3(0.07, 0.05, 0.1);

outColor = vec4(ambient + color * diffuse, 1.0);
}
28 changes: 28 additions & 0 deletions src/shaders/Sky.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#extension GL_EXT_multiview : enable

layout(binding = 0) uniform World
{
mat4 matrix;
} world;

layout(binding = 1) uniform ViewProjection
{
mat4 matrices[2];
} viewProjection;

layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec3 inColor;
//layout(location = 3) in vec3 colorMultiplier;

layout(location = 0) out vec3 normal; // In world space
layout(location = 1) out vec3 color;

void main()
{
gl_Position = viewProjection.matrices[gl_ViewIndex] * world.matrix * vec4(inPosition, 1.0);

normal = normalize(vec3(world.matrix * vec4(inNormal, 0.0)));
color = inColor
;//*colorMultiplier;
}

0 comments on commit 05f6d35

Please sign in to comment.