diff options
author | Robert Holcomb <bob_holcomb@hotmail.com> | 2009-09-10 07:00:50 +0400 |
---|---|---|
committer | Robert Holcomb <bob_holcomb@hotmail.com> | 2009-09-10 07:00:50 +0400 |
commit | dac27004b863da96c57b071fc0479680e06a9725 (patch) | |
tree | fcabe2c16a70aa67078e45e679a54306a48b76e3 /source/blender | |
parent | d6a706dee9b59e32ca9c60645680ea4170e6c1d4 (diff) |
committing patch #19252-Soft/Linear Light blend modes+Darken mode bug fix
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 51 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/texture.c | 25 |
7 files changed, 73 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 53de570b55e..e6f9ac2f404 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1031,15 +1031,15 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } break; case MA_RAMP_DARK: - tmp= fac*col[0]; - if(tmp < *r) *r= tmp; - if(g) { - tmp= fac*col[1]; - if(tmp < *g) *g= tmp; - tmp= fac*col[2]; - if(tmp < *b) *b= tmp; - } - break; + tmp=col[0]+((1-col[0])*facm); + if(tmp < *r) *r= tmp; + if(g) { + tmp=col[1]+((1-col[1])*facm); + if(tmp < *g) *g= tmp; + tmp=col[2]+((1-col[2])*facm); + if(tmp < *b) *b= tmp; + } + break; case MA_RAMP_LIGHT: tmp= fac*col[0]; if(tmp > *r) *r= tmp; @@ -1169,8 +1169,37 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } } break; - } - + case MA_RAMP_SOFT: + if (g){ + float scr, scg, scb; + + /* first calculate non-fac based Screen mix */ + scr = 1.0 - ((1.0 - col[0])) * (1.0 - *r); + scg = 1.0 - ((1.0 - col[1])) * (1.0 - *g); + scb = 1.0 - ((1.0 - col[2])) * (1.0 - *b); + + *r = facm*(*r) + fac*(((1.0 - *r) * col[0] * (*r)) + (*r * scr)); + *g = facm*(*g) + fac*(((1.0 - *g) * col[1] * (*g)) + (*g * scg)); + *b = facm*(*b) + fac*(((1.0 - *b) * col[2] * (*b)) + (*b * scb)); + } + break; + case MA_RAMP_LINEAR: + if (col[0] > 0.5) + *r = *r + fac*(2*(col[0]-0.5)); + else + *r = *r + fac*(2*(col[0]) - 1); + if (g){ + if (col[1] > 0.5) + *g = *g + fac*(2*(col[1]-0.5)); + else + *g = *g + fac*(2*(col[1]) -1); + if (col[2] > 0.5) + *b = *b + fac*(2*(col[2]-0.5)); + else + *b = *b + fac*(2*(col[2]) - 1); + } + break; + } } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 2f64108384e..7617f328fd9 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -247,7 +247,7 @@ static int node_buts_mix_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf /* blend type */ uiBlockBeginAlign(block); - bt=uiDefButS(block, MENU, B_NODE_EXEC, "Mix %x0|Add %x1|Subtract %x3|Multiply %x2|Screen %x4|Overlay %x9|Divide %x5|Difference %x6|Darken %x7|Lighten %x8|Dodge %x10|Burn %x11|Color %x15|Value %x14|Saturation %x13|Hue %x12", + bt=uiDefButS(block, MENU, B_NODE_EXEC, "Mix %x0|Add %x1|Subtract %x3|Multiply %x2|Screen %x4|Overlay %x9|Divide %x5|Difference %x6|Darken %x7|Lighten %x8|Dodge %x10|Burn %x11|Color %x15|Value %x14|Saturation %x13|Hue %x12|Soft Light %x16|Linear Light %x17", (short)butr->xmin, (short)butr->ymin, butr->xmax-butr->xmin -(a_but?20:0), 20, &node->custom1, 0, 0, 0, 0, ""); uiButSetFunc(bt, node_but_title_cb, node, bt); diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index f268c117065..55e3c9107e4 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -279,6 +279,8 @@ typedef struct Material { #define MA_RAMP_SAT 13 #define MA_RAMP_VAL 14 #define MA_RAMP_COLOR 15 +#define MA_RAMP_SOFT 16 +#define MA_RAMP_LINEAR 17 /* texco */ #define TEXCO_ORCO 1 diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 4df63ee9cd9..c13c0522004 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -448,6 +448,8 @@ typedef struct TexMapping { #define MTEX_BLEND_VAL 12 #define MTEX_BLEND_COLOR 13 #define MTEX_NUM_BLENDTYPES 14 +#define MTEX_SOFT_LIGHT 15 +#define MTEX_LIN_LIGHT 16 /* brush_map_mode */ #define MTEX_MAP_MODE_FIXED 0 diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 651aeae217e..cd1159bc138 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -616,6 +616,8 @@ static void rna_def_material_colors(StructRNA *srna) {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""}, {MA_RAMP_VAL, "VALUE", 0, "Value", ""}, {MA_RAMP_COLOR, "COLOR", 0, "Color", ""}, + {MA_RAMP_SOFT, "SOFT LIGHT", 0, "Soft Light", ""}, + {MA_RAMP_LINEAR, "LINEAR LIGHT", 0, "Linear Light", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_ramp_input_items[] = { diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index b11e5c6c12f..f6835f3e7b5 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -374,6 +374,8 @@ static void rna_def_mtex(BlenderRNA *brna) {MTEX_BLEND_SAT, "SATURATION", 0, "Saturation", ""}, {MTEX_BLEND_VAL, "VALUE", 0, "Value", ""}, {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""}, + {MTEX_SOFT_LIGHT, "SOFT LIGHT", 0, "Soft Light", ""}, + {MTEX_LIN_LIGHT , "LINEAR LIGHT", 0, "Linear Light", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_map_mode_items[] = { diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 4d4a2c04808..2d2c01e0bf1 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -1455,12 +1455,22 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg VECCOPY(in, out); ramp_blend(MA_RAMP_COLOR, in, in+1, in+2, fact, tex); break; + case MTEX_SOFT_LIGHT: + fact*= facg; + VECCOPY(in, out); + ramp_blend(MA_RAMP_SOFT, in, in+1, in+2, fact, tex); + break; + case MTEX_LIN_LIGHT: + fact*= facg; + VECCOPY(in, out); + ramp_blend(MA_RAMP_LINEAR, in, in+1, in+2, fact, tex); + break; } } float texture_value_blend(float tex, float out, float fact, float facg, int blendtype, int flip) { - float in=0.0, facm, col; + float in=0.0, facm, col, scf; fact*= facg; facm= 1.0-fact; @@ -1505,6 +1515,19 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen col= fact*tex; if(col > out) in= col; else in= out; break; + + case MTEX_SOFT_LIGHT: + col= fact*tex; + scf=1.0 - (1.0 - tex) * (1.0 - out); + in= facm*out + fact * ((1.0 - out) * tex * out) + (out * scf); + break; + + case MTEX_LIN_LIGHT: + if (tex > 0.5) + in = out + fact*(2*(tex - 0.5)); + else + in = out + fact*(2*tex - 1); + break; } return in; |