[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48319] branches/soc-2012-bratwurst/source /blender/editors/sculpt_paint/paint_cursor.c: Overlay for Tiled style brushes.
Antony Riakiotakis
kalast at gmail.com
Tue Jun 26 20:06:49 CEST 2012
Revision: 48319
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48319
Author: psy-fi
Date: 2012-06-26 18:06:42 +0000 (Tue, 26 Jun 2012)
Log Message:
-----------
Overlay for Tiled style brushes. The implementation uses openGL
multitexture to minimize texture uploads. The curve strength is written
to a separate texture and modulated with the view texture at runtime.
Unfortunately, I haven't found a way to get a consistent result with the
rest of the brushes because this would require inverting the alpha after
the texture combine operation.
Modified Paths:
--------------
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-06-26 17:51:25 UTC (rev 48318)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-06-26 18:06:42 UTC (rev 48319)
@@ -307,12 +307,8 @@
glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE0);
- glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -361,7 +357,7 @@
avg = BKE_brush_curve_strength(br, len, 1); /* Falloff curve */
- curve_buffer[index] = 255 - (GLubyte)(255 * avg);
+ curve_buffer[index] = (GLubyte)(255 * avg);
}
else {
curve_buffer[index] = 0;
@@ -390,15 +386,20 @@
MEM_freeN(curve_buffer);
}
- glEnable(GL_TEXTURE_2D);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_TEXTURE1);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR);
+
glActiveTexture(GL_TEXTURE0);
return 1;
@@ -580,6 +581,7 @@
} else {
short sizex = vc->ar->winrct.xmax - vc->ar->winrct.xmin;
short sizey = vc->ar->winrct.ymax - vc->ar->winrct.ymin;
+
glTexCoord2f(quad.xmin/sizex, quad.ymin/sizey);
glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
glVertex2f(quad.xmin, quad.ymin);
More information about the Bf-blender-cvs
mailing list