[Bf-blender-cvs] [e148661d8d] clay-engine: Use vec2 for screen space stuff

Clément Foucault noreply at git.blender.org
Thu Feb 2 21:45:27 CET 2017


Commit: e148661d8d8fa458b2c8198bb396b6c5f53510b3
Author: Clément Foucault
Date:   Thu Feb 2 21:44:14 2017 +0100
Branches: clay-engine
https://developer.blender.org/rBe148661d8d8fa458b2c8198bb396b6c5f53510b3

Use vec2 for screen space stuff

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

M	source/blender/draw/intern/draw_cache.c
M	source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl

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

diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 2f571ec7f3..1255a083b8 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -412,13 +412,13 @@ Batch *DRW_cache_lamp_get(void)
 {
 #define NSEGMENTS 8
 	if (!SHC.drw_lamp) {
-		float v[3] = {0.0f, 0.0f, 0.0f};
+		float v[2];
 
 		/* Position Only 3D format */
 		static VertexFormat format = { 0 };
 		static unsigned pos_id;
 		if (format.attrib_ct == 0) {
-			pos_id = add_attrib(&format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
+			pos_id = add_attrib(&format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
 		}
 
 		VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -427,12 +427,10 @@ Batch *DRW_cache_lamp_get(void)
 		for (int a = 0; a < NSEGMENTS; a++) {
 			v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS));
 			v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS));
-			v[2] = 0.0f;
 			setAttrib(vbo, pos_id, a * 2, v);
 
 			v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS));
 			v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS));
-			v[2] = 0.0f;
 			setAttrib(vbo, pos_id, a * 2 + 1, v);
 		}
 
@@ -445,13 +443,13 @@ Batch *DRW_cache_lamp_get(void)
 Batch *DRW_cache_lamp_sunrays_get(void)
 {
 	if (!SHC.drw_lamp_sunrays) {
-		float v[3], v1[3], v2[3];
+		float v[2], v1[2], v2[2];
 
 		/* Position Only 3D format */
 		static VertexFormat format = { 0 };
 		static unsigned pos_id;
 		if (format.attrib_ct == 0) {
-			pos_id = add_attrib(&format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
+			pos_id = add_attrib(&format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
 		}
 
 		VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -460,10 +458,9 @@ Batch *DRW_cache_lamp_sunrays_get(void)
 		for (int a = 0; a < 8; a++) {
 			v[0] = sinf((2.0f * M_PI * a) / 8.0f);
 			v[1] = cosf((2.0f * M_PI * a) / 8.0f);
-			v[2] = 0.0f;
 
-			mul_v3_v3fl(v1, v, 1.2f);
-			mul_v3_v3fl(v2, v, 2.5f);
+			mul_v2_v2fl(v1, v, 1.2f);
+			mul_v2_v2fl(v2, v, 2.5f);
 
 			setAttrib(vbo, pos_id, a * 2, v1);
 			setAttrib(vbo, pos_id, a * 2 + 1, v2);
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl
index 8d091e9f43..dbc683ef42 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl
@@ -4,7 +4,7 @@ uniform vec3 screen_vecs[2];
 uniform float size;
 uniform float pixel_size;
 
-in vec3 pos;
+in vec2 pos;
 in mat4 InstanceModelMatrix;
 
 #define lamp_pos InstanceModelMatrix[3].xyz




More information about the Bf-blender-cvs mailing list