generated from jaredlll08/MultiLoader-Template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48e71df
commit 13e7397
Showing
6 changed files
with
155 additions
and
9 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
common/src/main/resources/assets/veil/pinwheel/shaders/include/color.glsl
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,15 @@ | ||
vec3 rgb2hsv(vec3 c) { | ||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); | ||
vec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy); | ||
vec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx); | ||
|
||
float d = q.x - min(q.w, q.y); | ||
float e = 1.0e-10; | ||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); | ||
} | ||
|
||
vec3 hsv2rgb(vec3 c) { | ||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); | ||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); | ||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); | ||
} |
10 changes: 1 addition & 9 deletions
10
common/src/main/resources/assets/veil/pinwheel/shaders/include/deferred_utils.glsl
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
110 changes: 110 additions & 0 deletions
110
common/src/main/resources/assets/veil/pinwheel/shaders/include/space_helper.glsl
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,110 @@ | ||
#veil:buffer veil:camera VeilCamera | ||
|
||
float getFov() { | ||
return 2.0 * atan(1.0 / VeilCamera.ProjMat[1][1]); | ||
} | ||
|
||
float getAspectRatio() { | ||
return VeilCamera.ProjMat[1][1] / VeilCamera.ProjMat[0][0]; | ||
} | ||
|
||
// World Space | ||
|
||
vec4 worldToViewSpace(vec4 pos) { | ||
vec4 viewSpacePos = VeilCamera.ViewMat * (pos - vec4(VeilCamera.CameraPosition, 0.0)); | ||
return viewSpacePos / viewSpacePos.w; | ||
} | ||
|
||
vec4 worldToClipSpace(vec4 pos) { | ||
vec4 viewSpacePos = VeilCamera.ViewMat * (pos - vec4(VeilCamera.CameraPosition, 0.0)); | ||
return VeilCamera.ProjMat * (viewSpacePos / viewSpacePos.w); | ||
} | ||
|
||
vec3 worldToScreenSpace(vec4 pos) { | ||
vec4 viewSpacePos = VeilCamera.ViewMat * (pos - vec4(VeilCamera.CameraPosition, 0.0)); | ||
vec4 clipSpace = VeilCamera.ProjMat * (viewSpacePos / viewSpacePos.w); | ||
clipSpace.xyz /= clipSpace.w; | ||
return vec3((clipSpace.xy + vec2(1.0)) / 2.0, clipSpace.z); | ||
} | ||
|
||
#define worldToViewSpacePosition(pos) worldToViewSpace(vec4(pos, 1.0)).xyz | ||
#define worldToClipSpacePosition(pos) worldToClipSpace(vec4(pos, 1.0)).xyz | ||
#define worldToScreenSpacePosition(pos) worldToScreenSpace(vec4(pos, 1.0)) | ||
#define worldToViewSpaceDirection(pos) worldToViewSpace(vec4(pos, 0.0)).xyz | ||
#define worldToClipSpaceDirection(pos) worldToClipSpace(vec4(pos, 0.0)).xyz | ||
#define worldToScreenSpaceDirection(pos) worldToScreenSpace(vec4(pos, 0.0)) | ||
|
||
// View Space | ||
|
||
vec4 viewToWorldSpace(vec4 pos) { | ||
return vec4(VeilCamera.CameraPosition, 0.0) + VeilCamera.IViewMat * pos; | ||
} | ||
|
||
vec4 viewToClipSpace(vec4 pos) { | ||
return VeilCamera.ProjMat * pos; | ||
} | ||
|
||
vec3 viewToScreenSpace(vec4 pos) { | ||
vec4 clipSpace = VeilCamera.ProjMat * pos; | ||
clipSpace.xyz /= clipSpace.w; | ||
return vec3((clipSpace.xy + vec2(1.0)) / 2.0, clipSpace.z); | ||
} | ||
|
||
#define viewToWorldSpacePosition(pos) viewToWorldSpace(vec4(pos, 1.0)).xyz | ||
#define viewToClipSpacePosition(pos) viewToClipSpace(vec4(pos, 1.0)).xyz | ||
#define viewToScreenSpacePosition(pos) viewToScreenSpace(vec4(pos, 1.0)) | ||
#define viewToWorldSpaceDirection(pos) viewToWorldSpace(vec4(pos, 0.0)).xyz | ||
#define viewToClipSpaceDirection(pos) viewToClipSpace(vec4(pos, 0.0)).xyz | ||
#define viewToScreenSpaceDirection(pos) viewToScreenSpace(vec4(pos, 0.0)) | ||
|
||
// Clip Space | ||
|
||
vec4 clipToWorldSpace(vec4 pos) { | ||
return vec4(VeilCamera.CameraPosition, 0.0) + VeilCamera.IViewMat * VeilCamera.IProjMat * pos; | ||
} | ||
|
||
vec4 clipToViewSpace(vec4 pos) { | ||
return VeilCamera.IProjMat * pos; | ||
} | ||
|
||
vec3 clipToScreenSpace(vec4 pos) { | ||
pos.xyz /= pos.w; | ||
return vec3((pos.xy + vec2(1.0)) / 2.0, pos.z); | ||
} | ||
|
||
#define clipToWorldSpacePosition(pos) clipToWorldSpace(vec4(pos, 1.0)).xyz | ||
#define clipToViewSpacePosition(pos) clipToViewSpace(vec4(pos, 1.0)).xyz | ||
#define clipToScreenSpacePosition(pos) clipToScreenSpace(vec4(pos, 1.0)) | ||
#define clipToWorldSpaceDirection(pos) clipToWorldSpace(vec4(pos, 0.0)).xyz | ||
#define clipToViewSpaceDirection(pos) clipToViewSpace(vec4(pos, 0.0)).xyz | ||
#define clipToScreenSpaceDirection(pos) clipToScreenSpace(vec4(pos, 0.0)) | ||
|
||
// Screen Space | ||
|
||
vec4 screenToWorldSpace(vec3 pos) { | ||
vec4 viewSpacePos = VeilCamera.IProjMat * (vec4(pos.xy, pos.z, 1.0) * 2.0 - 1.0); | ||
return vec4(VeilCamera.CameraPosition, 0.0) + VeilCamera.IViewMat * (viewSpacePos / viewSpacePos.w); | ||
} | ||
|
||
vec4 screenToViewSpace(vec3 pos) { | ||
vec4 viewSpacePos = VeilCamera.IProjMat * (vec4(pos.xy, pos.z, 1.0) * 2.0 - 1.0); | ||
return viewSpacePos / viewSpacePos.w; | ||
} | ||
|
||
vec4 screenToClipSpace(vec3 pos) { | ||
return vec4(pos.xy, pos.z, 1.0) * 2.0 - 1.0; | ||
} | ||
|
||
vec4 screenToWorldSpace(vec2 uv, float depth) { | ||
vec4 viewSpacePos = VeilCamera.IProjMat * (vec4(uv, depth, 1.0) * 2.0 - 1.0); | ||
return vec4(VeilCamera.CameraPosition, 0.0) + VeilCamera.IViewMat * (viewSpacePos / viewSpacePos.w); | ||
} | ||
|
||
vec4 screenToViewSpace(vec2 uv, float depth) { | ||
vec4 viewSpacePos = VeilCamera.IProjMat * (vec4(uv, depth, 1.0) * 2.0 - 1.0); | ||
return viewSpacePos / viewSpacePos.w; | ||
} | ||
|
||
vec4 screenToClipSpace(vec2 uv, float depth) { | ||
return vec4(uv, depth, 1.0) * 2.0 - 1.0; | ||
} |
9 changes: 9 additions & 0 deletions
9
common/src/main/resources/resourcepacks/fog/assets/veil/pinwheel/post/space_test.json
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,9 @@ | ||
{ | ||
"stages": [ | ||
{ | ||
"type": "veil:blit", | ||
"shader": "veil:space_test", | ||
"in": "minecraft:main" | ||
} | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
.../src/main/resources/resourcepacks/fog/assets/veil/pinwheel/shaders/program/space_test.fsh
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,16 @@ | ||
#include veil:space_helper | ||
|
||
uniform sampler2D DiffuseSampler0; | ||
uniform sampler2D DiffuseDepthSampler; | ||
|
||
in vec2 texCoord; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() { | ||
vec4 baseColor = texture(DiffuseSampler0, texCoord); | ||
float depthSample = texture(DiffuseDepthSampler, texCoord).r; | ||
vec4 pos = screenToWorldSpace(texCoord, depthSample); | ||
|
||
fragColor = vec4(pos.xyz, 1.0); | ||
} |
4 changes: 4 additions & 0 deletions
4
...src/main/resources/resourcepacks/fog/assets/veil/pinwheel/shaders/program/space_test.json
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,4 @@ | ||
{ | ||
"vertex": "veil:blit_screen", | ||
"fragment": "veil:space_test" | ||
} |