[Bf-blender-cvs] [1756984] temp_viewport_fx_merge: Basic shaders

Antony Riakiotakis noreply at git.blender.org
Wed Mar 18 20:29:41 CET 2015


Commit: 17569847e85c12b51d1fc193ea63d6a0830e97f1
Author: Antony Riakiotakis
Date:   Wed Mar 18 20:27:54 2015 +0100
Branches: temp_viewport_fx_merge
https://developer.blender.org/rB17569847e85c12b51d1fc193ea63d6a0830e97f1

Basic shaders

===================================================================

M	source/blender/gpu/CMakeLists.txt
A	source/blender/gpu/shaders/gpu_shader_common_attribs.glsl
A	source/blender/gpu/shaders/gpu_shader_common_constants.glsl
A	source/blender/gpu/shaders/gpu_shader_common_uniforms.glsl

===================================================================

diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 443673a..f478c44 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -81,6 +81,9 @@ set(SRC
 	shaders/gpu_shader_vsm_store_frag.glsl
 	shaders/gpu_shader_vsm_store_vert.glsl
 	shaders/gpu_shader_fx_depth_resolve.glsl
+	shaders/gpu_shader_common_uniforms.glsl
+	shaders/gpu_shader_common_constants.glsl
+	shaders/gpu_shader_common_attribs.glsl
 
 	GPU_aspect.h
 	GPU_buffers.h
@@ -122,6 +125,9 @@ data_to_c_simple(shaders/gpu_shader_fx_dof_frag.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_fx_dof_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_fx_depth_resolve.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_fx_lib.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_common_uniforms.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_common_constants.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_common_attribs.glsl SRC)
 
 if(WITH_GAMEENGINE)
 	add_definitions(-DWITH_GAMEENGINE)
diff --git a/source/blender/gpu/shaders/gpu_shader_common_attribs.glsl b/source/blender/gpu/shaders/gpu_shader_common_attribs.glsl
new file mode 100644
index 0000000..9b49085
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_common_attribs.glsl
@@ -0,0 +1,54 @@
+/* begin known attributes */
+
+attribute vec4 b_Vertex;
+
+
+
+attribute vec4 b_Color;
+
+
+
+#ifdef USE_LIGHTING
+attribute vec3 b_Normal;
+#endif
+
+
+
+#ifdef USE_TEXTURE_2D
+
+#if GPU_MAX_COMMON_TEXCOORDS > 0
+attribute vec4 b_MultiTexCoord0;
+#endif
+
+#if GPU_MAX_COMMON_TEXCOORDS > 1
+attribute vec4 b_MultiTexCoord1;
+#endif
+
+#if GPU_MAX_COMMON_TEXCOORDS > 2
+attribute vec4 b_MultiTexCoord2;
+#endif
+
+#if GPU_MAX_COMMON_TEXCOORDS > 3
+attribute vec4 b_MultiTexCoord3;
+#endif
+
+#if GPU_MAX_COMMON_TEXCOORDS > 4
+attribute vec4 b_MultiTexCoord4;
+#endif
+
+#if GPU_MAX_COMMON_TEXCOORDS > 5
+attribute vec4 b_MultiTexCoord5;
+#endif
+
+#if GPU_MAX_COMMON_TEXCOORDS > 6
+attribute vec4 b_MultiTexCoord6;
+#endif
+
+#if GPU_MAX_COMMON_TEXCOORDS > 7
+attribute vec4 b_MultiTexCoord7;
+#endif
+
+#endif
+
+/* end known attributes */
+
diff --git a/source/blender/gpu/shaders/gpu_shader_common_constants.glsl b/source/blender/gpu/shaders/gpu_shader_common_constants.glsl
new file mode 100644
index 0000000..fd7857c
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_common_constants.glsl
@@ -0,0 +1,16 @@
+/* begin common constants */
+
+#ifdef USE_TEXTURE_2D
+const int b_MaxTextureCoords             = GPU_MAX_COMMON_TEXCOORDS;
+const int b_MaxCombinedTextureImageUnits = GPU_MAX_COMMON_SAMPLERS;
+#endif
+
+#ifdef USE_LIGHTING
+const int b_MaxLights = GPU_MAX_COMMON_LIGHTS;
+#endif
+
+#ifdef USE_CLIP_PLANES
+const int b_MaxClipPlanes = GPU_MAX_COMMON_CLIP_PLANES;
+#endif
+
+/* end known constants */
diff --git a/source/blender/gpu/shaders/gpu_shader_common_uniforms.glsl b/source/blender/gpu/shaders/gpu_shader_common_uniforms.glsl
new file mode 100644
index 0000000..10f00ae
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_common_uniforms.glsl
@@ -0,0 +1,63 @@
+/* begin common uniforms */
+
+uniform mat4 b_ModelViewMatrix;
+uniform mat4 b_ProjectionMatrix;
+uniform mat4 b_ModelViewProjectionMatrix;
+
+
+#ifdef USE_TEXTURE_2D
+
+uniform mat4 b_TextureMatrix[b_MaxTextureCoords];
+
+uniform sampler2D b_Sampler2D[b_MaxCombinedTextureImageUnits];
+
+#endif
+
+
+#ifdef USE_LIGHTING
+
+uniform mat3 b_NormalMatrix;  // transpose of upper 3x3 of b_ModelViewMatrix
+
+uniform mat4 b_ModelViewMatrixInverse;
+
+struct b_MaterialParameters {
+    vec4  specular;  // Scm * Scli
+    float shininess; // Srm
+};
+
+uniform b_MaterialParameters b_FrontMaterial;
+
+struct b_LightSourceParameters {
+    vec4  diffuse;              // Dcli
+    vec4  specular;             // Scli
+    vec4  position;             // Ppli
+
+    vec3  spotDirection;        // Sdli
+    float spotExponent;         // Srli
+    float spotCutoff;           // Crli
+                                // (range: [0.0,90.0], 180.0)
+
+    float spotCosCutoff;        // Derived: cos(Crli)
+                                // (range: [1.0,0.0],-1.0)
+
+    float constantAttenuation;  // K0
+    float linearAttenuation;    // K1
+    float quadraticAttenuation; // K2
+};
+
+uniform b_LightSourceParameters b_LightSource[b_MaxLights];
+
+uniform int b_LightCount;
+
+#endif
+
+
+#ifdef USE_CLIP_PLANES
+
+uniform double b_ClipPlane[b_MaxClipPlanes][4];
+
+uniform int b_ClipPlaneCount;
+
+#endif
+
+/* end common uniforms */
\ No newline at end of file




More information about the Bf-blender-cvs mailing list