Skip to content

Commit

Permalink
Worked on refactor ^_^
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceKnowsHow committed Aug 11, 2017
1 parent 8e8f364 commit 385ca0d
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 87 deletions.
15 changes: 7 additions & 8 deletions shaders/composite.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ varying vec2 texcoord;
#include "/lib/Uniform/Shading_Variables.glsl"
#include "/UserProgram/centerDepthSmooth.glsl"
#include "/lib/Uniform/Shadow_View_Matrix.vsh"
#include "/lib/Vertex/Shading_Setup.vsh"

#define COMPOSITE0_SCALE 0.50 // [0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00]

void main() {
#if defined GI_ENABLED || defined AO_ENABLED || defined VOLUMETRIC_LIGHT
#if !(defined GI_ENABLED || defined AO_ENABLED || defined VOLUMETRIC_LIGHT)
gl_Position = vec4(-1.0); return;
#endif

texcoord = gl_MultiTexCoord0.st;
gl_Position = ftransform();

gl_Position.xy = ((gl_Position.xy * 0.5 + 0.5) * COMPOSITE0_SCALE) * 2.0 - 1.0;


SetupProjection();

#include "/lib/Vertex/Shading_Setup.vsh"
#else
gl_Position = vec4(-1.0);
#endif
}
SetupShading();
}
7 changes: 3 additions & 4 deletions shaders/composite1.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ flat varying vec2 pixelSize;
#include "/lib/Uniform/Shading_Variables.glsl"
#include "/UserProgram/centerDepthSmooth.glsl"
#include "/lib/Uniform/Shadow_View_Matrix.vsh"
#include "/lib/Vertex/Shading_Setup.vsh"

void main() {
texcoord = gl_MultiTexCoord0.st;
gl_Position = ftransform();

pixelSize = 1.0 / vec2(viewWidth, viewHeight);


SetupProjection();

#include "/lib/Vertex/Shading_Setup.vsh"
}
SetupShading();
}
7 changes: 3 additions & 4 deletions shaders/composite2.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ flat varying vec2 pixelSize;
#include "/lib/Uniform/Shading_Variables.glsl"
#include "/UserProgram/centerDepthSmooth.glsl"
#include "/lib/Uniform/Shadow_View_Matrix.vsh"
#include "/lib/Vertex/Shading_Setup.vsh"

void main() {
texcoord = gl_MultiTexCoord0.st;
gl_Position = ftransform();

pixelSize = 1.0 / vec2(viewWidth, viewHeight);


SetupProjection();

#include "/lib/Vertex/Shading_Setup.vsh"
}
SetupShading();
}
6 changes: 3 additions & 3 deletions shaders/final.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ flat varying vec2 pixelSize;
#include "/lib/Uniform/Shading_Variables.glsl"
#include "/UserProgram/centerDepthSmooth.glsl"
#include "/lib/Uniform/Shadow_View_Matrix.vsh"
#include "/lib/Vertex/Shading_Setup.vsh"

void main() {
texcoord = gl_MultiTexCoord0.st;
Expand All @@ -35,6 +36,5 @@ void main() {
pixelSize = 1.0 / vec2(viewWidth, viewHeight);

SetupProjection();

#include "/lib/Vertex/Shading_Setup.vsh"
}
SetupShading();
}
2 changes: 2 additions & 0 deletions shaders/gbuffers_damagedblock.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
#define ShaderStage -2
#include "/lib/Syntax.glsl"

#define GetMaterialIDs(a) 1.0


#include "gbuffers_main.vsh"
2 changes: 2 additions & 0 deletions shaders/gbuffers_entities.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
#define ShaderStage -2
#include "/lib/Syntax.glsl"

#define GetMaterialIDs(a) 1.0


#include "gbuffers_main.vsh"
2 changes: 2 additions & 0 deletions shaders/gbuffers_hand.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
#define ShaderStage -2
#include "/lib/Syntax.glsl"

#define GetMaterialIDs(a) 5.0


