diff --git a/files/shaders/CMakeLists.txt b/files/shaders/CMakeLists.txt index edb5b51f2..a7b631139 100644 --- a/files/shaders/CMakeLists.txt +++ b/files/shaders/CMakeLists.txt @@ -8,6 +8,7 @@ set(SHADER_FILES water_nm.png objects_vertex.glsl objects_fragment.glsl + lighting.glsl ) copy_all_files(${CMAKE_CURRENT_SOURCE_DIR} ${DDIR} "${SHADER_FILES}") diff --git a/files/shaders/lighting.glsl b/files/shaders/lighting.glsl new file mode 100644 index 000000000..98490b8b8 --- /dev/null +++ b/files/shaders/lighting.glsl @@ -0,0 +1,37 @@ +#define MAX_LIGHTS 8 + +vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor) +{ + vec3 lightDir; + float d; + +#if @colorMode == 2 + vec4 diffuse = vertexColor; + vec3 ambient = vertexColor.xyz; +#else + vec4 diffuse = gl_FrontMaterial.diffuse; + vec3 ambient = gl_FrontMaterial.ambient.xyz; +#endif + vec4 lightResult = vec4(0.0, 0.0, 0.0, diffuse.a); + + for (int i=0; i