Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-07-11 20:17:29 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-07-11 20:17:40 +0400
commit4097f9c3c48bcf2df25451c1003f43e8fc0154f3 (patch)
tree936ed2490debc16a1977ee91fde807e90e2abe3f /source/blender/gpu/shaders
parent1aabbf8476a253b49437691c041bede34d8f4227 (diff)
Another attempt for T40981, clipping border does not work with GLSL on
ATIs. This is actually a test to see if this can be enabled on ATI cards. According to various sources, newer ATI cards supporting GLSL 3.0 support gl_ClippingDistance in shaders, which is the forward compatible way to do custom clipping. This fix will bind 6 additional varying variables on ATIs, which may lead to some shaders not compiling due to limiting out of those variables, or to performance degradation. Also I do not have an ATI handy to test. Having those in mind, this commit may well be reverted later. Clipping planes are usually 4 (6 is for cube clipping), but making shaders depend on viewport state is really bad, and would lead to recompilation, so I took the worst case here to avoid that. Hopefully driver does some optimization there.
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_simple_vert.glsl12
-rw-r--r--source/blender/gpu/shaders/gpu_shader_vertex.glsl12
2 files changed, 20 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_simple_vert.glsl b/source/blender/gpu/shaders/gpu_shader_simple_vert.glsl
index 830dbec75e2..e094f22637b 100644
--- a/source/blender/gpu/shaders/gpu_shader_simple_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_simple_vert.glsl
@@ -15,6 +15,10 @@ varying vec4 varying_vertex_color;
varying vec2 varying_texture_coord;
#endif
+#ifdef CLIP_WORKAROUND
+varying float gl_ClipDistance[6];
+#endif
+
void main()
{
vec4 co = gl_ModelViewMatrix * gl_Vertex;
@@ -29,10 +33,14 @@ void main()
gl_Position = gl_ProjectionMatrix * co;
-#ifndef GPU_ATI
+#ifdef CLIP_WORKAROUND
+ int i;
+ for(i = 0; i < 6; i++)
+ gl_ClipDistance[i] = dot(co, gl_ClipPlane[i]);
+#else
// Setting gl_ClipVertex is necessary to get glClipPlane working on NVIDIA
// graphic cards, while on ATI it can cause a software fallback.
- gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
+ gl_ClipVertex = co;
#endif
#ifdef USE_COLOR
diff --git a/source/blender/gpu/shaders/gpu_shader_vertex.glsl b/source/blender/gpu/shaders/gpu_shader_vertex.glsl
index 159e531eb44..96ce00e214f 100644
--- a/source/blender/gpu/shaders/gpu_shader_vertex.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_vertex.glsl
@@ -2,6 +2,10 @@
varying vec3 varposition;
varying vec3 varnormal;
+#ifdef CLIP_WORKAROUND
+varying float gl_ClipDistance[6];
+#endif
+
void main()
{
vec4 co = gl_ModelViewMatrix * gl_Vertex;
@@ -10,9 +14,13 @@ void main()
varnormal = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ProjectionMatrix * co;
-#ifndef GPU_ATI
+#ifdef CLIP_WORKAROUND
+ int i;
+ for(i = 0; i < 6; i++)
+ gl_ClipDistance[i] = dot(co, gl_ClipPlane[i]);
+#else
// Setting gl_ClipVertex is necessary to get glClipPlane working on NVIDIA
// graphic cards, while on ATI it can cause a software fallback.
- gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
+ gl_ClipVertex = co;
#endif