Skip to content

Commit

Permalink
Use "in", "out" keywords instead of deprecated "varying", "attribute"…
Browse files Browse the repository at this point in the history
… in shaders

This means opengl 3.0 ("130", circa 2010) instead of 2.1 ("120", circa 2008)
Seeing as how it's 2018 and 3.0 is now 10 years old, I guess this should be ok.

Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
  • Loading branch information
smcameron committed Apr 23, 2018
1 parent dd83ea6 commit 3c8ea5c
Show file tree
Hide file tree
Showing 40 changed files with 234 additions and 173 deletions.
2 changes: 1 addition & 1 deletion graph_dev_opengl.c
Expand Up @@ -24,7 +24,7 @@
#include "snis_typeface.h"
#include "opengl_cap.h"

#define OPENGL_VERSION_STRING "#version 120\n"
#define OPENGL_VERSION_STRING "#version 130\n"
#define AMBIENT_LIGHT_DEFINE "#define AMBIENT 0.05\n"
#define UNIVERSAL_SHADER_HEADER \
OPENGL_VERSION_STRING \
Expand Down
25 changes: 15 additions & 10 deletions share/snis/shader/alpha_by_normal.shader
@@ -1,22 +1,22 @@

varying vec4 v_TintColor;
#if defined(TEXTURED_ALPHA_BY_NORMAL)
varying vec2 v_TexCoord; // This will be passed into the fragment shader.
#endif

uniform float u_Invert;

#if defined(INCLUDE_VS)
out vec4 v_TintColor;
out float v_EyeDot;
#if defined(TEXTURED_ALPHA_BY_NORMAL)
out vec2 v_TexCoord; // This will be passed into the fragment shader.
#endif

uniform mat4 u_MVPMatrix; // A constant representing the combined model/view/projection matrix.
uniform mat4 u_MVMatrix;
uniform vec4 u_TintColor;
uniform mat3 u_NormalMatrix;
varying float v_EyeDot;

