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:
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_basic_frag.glsl')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_basic_frag.glsl28
1 files changed, 22 insertions, 6 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_basic_frag.glsl b/source/blender/gpu/shaders/gpu_shader_basic_frag.glsl
index 6b6679b60df..01a335af048 100644
--- a/source/blender/gpu/shaders/gpu_shader_basic_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_basic_frag.glsl
@@ -3,6 +3,7 @@
*
* USE_COLOR: use glColor for diffuse colors
* USE_TEXTURE: use texture for diffuse colors
+ * USE_TEXTURE_RECTANGLE: use GL_TEXTURE_RECTANGLE instead of GL_TEXTURE_2D
* USE_SCENE_LIGHTING: use lights (up to 8)
* USE_SOLID_LIGHTING: assume 3 directional lights for solid draw mode
* USE_TWO_SIDED: flip normal towards viewer
@@ -27,8 +28,11 @@
#define STIPPLE_S3D_INTERLACE_CHECKERBOARD_SWAP 11
#if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
+#if defined(USE_FLAT_NORMAL)
+varying vec3 eyespace_vert_pos;
+#else
varying vec3 varying_normal;
-
+#endif
#ifndef USE_SOLID_LIGHTING
varying vec3 varying_position;
#endif
@@ -39,8 +43,16 @@ varying vec4 varying_vertex_color;
#endif
#ifdef USE_TEXTURE
+#ifdef USE_TEXTURE_RECTANGLE
+#define sampler2D_default sampler2DRect
+#define texture2D_default texture2DRect
+#else
+#define sampler2D_default sampler2D
+#define texture2D_default texture2D
+#endif
+
varying vec2 varying_texture_coord;
-uniform sampler2D texture_map;
+uniform sampler2D_default texture_map;
#endif
#ifdef USE_STIPPLE
@@ -137,7 +149,11 @@ void main()
#if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
/* compute normal */
+#if defined(USE_FLAT_NORMAL)
+ vec3 N = normalize(cross(dFdx(eyespace_vert_pos), dFdy(eyespace_vert_pos)));
+#else
vec3 N = normalize(varying_normal);
+#endif
#ifdef USE_TWO_SIDED
if (!gl_FrontFacing)
@@ -229,12 +245,12 @@ void main()
float alpha;
#if defined(USE_TEXTURE) && defined(USE_COLOR)
- vec4 texture_color = texture2D(texture_map, varying_texture_coord);
+ vec4 texture_color = texture2D_default(texture_map, varying_texture_coord);
L_diffuse *= texture_color.rgb * varying_vertex_color.rgb;
alpha = texture_color.a * varying_vertex_color.a;
#elif defined(USE_TEXTURE)
- vec4 texture_color = texture2D(texture_map, varying_texture_coord);
+ vec4 texture_color = texture2D_default(texture_map, varying_texture_coord);
L_diffuse *= texture_color.rgb;
alpha = texture_color.a;
@@ -259,9 +275,9 @@ void main()
/* no lighting */
#if defined(USE_TEXTURE) && defined(USE_COLOR)
- gl_FragColor = texture2D(texture_map, varying_texture_coord) * varying_vertex_color;
+ gl_FragColor = texture2D_default(texture_map, varying_texture_coord) * varying_vertex_color;
#elif defined(USE_TEXTURE)
- gl_FragColor = texture2D(texture_map, varying_texture_coord);
+ gl_FragColor = texture2D_default(texture_map, varying_texture_coord);
#elif defined(USE_COLOR)
gl_FragColor = varying_vertex_color;
#else