This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/gpu/shaders/gpu_shader_simple_vert.glsl
Antonis Ryakiotakis 4097f9c3c4 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.
2014-07-11 19:17:40 +03:00

55 lines
1.1 KiB
GLSL

#if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
varying vec3 varying_normal;
#ifndef USE_SOLID_LIGHTING
varying vec3 varying_position;
#endif
#endif
#ifdef USE_COLOR
varying vec4 varying_vertex_color;
#endif
#ifdef USE_TEXTURE
varying vec2 varying_texture_coord;
#endif
#ifdef CLIP_WORKAROUND
varying float gl_ClipDistance[6];
#endif
void main()
{
vec4 co = gl_ModelViewMatrix * gl_Vertex;
#if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
varying_normal = normalize(gl_NormalMatrix * gl_Normal);
#ifndef USE_SOLID_LIGHTING
varying_position = co.xyz;
#endif
#endif
gl_Position = gl_ProjectionMatrix * co;
#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 = co;
#endif
#ifdef USE_COLOR
varying_vertex_color = gl_Color;
#endif
#ifdef USE_TEXTURE
varying_texture_coord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
#endif
}