7 * ***** BEGIN GPL LICENSE BLOCK *****
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL LICENSE BLOCK *****
36 #include "MEM_guardedalloc.h"
38 #include "DNA_curve_types.h"
39 #include "DNA_material_types.h"
40 #include "DNA_mesh_types.h"
41 #include "DNA_meta_types.h"
42 #include "DNA_node_types.h"
43 #include "DNA_object_types.h"
44 #include "DNA_scene_types.h"
45 #include "DNA_texture_types.h"
47 #include "BLI_blenlib.h"
48 #include "BLI_arithb.h"
50 #include "BKE_bad_level_calls.h"
51 #include "BKE_blender.h"
52 #include "BKE_displist.h"
53 #include "BKE_global.h"
54 #include "BKE_icons.h"
55 #include "BKE_library.h"
57 #include "BKE_material.h"
60 #include "BKE_utildefines.h"
62 #ifndef DISABLE_PYTHON
63 #include "BPY_extern.h"
66 #include "GPU_material.h"
68 /* used in UI and render */
71 /* called on startup, creator.c */
72 void init_def_material(void)
74 init_material(&defmaterial);
77 /* not material itself */
78 void free_material(Material *ma)
83 #ifndef DISABLE_PYTHON
84 BPY_free_scriptlink(&ma->scriptlink);
87 for(a=0; a<MAX_MTEX; a++) {
89 if(mtex && mtex->tex) mtex->tex->id.us--;
90 if(mtex) MEM_freeN(mtex);
93 if(ma->ramp_col) MEM_freeN(ma->ramp_col);
94 if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
96 BKE_previewimg_free(&ma->preview);
97 BKE_icon_delete((struct ID*)ma);
100 /* is no lib link block, but material extension */
102 ntreeFreeTree(ma->nodetree);
103 MEM_freeN(ma->nodetree);
106 if(ma->gpumaterial.first)
107 GPU_material_free(ma);
110 void init_material(Material *ma)
112 ma->r= ma->g= ma->b= ma->ref= 0.8;
113 ma->specr= ma->specg= ma->specb= 1.0;
114 ma->mirr= ma->mirg= ma->mirb= 1.0;
118 ma->spec= ma->hasize= 0.5;
120 ma->starc= ma->ringc= 4;
123 ma->flaresize= ma->subsize= 1.0;
136 ma->strand_sta= ma->strand_end= 1.0f;
140 ma->ray_depth_tra= 2;
141 ma->fresnel_mir= 0.0;
142 ma->fresnel_tra= 0.0;
143 ma->fresnel_tra_i= 1.25;
144 ma->fresnel_mir_i= 1.25;
147 ma->shad_alpha= 1.0f;
149 ma->gloss_mir = ma->gloss_tra= 1.0;
150 ma->samp_gloss_mir = ma->samp_gloss_tra= 18;
151 ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005;
153 ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
155 ma->rampfac_col= 1.0;
156 ma->rampfac_spec= 1.0;
157 ma->pr_lamp= 3; /* two lamps, is bits */
158 ma->pr_type= MA_SPHERE;
160 ma->sss_radius[0]= 1.0f;
161 ma->sss_radius[1]= 1.0f;
162 ma->sss_radius[2]= 1.0f;
163 ma->sss_col[0]= 0.8f;
164 ma->sss_col[1]= 0.8f;
165 ma->sss_col[2]= 0.8f;
166 ma->sss_error= 0.05f;
169 ma->sss_colfac= 1.0f;
170 ma->sss_texfac= 0.0f;
174 ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR;
179 Material *add_material(char *name)
183 ma= alloc_libblock(&G.main->mat, ID_MA, name);
190 Material *copy_material(Material *ma)
195 man= copy_libblock(ma);
197 id_us_plus((ID *)man->ipo);
198 id_us_plus((ID *)man->group);
201 for(a=0; a<MAX_MTEX; a++) {
203 man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
204 memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
205 id_us_plus((ID *)man->mtex[a]->tex);
209 #ifndef DISABLE_PYTHON
210 BPY_copy_scriptlink(&ma->scriptlink);
213 if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
214 if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
216 if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);
219 man->nodetree= ntreeCopyTree(ma->nodetree, 0); /* 0 == full new tree */
222 man->gpumaterial.first= man->gpumaterial.last= NULL;
227 void make_local_material(Material *ma)
234 int a, local=0, lib=0;
236 /* - only lib users: do nothing
237 * - only local users: set flag
241 if(ma->id.lib==0) return;
244 ma->id.flag= LIB_LOCAL;
245 new_id(0, (ID *)ma, 0);
246 for(a=0; a<MAX_MTEX; a++) {
247 if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
254 ob= G.main->object.first;
257 for(a=0; a<ob->totcol; a++) {
259 if(ob->id.lib) lib= 1;
267 me= G.main->mesh.first;
270 for(a=0; a<me->totcol; a++) {
272 if(me->id.lib) lib= 1;
280 cu= G.main->curve.first;
283 for(a=0; a<cu->totcol; a++) {
285 if(cu->id.lib) lib= 1;
293 mb= G.main->mball.first;
296 for(a=0; a<mb->totcol; a++) {
298 if(mb->id.lib) lib= 1;
306 if(local && lib==0) {
308 ma->id.flag= LIB_LOCAL;
310 for(a=0; a<MAX_MTEX; a++) {
311 if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
314 new_id(0, (ID *)ma, 0);
316 else if(local && lib) {
318 man= copy_material(ma);
322 ob= G.main->object.first;
325 for(a=0; a<ob->totcol; a++) {
338 me= G.main->mesh.first;
341 for(a=0; a<me->totcol; a++) {
354 cu= G.main->curve.first;
357 for(a=0; a<cu->totcol; a++) {
370 mb= G.main->mball.first;
373 for(a=0; a<mb->totcol; a++) {
388 Material ***give_matarar(Object *ob)
394 if(ob->type==OB_MESH) {
398 else if ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF) {
402 else if(ob->type==OB_MBALL) {
409 short *give_totcolp(Object *ob)
415 if(ob->type==OB_MESH) {
417 return &(me->totcol);
419 else if ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF) {
421 return &(cu->totcol);
423 else if(ob->type==OB_MBALL) {
425 return &(mb->totcol);
430 Material *give_current_material(Object *ob, int act)
432 Material ***matarar, *ma;
435 if(ob==NULL) return NULL;
437 /* if object cannot have material, totcolp==NULL */
438 totcolp= give_totcolp(ob);
439 if(totcolp==NULL || ob->totcol==0) return NULL;
441 if(act>ob->totcol) act= ob->totcol;
442 else if(act<=0) act= 1;
444 if( BTST(ob->colbits, act-1) ) { /* in object */
449 /* check for inconsistancy */
450 if(*totcolp < ob->totcol)
451 ob->totcol= *totcolp;
452 if(act>ob->totcol) act= ob->totcol;
454 matarar= give_matarar(ob);
456 if(matarar && *matarar) ma= (*matarar)[act-1];
464 ID *material_from(Object *ob, int act)
469 if(ob->totcol==0) return ob->data;
472 if( BTST(ob->colbits, act-1) ) return (ID *)ob;
473 else return ob->data;
476 /* GS reads the memory pointed at in a specific ordering. There are,
477 * however two definitions for it. I have jotted them down here, both,
478 * but I think the first one is actually used. The thing is that
479 * big-endian systems might read this the wrong way round. OTOH, we
480 * constructed the IDs that are read out with this macro explicitly as
481 * well. I expect we'll sort it out soon... */
484 #define GS(a) (*((short *)(a)))
486 /* from misc_util: flip the bytes from x */
487 /* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */
489 void test_object_materials(ID *id)
491 /* make the ob mat-array same size as 'ob->data' mat-array */
501 if( GS(id->name)==ID_ME ) {
505 else if( GS(id->name)==ID_CU ) {
509 else if( GS(id->name)==ID_MB ) {
515 ob= G.main->object.first;
526 else if(ob->totcol<totcol) {
527 newmatar= MEM_callocN(sizeof(void *)*totcol, "newmatar");
529 memcpy(newmatar, ob->mat, sizeof(void *)*ob->totcol);
535 if(ob->totcol && ob->actcol==0) ob->actcol= 1;
536 if(ob->actcol>ob->totcol) ob->actcol= ob->totcol;
543 void assign_material(Object *ob, Material *ma, int act)
545 Material *mao, **matar, ***matarar;
548 if(act>MAXMAT) return;
553 totcolp= give_totcolp(ob);
554 matarar= give_matarar(ob);
556 if(totcolp==0 || matarar==0) return;
558 if( act > *totcolp) {
559 matar= MEM_callocN(sizeof(void *)*act, "matarray1");
561 memcpy(matar, *matarar, sizeof(void *)*( *totcolp ));
568 if(act > ob->totcol) {
569 matar= MEM_callocN(sizeof(void *)*act, "matarray2");
571 memcpy(matar, ob->mat, sizeof(void *)*( ob->totcol ));
580 if( BTST(ob->colbits, act-1) ) { /* in object */
582 if(mao) mao->id.us--;
586 mao= (*matarar)[act-1];
587 if(mao) mao->id.us--;
588 (*matarar)[act-1]= ma;
590 id_us_plus((ID *)ma);
591 test_object_materials(ob->data);
594 int find_material_index(Object *ob, Material *ma)
599 if(ma==NULL) return 0;
601 totcolp= give_totcolp(ob);
602 matarar= give_matarar(ob);
604 if(totcolp==NULL || matarar==NULL) return 0;
606 for(a=0; a<*totcolp; a++)
607 if((*matarar)[a]==ma)
614 void new_material_to_objectdata(Object *ob)
619 if(ob->totcol>=MAXMAT) return;
621 ma= give_current_material(ob, ob->actcol);
623 ma= add_material("Material");
625 ma= copy_material(ma);
627 ma->id.us= 0; /* eeh... */
630 if( BTST(ob->colbits, ob->actcol-1) ) {
631 ob->colbits= BSET(ob->colbits, ob->totcol);
635 assign_material(ob, ma, ob->totcol+1);
636 ob->actcol= ob->totcol;
639 static void do_init_render_material(Material *ma, int r_mode, float *amb)
642 int a, needuv=0, needtang=0;
644 if(ma->flarec==0) ma->flarec= 1;
646 /* add all texcoflags from mtex, texco and mapto were cleared in advance */
647 for(a=0; a<MAX_MTEX; a++) {
649 /* separate tex switching */
650 if(ma->septex & (1<<a)) continue;
653 if(mtex && mtex->tex && mtex->tex->type) {
655 ma->texco |= mtex->texco;
656 ma->mapto |= mtex->mapto;
658 if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA;
661 if(ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1;
662 else if(ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1;
663 else if(ma->texco & (TEXCO_LAVECTOR|TEXCO_VIEW|TEXCO_STICKY)) needuv= 1;
665 if((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT))
670 if(needtang) ma->mode |= MA_NORMAP_TANG;
671 else ma->mode &= ~MA_NORMAP_TANG;
674 if(ma->mode & MA_RADIO) needuv= 1;
676 if(ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) {
678 if(r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */
680 if(needuv) ma->texco |= NEED_UV;
682 /* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */
683 if(r_mode & R_RAYTRACE) {
684 if(ma->mode & (MA_RAYMIRROR|MA_RAYTRANSP|MA_SHADOW_TRA)) {
685 ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM;
686 if(r_mode & R_OSA) ma->texco |= TEXCO_OSA;
691 ma->ambr= ma->amb*amb[0];
692 ma->ambg= ma->amb*amb[1];
693 ma->ambb= ma->amb*amb[2];
695 /* will become or-ed result of all node modes */
696 ma->mode_l= ma->mode;
697 ma->mode_l &= ~MA_SHLESS;
699 if(ma->strand_surfnor > 0.0f)
700 ma->mode_l |= MA_STR_SURFDIFF;
703 static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode, float *amb)
707 for(node=ntree->nodes.first; node; node= node->next) {
709 if(GS(node->id->name)==ID_MA) {
710 Material *ma= (Material *)node->id;
712 do_init_render_material(ma, r_mode, amb);
713 basemat->texco |= ma->texco;
714 basemat->mode_l |= ma->mode_l;
717 else if(node->type==NODE_GROUP)
718 init_render_nodetree((bNodeTree *)node->id, basemat, r_mode, amb);
721 /* parses the geom+tex nodes */
722 ntreeShaderGetTexcoMode(ntree, r_mode, &basemat->texco, &basemat->mode_l);
725 void init_render_material(Material *mat, int r_mode, float *amb)
728 do_init_render_material(mat, r_mode, amb);
730 if(mat->nodetree && mat->use_nodes) {
731 init_render_nodetree(mat->nodetree, mat, r_mode, amb);
733 ntreeBeginExecTree(mat->nodetree); /* has internal flag to detect it only does it once */
737 void init_render_materials(int r_mode, float *amb)
741 /* clear these flags before going over materials, to make sure they
742 * are cleared only once, otherwise node materials contained in other
743 * node materials can go wrong */
744 for(ma= G.main->mat.first; ma; ma= ma->id.next) {
751 /* two steps, first initialize, then or the flags for layers */
752 for(ma= G.main->mat.first; ma; ma= ma->id.next) {
753 /* is_used flag comes back in convertblender.c */
754 ma->flag &= ~MA_IS_USED;
756 init_render_material(ma, r_mode, amb);
759 do_init_render_material(&defmaterial, r_mode, amb);
762 /* only needed for nodes now */
763 void end_render_material(Material *mat)
765 if(mat && mat->nodetree && mat->use_nodes)
766 ntreeEndExecTree(mat->nodetree); /* has internal flag to detect it only does it once */
769 void end_render_materials(void)
772 for(ma= G.main->mat.first; ma; ma= ma->id.next)
774 end_render_material(ma);
777 static int material_in_nodetree(bNodeTree *ntree, Material *mat)
781 for(node=ntree->nodes.first; node; node= node->next) {
782 if(node->id && GS(node->id->name)==ID_MA) {
783 if(node->id==(ID*)mat)
786 else if(node->type==NODE_GROUP)
787 if(material_in_nodetree((bNodeTree*)node->id, mat))
794 int material_in_material(Material *parmat, Material *mat)
798 else if(parmat->nodetree && parmat->use_nodes)
799 return material_in_nodetree(parmat->nodetree, mat);
804 /* ****************** */
806 char colname_array[125][20]= {
807 "Black","DarkRed","HalfRed","Red","Red",
808 "DarkGreen","DarkOlive","Brown","Chocolate","OrangeRed",
809 "HalfGreen","GreenOlive","DryOlive","Goldenrod","DarkOrange",
810 "LightGreen","Chartreuse","YellowGreen","Yellow","Gold",
811 "Green","LawnGreen","GreenYellow","LightOlive","Yellow",
812 "DarkBlue","DarkPurple","HotPink","VioletPink","RedPink",
813 "SlateGray","DarkGrey","PalePurple","IndianRed","Tomato",
814 "SeaGreen","PaleGreen","GreenKhaki","LightBrown","LightSalmon",
815 "SpringGreen","PaleGreen","MediumOlive","YellowBrown","LightGold",
816 "LightGreen","LightGreen","LightGreen","GreenYellow","PaleYellow",
817 "HalfBlue","DarkSky","HalfMagenta","VioletRed","DeepPink",
818 "SteelBlue","SkyBlue","Orchid","LightHotPink","HotPink",
819 "SeaGreen","SlateGray","MediumGrey","Burlywood","LightPink",
820 "SpringGreen","Aquamarine","PaleGreen","Khaki","PaleOrange",
821 "SpringGreen","SeaGreen","PaleGreen","PaleWhite","YellowWhite",
822 "LightBlue","Purple","MediumOrchid","Magenta","Magenta",
823 "RoyalBlue","SlateBlue","MediumOrchid","Orchid","Magenta",
824 "DeepSkyBlue","LightSteelBlue","LightSkyBlue","Violet","LightPink",
825 "Cyan","DarkTurquoise","SkyBlue","Grey","Snow",
826 "Mint","Mint","Aquamarine","MintCream","Ivory",
827 "Blue","Blue","DarkMagenta","DarkOrchid","Magenta",
828 "SkyBlue","RoyalBlue","LightSlateBlue","MediumOrchid","Magenta",
829 "DodgerBlue","SteelBlue","MediumPurple","PalePurple","Plum",
830 "DeepSkyBlue","PaleBlue","LightSkyBlue","PalePurple","Thistle",
831 "Cyan","ColdBlue","PaleTurquoise","GhostWhite","White"
834 void automatname(Material *ma)
840 if(ma->mode & MA_SHLESS) ref= 1.0;
843 r= (int)(4.99*(ref*ma->r));
844 g= (int)(4.99*(ref*ma->g));
845 b= (int)(4.99*(ref*ma->b));
848 new_id(&G.main->mat, (ID *)ma, colname_array[nr]);
853 void delete_material_index()
855 Material *mao, ***matarar;
863 error("Unable to perform function in EditMode");
866 ob= ((G.scene->basact)? (G.scene->basact->object) : 0) ;
867 if(ob==0 || ob->totcol==0) return;
869 /* take a mesh/curve/mball as starting point, remove 1 index,
870 * AND with all objects that share the ob->data
872 * after that check indices in mesh/curve/mball!!!
875 totcolp= give_totcolp(ob);
876 matarar= give_matarar(ob);
878 /* we delete the actcol */
880 mao= (*matarar)[ob->actcol-1];
881 if(mao) mao->id.us--;
884 for(a=ob->actcol; a<ob->totcol; a++) {
885 (*matarar)[a-1]= (*matarar)[a];
895 obt= G.main->object.first;
898 if(obt->data==ob->data) {
900 /* WATCH IT: do not use actcol from ob or from obt (can become zero) */
901 mao= obt->mat[actcol-1];
902 if(mao) mao->id.us--;
904 for(a=actcol; a<obt->totcol; a++) obt->mat[a-1]= obt->mat[a];
906 if(obt->actcol > obt->totcol) obt->actcol= obt->totcol;
916 /* check indices from mesh */
918 if(ob->type==OB_MESH) {
919 Mesh *me= get_mesh(ob);
920 mesh_delete_material_index(me, actcol-1);
921 freedisplist(&ob->disp);
923 else if ELEM(ob->type, OB_CURVE, OB_SURF) {
928 if(nu->mat_nr && nu->mat_nr>=actcol-1) {
930 if (ob->type == OB_CURVE) nu->charidx--;
934 freedisplist(&ob->disp);
939 /* r g b = current value, col = new value, fac==0 is no change */
940 /* if g==NULL, it only does r channel */
941 void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col)
943 float tmp, facm= 1.0-fac;
947 *r = facm*(*r) + fac*col[0];
949 *g = facm*(*g) + fac*col[1];
950 *b = facm*(*b) + fac*col[2];
961 *r *= (facm + fac*col[0]);
963 *g *= (facm + fac*col[1]);
964 *b *= (facm + fac*col[2]);
968 *r = 1.0 - (facm + fac*(1.0 - col[0])) * (1.0 - *r);
970 *g = 1.0 - (facm + fac*(1.0 - col[1])) * (1.0 - *g);
971 *b = 1.0 - (facm + fac*(1.0 - col[2])) * (1.0 - *b);
974 case MA_RAMP_OVERLAY:
976 *r *= (facm + 2.0f*fac*col[0]);
978 *r = 1.0 - (facm + 2.0f*fac*(1.0 - col[0])) * (1.0 - *r);
981 *g *= (facm + 2.0f*fac*col[1]);
983 *g = 1.0 - (facm + 2.0f*fac*(1.0 - col[1])) * (1.0 - *g);
985 *b *= (facm + 2.0f*fac*col[2]);
987 *b = 1.0 - (facm + 2.0f*fac*(1.0 - col[2])) * (1.0 - *b);
999 *r = facm*(*r) + fac*(*r)/col[0];
1002 *g = facm*(*g) + fac*(*g)/col[1];
1004 *b = facm*(*b) + fac*(*b)/col[2];
1008 *r = facm*(*r) + fac*fabs(*r-col[0]);
1010 *g = facm*(*g) + fac*fabs(*g-col[1]);
1011 *b = facm*(*b) + fac*fabs(*b-col[2]);
1016 if(tmp < *r) *r= tmp;
1019 if(tmp < *g) *g= tmp;
1021 if(tmp < *b) *b= tmp;
1026 if(tmp > *r) *r= tmp;
1029 if(tmp > *g) *g= tmp;
1031 if(tmp > *b) *b= tmp;
1038 tmp = 1.0 - fac*col[0];
1041 else if ((tmp = (*r) / tmp)> 1.0)
1048 tmp = 1.0 - fac*col[1];
1051 else if ((tmp = (*g) / tmp) > 1.0 )
1057 tmp = 1.0 - fac*col[2];
1060 else if ((tmp = (*b) / tmp) > 1.0 )
1070 tmp = facm + fac*col[0];
1074 else if (( tmp = (1.0 - (1.0 - (*r)) / tmp )) < 0.0)
1082 tmp = facm + fac*col[1];
1085 else if (( tmp = (1.0 - (1.0 - (*g)) / tmp )) < 0.0 )
1092 tmp = facm + fac*col[2];
1095 else if (( tmp = (1.0 - (1.0 - (*b)) / tmp )) < 0.0 )
1106 float colH,colS,colV;
1107 float tmpr,tmpg,tmpb;
1108 rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
1110 rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
1111 hsv_to_rgb( colH , rS, rV, &tmpr, &tmpg, &tmpb);
1112 *r = facm*(*r) + fac*tmpr;
1113 *g = facm*(*g) + fac*tmpg;
1114 *b = facm*(*b) + fac*tmpb;
1121 float colH,colS,colV;
1122 rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
1124 rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
1125 hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r, g, b);
1132 float colH,colS,colV;
1133 rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
1134 rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
1135 hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r, g, b);
1141 float colH,colS,colV;
1142 float tmpr,tmpg,tmpb;
1143 rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
1145 rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
1146 hsv_to_rgb( colH, colS, rV, &tmpr, &tmpg, &tmpb);
1147 *r = facm*(*r) + fac*tmpr;
1148 *g = facm*(*g) + fac*tmpg;
1149 *b = facm*(*b) + fac*tmpb;