Browse Source

Shaders: group things together also in GLSL sources.

It was also becoming quite a mess in there.
pull/518/head
Vladimír Vondruš 5 years ago
parent
commit
9f0a61e76e
  1. 6
      src/Magnum/Shaders/AbstractVector.vert
  2. 8
      src/Magnum/Shaders/DistanceFieldVector.frag
  3. 20
      src/Magnum/Shaders/Flat.frag
  4. 24
      src/Magnum/Shaders/Flat.vert
  5. 2
      src/Magnum/Shaders/FullScreenTriangle.glsl
  6. 22
      src/Magnum/Shaders/MeshVisualizer.frag
  7. 19
      src/Magnum/Shaders/MeshVisualizer.geom
  8. 14
      src/Magnum/Shaders/MeshVisualizer.vert
  9. 63
      src/Magnum/Shaders/Phong.frag
  10. 6
      src/Magnum/Shaders/Phong.vert
  11. 6
      src/Magnum/Shaders/Vector.frag
  12. 4
      src/Magnum/Shaders/VertexColor.frag
  13. 6
      src/Magnum/Shaders/VertexColor.vert

6
src/Magnum/Shaders/AbstractVector.vert

@ -28,6 +28,8 @@
#define out varying
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0)
#endif
@ -58,6 +60,8 @@ uniform mediump mat3 textureMatrix
;
#endif
/* Inputs */
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = POSITION_ATTRIBUTE_LOCATION)
#endif
@ -74,6 +78,8 @@ layout(location = TEXTURECOORDINATES_ATTRIBUTE_LOCATION)
#endif
in mediump vec2 textureCoordinates;
/* Outputs */
out mediump vec2 interpolatedTextureCoordinates;
void main() {

8
src/Magnum/Shaders/DistanceFieldVector.frag

@ -29,6 +29,8 @@
#define texture texture2D
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 2)
#endif
@ -61,14 +63,20 @@ uniform lowp float smoothness
#endif
;
/* Textures */
#ifdef EXPLICIT_TEXTURE_LAYER
/* See AbstractVector.h for details about the ID */
layout(binding = 6)
#endif
uniform lowp sampler2D vectorTexture;
/* Inputs */
in mediump vec2 interpolatedTextureCoordinates;
/* OUtput */
#ifdef NEW_GLSL
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = COLOR_OUTPUT_ATTRIBUTE_LOCATION)

20
src/Magnum/Shaders/Flat.frag

@ -33,12 +33,7 @@
#define in varying
#endif
#ifdef TEXTURED
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 0)
#endif
uniform lowp sampler2D textureData;
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 2)
@ -68,6 +63,17 @@ layout(location = 4)
uniform highp uint objectId; /* defaults to zero */
#endif
/* Textures */
#ifdef TEXTURED
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 0)
#endif
uniform lowp sampler2D textureData;
#endif
/* Inputs */
#ifdef TEXTURED
in mediump vec2 interpolatedTextureCoordinates;
#endif
@ -80,6 +86,8 @@ in lowp vec4 interpolatedVertexColor;
flat in highp uint interpolatedInstanceObjectId;
#endif
/* Outputs */
#ifdef NEW_GLSL
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = COLOR_OUTPUT_ATTRIBUTE_LOCATION)

24
src/Magnum/Shaders/Flat.vert

