From d0186d81127056ac2647807dcf05b454e234a7cb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 11 Apr 2023 22:54:44 +0100 Subject: Move the vertex/fragment shader interface for materials into an include --- gfx/gl/shaders/basicShader.fs | 5 +---- gfx/gl/shaders/basicShader.vs | 5 +---- gfx/gl/shaders/landmassShader.fs | 4 +--- gfx/gl/shaders/landmassShader.vs | 5 +---- gfx/gl/shaders/materialInterface.glsl | 4 ++++ gfx/gl/shaders/waterShader.fs | 4 +--- gfx/gl/shaders/waterShader.vs | 4 +--- 7 files changed, 10 insertions(+), 21 deletions(-) create mode 100644 gfx/gl/shaders/materialInterface.glsl (limited to 'gfx/gl/shaders') diff --git a/gfx/gl/shaders/basicShader.fs b/gfx/gl/shaders/basicShader.fs index 0d0b904..8bb6350 100644 --- a/gfx/gl/shaders/basicShader.fs +++ b/gfx/gl/shaders/basicShader.fs @@ -1,9 +1,6 @@ #version 330 core -in vec3 FragPos; -in vec2 TexCoords; -in vec3 Normal; -in vec4 Colour; +include(`materialInterface.glsl') include(`geometryOut.glsl') uniform sampler2D texture0; diff --git a/gfx/gl/shaders/basicShader.vs b/gfx/gl/shaders/basicShader.vs index a96d478..4d648f3 100644 --- a/gfx/gl/shaders/basicShader.vs +++ b/gfx/gl/shaders/basicShader.vs @@ -1,10 +1,7 @@ #version 330 core include(`meshIn.glsl') -out vec3 FragPos; -out vec2 TexCoords; -out vec3 Normal; -out vec4 Colour; +include(`materialInterface.glsl') uniform mat4 viewProjection; uniform mat4 model; diff --git a/gfx/gl/shaders/landmassShader.fs b/gfx/gl/shaders/landmassShader.fs index 5daeeb6..f3cc3e8 100644 --- a/gfx/gl/shaders/landmassShader.fs +++ b/gfx/gl/shaders/landmassShader.fs @@ -1,8 +1,6 @@ #version 330 core -in vec3 FragPos; -in vec2 TexCoords; -in vec3 Normal; +include(`materialInterface.glsl') include(`geometryOut.glsl') uniform sampler2D texture0; diff --git a/gfx/gl/shaders/landmassShader.vs b/gfx/gl/shaders/landmassShader.vs index 3eb9aa3..cabe39f 100644 --- a/gfx/gl/shaders/landmassShader.vs +++ b/gfx/gl/shaders/landmassShader.vs @@ -1,10 +1,7 @@ #version 330 core include(`meshIn.glsl') -out vec3 FragPos; -out vec2 TexCoords; -out vec3 Normal; -out vec4 Colour; +include(`materialInterface.glsl') uniform mat4 viewProjection; diff --git a/gfx/gl/shaders/materialInterface.glsl b/gfx/gl/shaders/materialInterface.glsl new file mode 100644 index 0000000..3e09c85 --- /dev/null +++ b/gfx/gl/shaders/materialInterface.glsl @@ -0,0 +1,4 @@ +ifelse(TYPE, .fs, in, out) vec3 FragPos; +ifelse(TYPE, .fs, in, out) vec2 TexCoords; +ifelse(TYPE, .fs, in, out) vec3 Normal; +ifelse(TYPE, .fs, in, out) vec4 Colour; diff --git a/gfx/gl/shaders/waterShader.fs b/gfx/gl/shaders/waterShader.fs index d457f27..5936da4 100644 --- a/gfx/gl/shaders/waterShader.fs +++ b/gfx/gl/shaders/waterShader.fs @@ -1,9 +1,7 @@ #version 330 core #extension GL_ARB_shading_language_420pack : enable -in vec3 FragPos; -in vec2 TexCoords; -in vec3 Normal; +include(`materialInterface.glsl') include(`geometryOut.glsl') uniform sampler2D texture0; diff --git a/gfx/gl/shaders/waterShader.vs b/gfx/gl/shaders/waterShader.vs index 6f96c19..a21b49f 100644 --- a/gfx/gl/shaders/waterShader.vs +++ b/gfx/gl/shaders/waterShader.vs @@ -1,9 +1,7 @@ #version 330 core include(`meshIn.glsl') -out vec3 FragPos; -out vec2 TexCoords; -out vec3 Normal; +include(`materialInterface.glsl') uniform mat4 viewProjection; uniform vec3 waves; -- cgit v1.2.3