11//? #version 150
2+ #ifdef GL_ES
3+ #extension GL_EXT_gpu_shader5: enable
4+ #extension GL_EXT_clip_cull_distance: enable
5+ precision highp float;
6+ precision highp int;
7+ precision highp samplerBuffer;
8+ #else
29#extension GL_ARB_gpu_shader5: enable
3-
410#ifndef GEOMETRY_FALLBACK
511#extension GL_ARB_shader_viewport_layer_array : enable
612#endif
13+ #endif
14+
15+ #if !defined(GL_ES) || defined(GL_EXT_clip_cull_distance)
16+ #define USE_HW_CLIP_DISTANCE
17+ #endif
718
819in vec4 vertPosition;
920in vec4 vertTexCoord;
@@ -33,11 +44,14 @@ uniform samplerBuffer transform_tex;
3344
3445#ifdef GEOMETRY_FALLBACK
3546out VertexOutput {
36- #if !defined(GL_ARB_gpu_shader5)
47+ #if !defined(GL_ARB_gpu_shader5) && !defined(GL_EXT_gpu_shader5)
3748 float instance;
3849#endif
3950 float clipModel;
4051 vec3 normal;
52+ #ifndef USE_HW_CLIP_DISTANCE
53+ float vClipDist;
54+ #endif
4155} vertOut;
4256#endif
4357
@@ -67,7 +81,7 @@ void main()
6781 normal = normalize(mat3(modelViewMatrix) * mat3(orient) * vertNormal);
6882 position = modelViewMatrix * orient * vertex;
6983
70- #if !defined(GL_ARB_gpu_shader5)
84+ #if !defined(GL_ARB_gpu_shader5) && !defined(GL_EXT_gpu_shader5)
7185 #ifdef APPLE
7286 vertOut.instance = float(gl_InstanceIDARB);
7387 #else
@@ -86,11 +100,19 @@ void main()
86100 gl_Position = position;
87101 }
88102
103+ #ifdef USE_HW_CLIP_DISTANCE
89104 if (use_clip_plane) {
90105 gl_ClipDistance[0] = dot(clip_equation, modelMatrix * orient * vertex);
91106 } else {
92107 gl_ClipDistance[0] = 1.0;
93108 }
109+ #else
110+ if (use_clip_plane) {
111+ vertOut.vClipDist = dot(clip_equation, modelMatrix * orient * vertex);
112+ } else {
113+ vertOut.vClipDist = 1.0;
114+ }
115+ #endif
94116
95117#ifdef GEOMETRY_FALLBACK
96118 vertOut.normal = normal;
0 commit comments