@ -32,6 +32,8 @@
#define out varying
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0)
#endif
@ -62,6 +64,8 @@ uniform mediump mat3 textureMatrix
;
#endif
/* Inputs */
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = POSITION_ATTRIBUTE_LOCATION)
#endif
@ -78,8 +82,6 @@ in highp vec4 position;
layout(location = TEXTURECOORDINATES_ATTRIBUTE_LOCATION)
#endif
in mediump vec2 textureCoordinates;
out mediump vec2 interpolatedTextureCoordinates;
#endif
#ifdef VERTEX_COLOR
@ -87,8 +89,6 @@ out mediump vec2 interpolatedTextureCoordinates;
layout(location = COLOR_ATTRIBUTE_LOCATION)
#endif
in lowp vec4 vertexColor;
out lowp vec4 interpolatedVertexColor;
#endif
#ifdef INSTANCED_OBJECT_ID
@ -96,8 +96,6 @@ out lowp vec4 interpolatedVertexColor;
layout(location = OBJECT_ID_ATTRIBUTE_LOCATION)
#endif
in highp uint instanceObjectId;
flat out highp uint interpolatedInstanceObjectId;
#endif
#ifdef INSTANCED_TRANSFORMATION
@ -120,6 +118,20 @@ layout(location = TEXTURE_OFFSET_ATTRIBUTE_LOCATION)
in mediump vec2 instancedTextureOffset;
#endif
/* Outputs */
#ifdef TEXTURED
out mediump vec2 interpolatedTextureCoordinates;
#endif
#ifdef VERTEX_COLOR
out lowp vec4 interpolatedVertexColor;
#endif
#ifdef INSTANCED_OBJECT_ID
flat out highp uint interpolatedInstanceObjectId;
#endif
void main() {
#ifdef TWO_DIMENSIONS
gl_Position.xywz = vec4(transformationProjectionMatrix*

2
src/Magnum/Shaders/FullScreenTriangle.glsl

@ -23,6 +23,8 @@
DEALINGS IN THE SOFTWARE.
*/
/* Inputs */
#if !defined(NEW_GLSL) || defined(DISABLE_GL_MAGNUM_shader_vertex_id)
#ifndef NEW_GLSL
#define in attribute

22
src/Magnum/Shaders/MeshVisualizer.frag

@ -44,6 +44,8 @@
#extension GL_NV_shader_noperspective_interpolation: require
#endif
/* Uniforms */
#if (defined(WIREFRAME_RENDERING) || defined(INSTANCED_OBJECT_ID) || defined(VERTEX_ID) || defined(PRIMITIVE_ID) || defined(PRIMITIVE_ID_FROM_VERTEX_ID)) && !defined(TBN_DIRECTION)
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 1)
@ -95,13 +97,6 @@ uniform lowp float smoothness
;
#endif
#if defined(INSTANCED_OBJECT_ID) || defined(VERTEX_ID) || defined(PRIMITIVE_ID) || defined(PRIMITIVE_ID_FROM_VERTEX_ID)
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 4)
#endif
uniform lowp sampler2D colorMapTexture;
#endif
#if defined(INSTANCED_OBJECT_ID) || defined(PRIMITIVE_ID) || defined(PRIMITIVE_ID_FROM_VERTEX_ID)
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 6)
@ -115,6 +110,17 @@ uniform lowp vec2 colorMapOffsetScale
#define colorMapScale colorMapOffsetScale.y
#endif
/* Textures */
#if defined(INSTANCED_OBJECT_ID) || defined(VERTEX_ID) || defined(PRIMITIVE_ID) || defined(PRIMITIVE_ID_FROM_VERTEX_ID)
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 4)
#endif
uniform lowp sampler2D colorMapTexture;
#endif
/* Inputs */
#if defined(WIREFRAME_RENDERING) || defined(TBN_DIRECTION)
#ifndef NO_GEOMETRY_SHADER
#if !defined(GL_ES) || defined(GL_NV_shader_noperspective_interpolation)
@ -141,6 +147,8 @@ in lowp vec4 backgroundColor;
in lowp vec4 lineColor;
#endif
/* Outputs */
#ifdef NEW_GLSL
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = COLOR_OUTPUT_ATTRIBUTE_LOCATION)

19
src/Magnum/Shaders/MeshVisualizer.geom

@ -34,6 +34,8 @@
#endif
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 5)
#endif
@ -81,6 +83,8 @@ uniform lowp float smoothness
;
#endif
/* Inputs */
#ifdef TANGENT_DIRECTION
in highp vec4 tangentEndpoint[];
#endif
@ -91,6 +95,18 @@ in highp vec4 bitangentEndpoint[];
in highp vec4 normalEndpoint[];
#endif
#ifdef INSTANCED_OBJECT_ID
flat in highp uint interpolatedVsInstanceObjectId[];
#endif
#ifdef VERTEX_ID
in highp float interpolatedVsMappedVertexId[];
#endif
#ifdef PRIMITIVE_ID_FROM_VERTEX_ID
flat in highp uint interpolatedVsPrimitiveId[];
#endif
/* Outputs */
layout(triangle_strip, max_vertices = MAX_VERTICES) out;
/* Interpolate in screen space (if possible) */
@ -100,15 +116,12 @@ noperspective
out lowp vec3 dist;
#ifdef INSTANCED_OBJECT_ID
flat in highp uint interpolatedVsInstanceObjectId[];
flat out highp uint interpolatedInstanceObjectId;
#endif
#ifdef VERTEX_ID
in highp float interpolatedVsMappedVertexId[];
out highp float interpolatedMappedVertexId;
#endif
#ifdef PRIMITIVE_ID_FROM_VERTEX_ID
flat in highp uint interpolatedVsPrimitiveId[];
flat out highp uint interpolatedPrimitiveId;
#endif

14
src/Magnum/Shaders/MeshVisualizer.vert

