This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Port most shaders to new format -Fix Entity movement code -Add LivingEntity
- Loading branch information
1 parent
5433db9
commit 36527c3
Showing
43 changed files
with
671 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
layout (set = 0, binding = 0) uniform sampler TextureSampler; | ||
layout (set = 0, binding = 1) uniform texture2D Texture; | ||
layout (set = 1, binding = 0) uniform TextureDrawParams { | ||
bool flip; | ||
}; | ||
|
||
void vert(vec3 position, out vec2 uv){ | ||
gl_Position = vec4((position.xy * 2) - 1, 0, 1); | ||
|
||
//Sample from source texture. | ||
|
||
uv = position.xy; | ||
if (flip) | ||
uv = vec2(uv.x, 1 - uv.y); | ||
} | ||
|
||
void frag(vec2 uv, out vec4 o_color){ | ||
o_color = texture(sampler2D(Texture, TextureSampler), uv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
layout (set = 0, binding = 0) uniform CameraData { | ||
mat4 VPMatrix; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "common/camera.glsl" | ||
#include "common/model.glsl" | ||
|
||
mat4 GetMVP(){ | ||
return ModelMatrix * VPMatrix; | ||
} | ||
|
||
vec4 ModelVertex(vec3 pos){ | ||
return vec4(pos, 1) * GetMVP(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#AREA FRAGMENT | ||
|
||
vec4 interpolatePixels(vec2 uv, vec2 uvMin, vec2 uvMax, texture2D tex, sampler sam) { | ||
vec2 inverseTexSize = textureSize(sampler2D(tex, sam), 0); | ||
vec2 texSize = 1 / inverseTexSize; | ||
|
||
vec2 oldUv = uv; | ||
|
||
vec2 boxSize = (abs(dFdx(oldUv)) + abs(dFdy(oldUv))) * inverseTexSize * 0.8; | ||
|
||
vec2 tx = oldUv * inverseTexSize - 0.5 * boxSize; | ||
vec2 tfract = fract(tx); | ||
vec2 txOffset = smoothstep(1 - boxSize, vec2(1), tfract); | ||
|
||
vec2 tmin = uvMin + 0.5 * texSize; | ||
vec2 tmax = uvMax - 0.5 * texSize; | ||
|
||
vec2 newUvMin = clamp((tx - tfract + 0.5) * texSize, tmin, tmax); | ||
vec2 newUvMax = clamp((tx - tfract + 0.5 + txOffset) * texSize, tmin, tmax); | ||
|
||
vec4 sampledColor = ( | ||
texture(sampler2D(tex, sam), newUvMin) + | ||
texture(sampler2D(tex, sam), newUvMax) + | ||
texture(sampler2D(tex, sam), vec2(newUvMin.x, newUvMax.y)) + | ||
texture(sampler2D(tex, sam), vec2(newUvMax.x, newUvMin.y)) | ||
) / 4; | ||
return sampledColor; | ||
} | ||
|
||
#END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
layout (set = 1, binding = 0) uniform ModelData { | ||
mat4 ModelMatrix; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
void doStuff(){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "common/camera.glsl" | ||
|
||
void vert(vec3 position, vec4 color, vec2 uv, out vec4 o_color){ | ||
vec4 pos = vec4(position, 1) * VPMatrix; | ||
gl_Position = pos; | ||
|
||
o_color = color; | ||
} | ||
|
||
void frag(vec4 color, out vec4 o_color){ | ||
o_color = color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
layout (set = 0, binding = 0) uniform sampler TextureSampler; | ||
layout (set = 0, binding = 1) uniform texture2D Texture; | ||
|
||
layout (set = 1, binding = 0) uniform TextureDrawParams { | ||
vec2 SrcMin; | ||
vec2 SrcMax; | ||
vec2 DstMin; | ||
vec2 DstMax; | ||
vec2 SrcSize; | ||
vec2 DstSize; | ||
}; | ||
|
||
|
||
void vert(vec3 Position, out vec2 o_uv){ | ||
vec2 scaledDstMin = DstMin / DstSize; | ||
vec2 scaledDstMax = DstMax / DstSize; | ||
|
||
//Move vertex to correct place on texture. | ||
vec2 uv = (scaledDstMin + (scaledDstMax - scaledDstMin) * Position.xy); | ||
uv.y = 1-uv.y; | ||
|
||
gl_Position = vec4((uv * 2) - 1, 0, 1); | ||
|
||
vec2 scaledSrcMin = SrcMin / SrcSize; | ||
vec2 scaledSrcMax = SrcMax / SrcSize; | ||
|
||
//Sample from source texture. | ||
o_uv = scaledSrcMin + (scaledSrcMax - scaledSrcMin) * Position.xy; | ||
} | ||
|
||
void frag(vec2 uv, out vec4 o_color){ | ||
o_color = texture(sampler2D(Texture, TextureSampler), uv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "common/camera_and_model.glsl" | ||
#include "common/filtering.glsl" | ||
|
||
layout (set = 2, binding = 0) uniform sampler TextureSampler; | ||
layout (set = 2, binding = 1) uniform texture2D Texture; | ||
|
||
void Unpack(int packedColor, int packedUV, out vec4 color, out vec2 uv){ | ||
color = vec4( | ||
(packedColor & 255) / 255.0f, | ||
((packedColor >> 8) & 255) / 255.0f, | ||
((packedColor >> 16) & 255) / 255.0f, | ||
((packedColor >> 24) & 255) / 255.0f | ||
); | ||
|
||
uv = vec2( | ||
(packedUV & 65535) / 65535.0f, | ||
((packedUV >> 16) & 65535) / 65535.0f | ||
); | ||
} | ||
|
||
float singleInterp(float strength, float baseColor) { | ||
float min = 0.95 * baseColor * baseColor; | ||
return min + (baseColor - min) * strength; | ||
} | ||
|
||
vec3 getColorMultiplier(float strength, vec3 baseColor) { | ||
return vec3( | ||
singleInterp(strength, baseColor.x), | ||
singleInterp(strength, baseColor.y), | ||
singleInterp(strength, baseColor.z) | ||
); | ||
} | ||
|
||
void vert(vec3 position, int packedColor, int packedUV, float ao, vec2 uvMin, vec2 uvMax, out vec4 o_color, out vec2 o_uv, out float o_distance, out vec2 o_uvMin, out vec2 o_uvMax){ | ||
Unpack(packedColor, packedUV, o_color, o_uv); | ||
o_color = o_color * vec4(getColorMultiplier(1-ao, vec3(0.9, 0.9, 1)), 1); | ||
|
||
vec4 pos = ModelVertex(position); | ||
gl_Position = pos; | ||
o_distance = pos.z; | ||
|
||
o_uvMin = uvMin; | ||
o_uvMax = uvMax; | ||
} | ||
|
||
void frag(vec4 color, vec2 uv, float distance, vec2 uvMin, vec2 uvMax, out vec4 o_color, out vec4 o_gbuffer){ | ||
o_color = interpolatePixels(uv, uvMin, uvMax, Texture, TextureSampler) * color; | ||
o_gbuffer = vec4(1, 1, 0, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Voxel.Common.World.Entity; | ||
using Voxel.Common.World.Entity.Player; | ||
|
||
namespace Voxel.Client.World.Entity; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.