Add shaders files for shader based lighting (ops)

This commit is contained in:
James Seibel
2021-12-08 23:07:10 -06:00
parent f9fa1a5260
commit 5c31927d54
3 changed files with 25 additions and 10 deletions
@@ -264,13 +264,13 @@ public class GLProxy
try
{
// get the shaders from the resource folder
// vertexShader = LodShader.loadShader(GL20.GL_VERTEX_SHADER, "shaders" + File.separator + "standard.vert", false);
// fragmentShader = LodShader.loadShader(GL20.GL_FRAGMENT_SHADER, "shaders" + File.separator + "flat_shaded.frag", false);
vertexShader = LodShader.loadShader(GL20.GL_VERTEX_SHADER, "shaders/standard.vert", false);
fragmentShader = LodShader.loadShader(GL20.GL_FRAGMENT_SHADER, "shaders/flat_shaded.frag", false);
// this can be used when testing shaders,
// since we can't hot swap the files in the resource folder
vertexShader = LodShader.loadShader(GL20.GL_VERTEX_SHADER, "C:/Users/James Seibel/Desktop/shaders/standard.vert", true);
fragmentShader = LodShader.loadShader(GL20.GL_FRAGMENT_SHADER, "C:/Users/James Seibel/Desktop/shaders/flat_shaded.frag", true);
// vertexShader = LodShader.loadShader(GL20.GL_VERTEX_SHADER, "C:/Users/James Seibel/Desktop/shaders/standard.vert", true);
// fragmentShader = LodShader.loadShader(GL20.GL_FRAGMENT_SHADER, "C:/Users/James Seibel/Desktop/shaders/flat_shaded.frag", true);
// create the shaders
+1 -2
View File
@@ -2,13 +2,12 @@
in vec4 vertexColor;
in vec4 vertexWorldPos;
//in vec2 textureCoord;
out vec4 fragColor;
//uniform sampler2D texImage;
uniform vec3 cameraPos;
uniform bool fogEnabled;
+20 -4
View File
@@ -2,30 +2,46 @@
in vec3 vPosition;
in vec4 color;
in float blockSkyLight;
in float blockLight;
out vec4 vertexColor;
out vec4 vertexWorldPos;
//out vec2 textureCoord;
out float depth;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform int worldSkyLight;
uniform sampler2D lightMap;
/**
* Vertex Shader
*
* author: James Seibel
* version: 11-26-2021
* version: 12-8-2021
*/
void main()
{
// just skylight
// good for sanity checks; but will cause OpenGL errors since we are binding unused data
// vertexColor = vec4(color.xyz * worldSkyLight / 16.0, color.w);
float blockLightTex = blockLight / 16.0;
float skyLightTex = worldSkyLight / 16.0;
// we don't really need alpha in the lightmap
// vertexColor = color * vec4(texture(lightMap, vec2(blockLightTex, skyLightTex)).xyz, 1);
vertexColor = color * texture(lightMap, vec2(blockLightTex, skyLightTex));
// TODO: add a simple white texture to support Optifine shaders
//textureCoord = textureCoord;
vertexColor = color;
vertexWorldPos = vec4(vPosition, 1);
// the vPosition needs to be converted to a vec4 so it can be multiplied