OpenGL: prepare GLSL for version 3.3
- use in/out instead of attribute/varying - use named output instead of gl_FragColor - use texture() instead of the multitude of older texture sampling functions The #if __VERSION__ == 120 paths (needed on Mac) will be removed after we switch to 3.3 core profile. Part of T49165 (general OpenGL upgrade)
This commit is contained in:
parent
159f56f4ab
commit
b95ee78ed3
|
@ -653,7 +653,7 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
|
|||
BLI_dynstr_append(ds, ");\n");
|
||||
}
|
||||
|
||||
BLI_dynstr_append(ds, "\n\tgl_FragColor = ");
|
||||
BLI_dynstr_append(ds, "\n\tfragColor = ");
|
||||
codegen_convert_datatype(ds, finaloutput->type, GPU_VEC4, "tmp", finaloutput->id);
|
||||
BLI_dynstr_append(ds, ";\n");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
|
||||
varying vec3 coords;
|
||||
#if __VERSION__ == 120
|
||||
varying vec3 coords;
|
||||
#define fragColor gl_FragColor
|
||||
#else
|
||||
in vec3 coords;
|
||||
out vec4 fragColor;
|
||||
#define texture1D texture
|
||||
#define texture3D texture
|
||||
#endif
|
||||
|
||||
uniform sampler3D flame_texture;
|
||||
uniform sampler1D spectrum_texture;
|
||||
|
@ -13,5 +21,5 @@ void main()
|
|||
color.rgb = emission.a * emission.rgb;
|
||||
color.a = emission.a;
|
||||
|
||||
gl_FragColor = color;
|
||||
fragColor = color;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,14 @@ uniform mat4 ModelViewMatrixInverse;
|
|||
uniform mat4 ProjectionMatrixInverse;
|
||||
uniform mat3 NormalMatrix;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
#define fragColor gl_FragColor
|
||||
#else
|
||||
out vec4 fragColor;
|
||||
#define texture2D texture
|
||||
#define textureCube texture
|
||||
#endif
|
||||
|
||||
/* Converters */
|
||||
|
||||
float convert_rgba_to_float(vec4 color)
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
|
||||
varying vec3 coords;
|
||||
#if __VERSION__ == 120
|
||||
varying vec3 coords;
|
||||
#define fragColor gl_FragColor
|
||||
#else
|
||||
in vec3 coords;
|
||||
out vec4 fragColor;
|
||||
#define texture1D texture
|
||||
#define texture3D texture
|
||||
#endif
|
||||
|
||||
uniform vec3 active_color;
|
||||
uniform float step_size;
|
||||
|
@ -44,5 +52,5 @@ void main()
|
|||
vec4 color = transfer_function * density_scale;
|
||||
#endif
|
||||
|
||||
gl_FragColor = color;
|
||||
fragColor = color;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
varying vec3 coords;
|
||||
#if __VERSION__ == 120
|
||||
varying vec3 coords;
|
||||
#else
|
||||
out vec3 coords;
|
||||
#endif
|
||||
|
||||
uniform vec3 min_location;
|
||||
uniform vec3 invsize;
|
||||
|
|
|
@ -12,8 +12,13 @@ out block {
|
|||
} outpt;
|
||||
#endif
|
||||
|
||||
varying vec3 varposition;
|
||||
varying vec3 varnormal;
|
||||
#if __VERSION__ == 120
|
||||
varying vec3 varposition;
|
||||
varying vec3 varnormal;
|
||||
#else
|
||||
out vec3 varposition;
|
||||
out vec3 varnormal;
|
||||
#endif
|
||||
|
||||
#ifdef CLIP_WORKAROUND
|
||||
varying float gl_ClipDistance[6];
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
|
||||
varying vec3 varposition;
|
||||
varying vec3 varnormal;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
varying vec3 varposition;
|
||||
varying vec3 varnormal;
|
||||
#else
|
||||
out vec3 varposition;
|
||||
out vec3 varnormal;
|
||||
#endif
|
||||
|
||||
/* Color, keep in sync with: gpu_shader_vertex.glsl */
|
||||
|
||||
|
|
|
@ -2,7 +2,13 @@
|
|||
* This fragment shader was initially found at http://fabiensanglard.net/shadowmappingVSM/index.php
|
||||
*/
|
||||
|
||||
varying vec4 v_position;
|
||||
#if __VERSION__ == 120
|
||||
varying vec4 v_position;
|
||||
#define fragColor gl_FragColor
|
||||
#else
|
||||
in vec4 v_position;
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -17,5 +23,6 @@ void main()
|
|||
float dy = dFdy(depth);
|
||||
moment2 += 0.25 * (dx * dx + dy * dy);
|
||||
|
||||
gl_FragColor = vec4(moment1, moment2, 0.0, 0.0);
|
||||
fragColor = vec4(moment1, moment2, 0.0, 0.0);
|
||||
// TODO: write to a 2-component target --^
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
varying vec4 v_position;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
varying vec4 v_position;
|
||||
#else
|
||||
out vec4 v_position;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue