[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55558] trunk/blender: Alpha mask textures porting part 1: Support for projective texturing.
Antony Riakiotakis
kalast at gmail.com
Mon Mar 25 02:00:18 CET 2013
Revision: 55558
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55558
Author: psy-fi
Date: 2013-03-25 01:00:16 +0000 (Mon, 25 Mar 2013)
Log Message:
-----------
Alpha mask textures porting part 1: Support for projective texturing.
Also add random mapping to brushes.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py
trunk/blender/release/scripts/startup/bl_ui/space_image.py
trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
trunk/blender/source/blender/blenkernel/BKE_blender.h
trunk/blender/source/blender/blenkernel/BKE_brush.h
trunk/blender/source/blender/blenkernel/intern/brush.c
trunk/blender/source/blender/blenkernel/intern/texture.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/blenloader/intern/versioning_250.c
trunk/blender/source/blender/blenloader/intern/writefile.c
trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
trunk/blender/source/blender/makesdna/DNA_brush_types.h
trunk/blender/source/blender/makesdna/DNA_texture_types.h
trunk/blender/source/blender/makesrna/intern/rna_brush.c
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py 2013-03-25 01:00:16 UTC (rev 55558)
@@ -112,3 +112,18 @@
col = layout.column(align=True)
col.label(text="Sample Bias:")
col.prop(brush, "texture_sample_bias", slider=True, text="")
+
+
+def brush_mask_texture_settings(layout, brush):
+ mask_tex_slot = brush.mask_texture_slot
+
+ if(brush.mask_texture):
+ layout.label(text="Mask Mapping:")
+ col = layout.column()
+ col.active = brush.brush_capabilities.has_texture_angle
+ col.prop(mask_tex_slot, "angle", text="")
+
+ # scale and offset
+ split = layout.split()
+ split.prop(mask_tex_slot, "offset")
+ split.prop(mask_tex_slot, "scale")
Modified: trunk/blender/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_image.py 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/release/scripts/startup/bl_ui/space_image.py 2013-03-25 01:00:16 UTC (rev 55558)
@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
from bpy.types import Header, Menu, Panel
-from bl_ui.properties_paint_common import UnifiedPaintPanel, brush_texture_settings
+from bl_ui.properties_paint_common import UnifiedPaintPanel, brush_texture_settings, brush_mask_texture_settings
from bpy.app.translations import pgettext_iface as iface_
@@ -729,6 +729,28 @@
brush_texture_settings(col, brush, 0)
+class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
+ bl_label = "Texture Mask"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw_header(self, context):
+ brush = context.tool_settings.image_paint.brush
+ tex_slot_alpha = brush.mask_texture_slot
+ self.layout.prop(brush, 'use_mask', text="")
+
+ def draw(self, context):
+ layout = self.layout
+
+ brush = context.tool_settings.image_paint.brush
+ tex_slot_alpha = brush.mask_texture_slot
+
+ col = layout.column()
+
+ col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
+
+ brush_mask_texture_settings(col, brush)
+
+
class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel):
bl_label = "Tool"
bl_options = {'DEFAULT_CLOSED'}
Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2013-03-25 01:00:16 UTC (rev 55558)
@@ -21,6 +21,7 @@
from bpy.types import Menu, Panel
from bl_ui.properties_paint_common import UnifiedPaintPanel
from bl_ui.properties_paint_common import brush_texture_settings
+from bl_ui.properties_paint_common import brush_mask_texture_settings
class View3DPanel():
@@ -782,6 +783,34 @@
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
+class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
+ bl_context = "imagepaint"
+ bl_label = "Texture Mask"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ brush = context.tool_settings.image_paint.brush
+ return (context.image_paint_object and brush and brush.image_tool != 'SOFTEN')
+
+ def draw_header(self, context):
+ brush = context.tool_settings.image_paint.brush
+ tex_slot_alpha = brush.mask_texture_slot
+ self.layout.prop(brush, 'use_mask', text="")
+
+ def draw(self, context):
+ layout = self.layout
+
+ brush = context.tool_settings.image_paint.brush
+ tex_slot_alpha = brush.mask_texture_slot
+
+ col = layout.column()
+
+ col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
+
+ brush_mask_texture_settings(col, brush)
+
+
class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
bl_label = "Stroke"
bl_options = {'DEFAULT_CLOSED'}
Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h 2013-03-25 01:00:16 UTC (rev 55558)
@@ -42,7 +42,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 266
-#define BLENDER_SUBVERSION 3
+#define BLENDER_SUBVERSION 4
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
Modified: trunk/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_brush.h 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/source/blender/blenkernel/BKE_brush.h 2013-03-25 01:00:16 UTC (rev 55558)
@@ -78,6 +78,8 @@
float rgba[4], const int thread, struct ImagePool *pool);
float BKE_brush_sample_tex_2D(const struct Scene *scene, struct Brush *brush, const float xy[2],
float rgba[4]);
+float BKE_brush_sample_masktex (const Scene *scene, struct Brush *br,const float point[3],
+ const int thread, struct ImagePool *pool);
void BKE_brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size,
struct ImBuf **imbuf, int use_color_correction);
Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c 2013-03-25 01:00:16 UTC (rev 55558)
@@ -107,6 +107,7 @@
/* BRUSH TEXTURE SETTINGS */
default_mtex(&brush->mtex);
+ default_mtex(&brush->mask_mtex);
brush->texture_sample_bias = 0; /* value to added to texture samples */
brush->texture_overlay_alpha = 33;
@@ -152,6 +153,9 @@
if (brush->mtex.tex)
id_us_plus((ID *)brush->mtex.tex);
+ if (brush->mask_mtex.tex)
+ id_us_plus((ID *)brush->mask_mtex.tex);
+
if (brush->icon_imbuf)
brushn->icon_imbuf = IMB_dupImBuf(brush->icon_imbuf);
@@ -174,6 +178,9 @@
if (brush->mtex.tex)
brush->mtex.tex->id.us--;
+ if (brush->mask_mtex.tex)
+ brush->mask_mtex.tex->id.us--;
+
if (brush->icon_imbuf)
IMB_freeImBuf(brush->icon_imbuf);
@@ -185,6 +192,7 @@
static void extern_local_brush(Brush *brush)
{
id_lib_extern((ID *)brush->mtex.tex);
+ id_lib_extern((ID *)brush->mask_mtex.tex);
id_lib_extern((ID *)brush->clone.image);
}
@@ -514,7 +522,9 @@
float radius = 1.0f; /* Quite warnings */
float co[3];
- if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
+ if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW ||
+ mtex->brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ {
/* keep coordinates relative to mouse */
rotation += ups->brush_rotation;
@@ -575,7 +585,61 @@
return intensity;
}
+float BKE_brush_sample_masktex (const Scene *scene, Brush *br,
+ const float point[3],
+ const int thread,
+ struct ImagePool *pool) {
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+ MTex *mtex = &br->mask_mtex;
+ if (mtex && mtex->tex) {
+ float rotation = -mtex->rot;
+ float point_2d[2] = {point[0], point[1]};
+ float x = 0.0f, y = 0.0f; /* Quite warnings */
+ float radius = 1.0f; /* Quite warnings */
+ float co[3];
+ float rgba[4], intensity = 1.0;
+
+ point_2d[0] -= ups->tex_mouse[0];
+ point_2d[1] -= ups->tex_mouse[1];
+
+ /* use pressure adjusted size for fixed mode */
+ radius = ups->pixel_radius;
+
+ x = point_2d[0];
+ y = point_2d[1];
+
+ x /= radius;
+ y /= radius;
+
+ /* it is probably worth optimizing for those cases where
+ * the texture is not rotated by skipping the calls to
+ * atan2, sqrtf, sin, and cos. */
+ if (rotation > 0.001f || rotation < -0.001f) {
+ const float angle = atan2f(y, x) + rotation;
+ const float flen = sqrtf(x * x + y * y);
+
+ x = flen * cosf(angle);
+ y = flen * sinf(angle);
+ }
+
+ x *= br->mask_mtex.size[0];
+ y *= br->mask_mtex.size[1];
+
+ co[0] = x + br->mask_mtex.ofs[0];
+ co[1] = y + br->mask_mtex.ofs[1];
+ co[2] = 0.0f;
+
+ externtex(mtex, co, &intensity,
+ rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool);
+
+ return intensity;
+ }
+ else {
+ return 1.0f;
+ }
+}
+
/* Brush Sampling for 2D brushes. when we unify the brush systems this will be necessarily a separate function */
float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2], float rgba[4])
{
Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c 2013-03-25 01:00:16 UTC (rev 55558)
@@ -804,6 +804,10 @@
if (br->id.lib) is_lib = TRUE;
else is_local = TRUE;
}
+ if (br->mask_mtex.tex == tex) {
+ if (br->id.lib) is_lib = TRUE;
+ else is_local = TRUE;
+ }
br = br->id.next;
}
pa = bmain->particle.first;
@@ -877,6 +881,13 @@
tex->id.us--;
}
}
+ if (br->mask_mtex.tex == tex) {
+ if (br->id.lib == NULL) {
+ br->mask_mtex.tex = tex_new;
+ tex_new->id.us++;
+ tex->id.us--;
+ }
+ }
br = br->id.next;
}
pa = bmain->particle.first;
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2013-03-24 20:59:53 UTC (rev 55557)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2013-03-25 01:00:16 UTC (rev 55558)
@@ -146,6 +146,7 @@
#include "BKE_screen.h"
#include "BKE_sequencer.h"
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list