#include "gbuffers_main.vsh"
5 changes: 2 additions & 3 deletions shaders/gbuffers_main.fsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* DRAWBUFFERS:01234 */

uniform sampler2D texture;
uniform sampler2D tex;
uniform sampler2D normals;
uniform sampler2D specular;

Expand All @@ -17,7 +17,6 @@ varying mat2x3 position;

varying vec3 worldDisplacement;

flat varying float mcID;
flat varying float materialIDs;

#include "/lib/Settings.glsl"
Expand All @@ -39,7 +38,7 @@ float LOD = 0.0;
#define GetTexture(x, y) texture2D(x, y)

vec4 GetDiffuse(vec2 coord) {
return vec4(color.rgb, 1.0) * GetTexture(texture, coord);
return vec4(color.rgb, 1.0) * GetTexture(tex, coord);
}

vec3 GetNormal(vec2 coord) {
Expand Down
6 changes: 1 addition & 5 deletions shaders/gbuffers_main.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ attribute vec4 mc_Entity;
attribute vec4 at_tangent;
attribute vec4 mc_midTexCoord;

uniform sampler2D lightmap;

uniform mat4 gbufferModelViewInverse;

uniform vec3 cameraPosition;
Expand All @@ -20,7 +18,6 @@ varying mat2x3 position;

varying vec3 worldDisplacement;

flat varying float mcID;
flat varying float materialIDs;

#include "/lib/Settings.glsl"
Expand Down Expand Up @@ -90,7 +87,6 @@ void main() {

color = abs(mc_Entity.x - 10.5) > 0.6 ? gl_Color.rgb : vec3(1.0);
texcoord = gl_MultiTexCoord0.st;
mcID = mc_Entity.x;
vertLightmap = GetDefaultLightmap();
materialIDs = GetMaterialIDs(int(mc_Entity.x));

Expand All @@ -109,4 +105,4 @@ void main() {


exit();
}
}
2 changes: 2 additions & 0 deletions shaders/gbuffers_spidereyes.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
#define ShaderStage -2
#include "/lib/Syntax.glsl"

#define GetMaterialIDs(a) 1.0


#include "gbuffers_main.vsh"
28 changes: 28 additions & 0 deletions shaders/gbuffers_terrain.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,33 @@
#include "/lib/Syntax.glsl"
#include "/lib/Misc/Menu_Initializer.glsl"

float GetMaterialIDs(int mc_ID) { // Gather material masks
float materialID = 1.0;

switch(mc_ID) {
case 31: // Tall Grass
case 37: // Dandelion
case 38: // Rose
case 59: // Wheat
case 83: // Sugar Cane
case 141: // Carrot
case 142: // Potatoes
case 175: // Double Tall Grass
case 18: // Generic leaves
case 106: // Vines
case 161: // New leaves
materialID = 2.0; break; // Translucent
case 10: // Flowing Lava
case 11: // Still Lava
case 50: // Torch
case 51: // Fire
case 89: // Glowstone
case 124: // Redstone Lamp
materialID = 3.0; break; // Emissive
}

return materialID;
}


#include "gbuffers_main.vsh"
2 changes: 2 additions & 0 deletions shaders/gbuffers_textured.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
#define ShaderStage -2
#include "/lib/Syntax.glsl"

#define GetMaterialIDs(a) 1.0


#include "gbuffers_main.vsh"
11 changes: 5 additions & 6 deletions shaders/gbuffers_water.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ uniform int isEyeInWater;
uniform int heldBlockLightValue;
uniform int heldBlockLightValue2;

uniform sampler2D texture;
uniform sampler2D tex;
uniform sampler2D normals;
uniform sampler2D specular;

Expand All @@ -41,7 +41,6 @@ varying mat2x3 position;

varying vec3 worldDisplacement;

flat varying float mcID;
flat varying float materialIDs;


Expand All @@ -62,7 +61,7 @@ flat varying float materialIDs;
#include "/lib/Fragment/Water_Waves.fsh"

vec4 GetDiffuse(vec2 coord) {
return vec4(color.rgb, 1.0) * texture2D(texture, coord);
return vec4(color.rgb, 1.0) * texture2D(tex, coord);
}

vec3 GetNormal(vec2 coord) {
Expand Down Expand Up @@ -177,15 +176,15 @@ vec3 GetWaveNormals(vec3 worldSpacePosition, vec3 flatWorldNormal) {

void main() {
if (CalculateFogFactor(position[0]) >= 1.0) discard;
if (!gl_FrontFacing && abs(materialIDs - 4.0) < 0.1) discard;
if (!gl_FrontFacing && materialIDs == 4.0) discard;

vec4 diffuse = GetDiffuse(texcoord);
vec3 normal = GetNormal(texcoord);
float specularity = GetSpecularity(texcoord);

Mask mask = EmptyMask;

if (abs(materialIDs - 4.0) < 0.1) {
if (materialIDs == 4.0) {
diffuse = vec4(0.215, 0.356, 0.533, 0.75);

normal = tbnMatrix * GetWaveNormals(position[1], tbnMatrix[2]);
Expand All @@ -203,4 +202,4 @@ void main() {
gl_FragData[4] = vec4(0.0);

exit();
}
}
27 changes: 18 additions & 9 deletions shaders/gbuffers_water.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ attribute vec4 mc_Entity;
attribute vec4 at_tangent;
attribute vec4 mc_midTexCoord;

uniform sampler2D lightmap;

uniform mat4 gbufferModelViewInverse;

uniform vec3 cameraPosition;
Expand All @@ -33,7 +31,6 @@ varying mat2x3 position;

varying vec3 worldDisplacement;

flat varying float mcID;
flat varying float materialIDs;

#include "/lib/Settings.glsl"
Expand All @@ -44,6 +41,23 @@ flat varying float materialIDs;
#include "/lib/Uniform/Shading_Variables.glsl"
#include "/UserProgram/centerDepthSmooth.glsl"
#include "/lib/Uniform/Shadow_View_Matrix.vsh"
#include "/lib/Vertex/Shading_Setup.vsh"

float GetMaterialIDs(int mc_ID) {
float materialID = 1.0;

switch(mc_ID) {
case 8:
case 9:
materialID = 4.0; break; // Water
}

// Custom Streams Mod ID's can go here:
// if (mc_Entity.x == 8 || mc_Entity.x == 9 || mc_Entity.x == 235 || mc_Entity.x == 236 ... )
// materialID = 4.0;

return materialID;
}


vec2 GetDefaultLightmap() {
Expand All @@ -52,8 +66,6 @@ vec2 GetDefaultLightmap() {
return clamp01(lightmapCoord / vec2(0.8745, 0.9373)).rg;
}

#include "/lib/Vertex/Materials.vsh"

vec3 GetWorldSpacePosition() {
vec3 position = transMAD(gl_ModelViewMatrix, gl_Vertex.xyz);

Expand Down Expand Up @@ -104,10 +116,10 @@ void main() {
#endif

SetupProjection();
SetupShading();

color = abs(mc_Entity.x - 10.5) > 0.6 ? gl_Color.rgb : vec3(1.0);
texcoord = gl_MultiTexCoord0.st;
mcID = mc_Entity.x;
vertLightmap = GetDefaultLightmap();
materialIDs = GetMaterialIDs(int(mc_Entity.x));

Expand All @@ -125,8 +137,5 @@ void main() {
tbnMatrix = CalculateTBN(worldSpacePosition);


#include "/lib/Vertex/Shading_Setup.vsh"


exit();
}
2 changes: 2 additions & 0 deletions shaders/gbuffers_weather.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
#define ShaderStage -2
#include "/lib/Syntax.glsl"

#define GetMaterialIDs(a) 1.0


#include "gbuffers_main.vsh"
40 changes: 0 additions & 40 deletions shaders/lib/Vertex/Materials.vsh

This file was deleted.

Loading

0 comments on commit 385ca0d

Please sign in to comment.