summaryrefslogtreecommitdiffstats
path: root/cwd
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cwd/shaders/block.fs42
-rw-r--r--cwd/shaders/block.gs32
-rw-r--r--cwd/shaders/block.vs22
3 files changed, 63 insertions, 33 deletions
diff --git a/cwd/shaders/block.fs b/cwd/shaders/block.fs
index d1716bc..15fd217 100644
--- a/cwd/shaders/block.fs
+++ b/cwd/shaders/block.fs
@@ -1,13 +1,13 @@
#version 330 core
-in vec2 UvPosition;
-in vec3 FragmentPosition;
-flat in int Block;
-flat in int State;
-in vec4 ndcPos;
-
-//uniform int Block;
-//uniform int State;
+in VS_OUT {
+ vec2 UvPosition;
+ vec3 FragmentPosition;
+ flat int Block;
+ flat int State;
+ vec4 ndcPos;
+} fs_in;
+
uniform sampler2D textureAtlas;
uniform float time;
uniform int isInside;
@@ -31,17 +31,17 @@ vec4 VTC(int value);
int GetBlockSide(){
int side=6;
- if (FragmentPosition.y==-0.5)
+ if (fs_in.FragmentPosition.y==-0.5)
side=0;
- else if (FragmentPosition.y==0.5)
+ else if (fs_in.FragmentPosition.y==0.5)
side=1;
- else if (FragmentPosition.x==-0.5)
+ else if (fs_in.FragmentPosition.x==-0.5)
side = 3;
- else if (FragmentPosition.x==0.5)
+ else if (fs_in.FragmentPosition.x==0.5)
side = 2;
- else if (FragmentPosition.z==-0.5)
+ else if (fs_in.FragmentPosition.z==-0.5)
side=4;
- else if (FragmentPosition.z==0.5)
+ else if (fs_in.FragmentPosition.z==0.5)
side=5;
return side;
}
@@ -67,15 +67,11 @@ vec3 hsv2rgb(vec3 c)
void main() {
-/*gl_FragColor = vec4(0,1,0,1);
-if (isInside==0)
- gl_FragColor = vec4(1,0,0,1);
- return;*/
vec4 BlockTextureCoords = GetTextureByBlockId();
- vec2 AtlasCoords = TransformTextureCoord(BlockTextureCoords, UvPosition);
+ vec2 AtlasCoords = TransformTextureCoord(BlockTextureCoords, fs_in.UvPosition);
gl_FragColor = texture(textureAtlas, AtlasCoords);
if (gl_FragColor.a<0.1) discard;
- if (Block==2 && side==1 || Block==18 || Block==31 && state==1 || Block==31 && state==2) { //Grass and leaves colorizing
+ if (fs_in.Block==2 && side==1 || fs_in.Block==18 || fs_in.Block==31 && state==1 || fs_in.Block==31 && state==2) { //Grass and leaves colorizing
const float BiomeColor = 0.275;
vec3 hsvColor = rgb2hsv(gl_FragColor.xyz);
hsvColor[0]+=BiomeColor;
@@ -93,9 +89,9 @@ vec4 GetTextureByBlockId() {
id = (index & 0xFF0) >> 4;
state = index & 0xF;
- if (id != Block)
+ if (id != fs_in.Block)
continue;
- if (state != State)
+ if (state != fs_in.State)
continue;
if (side == 6)
return textureData[i];
@@ -155,7 +151,7 @@ vec4 GetDepthColor() {
}
vec4 GetCheckerColor() {
- if (UvPosition.x>0.5 && UvPosition.y<0.5 || UvPosition.x<0.5 && UvPosition.y>0.5)
+ if (fs_in.UvPosition.x>0.5 && fs_in.UvPosition.y<0.5 || fs_in.UvPosition.x<0.5 && fs_in.UvPosition.y>0.5)
return vec4(0.7,0.7,0,1);
else
return vec4(0,0,0,1);
diff --git a/cwd/shaders/block.gs b/cwd/shaders/block.gs
new file mode 100644
index 0000000..17d61c3
--- /dev/null
+++ b/cwd/shaders/block.gs
@@ -0,0 +1,32 @@
+#version 330 core
+
+in gl_Vertex
+{
+ vec4 gl_Position;
+ float gl_PointSize;
+ float gl_ClipDistance[];
+} gl_in[];
+
+in VS_OUT {
+ vec2 UvPosition;
+ vec3 FragmentPosition;
+ flat int Block;
+ flat int State;
+ vec4 ndcPos;
+} gs_in[];
+
+out GS_OUT {
+ vec2 UvPosition;
+ vec3 FragmentPosition;
+ flat int Block;
+ flat int State;
+ vec4 ndcPos;
+} gs_out[];
+
+void main() {
+ gs_out[0].UvPosition = gs_in[0].UvPosition;
+ gs_out[0].FragmentPosition = gs_in[0].FragmentPosition;
+ gs_out[0].Block = gs_in[0].Block;
+ gs_out[0].State = gs_in[0].State;
+ gs_out[0].ndcPos = gs_in[0].ndcPos;
+} \ No newline at end of file
diff --git a/cwd/shaders/block.vs b/cwd/shaders/block.vs
index 6c45c24..457d5dd 100644
--- a/cwd/shaders/block.vs
+++ b/cwd/shaders/block.vs
@@ -5,11 +5,13 @@ layout (location = 7) in vec2 BlockId;
layout (location = 8) in mat4 model;
//layout (location = 12) in something....
-out vec2 UvPosition;
-out vec3 FragmentPosition;
-flat out int Block;
-flat out int State;
-out vec4 ndcPos;
+out VS_OUT {
+ vec2 UvPosition;
+ vec3 FragmentPosition;
+ flat int Block;
+ flat int State;
+ vec4 ndcPos;
+} vs_out;
uniform mat4 view;
uniform mat4 projection;
@@ -17,13 +19,13 @@ uniform float time;
void main()
{
- UvPosition = vec2(UvCoordinates.x,UvCoordinates.y);
- FragmentPosition = position;
- Block = int(BlockId.x);
- State = int(BlockId.y);
+ vs_out.UvPosition = vec2(UvCoordinates.x,UvCoordinates.y);
+ vs_out.FragmentPosition = position;
+ vs_out.Block = int(BlockId.x);
+ vs_out.State = int(BlockId.y);
vec4 sourcePosition = vec4(position,1.0f);
- ndcPos = (projection*view*model) * sourcePosition;
+ vs_out.ndcPos = (projection*view*model) * sourcePosition;
gl_Position = projection * view * model * sourcePosition;
}