diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-06-14 16:22:52 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-06-14 16:22:52 +0200 |
commit | ac8905602d1f221a71ddcdc86796344101276321 (patch) | |
tree | 21deaeb615d6789e7ddf14844cbf8faf0081af7e /cwd/shaders | |
parent | 2017-06-07 (diff) | |
download | AltCraft-ac8905602d1f221a71ddcdc86796344101276321.tar AltCraft-ac8905602d1f221a71ddcdc86796344101276321.tar.gz AltCraft-ac8905602d1f221a71ddcdc86796344101276321.tar.bz2 AltCraft-ac8905602d1f221a71ddcdc86796344101276321.tar.lz AltCraft-ac8905602d1f221a71ddcdc86796344101276321.tar.xz AltCraft-ac8905602d1f221a71ddcdc86796344101276321.tar.zst AltCraft-ac8905602d1f221a71ddcdc86796344101276321.zip |
Diffstat (limited to '')
-rw-r--r-- | cwd/shaders/block.fs | 18 | ||||
-rw-r--r-- | cwd/shaders/block.vs | 15 | ||||
-rw-r--r-- | cwd/shaders/simple.fs | 7 | ||||
-rw-r--r-- | cwd/shaders/simple.vs | 9 |
4 files changed, 43 insertions, 6 deletions
diff --git a/cwd/shaders/block.fs b/cwd/shaders/block.fs index 8795fb2..d1716bc 100644 --- a/cwd/shaders/block.fs +++ b/cwd/shaders/block.fs @@ -1,11 +1,17 @@ #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; +//uniform int Block; +//uniform int State; uniform sampler2D textureAtlas; uniform float time; +uniform int isInside; +uniform vec2 windowSize; // TextureIndex: [most significant bit]<-...<-side[3bit]<-id[13]<-state[4] layout(std140) uniform TextureIndexes { // binding point: 0 @@ -23,7 +29,6 @@ vec4 GetDepthColor(); vec4 GetCheckerColor(); vec4 VTC(int value); -in vec3 FragmentPosition; int GetBlockSide(){ int side=6; if (FragmentPosition.y==-0.5) @@ -62,10 +67,15 @@ 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); gl_FragColor = texture(textureAtlas, AtlasCoords); - if (id==2 && side==1) { //Grass colorizing + 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 const float BiomeColor = 0.275; vec3 hsvColor = rgb2hsv(gl_FragColor.xyz); hsvColor[0]+=BiomeColor; diff --git a/cwd/shaders/block.vs b/cwd/shaders/block.vs index e8756c0..6c45c24 100644 --- a/cwd/shaders/block.vs +++ b/cwd/shaders/block.vs @@ -1,18 +1,29 @@ #version 330 core layout (location = 0) in vec3 position; layout (location = 2) in vec2 UvCoordinates; +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; uniform mat4 view; uniform mat4 projection; uniform float time; -uniform mat4 model; void main() { - gl_Position = projection * view * model * vec4(position, 1.0f); UvPosition = vec2(UvCoordinates.x,UvCoordinates.y); FragmentPosition = position; + Block = int(BlockId.x); + State = int(BlockId.y); + + vec4 sourcePosition = vec4(position,1.0f); + ndcPos = (projection*view*model) * sourcePosition; + gl_Position = projection * view * model * sourcePosition; + } diff --git a/cwd/shaders/simple.fs b/cwd/shaders/simple.fs new file mode 100644 index 0000000..34cc192 --- /dev/null +++ b/cwd/shaders/simple.fs @@ -0,0 +1,7 @@ +#version 330 core + +uniform vec3 color; + +void main(){ + gl_FragColor = vec4(color,1); +}
\ No newline at end of file diff --git a/cwd/shaders/simple.vs b/cwd/shaders/simple.vs new file mode 100644 index 0000000..8c9f37f --- /dev/null +++ b/cwd/shaders/simple.vs @@ -0,0 +1,9 @@ +#version 330 core + +uniform mat4 view; +uniform mat4 projection; +layout (location = 0) in vec3 position; + +void main(){ + gl_Position = vec4(position,1);//projection*view*vec4(position,1); +}
\ No newline at end of file |