attribute vec4 a_Position; // Per-vertex position information we will pass in.
attribute vec3 a_Normal;
in vec4 a_Position; // Per-vertex position information we will pass in.
in vec3 a_Normal;
#if defined(TEXTURED_ALPHA_BY_NORMAL)
attribute vec2 a_TexCoord; // Per-vertex texture coord we will pass in.
in vec2 a_TexCoord; // Per-vertex texture coord we will pass in.
#endif
void main()
{
Expand All @@ -38,10 +38,15 @@ uniform float u_Invert;
#endif

#if defined(INCLUDE_FS)
in vec4 v_TintColor;
in float v_EyeDot;
#if defined(TEXTURED_ALPHA_BY_NORMAL)
in vec2 v_TexCoord; // This will be passed into the fragment shader.
#endif

#if defined(TEXTURED_ALPHA_BY_NORMAL)
uniform sampler2D u_AlbedoTex;
#endif
varying float v_EyeDot;

void main()
{
Expand Down
6 changes: 3 additions & 3 deletions share/snis/shader/atmosphere.frag
Expand Up @@ -2,9 +2,9 @@
uniform vec3 u_LightPos; // The position of the light in eye space.
uniform float u_Alpha; // Relative alpha, 0.0 - 1.0.

varying vec3 v_Position; // Interpolated position for this fragment.
varying vec3 v_Color; // This is the color from the vertex shader interpolated across the triangle per fragment
varying vec3 v_Normal; // Interpolated normal for this fragment.
in vec3 v_Position; // Interpolated position for this fragment.
in vec3 v_Color; // This is the color from the vertex shader interpolated across the triangle per fragment
in vec3 v_Normal; // Interpolated normal for this fragment.

#if !defined(AMBIENT)
#define AMBIENT 0.01
Expand Down
10 changes: 5 additions & 5 deletions share/snis/shader/atmosphere.vert
Expand Up @@ -4,12 +4,12 @@ uniform mat4 u_MVMatrix; // A constant representing the combined model/vie
uniform mat3 u_NormalMatrix;
uniform vec3 u_Color; // Per-object color information we will pass in.

attribute vec4 a_Position; // Per-vertex position information we will pass in.
attribute vec3 a_Normal; // Per-vertex normal information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.
in vec3 a_Normal; // Per-vertex normal information we will pass in.

varying vec3 v_Position; // This will be passed into the fragment shader.
varying vec3 v_Color; // This will be passed into the fragment shader.
varying vec3 v_Normal; // This will be passed into the fragment shader.
out vec3 v_Position; // This will be passed into the fragment shader.
out vec3 v_Color; // This will be passed into the fragment shader.
out vec3 v_Normal; // This will be passed into the fragment shader.

// The entry point for our vertex shader.
void main()
Expand Down
2 changes: 1 addition & 1 deletion share/snis/shader/color_by_w.frag
@@ -1,5 +1,5 @@

varying vec3 v_Color; // Per-vertex color information
in vec3 v_Color; // Per-vertex color information

void main()
{
Expand Down
4 changes: 2 additions & 2 deletions share/snis/shader/color_by_w.vert
Expand Up @@ -9,9 +9,9 @@ uniform float u_CenterW;
uniform vec3 u_FarColor;
uniform float u_FarW;

attribute vec4 a_Position; // Per-vertex position information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.

varying vec3 v_Color;
out vec3 v_Color;

void main()
{
Expand Down
7 changes: 4 additions & 3 deletions share/snis/shader/fs-effect-copy.shader
Expand Up @@ -18,13 +18,13 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

varying vec2 v_TexCoord;

#ifdef INCLUDE_VS
out vec2 v_TexCoord;
uniform mat4 u_MVPMatrix;

attribute vec4 a_Position;
attribute vec2 a_TexCoord;
in vec4 a_Position;
in vec2 a_TexCoord;

void main(void)
{
Expand All @@ -34,6 +34,7 @@ varying vec2 v_TexCoord;
#endif

#ifdef INCLUDE_FS
in vec2 v_TexCoord;
uniform sampler2D texture0Sampler;
uniform vec4 u_TintColor;

Expand Down
4 changes: 2 additions & 2 deletions share/snis/shader/line-single-color.frag
Expand Up @@ -25,8 +25,8 @@ uniform float u_DotSize;
uniform float u_DotPitch;
uniform vec4 u_LineColor;

varying float v_IsDotted;
varying vec4 v_Dist;
in float v_IsDotted;
in vec4 v_Dist;

void main(void)
{
Expand Down
12 changes: 6 additions & 6 deletions share/snis/shader/line-single-color.vert
Expand Up @@ -24,14 +24,14 @@
uniform mat4 u_MVPMatrix;
uniform vec2 u_Viewport;

attribute vec4 a_MultiOne;
attribute vec4 a_Position;
in vec4 a_MultiOne;
in vec4 a_Position;
// Coordinates of the line vertices this vertex belongs to
attribute vec4 a_LineVertex0;
attribute vec4 a_LineVertex1;
in vec4 a_LineVertex0;
in vec4 a_LineVertex1;

varying float v_IsDotted;
varying vec4 v_Dist;
out float v_IsDotted;
out vec4 v_Dist;

void main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion share/snis/shader/per_vertex_color.frag
@@ -1,5 +1,5 @@

varying vec4 v_Color; // Per-vertex color information we got passed.
in vec4 v_Color; // Per-vertex color information we got passed.

void main()
{
Expand Down
6 changes: 3 additions & 3 deletions share/snis/shader/per_vertex_color.vert
@@ -1,10 +1,10 @@

uniform mat4 u_MVPMatrix; // A constant representing the combined model/view/projection matrix.

attribute vec4 a_Position; // Per-vertex position information we will pass in.
attribute vec4 a_Color; // Per-vertex color information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.
in vec4 a_Color; // Per-vertex color information we will pass in.

varying vec4 v_Color; // Per-vertex color information we will pass down.
out vec4 v_Color; // Per-vertex color information we will pass down.

void main()
{
Expand Down
2 changes: 1 addition & 1 deletion share/snis/shader/point_cloud-intensity-noise.frag
@@ -1,5 +1,5 @@

varying vec4 v_Color;
in vec4 v_Color;

void main()
{
Expand Down
4 changes: 2 additions & 2 deletions share/snis/shader/point_cloud-intensity-noise.vert
Expand Up @@ -4,9 +4,9 @@ uniform float u_PointSize;
uniform vec4 u_Color;
uniform float u_Time; // 0 - 1 in seconds period

attribute vec4 a_Position; // Per-vertex position information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.

varying vec4 v_Color;
out vec4 v_Color;

/* Return a pseudo-random number 0 - 1 for a two element seed
http://stackoverflow.com/questions/12964279/whats-the-origin-of-this-glsl-rand-one-liner */
Expand Down
2 changes: 1 addition & 1 deletion share/snis/shader/point_cloud.vert
Expand Up @@ -2,7 +2,7 @@
uniform mat4 u_MVPMatrix; // A constant representing the combined model/view/projection matrix.
uniform float u_PointSize;

attribute vec4 a_Position; // Per-vertex position information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.

void main()
{
Expand Down
6 changes: 3 additions & 3 deletions share/snis/shader/single-color-lit-per-pixel.frag
@@ -1,9 +1,9 @@

uniform vec3 u_LightPos; // The position of the light in eye space.

varying vec3 v_Position; // Interpolated position for this fragment.
varying vec3 v_Color; // This is the color from the vertex shader interpolated across the triangle per fragment
varying vec3 v_Normal; // Interpolated normal for this fragment.
in vec3 v_Position; // Interpolated position for this fragment.
in vec3 v_Color; // This is the color from the vertex shader interpolated across the triangle per fragment
in vec3 v_Normal; // Interpolated normal for this fragment.

#if !defined(AMBIENT)
#define AMBIENT 0.1
Expand Down
10 changes: 5 additions & 5 deletions share/snis/shader/single-color-lit-per-pixel.vert
Expand Up @@ -4,12 +4,12 @@ uniform mat4 u_MVMatrix; // A constant representing the combined model/vie
uniform mat3 u_NormalMatrix;
uniform vec3 u_Color; // Per-object color information we will pass in.

attribute vec4 a_Position; // Per-vertex position information we will pass in.
attribute vec3 a_Normal; // Per-vertex normal information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.
in vec3 a_Normal; // Per-vertex normal information we will pass in.

varying vec3 v_Position; // This will be passed into the fragment shader.
varying vec3 v_Color; // This will be passed into the fragment shader.
varying vec3 v_Normal; // This will be passed into the fragment shader.
out vec3 v_Position; // This will be passed into the fragment shader.
out vec3 v_Color; // This will be passed into the fragment shader.
out vec3 v_Normal; // This will be passed into the fragment shader.

// The entry point for our vertex shader.
void main()
Expand Down
2 changes: 1 addition & 1 deletion share/snis/shader/single-color-lit-per-vertex.frag
@@ -1,5 +1,5 @@

varying vec3 v_Color;
in vec3 v_Color;

void main()
{
Expand Down
6 changes: 3 additions & 3 deletions share/snis/shader/single-color-lit-per-vertex.vert
Expand Up @@ -6,10 +6,10 @@ uniform vec3 u_Color; // Per-object color information we will pass in.

uniform vec3 u_LightPos; // The position of the light in eye space.

attribute vec4 a_Position; // Per-vertex position information we will pass in.
attribute vec3 a_Normal; // Per-vertex normal information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.
in vec3 a_Normal; // Per-vertex normal information we will pass in.

varying vec3 v_Color; // This will be passed into the fragment shader.
out vec3 v_Color; // This will be passed into the fragment shader.

#if !defined(AMBIENT)
#define AMBIENT 0.1
Expand Down
2 changes: 1 addition & 1 deletion share/snis/shader/single_color.vert
@@ -1,7 +1,7 @@

uniform mat4 u_MVPMatrix; // A constant representing the combined model/view/projection matrix.

attribute vec4 a_Position; // Per-vertex position information we will pass in.
in vec4 a_Position; // Per-vertex position information we will pass in.

void main()
{
Expand Down
2 changes: 1 addition & 1 deletion share/snis/shader/skybox.frag
@@ -1,7 +1,7 @@

uniform samplerCube texture;

varying vec3 texCoord;
in vec3 texCoord;

void main (void) {
gl_FragColor = textureCube(texture, texCoord);
Expand Down
5 changes: 2 additions & 3 deletions share/snis/shader/skybox.vert
@@ -1,9 +1,8 @@

uniform mat4 MVP;

attribute vec3 vertex;

varying vec3 texCoord;
in vec3 vertex;
out vec3 texCoord;

void main() {
texCoord = vertex;
Expand Down
15 changes: 9 additions & 6 deletions share/snis/shader/smaa-blend.shader
Expand Up @@ -18,15 +18,15 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

varying vec2 v_TexCoord;
varying vec2 v_PixCoord;
varying vec4 v_Offset[3];

#if defined(INCLUDE_VS)
out vec2 v_TexCoord;
out vec2 v_PixCoord;
out vec4 v_Offset[3];

uniform mat4 u_MVPMatrix;

attribute vec4 a_Position;
attribute vec2 a_TexCoord;
in vec4 a_Position;
in vec2 a_TexCoord;

void main()
{
Expand All @@ -38,6 +38,9 @@ varying vec4 v_Offset[3];
#endif

#if defined(INCLUDE_FS)
in vec2 v_TexCoord;
in vec2 v_PixCoord;
in vec4 v_Offset[3];
uniform sampler2D u_EdgeTex;
uniform sampler2D u_AreaTex;
uniform sampler2D u_SearchTex;
Expand Down
13 changes: 8 additions & 5 deletions share/snis/shader/smaa-edge.shader
Expand Up @@ -18,14 +18,14 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

varying vec2 v_TexCoord;
varying vec4 v_Offset[3];

#if defined(INCLUDE_VS)
out vec2 v_TexCoord;
out vec4 v_Offset[3];

uniform mat4 u_MVPMatrix;

attribute vec4 a_Position;
attribute vec2 a_TexCoord;
in vec4 a_Position;
in vec2 a_TexCoord;

void main()
{
Expand All @@ -37,6 +37,9 @@ varying vec4 v_Offset[3];
#endif

#if defined(INCLUDE_FS)
in vec2 v_TexCoord;
in vec4 v_Offset[3];

uniform sampler2D u_AlbedoTex;

void main()
Expand Down
12 changes: 7 additions & 5 deletions share/snis/shader/smaa-neighborhood.shader
Expand Up @@ -18,14 +18,14 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

varying vec2 v_TexCoord;
varying vec4 v_Offset;

#if defined(INCLUDE_VS)
out vec2 v_TexCoord;
out vec4 v_Offset;

uniform mat4 u_MVPMatrix;

attribute vec4 a_Position;
attribute vec2 a_TexCoord;
in vec4 a_Position;
in vec2 a_TexCoord;

void main()
{
Expand All @@ -37,6 +37,8 @@ varying vec4 v_Offset;
#endif

#if defined(INCLUDE_FS)
in vec2 v_TexCoord;
in vec4 v_Offset;
uniform sampler2D u_AlbedoTex;
uniform sampler2D u_BlendTex;

Expand Down

0 comments on commit 3c8ea5c

Please sign in to comment.