@ -32,6 +32,8 @@
#define out varying
#endif
/* Uniforms */
#ifdef TWO_DIMENSIONS
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0)
@ -95,6 +97,8 @@ uniform highp float lineLength
;
#endif
/* Inputs */
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = POSITION_ATTRIBUTE_LOCATION)
#endif
@ -135,8 +139,6 @@ layout(location = 4)
in lowp float vertexIndex;
#define gl_VertexID int(vertexIndex)
#endif
out vec3 barycentric;
#endif
#ifdef INSTANCED_OBJECT_ID
@ -144,7 +146,15 @@ out vec3 barycentric;
layout(location = OBJECT_ID_ATTRIBUTE_LOCATION)
#endif
in highp uint instanceObjectId;
#endif
/* Outputs */
#if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER)
out vec3 barycentric;
#endif
#ifdef INSTANCED_OBJECT_ID
#ifdef NO_GEOMETRY_SHADER
flat out highp uint interpolatedInstanceObjectId;
#else

63
src/Magnum/Shaders/Phong.frag

@ -37,12 +37,7 @@
#define const
#endif
#ifdef AMBIENT_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 0)
#endif
uniform lowp sampler2D ambientTexture;
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 4)
@ -58,12 +53,6 @@ uniform lowp vec4 ambientColor
;
#if LIGHT_COUNT
#ifdef DIFFUSE_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 1)
#endif
uniform lowp sampler2D diffuseTexture;
#endif
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 5)
@ -74,20 +63,6 @@ uniform lowp vec4 diffuseColor
#endif
;
#ifdef SPECULAR_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 2)
#endif
uniform lowp sampler2D specularTexture;
#endif
#ifdef NORMAL_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 3)
#endif
uniform lowp sampler2D normalTexture;
#endif
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 6)
#endif
@ -170,6 +145,40 @@ uniform lowp float lightRanges[LIGHT_COUNT]
;
#endif
/* Textures */
#ifdef AMBIENT_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 0)
#endif
uniform lowp sampler2D ambientTexture;
#endif
#if LIGHT_COUNT
#ifdef DIFFUSE_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 1)
#endif
uniform lowp sampler2D diffuseTexture;
#endif
#ifdef SPECULAR_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 2)
#endif
uniform lowp sampler2D specularTexture;
#endif
#ifdef NORMAL_TEXTURE
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 3)
#endif
uniform lowp sampler2D normalTexture;
#endif
#endif
/* Inputs */
#if LIGHT_COUNT
in mediump vec3 transformedNormal;
#ifdef NORMAL_TEXTURE
@ -196,6 +205,8 @@ in lowp vec4 interpolatedVertexColor;
flat in highp uint interpolatedInstanceObjectId;
#endif
/* Outputs */
#ifdef NEW_GLSL
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = COLOR_OUTPUT_ATTRIBUTE_LOCATION)

6
src/Magnum/Shaders/Phong.vert

@ -32,6 +32,8 @@
#define out varying
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0)
#endif
@ -84,6 +86,8 @@ uniform highp vec4 lightPositions[LIGHT_COUNT]
;
#endif
/* Inputs */
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = POSITION_ATTRIBUTE_LOCATION)
#endif
@ -162,6 +166,8 @@ layout(location = TEXTURE_OFFSET_ATTRIBUTE_LOCATION)
in mediump vec2 instancedTextureOffset;
#endif
/* Outputs */
#if LIGHT_COUNT
out mediump vec3 transformedNormal;
#ifdef NORMAL_TEXTURE

6
src/Magnum/Shaders/Vector.frag

@ -29,6 +29,8 @@
#define texture texture2D
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 2)
#endif
@ -49,8 +51,12 @@ layout(binding = 6)
#endif
uniform lowp sampler2D vectorTexture;
/* Inputs */
in mediump vec2 interpolatedTextureCoordinates;
/* Outputs */
#ifdef NEW_GLSL
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = COLOR_OUTPUT_ATTRIBUTE_LOCATION)

4
src/Magnum/Shaders/VertexColor.frag

@ -28,8 +28,12 @@
#define fragmentColor gl_FragColor
#endif
/* Inputs */
in lowp vec4 interpolatedColor;
/* Outputs */
#ifdef NEW_GLSL
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = COLOR_OUTPUT_ATTRIBUTE_LOCATION)

6
src/Magnum/Shaders/VertexColor.vert

@ -28,6 +28,8 @@
#define out varying
#endif
/* Uniforms */
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0)
#endif
@ -47,6 +49,8 @@ uniform highp mat4 transformationProjectionMatrix
#error
#endif
/* Inputs */
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = POSITION_ATTRIBUTE_LOCATION)
#endif
@ -63,6 +67,8 @@ layout(location = COLOR_ATTRIBUTE_LOCATION)
#endif
in lowp vec4 color;
/* Outputs */
out lowp vec4 interpolatedColor;
void main() {

Loading…
Cancel
Save