2 * $Id: buttons_shading.c 13271 2008-01-17 15:45:40Z ton $
4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: not all of this file anymore. :)
27 * ***** END GPL LICENSE BLOCK *****
39 #include "IMB_imbuf_types.h"
40 #include "IMB_imbuf.h"
42 #include "MEM_guardedalloc.h"
44 #include "DNA_brush_types.h"
45 #include "DNA_curve_types.h"
46 #include "DNA_customdata_types.h"
47 #include "DNA_image_types.h"
48 #include "DNA_lamp_types.h"
49 #include "DNA_material_types.h"
50 #include "DNA_mesh_types.h"
51 #include "DNA_meshdata_types.h"
52 #include "DNA_object_types.h"
53 #include "DNA_node_types.h"
54 #include "DNA_packedFile_types.h"
55 #include "DNA_radio_types.h"
56 #include "DNA_screen_types.h"
57 #include "DNA_space_types.h"
58 #include "DNA_scene_types.h"
59 #include "DNA_texture_types.h"
60 #include "DNA_userdef_types.h"
61 #include "DNA_view3d_types.h"
62 #include "DNA_world_types.h"
64 #include "BKE_colortools.h"
65 #include "BKE_displist.h"
66 #include "BKE_effect.h"
67 #include "BKE_global.h"
68 #include "BKE_library.h"
71 #include "BKE_material.h"
72 #include "BKE_utildefines.h"
73 #include "BKE_texture.h"
75 #include "BKE_packedFile.h"
76 #include "BKE_plugin_types.h"
77 #include "BKE_image.h"
79 #include "BLI_blenlib.h"
82 #include "BSE_filesel.h"
83 #include "BSE_headerbuttons.h"
86 #include "BDR_drawmesh.h"
88 #include "BIF_drawimage.h"
90 #include "BIF_graphics.h"
91 #include "BIF_keyval.h"
92 #include "BIF_mainqueue.h"
93 #include "BIF_resources.h"
94 #include "BIF_screen.h"
95 #include "BIF_mywindow.h"
96 #include "BIF_space.h"
97 #include "BIF_glutil.h"
98 #include "BIF_interface.h"
99 #include "BIF_toolbox.h"
100 #include "BIF_space.h"
101 #include "BIF_previewrender.h"
102 #include "BIF_butspace.h"
103 #include "BIF_writeimage.h"
104 #include "BIF_toets.h"
106 #include "mydevice.h"
110 #include "RE_pipeline.h"
112 /* -----includes for this file specific----- */
114 #include "butspace.h" // own module
117 static MTex emptytex
;
118 static int packdummy
= 0;
120 static char *mapto_blendtype_pup(void)
122 static char formatstr
[] = "|%s %%x%d";
123 static char string
[1024];
126 str
+= sprintf(str
, formatstr
, "Mix", MTEX_BLEND
);
128 str
+= sprintf(str
, formatstr
, "Add", MTEX_ADD
);
129 str
+= sprintf(str
, formatstr
, "Subtract", MTEX_SUB
);
131 str
+= sprintf(str
, formatstr
, "Multiply", MTEX_MUL
);
132 str
+= sprintf(str
, formatstr
, "Screen", MTEX_SCREEN
);
133 str
+= sprintf(str
, formatstr
, "Overlay", MTEX_OVERLAY
);
135 str
+= sprintf(str
, formatstr
, "Difference", MTEX_DIFF
);
136 str
+= sprintf(str
, formatstr
, "Divide", MTEX_DIV
);
138 str
+= sprintf(str
, formatstr
, "Darken", MTEX_DARK
);
139 str
+= sprintf(str
, formatstr
, "Lighten", MTEX_LIGHT
);
141 str
+= sprintf(str
, formatstr
, "Hue", MTEX_BLEND_HUE
);
142 str
+= sprintf(str
, formatstr
, "Saturation", MTEX_BLEND_SAT
);
143 str
+= sprintf(str
, formatstr
, "Value", MTEX_BLEND_VAL
);
144 str
+= sprintf(str
, formatstr
, "Color", MTEX_BLEND_COLOR
);
149 void shade_buttons_change_3d(void)
156 for(sa
= G
.curscreen
->areabase
.first
; sa
; sa
= sa
->next
) {
157 if(sa
->spacetype
==SPACE_VIEW3D
) {
158 View3D
*v3d
= sa
->spacedata
.first
;
160 if(v3d
->drawtype
>= OB_SOLID
) addqueue(sa
->win
, REDRAW
, 0);
161 if(v3d
->drawtype
== OB_SHADED
) {
162 if(ob
->type
==OB_LAMP
) reshadeall_displist();
164 /* all objects using material */
165 Base
*base
= FIRSTBASE
;
166 Material
*ma
= give_current_material(ob
, ob
->actcol
);
170 if(base
->lay
& G
.vd
->lay
) {
171 for(a
=1; a
<=ob
->totcol
; a
++) {
172 if(ma
== give_current_material(base
->object
, a
)) {
173 freedisplist(&(base
->object
->disp
));
186 /* *************************** TEXTURE ******************************** */
188 static void load_image_cb(char *str
, void *ima_pp_v
, void *iuser_v
) /* called from fileselect or button */
190 Image
**ima_pp
= (Image
**)ima_pp_v
;
193 ima
= BKE_add_image_file(str
);
200 BKE_image_signal(ima
, iuser_v
, IMA_SIGNAL_RELOAD
);
202 /* button event gets lost when it goes via filewindow */
203 if(G
.buts
&& G
.buts
->lockpoin
) {
204 Tex
*tex
= G
.buts
->lockpoin
;
205 if(GS(tex
->id
.name
)==ID_TE
) {
206 BIF_preview_changed(ID_TE
);
207 allqueue(REDRAWBUTSSHADING
, 0);
208 allqueue(REDRAWOOPS
, 0);
213 BIF_undo_push("Load image");
216 static void load_plugin_tex(char *str
, void *tex_v
, void *unused
) /* called from fileselect */
220 if(tex
->type
!=TEX_PLUGIN
) return;
222 if(tex
->plugin
) free_plugin_tex(tex
->plugin
);
225 tex
->plugin
= add_plugin_tex(str
);
227 allqueue(REDRAWBUTSSHADING
, 0);
228 BIF_preview_changed(ID_TE
);
231 static void save_env(char *name
)
237 BLI_convertstringcode(str
, G
.sce
, G
.scene
->r
.cfra
);
238 tex
= G
.buts
->lockpoin
;
240 if(tex
&& GS(tex
->id
.name
)==ID_TE
) {
241 if(tex
->env
&& tex
->env
->ok
&& saveover(str
)) {
243 BIF_save_envmap(tex
->env
, str
);
251 static int vergcband(const void *a1
, const void *a2
)
253 const CBData
*x1
=a1
, *x2
=a2
;
255 if( x1
->pos
> x2
->pos
) return 1;
256 else if( x1
->pos
< x2
->pos
) return -1;
260 void do_texbuts(unsigned short event
)
266 tex
= G
.buts
->lockpoin
;
270 BIF_preview_changed(ID_TE
);
271 allqueue(REDRAWBUTSSHADING
, 0);
273 if(tex
&& G
.scene
->nodetree
) {
274 NodeTagIDChanged(G
.scene
->nodetree
, &tex
->id
);
275 allqueue(RECALC_COMPOSITE
, 0);
279 scrarea_queue_headredraw(curarea
);
280 BIF_preview_changed(ID_TE
);
281 allqueue(REDRAWBUTSSHADING
, 0);
282 if(G
.buts
->texfrom
== 3) /* brush texture */
283 allqueue(REDRAWIMAGE
, 0);
286 if(tex
==NULL
) return;
288 allqueue(REDRAWBUTSSHADING
, 0);
289 BIF_preview_changed(ID_TE
);
291 if(tex
&& G
.scene
->nodetree
) {
292 NodeTagIDChanged(G
.scene
->nodetree
, &tex
->id
);
293 allqueue(RECALC_COMPOSITE
, 0);
297 if(tex
==NULL
) return;
299 BIF_undo_push("Default texture vars");
300 allqueue(REDRAWBUTSSHADING
, 0);
301 BIF_preview_changed(ID_TE
);
305 BIF_preview_changed(ID_TE
);
306 allqueue(REDRAWBUTSSHADING
, 0);
309 if(G
.scene
->nodetree
) {
310 NodeTagIDChanged(G
.scene
->nodetree
, &tex
->id
);
311 allqueue(RECALC_COMPOSITE
, 0);
313 if(tex
->ima
&& (tex
->imaflag
& TEX_MIPMAP
) && (tex
->ima
->flag
& IMA_FIELDS
)) {
314 error("Cannot combine fields and mipmap");
315 tex
->imaflag
-= TEX_MIPMAP
;
318 BKE_free_envmapdata(tex
->env
);
324 allqueue(REDRAWBUTSSHADING
, 0);
325 BIF_preview_changed(ID_TE
);
326 shade_buttons_change_3d();
331 if(tex
==NULL
) return;
333 sa
= closest_bigger_area();
335 if(tex
->plugin
) strcpy(str
, tex
->plugin
->name
);
337 strcpy(str
, U
.plugtexdir
);
339 activate_fileselect_args(FILE_SPECIAL
, "SELECT PLUGIN", str
, load_plugin_tex
, tex
, NULL
);
344 if(tex
==NULL
|| tex
->plugin
==NULL
) return;
345 strcpy(str
, tex
->plugin
->name
);
346 free_plugin_tex(tex
->plugin
);
348 tex
->plugin
= add_plugin_tex(str
);
349 allqueue(REDRAWBUTSSHADING
, 0);
350 BIF_preview_changed(ID_TE
);
354 if(tex
==NULL
) return;
355 if(tex
->coba
==NULL
) tex
->coba
= add_colorband(0);
356 allqueue(REDRAWBUTSSHADING
, 0);
357 BIF_preview_changed(ID_TE
); // also ramps, so we do this
362 BKE_free_envmap(tex
->env
);
364 allqueue(REDRAWBUTSSHADING
, 0);
365 BIF_preview_changed(ID_TE
);
370 BKE_free_envmapdata(tex
->env
);
371 allqueue(REDRAWBUTSSHADING
, 0);
372 BIF_preview_changed(ID_TE
);
376 tex
= G
.main
->tex
.first
;
378 if(tex
->id
.us
&& tex
->type
==TEX_ENVMAP
) {
380 if(tex
->env
->stype
!=ENV_LOAD
) BKE_free_envmapdata(tex
->env
);
385 allqueue(REDRAWBUTSSHADING
, 0);
386 BIF_preview_changed(ID_TE
);
389 if(tex
->env
&& tex
->env
->ok
) {
390 if(tex
->env
->type
==ENV_PLANE
) {
391 notice("Sorry, not implemented yet");
394 sa
= closest_bigger_area();
396 save_image_filesel_str(str
);
397 activate_fileselect(FILE_SPECIAL
, str
, G
.ima
, save_env
);
402 if(tex
->env
&& tex
->env
->object
) {
403 BIF_preview_changed(ID_TE
);
404 if ELEM(tex
->env
->object
->type
, OB_CAMERA
, OB_LAMP
) {
405 error("Camera or Lamp not allowed");
406 tex
->env
->object
= NULL
;
412 if(event
>=B_PLUGBUT
&& event
<=B_PLUGBUT
+23) {
413 PluginTex
*pit
= tex
->plugin
;
414 if(pit
&& pit
->callback
) {
415 pit
->callback(event
- B_PLUGBUT
);
416 BIF_preview_changed(ID_TE
);
417 allqueue(REDRAWBUTSSHADING
, 0);
423 static void texture_panel_plugin(Tex
*tex
)
430 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_plugin", UI_EMBOSS
, UI_HELV
, curarea
->win
);
431 if(uiNewPanel(curarea
, block
, "Plugin", "Texture", 640, 0, 318, 204)==0) return;
432 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
434 if(tex
->plugin
&& tex
->plugin
->doit
) {
438 for(a
=0; a
<pit
->stypes
; a
++) {
439 uiDefButS(block
, ROW
, B_TEXREDR_PRV
, pit
->stnames
+16*a
, (76*a
), 152, 75, 20, &tex
->stype
, 2.0, (float)a
, 0, 0, "");
444 for(a
=0; a
<pit
->vars
; a
++, varstr
++) {
446 yco
= 125 - 20*(a
% 6)+1;
447 uiDefBut(block
, varstr
->type
, B_PLUGBUT
+a
, varstr
->name
, xco
,yco
,137,19, &(pit
->data
[a
]), varstr
->min
, varstr
->max
, 100, 0, varstr
->tip
);
450 uiDefBut(block
, TEX
, B_NAMEPLUGIN
, "", 0,180,318,24, pit
->name
, 0.0, 159.0, 0, 0, "");
453 uiDefBut(block
, BUT
, B_LOADPLUGIN
, "Load Plugin", 0,204,137,24, 0, 0, 0, 0, 0, "");
458 static void texture_panel_magic(Tex
*tex
)
462 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_magic", UI_EMBOSS
, UI_HELV
, curarea
->win
);
463 if(uiNewPanel(curarea
, block
, "Magic", "Texture", 640, 0, 318, 204)==0) return;
464 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
466 uiBlockBeginAlign(block
);
467 uiDefButS(block
, NUM
, B_TEXPRV
, "Depth:", 10, 90, 150, 19, &tex
->noisedepth
, 0.0, 10.0, 0, 0, "Sets the depth of the pattern");
468 uiDefButF(block
, NUM
, B_TEXPRV
, "Turbulence:", 10, 70, 150, 19, &tex
->turbul
, 0.0, 200.0, 10, 0, "Sets the strength of the pattern");
471 static void texture_panel_blend(Tex
*tex
)
475 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_blend", UI_EMBOSS
, UI_HELV
, curarea
->win
);
476 if(uiNewPanel(curarea
, block
, "Blend", "Texture", 640, 0, 318, 204)==0) return;
477 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
479 uiBlockBeginAlign(block
);
480 uiDefButS(block
, ROW
, B_TEXPRV
, "Lin", 10, 180, 75, 19, &tex
->stype
, 2.0, 0.0, 0, 0, "Creates a linear progresion");
481 uiDefButS(block
, ROW
, B_TEXPRV
, "Quad", 85, 180, 75, 19, &tex
->stype
, 2.0, 1.0, 0, 0, "Creates a quadratic progression");
482 uiDefButS(block
, ROW
, B_TEXPRV
, "Ease", 160, 180, 75, 19, &tex
->stype
, 2.0, 2.0, 0, 0, "Creates a progression easing from one step to the next");
483 uiDefButBitS(block
, TOG
, TEX_FLIPBLEND
, B_TEXPRV
, "Flip XY", 235, 180, 75, 19, &tex
->flag
, 0, 0, 0, 0, "Flips the direction of the progression 90 degrees");
485 uiDefButS(block
, ROW
, B_TEXPRV
, "Diag", 10, 160, 75, 19, &tex
->stype
, 2.0, 3.0, 0, 0, "Use a diagonal progression");
486 uiDefButS(block
, ROW
, B_TEXPRV
, "Sphere", 85, 160, 75, 19, &tex
->stype
, 2.0, 4.0, 0, 0, "Use progression with the shape of a sphere");
487 uiDefButS(block
, ROW
, B_TEXPRV
, "Halo", 160, 160, 75, 19, &tex
->stype
, 2.0, 5.0, 0, 0, "Use a quadratic progression with the shape of a sphere");
488 uiDefButS(block
, ROW
, B_TEXPRV
, "Radial", 235, 160, 75, 19, &tex
->stype
, 2.0, 6.0, 0, 0, "Use a polar progression");
492 /* newnoise: noisebasis menu string */
493 static char* noisebasis_menu()
495 static char nbmenu
[256];
496 sprintf(nbmenu
, "Noise Basis %%t|Blender Original %%x%d|Original Perlin %%x%d|Improved Perlin %%x%d|Voronoi F1 %%x%d|Voronoi F2 %%x%d|Voronoi F3 %%x%d|Voronoi F4 %%x%d|Voronoi F2-F1 %%x%d|Voronoi Crackle %%x%d|CellNoise %%x%d", TEX_BLENDER
, TEX_STDPERLIN
, TEX_NEWPERLIN
, TEX_VORONOI_F1
, TEX_VORONOI_F2
, TEX_VORONOI_F3
, TEX_VORONOI_F4
, TEX_VORONOI_F2F1
, TEX_VORONOI_CRACKLE
, TEX_CELLNOISE
);
500 static void texture_panel_wood(Tex
*tex
)
504 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_wood", UI_EMBOSS
, UI_HELV
, curarea
->win
);
505 if(uiNewPanel(curarea
, block
, "Wood", "Texture", 640, 0, 318, 204)==0) return;
506 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
508 uiBlockBeginAlign(block
);
509 uiDefButS(block
, ROW
, B_TEXPRV
, "Bands", 10, 180, 75, 18, &tex
->stype
, 2.0, 0.0, 0, 0, "Uses standard wood texture in bands");
510 uiDefButS(block
, ROW
, B_TEXPRV
, "Rings", 85, 180, 75, 18, &tex
->stype
, 2.0, 1.0, 0, 0, "Uses wood texture in rings");
511 uiDefButS(block
, ROW
, B_TEXPRV
, "BandNoise", 160, 180, 75, 18, &tex
->stype
, 2.0, 2.0, 0, 0, "Adds noise to standard wood");
512 uiDefButS(block
, ROW
, B_TEXPRV
, "RingNoise", 235, 180, 75, 18, &tex
->stype
, 2.0, 3.0, 0, 0, "Adds noise to rings");
514 uiDefButS(block
, ROW
, B_TEXPRV
, "Sin", 10, 160, 50, 19, &tex
->noisebasis2
, 8.0, 0.0, 0, 0, "Uses a sine wave to produce bands");
515 uiDefButS(block
, ROW
, B_TEXPRV
, "Saw", 60, 160, 50, 19, &tex
->noisebasis2
, 8.0, 1.0, 0, 0, "Uses a saw wave to produce bands");
516 uiDefButS(block
, ROW
, B_TEXPRV
, "Tri", 110, 160, 50, 19, &tex
->noisebasis2
, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce bands");
517 uiDefButS(block
, ROW
, B_TEXPRV
, "Soft noise", 160, 160, 75, 19, &tex
->noisetype
, 12.0, 0.0, 0, 0, "Generates soft noise");
518 uiDefButS(block
, ROW
, B_TEXPRV
, "Hard noise", 235, 160, 75, 19, &tex
->noisetype
, 12.0, 1.0, 0, 0, "Generates hard noise");
520 uiBlockBeginAlign(block
);
521 uiDefButF(block
, NUM
, B_TEXPRV
, "NoiseSize :", 10, 130, 150, 19, &tex
->noisesize
, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
522 uiDefButF(block
, NUM
, B_TEXPRV
, "Turbulence:", 160, 130, 150, 19, &tex
->turbul
, 0.0, 200.0, 10, 0, "Sets the turbulence of the bandnoise and ringnoise types");
523 uiBlockEndAlign(block
);
525 /* newnoise: noisebasis menu */
526 uiDefBut(block
, LABEL
, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
527 uiDefButS(block
, MENU
, B_TEXPRV
, noisebasis_menu(), 10, 10, 150, 19, &tex
->noisebasis
, 0,0,0,0, "Sets the noise basis used for turbulence");
528 uiDefButF(block
, NUM
, B_NOP
, "Nabla: ", 160, 10, 150, 19, &tex
->nabla
, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
532 static void texture_panel_stucci(Tex
*tex
)
536 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_stucci", UI_EMBOSS
, UI_HELV
, curarea
->win
);
537 if(uiNewPanel(curarea
, block
, "Stucci", "Texture", 640, 0, 318, 204)==0) return;
538 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
540 uiBlockBeginAlign(block
);
541 uiDefButS(block
, ROW
, B_TEXPRV
, "Plastic", 10, 180, 100, 19, &tex
->stype
, 2.0, 0.0, 0, 0, "Uses standard stucci");
542 uiDefButS(block
, ROW
, B_TEXPRV
, "Wall In", 110, 180, 100, 19, &tex
->stype
, 2.0, 1.0, 0, 0, "Creates Dimples");
543 uiDefButS(block
, ROW
, B_TEXPRV
, "Wall Out", 210, 180, 100, 19, &tex
->stype
, 2.0, 2.0, 0, 0, "Creates Ridges");
545 uiDefButS(block
, ROW
, B_TEXPRV
, "Soft noise", 10, 160, 150, 19, &tex
->noisetype
, 12.0, 0.0, 0, 0, "Generates soft noise");
546 uiDefButS(block
, ROW
, B_TEXPRV
, "Hard noise", 160, 160, 150, 19, &tex
->noisetype
, 12.0, 1.0, 0, 0, "Generates hard noise");
548 uiBlockBeginAlign(block
);
549 uiDefButF(block
, NUM
, B_TEXPRV
, "NoiseSize :", 10, 110, 150, 19, &tex
->noisesize
, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
550 uiDefButF(block
, NUM
, B_TEXPRV
, "Turbulence:", 10, 90, 150, 19, &tex
->turbul
, 0.0, 200.0, 10, 0, "Sets the depth of the stucci");
551 uiBlockEndAlign(block
);
553 /* newnoise: noisebasis menu */
554 uiDefBut(block
, LABEL
, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
555 uiDefButS(block
, MENU
, B_TEXPRV
, noisebasis_menu(), 10, 10, 150, 19, &tex
->noisebasis
, 0,0,0,0, "Sets the noise basis used for turbulence");
556 // note, nabla not supported here!
557 // uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
561 static void texture_panel_marble(Tex
*tex
)
565 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_marble", UI_EMBOSS
, UI_HELV
, curarea
->win
);
566 if(uiNewPanel(curarea
, block
, "Marble", "Texture", 640, 0, 318, 204)==0) return;
567 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
569 uiBlockBeginAlign(block
);
570 uiDefButS(block
, ROW
, B_TEXPRV
, "Soft", 10, 180, 100, 18, &tex
->stype
, 2.0, 0.0, 0, 0, "Uses soft marble");
571 uiDefButS(block
, ROW
, B_TEXPRV
, "Sharp", 110, 180, 100, 18, &tex
->stype
, 2.0, 1.0, 0, 0, "Uses more clearly defined marble");
572 uiDefButS(block
, ROW
, B_TEXPRV
, "Sharper", 210, 180, 100, 18, &tex
->stype
, 2.0, 2.0, 0, 0, "Uses very clearly defined marble");
574 uiDefButS(block
, ROW
, B_TEXPRV
, "Soft noise", 10, 160, 150, 19, &tex
->noisetype
, 12.0, 0.0, 0, 0, "Generates soft noise");
575 uiDefButS(block
, ROW
, B_TEXPRV
, "Hard noise", 160, 160, 150, 19, &tex
->noisetype
, 12.0, 1.0, 0, 0, "Generates hard noise");
577 uiDefButS(block
, ROW
, B_TEXPRV
, "Sin", 10, 140, 100, 18, &tex
->noisebasis2
, 8.0, 0.0, 0, 0, "Uses a sine wave to produce bands.");
578 uiDefButS(block
, ROW
, B_TEXPRV
, "Saw", 110, 140, 100, 18, &tex
->noisebasis2
, 8.0, 1.0, 0, 0, "Uses a saw wave to produce bands");
579 uiDefButS(block
, ROW
, B_TEXPRV
, "Tri", 210, 140, 100, 18, &tex
->noisebasis2
, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce bands");
581 uiBlockBeginAlign(block
);
582 uiDefButF(block
, NUM
, B_TEXPRV
, "NoiseSize :", 10, 110, 150, 19, &tex
->noisesize
, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
583 uiDefButS(block
, NUM
, B_TEXPRV
, "NoiseDepth:", 10, 90, 150, 19, &tex
->noisedepth
, 0.0, 6.0, 0, 0, "Sets the depth of the marble calculation");
584 uiDefButF(block
, NUM
, B_TEXPRV
, "Turbulence:", 10, 70, 150, 19, &tex
->turbul
, 0.0, 200.0, 10, 0, "Sets the turbulence of the sine bands");
585 uiBlockEndAlign(block
);
587 /* newnoise: noisebasis menu */
588 uiDefBut(block
, LABEL
, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
589 uiDefButS(block
, MENU
, B_TEXPRV
, noisebasis_menu(), 10, 10, 150, 19, &tex
->noisebasis
, 0,0,0,0, "Sets the noise basis used for turbulence");
590 uiDefButF(block
, NUM
, B_NOP
, "Nabla: ", 160, 10, 150, 19, &tex
->nabla
, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
594 static void texture_panel_clouds(Tex
*tex
)
598 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_clouds", UI_EMBOSS
, UI_HELV
, curarea
->win
);
599 if(uiNewPanel(curarea
, block
, "Clouds", "Texture", 640, 0, 318, 204)==0) return;
600 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
602 uiBlockBeginAlign(block
);
603 uiDefButS(block
, ROW
, B_TEXPRV
, "Default", 10, 180, 70, 18, &tex
->stype
, 2.0, 0.0, 0, 0, "Uses standard noise");
604 uiDefButS(block
, ROW
, B_TEXPRV
, "Color", 80, 180, 70, 18, &tex
->stype
, 2.0, 1.0, 0, 0, "Lets Noise return RGB value");
605 uiDefButS(block
, ROW
, B_TEXPRV
, "Soft noise", 155, 180, 75, 18, &tex
->noisetype
, 12.0, 0.0, 0, 0, "Generates soft noise");
606 uiDefButS(block
, ROW
, B_TEXPRV
, "Hard noise", 230, 180, 80, 18, &tex
->noisetype
, 12.0, 1.0, 0, 0, "Generates hard noise");
607 uiBlockBeginAlign(block
);
608 uiDefButF(block
, NUM
, B_TEXPRV
, "NoiseSize :", 10, 130, 150, 19, &tex
->noisesize
, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
609 uiDefButS(block
, NUM
, B_TEXPRV
, "NoiseDepth:", 160, 130, 150, 19, &tex
->noisedepth
, 0.0, 6.0, 0, 0, "Sets the depth of the cloud calculation");
610 uiBlockEndAlign(block
);
612 /* newnoise: noisebasis menu */
613 uiDefBut(block
, LABEL
, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
614 uiDefButS(block
, MENU
, B_TEXPRV
, noisebasis_menu(), 10, 10, 150, 19, &tex
->noisebasis
, 0,0,0,0, "Sets the noise basis used for turbulence");
615 uiDefButF(block
, NUM
, B_NOP
, "Nabla: ", 160, 10, 150, 19, &tex
->nabla
, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
619 static void texture_panel_clouds2(Tex
*tex
)
623 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_clouds2", UI_EMBOSS
, UI_HELV
, curarea
->win
);
624 if (uiNewPanel(curarea
, block
, "Clouds2", "Texture", 640, 0, 318, 204)==0)
627 uiSetButLock(tex
->id
.lib
!= 0, "Can't edit library data");
628 uiBlockBeginAlign(block
);
630 uiDefButS(block
, ROW
, B_TEXPRV
, "Intens", 10, 180, 100, 18, &tex
->stype
, 1.0, 0.0, 0, 0, "noise affects color intensity");
631 uiDefButS(block
, ROW
, B_TEXPRV
, "Color", 110, 180, 100, 18, &tex
->stype
, 1.0, 1.0, 0, 0, "noise affects color");
632 uiBlockBeginAlign(block
);
634 uiDefButF(block
, NUM
, B_TEXPRV
, "Scale :", 10, 110, 150, 19, &tex
->noisesize
, -20.0, 20.0, 100, 0, "Sets scaling for noise input");
635 uiDefButS(block
, NUM
, B_TEXPRV
, "NoiseDepth:", 10, 90, 150, 19, &tex
->noisedepth
, 1.0, 12.0, 1000, 0, "Sets the depth of the texture calculation");
636 uiDefButF(block
, NUM
, B_TEXPRV
, "Offset:", 10, 70, 150, 19, &tex
->cl2_offset
, -20.0, 20.0, 100, 0, "Sets the offset");
637 uiDefButF(block
, NUM
, B_TEXPRV
, "Falloff:", 10, 50, 150, 19, &tex
->cl2_falloff
, -20.0, 20.0, 100, 0, "Sets the falloff");
638 uiBlockEndAlign(block
);
641 /*****************************************/
642 /* newnoise: panel(s) for musgrave types */
643 /*****************************************/
645 static void texture_panel_musgrave(Tex
*tex
)
650 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_musgrave", UI_EMBOSS
, UI_HELV
, curarea
->win
);
651 if(uiNewPanel(curarea
, block
, "Musgrave", "Texture", 640, 0, 318, 204)==0) return;
652 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
654 str
= "Multifractal %x0|Ridged Multifractal %x1|Hybrid Multifractal %x2|Hetero Terrain %x4|fBm %x3";
655 uiDefButS(block
, MENU
, B_TEXREDR_PRV
, str
, 10, 160, 150, 19, &tex
->stype
, 0.0, 0.0, 0, 0, "Sets Musgrave type");
657 uiBlockBeginAlign(block
);
658 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "H: ", 10, 130, 150, 19, &tex
->mg_H
, 0.0001, 2.0, 10, 0, "Sets the highest fractal dimension");
659 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "Lacu: ", 160, 130, 150, 19, &tex
->mg_lacunarity
, 0.0, 6.0, 10, 0, "Sets the gap between succesive frequencies");
660 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "Octs: ", 10, 110, 150, 19, &tex
->mg_octaves
, 0.0, 8.0, 10, 0, "Sets the number of frequencies used");
661 if ((tex
->stype
==TEX_RIDGEDMF
) || (tex
->stype
==TEX_HYBRIDMF
) || (tex
->stype
==TEX_HTERRAIN
)) {
662 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "Ofst: ", 160, 110, 150, 19, &tex
->mg_offset
, 0.0, 6.0, 10, 0, "Sets the fractal offset");
663 if ((tex
->stype
==TEX_RIDGEDMF
) || (tex
->stype
==TEX_HYBRIDMF
))
664 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "Gain: ", 10, 90, 150, 19, &tex
->mg_gain
, 0.0, 6.0, 10, 0, "Sets the gain multiplier");
667 uiBlockBeginAlign(block
);
668 /* noise output scale */
669 uiDefButF(block
, NUM
, B_TEXPRV
, "iScale: ", 10, 60, 150, 19, &tex
->ns_outscale
, 0.0, 10.0, 10, 0, "Scales intensity output");
670 /* frequency scale */
671 uiDefButF(block
, NUM
, B_TEXPRV
, "NoiseSize: ", 160, 60, 150, 19, &tex
->noisesize
, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
672 uiBlockEndAlign(block
);
674 /* noisebasis menu */
675 uiDefBut(block
, LABEL
, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, "");
676 uiDefButS(block
, MENU
, B_TEXPRV
, noisebasis_menu(), 10, 10, 150, 19, &tex
->noisebasis
, 0,0,0,0, "Sets the noise basis used for turbulence");
677 uiDefButF(block
, NUM
, B_NOP
, "Nabla: ", 160, 10, 150, 19, &tex
->nabla
, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
682 static void texture_panel_distnoise(Tex
*tex
)
685 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_distnoise", UI_EMBOSS
, UI_HELV
, curarea
->win
);
686 if(uiNewPanel(curarea
, block
, "Distorted Noise", "Texture", 640, 0, 318, 204)==0) return;
687 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
689 uiBlockBeginAlign(block
);
690 /* distortion amount */
691 uiDefButF(block
, NUM
, B_TEXPRV
, "DistAmnt: ", 10, 130, 150, 19, &tex
->dist_amount
, 0.0, 10.0, 10, 0, "Sets amount of distortion");
692 /* frequency scale */
693 uiDefButF(block
, NUM
, B_TEXPRV
, "NoiseSize: ", 160, 130, 150, 19, &tex
->noisesize
, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
694 uiBlockEndAlign(block
);
696 uiDefBut(block
, LABEL
, 0, "Distortion Noise", 10, 100, 150, 19, 0, 0.0, 0.0, 0, 0, "");
697 uiDefBut(block
, LABEL
, 0, "Noise Basis", 160, 100, 150, 19, 0, 0.0, 0.0, 0, 0, "");
699 uiBlockBeginAlign(block
);
700 /* noisebasis used for the distortion */
701 uiDefButS(block
, MENU
, B_TEXPRV
, noisebasis_menu(), 10, 80, 150, 19, &tex
->noisebasis
, 0,0,0,0, "Sets the noise basis which does the distortion");
702 /* noisebasis to distort */
703 uiDefButS(block
, MENU
, B_TEXPRV
, noisebasis_menu(), 160, 80, 150, 19, &tex
->noisebasis2
, 0,0,0,0, "Sets the noise basis to distort");
704 uiBlockEndAlign(block
);
706 uiDefButF(block
, NUM
, B_NOP
, "Nabla: ", 10, 50, 150, 19, &tex
->nabla
, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
710 static void texture_panel_voronoi(Tex
*tex
)
714 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_voronoi", UI_EMBOSS
, UI_HELV
, curarea
->win
);
715 if(uiNewPanel(curarea
, block
, "Voronoi", "Texture", 640, 0, 318, 204)==0) return;
716 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
719 uiBlockBeginAlign(block
);
720 uiDefButS(block
, ROW
, B_TEXPRV
, "Int", 10, 180, 75, 18, &tex
->vn_coltype
, 1.0, 0.0, 0, 0, "Only calculate intensity");
721 uiDefButS(block
, ROW
, B_TEXPRV
, "Col1", 85, 180, 75, 18, &tex
->vn_coltype
, 1.0, 1.0, 0, 0, "Color cells by position");
722 uiDefButS(block
, ROW
, B_TEXPRV
, "Col2", 160, 180, 75, 18, &tex
->vn_coltype
, 1.0, 2.0, 0, 0, "Same as Col1 + outline based on F2-F1");
723 uiDefButS(block
, ROW
, B_TEXPRV
, "Col3", 235, 180, 75, 18, &tex
->vn_coltype
, 1.0, 3.0, 0, 0, "Same as Col2 * intensity");
724 uiBlockEndAlign(block
);
726 /* distance metric */
727 sprintf(dm_menu
, "Distance Metric %%t|Actual Distance %%x%d|Distance Squared %%x%d|Manhattan %%x%d|Chebychev %%x%d|Minkovsky 1/2 %%x%d|Minkovsky 4 %%x%d|Minkovsky %%x%d", TEX_DISTANCE
, TEX_DISTANCE_SQUARED
, TEX_MANHATTAN
, TEX_CHEBYCHEV
, TEX_MINKOVSKY_HALF
, TEX_MINKOVSKY_FOUR
, TEX_MINKOVSKY
);
728 uiDefBut(block
, LABEL
, B_TEXPRV
, "Distance Metric", 10, 160, 150, 19, 0, 0, 0, 0, 0, "");
729 uiDefButS(block
, MENU
, B_TEXPRV
, dm_menu
, 10, 140, 150, 19, &tex
->vn_distm
, 0,0,0,0, "Sets the distance metric to be used");
731 if (tex
->vn_distm
==TEX_MINKOVSKY
)
732 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "Exp: ", 10, 120, 150, 19, &tex
->vn_mexp
, 0.01, 10.0, 10, 0, "Sets minkovsky exponent");
734 uiBlockBeginAlign(block
);
735 uiDefButF(block
, NUM
, B_TEXPRV
, "iScale: ", 160, 140, 150, 19, &tex
->ns_outscale
, 0.01, 10.0, 10, 0, "Scales intensity output");
736 uiDefButF(block
, NUM
, B_TEXPRV
, "Size: ", 160, 120, 150, 19, &tex
->noisesize
, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
737 uiBlockBeginAlign(block
);
738 uiDefButF(block
, NUM
, B_NOP
, "Nabla: ", 160, 70, 150, 19, &tex
->nabla
, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal");
741 uiBlockBeginAlign(block
);
742 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "W1: ", 10, 70, 150, 19, &tex
->vn_w1
, -2.0, 2.0, 10, 0, "Sets feature weight 1");
743 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "W2: ", 10, 50, 150, 19, &tex
->vn_w2
, -2.0, 2.0, 10, 0, "Sets feature weight 2");
744 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "W3: ", 10, 30, 150, 19, &tex
->vn_w3
, -2.0, 2.0, 10, 0, "Sets feature weight 3");
745 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "W4: ", 10, 10, 150, 19, &tex
->vn_w4
, -2.0, 2.0, 10, 0, "Sets feature weight 4");
749 static char *layer_menu(RenderResult
*rr
, short *curlay
)
752 int len
= 64 + 32*BLI_countlist(&rr
->layers
);
754 char *str
= MEM_callocN(len
, "menu layers");
756 strcpy(str
, "Layer %t");
761 a
+= sprintf(str
+a
, "|Composite %%x0");
764 for(rl
= rr
->layers
.first
; rl
; rl
= rl
->next
, nr
++) {
765 a
+= sprintf(str
+a
, "|%s %%x%d", rl
->name
, nr
);
768 /* no curlay clip here, on render (redraws) the amount of layers can be 1 fir single-layer render */
773 /* rl==NULL means composite result */
774 static char *pass_menu(RenderLayer
*rl
, short *curpass
)
777 int len
= 64 + 32*(rl
?BLI_countlist(&rl
->passes
):1);
779 char *str
= MEM_callocN(len
, "menu layers");
781 strcpy(str
, "Pass %t");
784 /* rendered results don't have a Combined pass */
785 if(rl
==NULL
|| rl
->rectf
) {
786 a
+= sprintf(str
+a
, "|Combined %%x0");
791 for(rpass
= rl
->passes
.first
; rpass
; rpass
= rpass
->next
, nr
++)
792 a
+= sprintf(str
+a
, "|%s %%x%d", rpass
->name
, nr
);
800 static void set_frames_cb(void *ima_v
, void *iuser_v
)
803 ImageUser
*iuser
= iuser_v
;
806 iuser
->frames
= IMB_anim_get_duration(ima
->anim
);
807 BKE_image_user_calc_imanr(iuser
, G
.scene
->r
.cfra
, 0);
811 static void image_src_change_cb(void *ima_v
, void *iuser_v
)
813 BKE_image_signal(ima_v
, iuser_v
, IMA_SIGNAL_SRC_CHANGE
);
816 /* buttons have 2 arg callbacks, filewindow has 3 args... so thats why the wrapper below */
817 static void image_browse_cb1(char *unused
, void *ima_pp_v
, void *iuser_v
)
819 Image
**ima_pp
= (Image
**)ima_pp_v
;
820 ImageUser
*iuser
= iuser_v
;
825 if(iuser
->menunr
== -2) {
826 activate_databrowse_args(&ima
->id
, ID_IM
, 0, &iuser
->menunr
, image_browse_cb1
, ima_pp
, iuser
);
828 else if (iuser
->menunr
>0) {
829 Image
*newima
= (Image
*) BLI_findlink(&G
.main
->image
, iuser
->menunr
-1);
831 if (newima
&& newima
!=ima
) {
833 id_us_plus(&newima
->id
);
834 if(ima
) ima
->id
.us
--;
836 BKE_image_signal(newima
, iuser
, IMA_SIGNAL_USER_NEW_IMAGE
);
838 BIF_undo_push("Browse image");
844 static void image_browse_cb(void *ima_pp_v
, void *iuser_v
)
846 image_browse_cb1(NULL
, ima_pp_v
, iuser_v
);
849 static void image_reload_cb(void *ima_v
, void *iuser_v
)
852 BKE_image_signal(ima_v
, iuser_v
, IMA_SIGNAL_RELOAD
);
856 static void image_field_test(void *ima_v
, void *iuser_v
)
861 ImBuf
*ibuf
= BKE_image_get_ibuf(ima
, iuser_v
);
864 if( !(ima
->flag
& IMA_FIELDS
) && (ibuf
->flags
& IB_fields
) ) nr
= 1;
865 if( (ima
->flag
& IMA_FIELDS
) && !(ibuf
->flags
& IB_fields
) ) nr
= 1;
867 BKE_image_signal(ima
, iuser_v
, IMA_SIGNAL_FREE
);
873 static void image_unlink_cb(void *ima_pp_v
, void *unused
)
875 Image
**ima_pp
= (Image
**)ima_pp_v
;
877 if(ima_pp
&& *ima_pp
) {
884 static void image_load_fs_cb(void *ima_pp_v
, void *iuser_v
)
886 Image
**ima_pp
= (Image
**)ima_pp_v
;
890 if(ima_pp
==NULL
) return;
892 sa
= closest_bigger_area();
894 if(*ima_pp
) name
= (*ima_pp
)->name
;
897 if (strcmp (U
.textudir
, "/") == 0)
903 else name
= U
.textudir
;
905 activate_fileselect_args(FILE_SPECIAL
, "SELECT IMAGE", name
, load_image_cb
, ima_pp_v
, iuser_v
);
908 /* 5 layer button callbacks... */
909 static void image_multi_cb(void *rr_v
, void *iuser_v
)
911 BKE_image_multilayer_index(rr_v
, iuser_v
);
913 static void image_multi_inclay_cb(void *rr_v
, void *iuser_v
)
915 RenderResult
*rr
= rr_v
;
916 ImageUser
*iuser
= iuser_v
;
917 int tot
= BLI_countlist(&rr
->layers
) + (rr
->rectf
?1:0); /* fake compo result layer */
918 if(iuser
->layer
<tot
-1)
920 BKE_image_multilayer_index(rr
, iuser
);
922 static void image_multi_declay_cb(void *rr_v
, void *iuser_v
)
924 ImageUser
*iuser
= iuser_v
;
927 BKE_image_multilayer_index(rr_v
, iuser
);
929 static void image_multi_incpass_cb(void *rr_v
, void *iuser_v
)
931 RenderResult
*rr
= rr_v
;
932 ImageUser
*iuser
= iuser_v
;
933 RenderLayer
*rl
= BLI_findlink(&rr
->layers
, iuser
->layer
);
935 int tot
= BLI_countlist(&rl
->passes
) + (rl
->rectf
?1:0); /* builtin render result has no combined pass in list */
936 if(iuser
->pass
<tot
-1) {
938 BKE_image_multilayer_index(rr
, iuser
);
942 static void image_multi_decpass_cb(void *rr_v
, void *iuser_v
)
944 ImageUser
*iuser
= iuser_v
;
947 BKE_image_multilayer_index(rr_v
, iuser
);
951 static void image_pack_cb(void *ima_v
, void *iuser_v
)
955 if(ima
->source
!=IMA_SRC_SEQUENCE
&& ima
->source
!=IMA_SRC_MOVIE
) {
956 if (ima
->packedfile
) {
957 if (G
.fileflags
& G_AUTOPACK
) {
958 if (okee("Disable AutoPack ?")) {
959 G
.fileflags
&= ~G_AUTOPACK
;
963 if ((G
.fileflags
& G_AUTOPACK
) == 0) {
964 unpackImage(ima
, PF_ASK
);
965 BIF_undo_push("Unpack image");
969 ImBuf
*ibuf
= BKE_image_get_ibuf(ima
, iuser_v
);
970 if (ibuf
&& (ibuf
->userflags
& IB_BITMAPDIRTY
)) {
971 error("Can't pack painted image. Save image or use Repack as PNG.");
973 ima
->packedfile
= newPackedFile(ima
->name
);
974 BIF_undo_push("Pack image");
981 static void image_load_cb(void *ima_pp_v
, void *iuser_v
)
984 Image
*ima
= *((Image
**)ima_pp_v
);
985 ImBuf
*ibuf
= BKE_image_get_ibuf(ima
, iuser_v
);
988 /* name in ima has been changed by button! */
989 BLI_strncpy(str
, ima
->name
, FILE_MAX
);
990 if(ibuf
) BLI_strncpy(ima
->name
, ibuf
->name
, FILE_MAX
);
992 load_image_cb(str
, ima_pp_v
, iuser_v
);
996 static void image_freecache_cb(void *ima_v
, void *unused
)
998 BKE_image_free_anim_ibufs(ima_v
, G
.scene
->r
.cfra
);
999 allqueue(REDRAWIMAGE
, 0);
1002 static void image_generated_change_cb(void *ima_v
, void *iuser_v
)
1004 BKE_image_signal(ima_v
, iuser_v
, IMA_SIGNAL_FREE
);
1007 static void image_user_change(void *iuser_v
, void *unused
)
1009 BKE_image_user_calc_imanr(iuser_v
, G
.scene
->r
.cfra
, 0);
1012 void uiblock_layer_pass_buttons(uiBlock
*block
, RenderResult
*rr
, ImageUser
*iuser
, int event
, int x
, int y
, int w
)
1015 RenderLayer
*rl
= NULL
;
1019 /* layer menu is 1/3 larger than pass */
1024 strp
= layer_menu(rr
, &iuser
->layer
);
1025 but
= uiDefButS(block
, MENU
, event
, strp
, x
, y
, wmenu1
, 20, &iuser
->layer
, 0,0,0,0, "Select Layer");
1026 uiButSetFunc(but
, image_multi_cb
, rr
, iuser
);
1029 rl
= BLI_findlink(&rr
->layers
, iuser
->layer
- (rr
->rectf
?1:0)); /* fake compo layer, return NULL is meant to be */
1030 strp
= pass_menu(rl
, &iuser
->pass
);
1031 but
= uiDefButS(block
, MENU
, event
, strp
, x
+wmenu1
, y
, wmenu2
, 20, &iuser
->pass
, 0,0,0,0, "Select Pass");
1032 uiButSetFunc(but
, image_multi_cb
, rr
, iuser
);
1036 static void uiblock_layer_pass_arrow_buttons(uiBlock
*block
, RenderResult
*rr
, ImageUser
*iuser
, int imagechanged
)
1040 if(rr
==NULL
|| iuser
==NULL
)
1042 if(rr
->layers
.first
==NULL
) {
1043 uiDefBut(block
, LABEL
, 0, "No Layers in Render Result,", 10, 107, 300, 20, NULL
, 1, 0, 0, 0, "");
1047 uiBlockBeginAlign(block
);
1049 /* decrease, increase arrows */
1050 but
= uiDefIconBut(block
, BUT
, imagechanged
, ICON_TRIA_LEFT
, 10,107,17,20, NULL
, 0, 0, 0, 0, "Previous Layer");
1051 uiButSetFunc(but
, image_multi_declay_cb
, rr
, iuser
);
1052 but
= uiDefIconBut(block
, BUT
, imagechanged
, ICON_TRIA_RIGHT
, 27,107,18,20, NULL
, 0, 0, 0, 0, "Next Layer");
1053 uiButSetFunc(but
, image_multi_inclay_cb
, rr
, iuser
);
1055 uiblock_layer_pass_buttons(block
, rr
, iuser
, imagechanged
, 45, 107, 230);
1057 /* decrease, increase arrows */
1058 but
= uiDefIconBut(block
, BUT
, imagechanged
, ICON_TRIA_LEFT
, 275,107,17,20, NULL
, 0, 0, 0, 0, "Previous Pass");
1059 uiButSetFunc(but
, image_multi_decpass_cb
, rr
, iuser
);
1060 but
= uiDefIconBut(block
, BUT
, imagechanged
, ICON_TRIA_RIGHT
, 292,107,18,20, NULL
, 0, 0, 0, 0, "Next Pass");
1061 uiButSetFunc(but
, image_multi_incpass_cb
, rr
, iuser
);
1063 uiBlockEndAlign(block
);
1067 /* The general Image panel with the loadsa callbacks! */
1068 void uiblock_image_panel(uiBlock
*block
, Image
**ima_pp
, ImageUser
*iuser
,
1069 short redraw
, short imagechanged
)
1071 Image
*ima
= *ima_pp
;
1073 char str
[128], *strp
;
1075 /* different stuff when we show viewer */
1076 if(ima
&& ima
->source
==IMA_SRC_VIEWER
) {
1077 ImBuf
*ibuf
= BKE_image_get_ibuf(ima
, iuser
);
1079 image_info(ima
, ibuf
, str
);
1080 uiDefBut(block
, LABEL
, 0, ima
->id
.name
+2, 10, 180, 300, 20, NULL
, 1, 0, 0, 0, "");
1081 uiDefBut(block
, LABEL
, 0, str
, 10, 160, 300, 20, NULL
, 1, 0, 0, 0, "");
1083 if(ima
->type
==IMA_TYPE_COMPOSITE
) {
1084 iuser
= ntree_get_active_iuser(G
.scene
->nodetree
);
1086 uiBlockBeginAlign(block
);
1087 uiDefIconTextBut(block
, BUT
, B_SIMA_RECORD
, ICON_REC
, "Record", 10,120,100,20, 0, 0, 0, 0, 0, "");
1088 uiDefIconTextBut(block
, BUT
, B_SIMA_PLAY
, ICON_PLAY
, "Play", 110,120,100,20, 0, 0, 0, 0, 0, "");
1089 but
= uiDefBut(block
, BUT
, B_NOP
, "Free Cache", 210,120,100,20, 0, 0, 0, 0, 0, "");
1090 uiButSetFunc(but
, image_freecache_cb
, ima
, NULL
);
1093 sprintf(str
, "(%d) Frames:", iuser
->framenr
);
1094 else strcpy(str
, "Frames:");
1095 uiBlockBeginAlign(block
);
1096 uiDefButI(block
, NUM
, imagechanged
, str
, 10, 90,150, 20, &iuser
->frames
, 0.0, MAXFRAMEF
, 0, 0, "Sets the number of images of a movie to use");
1097 uiDefButI(block
, NUM
, imagechanged
, "StartFr:", 160,90,150,20, &iuser
->sfra
, 1.0, MAXFRAMEF
, 0, 0, "Sets the global starting frame of the movie");
1100 else if(ima
->type
==IMA_TYPE_R_RESULT
) {
1101 /* browse layer/passes */
1102 uiblock_layer_pass_arrow_buttons(block
, RE_GetResult(RE_GetRender(G
.scene
->id
.name
)), iuser
, imagechanged
);
1107 /* the main ima source types */
1109 uiSetButLock(ima
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
1110 uiBlockBeginAlign(block
);
1111 uiBlockSetFunc(block
, image_src_change_cb
, ima
, iuser
);
1112 uiDefButS(block
, ROW
, imagechanged
, "Still", 10, 180, 60, 20, &ima
->source
, 0.0, IMA_SRC_FILE
, 0, 0, "Single Image file");
1113 uiDefButS(block
, ROW
, imagechanged
, "Movie", 70, 180, 60, 20, &ima
->source
, 0.0, IMA_SRC_MOVIE
, 0, 0, "Movie file");
1114 uiDefButS(block
, ROW
, imagechanged
, "Sequence", 130, 180, 90, 20, &ima
->source
, 0.0, IMA_SRC_SEQUENCE
, 0, 0, "Multiple Image files, as a sequence");
1115 uiDefButS(block
, ROW
, imagechanged
, "Generated", 220, 180, 90, 20, &ima
->source
, 0.0, IMA_SRC_GENERATED
, 0, 0, "Generated Image");
1116 uiBlockSetFunc(block
, NULL
, NULL
, NULL
);
1119 uiDefBut(block
, LABEL
, 0, " ", 10, 180, 300, 20, 0, 0, 0, 0, 0, ""); /* for align in panel */
1122 IMAnames_to_pupstring(&strp
, NULL
, NULL
, &(G
.main
->image
), NULL
, &iuser
->menunr
);
1124 uiBlockBeginAlign(block
);
1125 but
= uiDefButS(block
, MENU
, imagechanged
, strp
, 10,155,23,20, &iuser
->menunr
, 0, 0, 0, 0, "Selects an existing Image or Movie");
1126 uiButSetFunc(but
, image_browse_cb
, ima_pp
, iuser
);
1130 /* name + options, or only load */
1132 int drawpack
= (ima
->source
!=IMA_SRC_SEQUENCE
&& ima
->source
!=IMA_SRC_MOVIE
&& ima
->ok
);
1134 but
= uiDefBut(block
, TEX
, B_IDNAME
, "IM:", 33, 155, 177, 20, ima
->id
.name
+2, 0.0, 21.0, 0, 0, "Current Image Datablock name.");
1135 uiButSetFunc(but
, test_idbutton_cb
, ima
->id
.name
, NULL
);
1136 but
= uiDefBut(block
, BUT
, imagechanged
, "Reload", 210, 155, 60, 20, NULL
, 0, 0, 0, 0, "Reloads Image or Movie");
1137 uiButSetFunc(but
, image_reload_cb
, ima
, iuser
);
1139 but
= uiDefIconBut(block
, BUT
, imagechanged
, ICON_X
, 270,155,20,20, 0, 0, 0, 0, 0, "Unlink Image block");
1140 uiButSetFunc(but
, image_unlink_cb
, ima_pp
, NULL
);
1141 sprintf(str
, "%d", ima
->id
.us
);
1142 uiDefBut(block
, BUT
, B_NOP
, str
, 290,155,20,20, 0, 0, 0, 0, 0, "Only displays number of users of Image block");
1144 but
= uiDefIconBut(block
, BUT
, imagechanged
, ICON_FILESEL
, 10, 135, 23, 20, 0, 0, 0, 0, 0, "Open Fileselect to load new Image");
1145 uiButSetFunc(but
, image_load_fs_cb
, ima_pp
, iuser
);
1146 but
= uiDefBut(block
, TEX
, imagechanged
, "", 33,135,257+(drawpack
?0:20),20, ima
->name
, 0.0, 239.0, 0, 0, "Image/Movie file name, change to load new");
1147 uiButSetFunc(but
, image_load_cb
, ima_pp
, iuser
);
1150 if (ima
->packedfile
) packdummy
= 1;
1152 but
= uiDefIconButBitI(block
, TOG
, 1, redraw
, ICON_PACKAGE
, 290,135,20,20, &packdummy
, 0, 0, 0, 0, "Toggles Packed status of this Image");
1153 uiButSetFunc(but
, image_pack_cb
, ima
, iuser
);
1158 but
= uiDefBut(block
, BUT
, imagechanged
, "Load", 33, 155, 100,20, NULL
, 0, 0, 0, 0, "Load new Image of Movie");
1159 uiButSetFunc(but
, image_load_fs_cb
, ima_pp
, iuser
);
1161 uiBlockEndAlign(block
);
1164 ImBuf
*ibuf
= BKE_image_get_ibuf(ima
, iuser
);
1166 /* check for re-render, only buttons */
1167 if(imagechanged
==B_IMAGECHANGED
) {
1168 if(iuser
->flag
& IMA_ANIM_REFRESHED
) {
1169 iuser
->flag
&= ~IMA_ANIM_REFRESHED
;
1170 BIF_preview_changed(ID_TE
);
1175 if(ima
->type
==IMA_TYPE_MULTILAYER
&& ima
->rr
) {
1176 uiblock_layer_pass_arrow_buttons(block
, ima
->rr
, iuser
, imagechanged
);
1179 image_info(ima
, ibuf
, str
);
1180 uiDefBut(block
, LABEL
, 0, str
, 10, 107, 300, 20, NULL
, 1, 0, 0, 0, "");
1183 /* exception, let's do because we only use this panel 3 times in blender... but not real good code! */
1184 if( (G
.f
& G_FACESELECT
) && G
.sima
&& &G
.sima
->iuser
==iuser
)
1186 /* left side default per-image options, right half the additional options */
1189 uiBlockBeginAlign(block
);
1190 but
= uiDefButBitS(block
, TOG
, IMA_FIELDS
, imagechanged
, "Fields", 10, 70, 100, 20, &ima
->flag
, 0, 0, 0, 0, "Click to enable use of fields in Image");
1191 uiButSetFunc(but
, image_field_test
, ima
, iuser
);
1192 uiDefButBitS(block
, TOG
, IMA_STD_FIELD
, B_NOP
, "Odd", 10, 50, 100, 20, &ima
->flag
, 0, 0, 0, 0, "Standard Field Toggle");
1193 uiBlockEndAlign(block
);
1195 uiBlockBeginAlign(block
);
1196 uiBlockSetFunc(block
, image_reload_cb
, ima
, iuser
);
1197 uiDefButBitS(block
, TOG
, IMA_ANTIALI
, B_NOP
, "Anti", 10, 10, 100, 20, &ima
->flag
, 0, 0, 0, 0, "Toggles Image anti-aliasing, only works with solid colors");
1198 uiDefButBitS(block
, TOG
, IMA_DO_PREMUL
, imagechanged
, "Premul", 110, 10, 100, 20, &ima
->flag
, 0, 0, 0, 0, "Toggles premultiplying alpha");
1199 uiBlockEndAlign(block
);
1201 if( ELEM(ima
->source
, IMA_SRC_MOVIE
, IMA_SRC_SEQUENCE
)) {
1202 sprintf(str
, "(%d) Frames:", iuser
->framenr
);
1204 uiBlockBeginAlign(block
);
1205 uiBlockSetFunc(block
, image_user_change
, iuser
, NULL
);
1206 uiDefButBitS(block
, TOG
, IMA_ANIM_ALWAYS
, B_NOP
, "Auto Refresh", 120, 70, 190, 20, &iuser
->flag
, 0, 0, 0, 0, "Always refresh Image on frame changes");
1209 uiDefButI(block
, NUM
, imagechanged
, str
, 120, 50,170, 20, &iuser
->frames
, 0.0, MAXFRAMEF
, 0, 0, "Sets the number of images of a movie to use");
1210 but
= uiDefBut(block
, BUT
, redraw
, "<", 290, 50, 20, 20, 0, 0, 0, 0, 0, "Copies number of frames in movie file to Frames: button");
1211 uiButSetFunc(but
, set_frames_cb
, ima
, iuser
);
1214 uiDefButI(block
, NUM
, imagechanged
, str
, 120, 50,190, 20, &iuser
->frames
, 0.0, MAXFRAMEF
, 0, 0, "Sets the number of images of a movie to use");
1216 uiDefButI(block
, NUM
, imagechanged
, "Offs:", 120,30,100,20, &iuser
->offset
, -MAXFRAMEF
, MAXFRAMEF
, 0, 0, "Offsets the number of the frame to use in the animation");
1217 uiDefButS(block
, NUM
, imagechanged
, "Fie/Ima:", 220,30,90,20, &iuser
->fie_ima
, 1.0, 200.0, 0, 0, "The number of fields per rendered frame (2 fields is 1 image)");
1219 uiDefButI(block
, NUM
, imagechanged
, "StartFr:", 120,10,100,20, &iuser
->sfra
, 1.0, MAXFRAMEF
, 0, 0, "Sets the global starting frame of the movie");
1220 uiDefButS(block
, TOG
, imagechanged
, "Cyclic", 220,10,90,20, &iuser
->cycl
, 0.0, 1.0, 0, 0, "Cycle the images in the movie");
1222 uiBlockSetFunc(block
, NULL
, iuser
, NULL
);
1224 else if(ima
->source
==IMA_SRC_GENERATED
) {
1226 uiBlockBeginAlign(block
);
1227 uiBlockSetFunc(block
, image_generated_change_cb
, ima
, iuser
);
1228 uiDefButS(block
, NUM
, imagechanged
, "SizeX:", 120,70,100,20, &ima
->gen_x
, 1.0, 5000.0, 0, 0, "Image size x");
1229 uiDefButS(block
, NUM
, imagechanged
, "SizeY:", 220,70,90,20, &ima
->gen_y
, 1.0, 5000.0, 0, 0, "Image size y");
1230 uiDefButS(block
, TOG
, imagechanged
, "UV Test grid",120,50,190,20, &ima
->gen_type
, 0.0, 1.0, 0, 0, "");
1231 uiBlockSetFunc(block
, NULL
, NULL
, NULL
);
1237 static void texture_panel_image(Image
**ima
, ImageUser
*iuser
)
1241 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_image", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1242 if(uiNewPanel(curarea
, block
, "Image", "Texture", 960, 0, 318, 204)==0) return;
1244 uiblock_image_panel(block
, ima
, iuser
, B_REDR
, B_IMAGECHANGED
);
1247 static void texture_panel_image_map(Tex
*tex
)
1251 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_image_map", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1252 if(uiNewPanel(curarea
, block
, "Map Image", "Texture", 640, 0, 318, 204)==0) return;
1253 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
1256 uiBlockBeginAlign(block
);
1257 uiDefButBitS(block
, TOG
, TEX_MIPMAP
, B_IMAGECHANGED
, "MipMap", 10, 180, 75, 20, &tex
->imaflag
, 0, 0, 0, 0, "Generates and uses mipmaps");
1258 uiDefButBitS(block
, TOG
, TEX_GAUSS_MIP
, 0, "Gauss", 85, 180, 75, 20, &tex
->imaflag
, 0, 0, 0, 0, "Enable Gauss filter to sample down mipmaps");
1259 uiDefButBitS(block
, TOG
, TEX_INTERPOL
, 0, "Interpol", 160, 180, 75, 20, &tex
->imaflag
, 0, 0, 0, 0, "Interpolates pixels using Area filter");
1260 uiDefButBitS(block
, TOG
, TEX_IMAROT
, B_TEXPRV
, "Rot90", 235, 180, 75, 20, &tex
->imaflag
, 0, 0, 0, 0, "Actually flips X and Y for rendering, rotates and mirrors");
1262 uiDefButBitS(block
, TOG
, TEX_USEALPHA
, B_TEXPRV
, "UseAlpha", 10, 160, 100, 20, &tex
->imaflag
, 0, 0, 0, 0, "Click to use Image's alpha channel");
1263 uiDefButBitS(block
, TOG
, TEX_CALCALPHA
, B_TEXPRV
, "CalcAlpha", 110, 160, 100, 20, &tex
->imaflag
, 0, 0, 0, 0, "Click to calculate an alpha channel based on Image RGB values");
1264 uiDefButBitS(block
, TOG
, TEX_NEGALPHA
, B_TEXPRV
, "NegAlpha", 210, 160, 100, 20, &tex
->flag
, 0, 0, 0, 0, "Click to invert the alpha values");
1266 uiBlockBeginAlign(block
);
1267 uiDefButBitS(block
, TOG
, TEX_FILTER_MIN
, B_TEXPRV
, "Min", 10, 120, 30, 20, &tex
->imaflag
, 0, 0, 0, 0, "Use Filtersize as a minimal filter value in pixels");
1268 uiDefButF(block
, NUM
, B_TEXPRV
, "Filter: ", 40,120,120,20, &tex
->filtersize
, 0.1, 50.0, 10, 3, "Multiplies the filter size used by mipmap and interpol");
1270 uiDefButBitS(block
, TOG
, TEX_NORMALMAP
, B_NOP
, "Normal Map", 160,120,150,20, &tex
->imaflag
,
1271 0, 0, 0, 0, "Use image RGB values for normal mapping");
1273 /* crop extend clip */
1275 uiBlockBeginAlign(block
);
1276 uiDefButS(block
, ROW
, B_TEXREDR_PRV
, "Extend", 10,90,63,19, &tex
->extend
, 4.0, 1.0, 0, 0, "Extends the color of the edge pixels");
1277 uiDefButS(block
, ROW
, B_TEXREDR_PRV
, "Clip", 73,90,48,19, &tex
->extend
, 4.0, 2.0, 0, 0, "Sets alpha 0.0 outside Image edges");
1278 uiDefButS(block
, ROW
, B_TEXREDR_PRV
, "ClipCube", 121,90,63,19, &tex
->extend
, 4.0, 4.0, 0, 0, "Sets alpha to 0.0 outside cubeshaped area around Image");
1279 uiDefButS(block
, ROW
, B_TEXREDR_PRV
, "Repeat", 184,90,63,19, &tex
->extend
, 4.0, 3.0, 0, 0, "Causes Image to repeat horizontally and vertically");
1280 uiDefButS(block
, ROW
, B_TEXREDR_PRV
, "Checker", 247,90,63,19, &tex
->extend
, 4.0, 5.0, 0, 0, "Causes Image to repeat in checker pattern");
1282 if(tex
->extend
==TEX_REPEAT
) {
1283 uiBlockBeginAlign(block
);
1284 uiDefButBitS(block
, TOG
, TEX_REPEAT_XMIR
, B_TEXPRV
, "Mirr", 10,60,30,19, &tex
->flag
, 0.0, 0.0, 0, 0, "Mirrors X direction repeat");
1285 uiDefButS(block
, NUM
, B_TEXPRV
, "Xrepeat:", 40,60,120,19, &tex
->xrepeat
, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the X direction");
1286 uiDefButBitS(block
, TOG
, TEX_REPEAT_YMIR
, B_TEXPRV
, "Mirr", 160,60,30,19, &tex
->flag
, 0.0, 0.0, 0, 0, "Mirrors Y direction repeat");
1287 uiDefButS(block
, NUM
, B_TEXPRV
, "Yrepeat:", 190,60,120,19, &tex
->yrepeat
, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the Y direction");
1289 else if(tex
->extend
==TEX_CHECKER
) {
1290 uiBlockBeginAlign(block
);
1291 uiDefButBitS(block
, TOG
, TEX_CHECKER_ODD
, B_TEXPRV
, "Odd", 10,60,100,19, &tex
->flag
, 0.0, 0.0, 0, 0, "Sets odd checker tiles");
1292 uiDefButBitS(block
, TOG
, TEX_CHECKER_EVEN
, B_TEXPRV
, "Even", 110,60,100,19, &tex
->flag
, 0.0, 0.0, 0, 0, "Sets even checker tiles");
1293 uiDefButF(block
, NUM
, B_TEXPRV
, "Mortar:", 210,60,100,19, &tex
->checkerdist
, 0.0, 0.99, 0, 0, "Set checkers distance (like mortar)");
1295 uiBlockBeginAlign(block
);
1296 uiDefButF(block
, NUM
, B_TEXPRV
, "MinX ", 10,30,150,19, &tex
->cropxmin
, -10.0, 10.0, 10, 0, "Sets minimum X value to crop Image");
1297 uiDefButF(block
, NUM
, B_TEXPRV
, "MinY ", 10,10,150,19, &tex
->cropymin
, -10.0, 10.0, 10, 0, "Sets minimum Y value to crop Image");
1299 uiBlockBeginAlign(block
);
1300 uiDefButF(block
, NUM
, B_TEXPRV
, "MaxX ", 160,30,150,19, &tex
->cropxmax
, -10.0, 10.0, 10, 0, "Sets maximum X value to crop Image");
1301 uiDefButF(block
, NUM
, B_TEXPRV
, "MaxY ", 160,10,150,19, &tex
->cropymax
, -10.0, 10.0, 10, 0, "Sets maximum Y value to crop Image");
1302 uiBlockEndAlign(block
);
1306 /***************************************/
1308 static void texture_panel_envmap(Tex
*tex
)
1314 short a
, xco
, yco
, dx
, dy
;
1315 char *strp
, str
[32];
1317 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_envmap", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1318 if(uiNewPanel(curarea
, block
, "Envmap", "Texture", 640, 0, 318, 204)==0) return;
1319 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
1321 if(tex
->env
==NULL
) {
1322 tex
->env
= BKE_add_envmap();
1323 tex
->env
->object
= OBACT
;
1328 uiBlockBeginAlign(block
);
1329 uiDefButS(block
, ROW
, B_REDR
, "Static", 10, 180, 100, 19, &env
->stype
, 2.0, 0.0, 0, 0, "Calculates environment map only once");
1330 uiDefButS(block
, ROW
, B_REDR
, "Anim", 110, 180, 100, 19, &env
->stype
, 2.0, 1.0, 0, 0, "Calculates environment map at each rendering");
1331 uiDefButS(block
, ROW
, B_ENV_FREE
, "Load", 210, 180, 100, 19, &env
->stype
, 2.0, 2.0, 0, 0, "Loads saved environment map from disk");
1332 uiBlockEndAlign(block
);
1334 if(env
->stype
==ENV_LOAD
) {
1337 IMAnames_to_pupstring(&strp
, NULL
, NULL
, &(G
.main
->image
), id
, &(G
.buts
->menunr
));
1339 uiBlockBeginAlign(block
);
1341 but
= uiDefButS(block
, MENU
, B_TEXPRV
, strp
, 10,145,23,20, &tex
->iuser
.menunr
, 0, 0, 0, 0, "Selects an existing environment map");
1342 uiButSetFunc(but
, image_browse_cb
, &tex
->ima
, &tex
->iuser
);
1345 but
= uiDefBut(block
, TEX
, B_NAMEIMA
, "", 35,145,255,20, tex
->ima
->name
, 0.0, 79.0, 0, 0, "Displays environment map name: click to change");
1346 uiButSetFunc(but
, image_load_cb
, &tex
->ima
, &tex
->iuser
);
1348 sprintf(str
, "%d", tex
->ima
->id
.us
);
1349 uiDefBut(block
, BUT
, 0, str
, 290,145,20,20, 0, 0, 0, 0, 0, "Displays number of users of environment map: click to make single user");
1350 uiBlockEndAlign(block
);
1352 but
= uiDefBut(block
, BUT
, B_IMAGECHANGED
, "Reload", 230,125,80,20, 0, 0, 0, 0, 0, "Reloads saved environment map");
1353 uiButSetFunc(but
, image_reload_cb
, tex
->ima
, NULL
);
1355 if (tex
->ima
->packedfile
) packdummy
= 1;
1357 but
= uiDefIconButBitI(block
, TOG
, 1, B_REDR
, ICON_PACKAGE
, 205,125,24,20, &packdummy
, 0, 0, 0, 0, "Toggles Packed status of this environment map");
1358 uiButSetFunc(but
, image_pack_cb
, tex
->ima
, &tex
->iuser
);
1360 else uiBlockEndAlign(block
);
1364 but
= uiDefBut(block
, BUT
, B_IMAGECHANGED
, "Load Image", 10,125,150,20, 0, 0, 0, 0, 0, "Loads saved environment map - file select");
1365 uiButSetFunc(but
, image_load_fs_cb
, &tex
->ima
, &tex
->iuser
);
1368 uiBlockBeginAlign(block
);
1369 uiDefBut(block
, BUT
, B_ENV_FREE
, "Free Data", 10,145,100,20, 0, 0, 0, 0, 0, "Releases all images associated with this environment map");
1370 uiDefBut(block
, BUT
, B_ENV_SAVE
, "Save EnvMap", 110,145,100,20, 0, 0, 0, 0, 0, "Saves current environment map");
1371 uiDefBut(block
, BUT
, B_ENV_FREE_ALL
, "Free all EnvMaps", 210,145,100,20, 0, 0, 0, 0, 0, "Frees all rendered environment maps for all materials");
1373 uiBlockBeginAlign(block
);
1374 uiDefButS(block
, ROW
, B_NOP
, "Cube", 10,120,100,20, &env
->type
, 3.0f
, 0.0f
, 0, 0, "Use environment map with six cube sides");
1375 uiDefButS(block
, ROW
, B_NOP
, "Plane", 110,120,100,20, &env
->type
, 3.0f
, 1.0f
, 0, 0, "Only one side is rendered, with Z axis pointing in direction of image");
1376 uiDefButF(block
, NUM
, B_NOP
, "Zoom: ", 210,120,100,20, &env
->viewscale
, 0.5f
, 5.0f
, 100, 2, "Zoom factor for planar environment map");
1377 uiBlockEndAlign(block
);
1380 uiDefIDPoinBut(block
, test_obpoin_but
, ID_OB
, B_ENV_OB
, "Ob:", 10,90,150,20, &(env
->object
), "Displays object to use as viewpoint for environment map: click to change");
1381 if(env
->stype
!=ENV_LOAD
)
1382 uiDefButS(block
, NUM
, B_ENV_FREE
, "CubeRes", 160,90,150,20, &env
->cuberes
, 50, 4096.0, 0, 0, "Sets the pixel resolution of the rendered environment map");
1384 uiBlockBeginAlign(block
);
1385 uiDefButBitS(block
, TOG
, TEX_FILTER_MIN
, B_TEXPRV
, "Min", 10, 65, 30, 20, &tex
->imaflag
, 0, 0, 0, 0, "Use Filtersize as a minimal filter value in pixels");
1386 uiDefButF(block
, NUM
, B_TEXPRV
, "Filter :", 40,65,120,20, &tex
->filtersize
, 0.1, 25.0, 0, 3, "Adjusts sharpness or blurriness of the reflection"),
1387 uiDefButS(block
, NUM
, B_ENV_FREE
, "Depth:", 160,65,150,20, &env
->depth
, 0, 5.0, 0, 0, "Sets the number of times a map will be rendered recursively mirror effects"),
1388 uiDefButF(block
, NUM
, REDRAWVIEW3D
, "ClipSta", 10,40,150,20, &env
->clipsta
, 0.01, 50.0, 100, 0, "Sets start value for clipping: objects nearer than this are not visible to map");
1389 uiDefButF(block
, NUM
, B_NOP
, "ClipEnd", 160,40,150,20, &env
->clipend
, 0.1, 20000.0, 1000, 0, "Sets end value for clipping beyond which objects are not visible to map");
1390 uiBlockEndAlign(block
);
1392 uiDefBut(block
, LABEL
, 0, "Don't render layer:", 10,10,140,22, 0, 0.0, 0.0, 0, 0, "");
1398 uiBlockBeginAlign(block
);
1400 uiDefButBitI(block
, TOG
, 1<<a
, 0, "", (xco
+a
*(dx
/2)), (yco
+dy
/2), (dx
/2), (1+dy
/2), (int *)&env
->notlay
, 0, 0, 0, 0, "Toggles layer visibility to environment map");
1402 uiDefButBitI(block
, TOG
, 1<<(a
+10), 0, "",(xco
+a
*(dx
/2)), yco
, (dx
/2), (dy
/2), (int *)&env
->notlay
, 0, 0, 0, 0, "Toggles layer visibility to environment map");
1404 uiBlockBeginAlign(block
);
1407 uiDefButBitI(block
, TOG
, 1<<a
, 0, "", (xco
+a
*(dx
/2)), (yco
+dy
/2), (dx
/2), (1+dy
/2), (int *)&env
->notlay
, 0, 0, 0, 0, "Toggles layer visibility to environment map");
1409 uiDefButBitI(block
, TOG
, 1<<(a
+10), 0, "",(xco
+a
*(dx
/2)), yco
, (dx
/2), (dy
/2), (int *)&env
->notlay
, 0, 0, 0, 0, "Toggles layer visibility to environment map");
1414 static void colorband_pos_cb(void *coba_v
, void *unused_v
)
1416 ColorBand
*coba
= coba_v
;
1419 if(coba
->tot
<2) return;
1421 for(a
=0; a
<coba
->tot
; a
++) coba
->data
[a
].cur
= a
;
1422 qsort(coba
->data
, coba
->tot
, sizeof(CBData
), vergcband
);
1423 for(a
=0; a
<coba
->tot
; a
++) {
1424 if(coba
->data
[a
].cur
==coba
->cur
) {
1425 if(coba
->cur
!=a
) addqueue(curarea
->win
, REDRAW
, 0); /* button cur */
1432 static void colorband_add_cb(void *coba_v
, void *unused_v
)
1434 ColorBand
*coba
= coba_v
;
1436 if(coba
->tot
< MAXCOLORBAND
-1) coba
->tot
++;
1437 coba
->cur
= coba
->tot
-1;
1439 colorband_pos_cb(coba
, NULL
);
1440 BIF_undo_push("Add colorband");
1444 static void colorband_del_cb(void *coba_v
, void *unused_v
)
1446 ColorBand
*coba
= coba_v
;
1449 if(coba
->tot
<2) return;
1451 for(a
=coba
->cur
; a
<coba
->tot
; a
++) {
1452 coba
->data
[a
]= coba
->data
[a
+1];
1454 if(coba
->cur
) coba
->cur
--;
1457 BIF_undo_push("Delete colorband");
1458 BIF_preview_changed(ID_TE
);
1462 /* offset aligns from bottom, standard width 300, height 115 */
1463 static void draw_colorband_buts(uiBlock
*block
, ColorBand
*coba
, int xoffs
, int yoffs
, int redraw
)
1468 if(coba
==NULL
) return;
1470 bt
= uiDefBut(block
, BUT
, redraw
, "Add", 80+xoffs
,95+yoffs
,37,20, 0, 0, 0, 0, 0, "Adds a new color position to the colorband");
1471 uiButSetFunc(bt
, colorband_add_cb
, coba
, NULL
);
1472 uiDefButS(block
, NUM
, redraw
, "Cur:", 117+xoffs
,95+yoffs
,81,20, &coba
->cur
, 0.0, (float)(coba
->tot
-1), 0, 0, "Displays the active color from the colorband");
1473 bt
= uiDefBut(block
, BUT
, redraw
, "Del", 199+xoffs
,95+yoffs
,37,20, 0, 0, 0, 0, 0, "Deletes the active position");
1474 uiButSetFunc(bt
, colorband_del_cb
, coba
, NULL
);
1475 uiDefButS(block
, ROW
, redraw
, "E", 236+xoffs
,95+yoffs
,16,20, &coba
->ipotype
, 5.0, 1.0, 0, 0, "Sets interpolation type 'Ease' (quadratic) ");
1476 uiDefButS(block
, ROW
, redraw
, "C", 252+xoffs
,95+yoffs
,16,20, &coba
->ipotype
, 5.0, 3.0, 0, 0, "Sets interpolation type Cardinal");
1477 uiDefButS(block
, ROW
, redraw
, "L", 268+xoffs
,95+yoffs
,16,20, &coba
->ipotype
, 5.0, 0.0, 0, 0, "Sets interpolation type Linear");
1478 uiDefButS(block
, ROW
, redraw
, "S", 284+xoffs
,95+yoffs
,16,20, &coba
->ipotype
, 5.0, 2.0, 0, 0, "Sets interpolation type B-Spline");
1480 uiDefBut(block
, BUT_COLORBAND
, redraw
, "", xoffs
,65+yoffs
,300,30, coba
, 0, 0, 0, 0, "");
1482 cbd
= coba
->data
+ coba
->cur
;
1484 uiBlockBeginAlign(block
);
1485 bt
= uiDefButF(block
, NUM
, redraw
, "Pos", xoffs
,40+yoffs
,110,20, &cbd
->pos
, 0.0, 1.0, 10, 0, "Sets the position of the active color");
1486 uiButSetFunc(bt
, colorband_pos_cb
, coba
, NULL
);
1487 uiDefButF(block
, COL
, redraw
, "", xoffs
,20+yoffs
,110,20, &(cbd
->r
), 0, 0, 0, B_BANDCOL
, "");
1488 uiDefButF(block
, NUMSLI
, redraw
, "A ", xoffs
,yoffs
,110,20, &cbd
->a
, 0.0, 1.0, 10, 0, "Sets the alpha value for this position");
1490 uiBlockBeginAlign(block
);
1491 uiDefButF(block
, NUMSLI
, redraw
, "R ", 115+xoffs
,40+yoffs
,185,20, &cbd
->r
, 0.0, 1.0, B_BANDCOL
, 0, "Sets the red value for the active color");
1492 uiDefButF(block
, NUMSLI
, redraw
, "G ", 115+xoffs
,20+yoffs
,185,20, &cbd
->g
, 0.0, 1.0, B_BANDCOL
, 0, "Sets the green value for the active color");
1493 uiDefButF(block
, NUMSLI
, redraw
, "B ", 115+xoffs
,yoffs
,185,20, &cbd
->b
, 0.0, 1.0, B_BANDCOL
, 0, "Sets the blue value for the active color");
1494 uiBlockEndAlign(block
);
1497 void draw_colorband_buts_small(uiBlock
*block
, ColorBand
*coba
, rctf
*butr
, int event
)
1501 float unit
= (butr
->xmax
-butr
->xmin
)/14.0f
;
1502 float xs
= butr
->xmin
;
1504 cbd
= coba
->data
+ coba
->cur
;
1506 uiBlockBeginAlign(block
);
1507 uiDefButF(block
, COL
, event
, "", xs
,butr
->ymin
+20.0f
,2.0f
*unit
,20, &(cbd
->r
), 0, 0, 0, B_BANDCOL
, "");
1508 uiDefButF(block
, NUM
, event
, "A:", xs
+2.0f
*unit
,butr
->ymin
+20.0f
,4.0f
*unit
,20, &(cbd
->a
), 0.0f
, 1.0f
, 10, 2, "");
1509 bt
= uiDefBut(block
, BUT
, event
, "Add", xs
+6.0f
*unit
,butr
->ymin
+20.0f
,2.0f
*unit
,20, NULL
, 0, 0, 0, 0, "Adds a new color position to the colorband");
1510 uiButSetFunc(bt
, colorband_add_cb
, coba
, NULL
);
1511 bt
= uiDefBut(block
, BUT
, event
, "Del", xs
+8.0f
*unit
,butr
->ymin
+20.0f
,2.0f
*unit
,20, NULL
, 0, 0, 0, 0, "Deletes the active position");
1512 uiButSetFunc(bt
, colorband_del_cb
, coba
, NULL
);
1513 uiDefButS(block
, ROW
, event
, "E", xs
+10.0f
*unit
,butr
->ymin
+20.0f
,unit
,20, &coba
->ipotype
, 5.0, 1.0, 0, 0, "Sets interpolation type 'Ease' (quadratic) ");
1514 uiDefButS(block
, ROW
, event
, "C", xs
+11.0f
*unit
,butr
->ymin
+20.0f
,unit
,20, &coba
->ipotype
, 5.0, 3.0, 0, 0, "Sets interpolation type Cardinal");
1515 uiDefButS(block
, ROW
, event
, "L", xs
+12.0f
*unit
,butr
->ymin
+20.0f
,unit
,20, &coba
->ipotype
, 5.0, 0.0, 0, 0, "Sets interpolation type Linear");
1516 uiDefButS(block
, ROW
, event
, "S", xs
+13.0f
*unit
,butr
->ymin
+20.0f
,unit
,20, &coba
->ipotype
, 5.0, 2.0, 0, 0, "Sets interpolation type B-Spline");
1518 uiDefBut(block
, BUT_COLORBAND
, event
, "", xs
,butr
->ymin
,butr
->xmax
-butr
->xmin
,20.0f
, coba
, 0, 0, 0, 0, "");
1519 uiBlockEndAlign(block
);
1523 static void texture_panel_colors(Tex
*tex
)
1527 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_colors", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1528 uiNewPanelTabbed("Texture", "Texture");
1529 if(uiNewPanel(curarea
, block
, "Colors", "Texture", 1280, 0, 318, 204)==0) return;
1533 uiBlockBeginAlign(block
);
1534 uiDefButBitS(block
, TOG
, TEX_COLORBAND
, B_COLORBAND
, "Colorband",10,180,80,20, &tex
->flag
, 0, 0, 0, 0, "Toggles colorband operations");
1536 if(tex
->flag
& TEX_COLORBAND
) {
1537 draw_colorband_buts(block
, tex
->coba
, 10, 85, B_TEXREDR_PRV
);
1541 if((tex
->flag
& TEX_COLORBAND
)==0) {
1542 uiBlockBeginAlign(block
);
1543 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "R ", 60,80,200,20, &tex
->rfac
, 0.0, 2.0, 0, 0, "Changes the red value of the texture");
1544 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "G ", 60,60,200,20, &tex
->gfac
, 0.0, 2.0, 0, 0, "Changes the green value of the texture");
1545 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "B ", 60,40,200,20, &tex
->bfac
, 0.0, 2.0, 0, 0, "Changes the blue value of the texture");
1548 uiBlockBeginAlign(block
);
1549 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "Bright", 10,10,150,20, &tex
->bright
, 0.0, 2.0, 0, 0, "Changes the brightness of the color or intensity of a texture");
1550 uiDefButF(block
, NUMSLI
, B_TEXPRV
, "Contr", 160,10,150,20, &tex
->contrast
, 0.01, 5.0, 0, 0, "Changes the contrast of the color or intensity of a texture");
1554 static void texture_panel_texture(MTex
*mtex
, Material
*ma
, World
*wrld
, Lamp
*la
, bNode
*node
, Brush
*br
, SculptData
*sd
)
1558 ID
*id
=NULL
, *idfrom
;
1563 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_texture", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1564 if(uiNewPanel(curarea
, block
, "Texture", "Texture", 320, 0, 318, 204)==0) return;
1566 /* first do the browse but */
1568 id
= (ID
*)mtex
->tex
;
1572 if(ma
) idfrom
= &ma
->id
;
1573 else if(wrld
) idfrom
= &wrld
->id
;
1574 else if(la
) idfrom
= &la
->id
;
1575 else if(br
) idfrom
= &br
->id
;
1576 else if(sd
) idfrom
= NULL
; /* Not sure what this does */
1579 uiBlockSetCol(block
, TH_BUT_SETTING2
);
1581 std_libbuttons(block
, 10, 180, 0, NULL
, B_TEXBROWSE
, ID_TE
, 0, id
, idfrom
, &(G
.buts
->texnr
), B_TEXALONE
, B_TEXLOCAL
, B_TEXDELETE
, B_AUTOTEXNAME
, B_KEEPDATA
);
1584 std_libbuttons(block
, 10, 180, 0, NULL
, B_WTEXBROWSE
, ID_TE
, 0, id
, idfrom
, &(G
.buts
->texnr
), B_TEXALONE
, B_TEXLOCAL
, B_TEXDELETE
, B_AUTOTEXNAME
, B_KEEPDATA
);
1587 std_libbuttons(block
, 10, 180, 0, NULL
, B_LTEXBROWSE
, ID_TE
, 0, id
, idfrom
, &(G
.buts
->texnr
), B_TEXALONE
, B_TEXLOCAL
, B_TEXDELETE
, B_AUTOTEXNAME
, B_KEEPDATA
);
1590 std_libbuttons(block
, 10, 180, 0, NULL
, B_BTEXBROWSE
, ID_TE
, 0, id
, idfrom
, &(G
.buts
->menunr
), B_TEXALONE
, B_TEXLOCAL
, B_TEXDELETE
, B_AUTOTEXNAME
, B_KEEPDATA
);
1593 std_libbuttons(block
, 10, 180, 0, NULL
, B_SCULPT_TEXBROWSE
, ID_TE
, 0, id
, idfrom
, &(G
.buts
->texnr
), B_TEXALONE
, B_TEXLOCAL
, B_TEXDELETE
, B_AUTOTEXNAME
, B_KEEPDATA
);
1598 uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
1600 /* From button: removed */
1604 uiBlockBeginAlign(block
);
1606 for(a
= 0; a
<MAX_MTEX
; a
++) {
1608 if(ma
) mt
= ma
->mtex
[a
];
1609 else if(wrld
) mt
= wrld
->mtex
[a
];
1610 else if(la
) mt
= la
->mtex
[a
];
1611 else if(br
) mt
= br
->mtex
[a
];
1612 else if(sd
) mt
= sd
->mtex
[a
];
1614 if(mt
&& mt
->tex
) splitIDname(mt
->tex
->id
.name
+2, str
, &loos
);
1615 else strcpy(str
, "");
1619 uiDefButC(block
, ROW
, B_TEXCHANNEL
, str
, 10,yco
,140,19, &(ma
->texact
), 0.0, (float)a
, 0, 0, "Click to select texture channel");
1623 uiDefButS(block
, ROW
, B_TEXCHANNEL
, str
, 10,yco
,140,19, &(wrld
->texact
), 0.0, (float)a
, 0, 0, "");
1627 uiDefButS(block
, ROW
, B_TEXCHANNEL
, str
, 10,yco
,140,19, &(la
->texact
), 0.0, (float)a
, 0, 0, "");
1631 uiDefButS(block
, ROW
, B_TEXCHANNEL
, str
, 10,yco
,140,19, &(br
->texact
), 0.0, (float)a
, 0, 0, "");
1635 uiDefButS(block
, ROW
, B_TEXCHANNEL
, str
, 10,yco
,140,19, &(sd
->texact
), 0.0, (float)a
, 0, 0, "");
1639 uiBlockEndAlign(block
);
1641 uiBlockSetCol(block
, TH_AUTO
);
1646 Tex
*tex
= (Tex
*)id
;
1648 uiSetButLock(tex
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
1650 /* newnoise: all texture types as menu, not enough room for more buttons.
1651 * Can widen panel, but looks ugly when other panels overlap it */
1653 sprintf(textypes
, "Texture Type %%t|None %%x%d|Image %%x%d|EnvMap %%x%d|Clouds %%x%d|Marble %%x%d|Stucci %%x%d|Wood %%x%d|Magic %%x%d|Blend %%x%d|Noise %%x%d|Plugin %%x%d|Musgrave %%x%d|Voronoi %%x%d|DistortedNoise %%x%d|Clouds2 %%x%d", 0, TEX_IMAGE
, TEX_ENVMAP
, TEX_CLOUDS
, TEX_MARBLE
, TEX_STUCCI
, TEX_WOOD
, TEX_MAGIC
, TEX_BLEND
, TEX_NOISE
, TEX_PLUGIN
, TEX_MUSGRAVE
, TEX_VORONOI
, TEX_DISTNOISE
, TEX_CLOUDS2
);
1654 uiDefBut(block
, LABEL
, 0, "Texture Type", 160, 150, 140, 20, 0, 0.0, 0.0, 0, 0, "");
1655 uiDefButS(block
, MENU
, B_TEXTYPE
, textypes
, 160, 125, 140, 25, &tex
->type
, 0,0,0,0, "Select texture type");
1659 // label to avoid centering
1660 uiDefBut(block
, LABEL
, 0, " ", 160, 10, 140, 20, 0, 0, 0, 0, 0, "");
1664 static void texture_panel_preview(MTex
*mtex
, int preview
)
1668 block
= uiNewBlock(&curarea
->uiblocks
, "texture_panel_preview", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1669 if(uiNewPanel(curarea
, block
, "Preview", "Texture", 0, 0, 318, 204)==0) return;
1671 if(preview
) uiBlockSetDrawExtraFunc(block
, BIF_previewdraw
);
1673 // label to force a boundbox for buttons not to be centered
1674 uiDefBut(block
, LABEL
, 0, " ", 20,20,10,10, 0, 0, 0, 0, 0, "");
1676 uiBlockBeginAlign(block
);
1677 uiDefButC(block
, ROW
, B_TEXREDR_PRV
, "Mat", 200,175,80,25, &G
.buts
->texfrom
, 3.0, 0.0, 0, 0, "Displays the textures of the active material");
1678 uiDefButC(block
, ROW
, B_TEXREDR_PRV
, "World", 200,150,80,25, &G
.buts
->texfrom
, 3.0, 1.0, 0, 0, "Displays the textures of the world block");
1679 uiDefButC(block
, ROW
, B_TEXREDR_PRV
, "Lamp", 200,125,80,25, &G
.buts
->texfrom
, 3.0, 2.0, 0, 0, "Displays the textures of the selected lamp");
1680 uiDefButC(block
, ROW
, B_TEXREDR_PRV
, "Brush", 200,100,80,25, &G
.buts
->texfrom
, 3.0, 3.0, 0, 0, "Displays the textures of the selected brush");
1681 uiBlockEndAlign(block
);
1683 if(mtex
&& mtex
->tex
)
1684 uiDefButBitS(block
, TOG
, TEX_PRV_ALPHA
, B_TEXREDR_PRV
, "Alpha", 200,60,80,20, &mtex
->tex
->flag
, 0, 0, 0, 0, "Show alpha in preview");
1686 uiDefBut(block
, BUT
, B_DEFTEXVAR
, "Default Vars",200,10,80,20, 0, 0, 0, 0, 0, "Sets all values to defaults");
1692 /* *************************** RADIO ******************************** */
1694 void do_radiobuts(unsigned short event
)
1700 rad
= G
.scene
->radio
;
1705 BIF_undo_push("Add radiosity");
1706 allqueue(REDRAWBUTSSHADING
, 0);
1707 allqueue(REDRAWVIEW3D
, 0);
1711 BIF_undo_push("Delete radiosity");
1712 allqueue(REDRAWBUTSSHADING
, 0);
1713 allqueue(REDRAWVIEW3D
, 0);
1717 allqueue(REDRAWBUTSSHADING
, 0);
1718 allqueue(REDRAWVIEW3D
, 0);
1721 rad_collect_meshes();
1722 allqueue(REDRAWBUTSSHADING
, 0);
1723 allqueue(REDRAWVIEW3D
, 0);
1726 if(phase
==RAD_PHASE_PATCHES
) {
1727 rad_limit_subdivide();
1728 allqueue(REDRAWBUTSSHADING
, 0);
1729 allqueue(REDRAWVIEW3D
, 0);
1733 if(phase
==RAD_PHASE_PATCHES
) {
1735 rad_subdivshootpatch();
1736 allqueue(REDRAWBUTSSHADING
, 0);
1737 allqueue(REDRAWVIEW3D
, 0);
1742 if(phase
==RAD_PHASE_PATCHES
) {
1744 rad_subdivshootelem();
1745 allqueue(REDRAWBUTSSHADING
, 0);
1746 allqueue(REDRAWVIEW3D
, 0);
1751 if(phase
==RAD_PHASE_PATCHES
) {
1755 allqueue(REDRAWBUTSSHADING
, 0);
1756 allqueue(REDRAWVIEW3D
, 0);
1761 allqueue(REDRAWVIEW3D
, 0);
1762 allqueue(REDRAWBUTSSHADING
, 0);
1766 if(phase
& RAD_PHASE_FACES
) make_face_tab();
1767 else make_node_display(); /* radio solver also uses nodes, different ones :) */
1768 allqueue(REDRAWVIEW3D
, 0);
1771 if(phase
& RAD_PHASE_FACES
) {
1773 removeEqualNodes(rad
->nodelim
);
1775 allqueue(REDRAWVIEW3D
, 0);
1776 allqueue(REDRAWBUTSSHADING
, 0);
1779 case B_RAD_NODEFILT
:
1780 if(phase
& RAD_PHASE_FACES
) {
1784 allqueue(REDRAWVIEW3D
, 0);
1787 case B_RAD_FACEFILT
:
1788 if(phase
& RAD_PHASE_FACES
) {
1790 allqueue(REDRAWVIEW3D
, 0);
1795 allqueue(REDRAWVIEW3D
, 0);
1798 if(phase
& RAD_PHASE_FACES
) rad_addmesh();
1799 BIF_undo_push("Radiosity add mesh");
1800 allqueue(REDRAWVIEW3D
, 0);
1803 if(phase
& RAD_PHASE_FACES
) rad_replacemesh();
1804 BIF_undo_push("Radiosity replace mesh");
1805 allqueue(REDRAWVIEW3D
, 0);
1812 static void radio_panel_calculation(Radio
*rad
, int flag
)
1816 block
= uiNewBlock(&curarea
->uiblocks
, "radio_panel_calculation", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1817 if(uiNewPanel(curarea
, block
, "Calculation", "Radio", 640, 0, 318, 204)==0) return;
1818 uiAutoBlock(block
, 10, 10, 300, 200, UI_BLOCK_ROWS
);
1820 if(flag
!= RAD_PHASE_PATCHES
) uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
1821 uiDefBut(block
, BUT
, B_RAD_GO
, "GO", 0, 0, 10, 15, NULL
, 0, 0, 0, 0, "Starts the radiosity simulation");
1823 uiBlockSetCol(block
, TH_AUTO
);
1824 uiDefButS(block
, NUM
, B_NOP
, "SubSh Patch:", 1, 0, 10, 10, &rad
->subshootp
, 0.0, 10.0, 0, 0, "Sets the number of times the environment is tested to detect pathes");
1825 uiDefButS(block
, NUM
, B_NOP
, "SubSh Element:", 1, 0, 10, 10, &rad
->subshoote
, 0.0, 10.0, 0, 0, "Sets the number of times the environment is tested to detect elements");
1827 if(flag
!= RAD_PHASE_PATCHES
) uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
1828 uiDefBut(block
, BUT
, B_RAD_SHOOTE
, "Subdiv Shoot Element", 2, 0, 10, 10, NULL
, 0, 0, 0, 0, "For pre-subdivision, Detects high energy changes and subdivide Elements");
1829 uiDefBut(block
, BUT
, B_RAD_SHOOTP
, "Subdiv Shoot Patch", 2, 0, 10, 10, NULL
, 0, 0, 0, 0, "For pre-subdivision, Detects high energy changes and subdivide Patches");
1831 uiBlockSetCol(block
, TH_AUTO
);
1832 uiDefButI(block
, NUM
, B_NOP
, "MaxEl:", 3, 0, 10, 10, &rad
->maxnode
, 1.0, 250000.0, 0, 0, "Sets the maximum allowed number of elements");
1833 uiDefButS(block
, NUM
, B_NOP
, "Max Subdiv Shoot:", 3, 0, 10, 10, &rad
->maxsublamp
, 1.0, 250.0, 0, 0, "Sets the maximum number of initial shoot patches that are evaluated");
1835 if(flag
& RAD_PHASE_FACES
);
1836 else uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
1837 uiDefBut(block
, BUT
, B_RAD_FACEFILT
, "FaceFilter", 4, 0, 10, 10, NULL
, 0, 0, 0, 0, "Forces an extra smoothing");
1838 uiDefBut(block
, BUT
, B_RAD_NODEFILT
, "Element Filter", 4, 0, 10, 10, NULL
, 0, 0, 0, 0, "Filters elements to remove aliasing artefacts");
1840 uiDefBut(block
, BUT
, B_RAD_NODELIM
, "RemoveDoubles", 5, 0, 30, 10, NULL
, 0.0, 50.0, 0, 0, "Joins elements which differ less than 'Lim'");
1841 uiBlockSetCol(block
, TH_AUTO
);
1842 uiDefButS(block
, NUM
, B_NOP
, "Lim:", 5, 0, 10, 10, &rad
->nodelim
, 0.0, 50.0, 0, 0, "Sets the range for removing doubles");
1847 static void radio_panel_tool(Radio
*rad
, int flag
)
1851 block
= uiNewBlock(&curarea
->uiblocks
, "radio_panel_tool", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1852 if(uiNewPanel(curarea
, block
, "Radio Tool", "Radio", 320, 0, 318, 204)==0) return;
1853 uiAutoBlock(block
, 10, 10, 300, 200, UI_BLOCK_ROWS
);
1855 if(flag
& RAD_PHASE_PATCHES
) uiBlockSetCol(block
, TH_BUT_SETTING1
);
1856 uiDefBut(block
, BUT
, B_RAD_COLLECT
, "Collect Meshes", 0, 0, 10, 15, NULL
, 0, 0, 0, 0, "Converts selected visible meshes to patches");
1858 if(flag
& RAD_PHASE_PATCHES
)uiBlockSetCol(block
, TH_AUTO
);
1859 else uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
1860 uiDefBut(block
, BUT
, B_RAD_FREE
, "Free Radio Data", 0, 0, 10, 15, NULL
, 0, 0, 0, 0, "Releases all memory used by Radiosity");
1862 if(flag
& RAD_PHASE_FACES
) uiBlockSetCol(block
, TH_AUTO
);
1863 else uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
1864 uiDefBut(block
, BUT
, B_RAD_REPLACE
, "Replace Meshes", 1, 0, 10, 12, NULL
, 0, 0, 0, 0, "Converts meshes to Mesh objects with vertex colors, changing input-meshes");
1865 uiDefBut(block
, BUT
, B_RAD_ADDMESH
, "Add new Meshes", 1, 0, 10, 12, NULL
, 0, 0, 0, 0, "Converts meshes to Mesh objects with vertex colors, unchanging input-meshes");
1867 uiBlockSetCol(block
, TH_AUTO
);
1868 uiDefButS(block
, ROW
, B_RAD_DRAW
, "Wire", 2, 0, 10, 10, &rad
->drawtype
, 0.0, 0.0, 0, 0, "Enables wireframe drawmode");
1869 uiDefButS(block
, ROW
, B_RAD_DRAW
, "Solid", 2, 0, 10, 10, &rad
->drawtype
, 0.0, 1.0, 0, 0, "Enables solid drawmode");
1870 uiDefButS(block
, ROW
, B_RAD_DRAW
, "Gour", 2, 0, 10, 10, &rad
->drawtype
, 0.0, 2.0, 0, 0, "Enables Gourad drawmode");
1871 uiDefButBitS(block
, TOG
, 1, B_RAD_DRAW
, "ShowLim", 2, 0, 10, 10, &rad
->flag
, 0, 0, 0, 0, "Draws patch and element limits");
1872 uiDefButBitS(block
, TOG
, 2, B_RAD_DRAW
, "Z", 2, 0, 3, 10, &rad
->flag
, 0, 0, 0, 0, "Draws limits differently");
1874 uiDefButS(block
, NUM
, B_RAD_LIMITS
, "ElMax:", 3, 0, 10, 10, &rad
->elma
, 1.0, 500.0, 0, 0, "Sets maximum size of an element");
1875 uiDefButS(block
, NUM
, B_RAD_LIMITS
, "ElMin:", 3, 0, 10, 10, &rad
->elmi
, 1.0, 100.0, 0, 0, "Sets minimum size of an element");
1876 uiDefButS(block
, NUM
, B_RAD_LIMITS
, "PaMax:", 3, 0, 10, 10, &rad
->pama
, 10.0, 1000.0, 0, 0, "Sets maximum size of a patch");
1877 uiDefButS(block
, NUM
, B_RAD_LIMITS
, "PaMin:", 3, 0, 10, 10, &rad
->pami
, 10.0, 1000.0, 0, 0, "Sets minimum size of a patch");
1879 uiDefBut(block
, BUT
, B_RAD_INIT
, "Limit Subdivide", 5, 0, 10, 10, NULL
, 0, 0, 0, 0, "Subdivides patches");
1883 static void radio_panel_render(Radio
*rad
)
1887 block
= uiNewBlock(&curarea
->uiblocks
, "radio_panel_render", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1888 if(uiNewPanel(curarea
, block
, "Radio Render", "Radio", 0, 0, 318, 204)==0) return;
1889 uiAutoBlock(block
, 210, 30, 230, 150, UI_BLOCK_ROWS
);
1891 uiDefButS(block
, NUMSLI
, B_RAD_LIMITS
, "Hemires:", 0, 0, 10, 10, &rad
->hemires
, 100.0, 1000.0, 100, 0, "Sets the size of a hemicube");
1892 uiDefButS(block
, NUM
, B_NOP
, "Max Iterations:", 2, 0, 10, 15, &rad
->maxiter
, 0.0, 10000.0, 0, 0, "Limits the maximum number of radiosity rounds");
1893 uiDefButF(block
, NUM
, B_RAD_FAC
, "Mult:", 3, 0, 10, 15, &rad
->radfac
, 0.001, 250.0, 100, 0, "Mulitplies the energy values");
1894 uiDefButF(block
, NUM
, B_RAD_FAC
, "Gamma:", 3, 0, 10, 15, &rad
->gamma
, 0.2, 10.0, 10, 0, "Changes the contrast of the energy values");
1895 uiDefButF(block
, NUMSLI
, B_NOP
, "Convergence:", 5, 0, 10, 10, &rad
->convergence
, 0.0, 1.0, 10, 0, "Sets the lower threshold of unshot energy");
1899 /* ***************************** WORLD ************************** */
1901 void do_worldbuts(unsigned short event
)
1903 static short mtexcopied
=0;
1904 static MTex mtexcopybuf
;
1909 case B_TEXCLEARWORLD
:
1910 wrld
= G
.buts
->lockpoin
;
1911 mtex
= wrld
->mtex
[ wrld
->texact
];
1913 if(mtex
->tex
) mtex
->tex
->id
.us
--;
1915 wrld
->mtex
[ wrld
->texact
]= 0;
1916 allqueue(REDRAWBUTSSHADING
, 0);
1917 allqueue(REDRAWOOPS
, 0);
1918 BIF_undo_push("Unlink world texture");
1919 BIF_preview_changed(ID_WO
);
1923 wrld
= G
.buts
->lockpoin
;
1924 if(wrld
&& wrld
->mtex
[(int)wrld
->texact
] ) {
1925 mtex
= wrld
->mtex
[(int)wrld
->texact
];
1926 if(mtex
->tex
==NULL
) {
1927 error("No texture available");
1930 memcpy(&mtexcopybuf
, wrld
->mtex
[(int)wrld
->texact
], sizeof(MTex
));
1936 wrld
= G
.buts
->lockpoin
;
1937 if(wrld
&& mtexcopied
&& mtexcopybuf
.tex
) {
1938 if(wrld
->mtex
[(int)wrld
->texact
]==NULL
)
1939 wrld
->mtex
[(int)wrld
->texact
]= MEM_mallocN(sizeof(MTex
), "mtex");
1940 else if(wrld
->mtex
[(int)wrld
->texact
]->tex
)
1941 wrld
->mtex
[(int)wrld
->texact
]->tex
->id
.us
--;
1943 memcpy(wrld
->mtex
[(int)wrld
->texact
], &mtexcopybuf
, sizeof(MTex
));
1945 id_us_plus((ID
*)mtexcopybuf
.tex
);
1946 BIF_undo_push("Paste mapping settings");
1947 BIF_preview_changed(ID_WO
);
1948 scrarea_queue_winredraw(curarea
);
1951 case B_AO_DISTANCES
:
1952 /* distances option only supports plain */
1953 wrld
= G
.buts
->lockpoin
;
1955 wrld
->aocolor
= WO_AOPLAIN
;
1956 scrarea_queue_winredraw(curarea
);
1961 static void world_panel_mapto(World
*wrld
)
1966 block
= uiNewBlock(&curarea
->uiblocks
, "world_panel_mapto", UI_EMBOSS
, UI_HELV
, curarea
->win
);
1967 uiNewPanelTabbed("Texture and Input", "World");
1968 if(uiNewPanel(curarea
, block
, "Map To", "World", 1280, 0, 318, 204)==0) return;
1970 uiSetButLock(wrld
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
1972 mtex
= wrld
->mtex
[ wrld
->texact
];
1976 mtex
->texco
= TEXCO_VIEW
;
1979 /* TEXTURE OUTPUT */
1980 uiBlockBeginAlign(block
);
1981 uiDefButBitS(block
, TOG
, MTEX_STENCIL
, B_WORLDPRV
, "Stencil", 10,125,45,19, &(mtex
->texflag
), 0, 0, 0, 0, "Sets the texture mapping to stencil mode");
1982 uiDefButBitS(block
, TOG
, MTEX_NEGATIVE
, B_WORLDPRV
, "Neg", 55,125,30,19, &(mtex
->texflag
), 0, 0, 0, 0, "Inverts the values of the texture to reverse its effect");
1983 uiDefButBitS(block
, TOG
, MTEX_RGBTOINT
, B_WORLDPRV
, "No RGB", 85,125,60,19, &(mtex
->texflag
), 0, 0, 0, 0, "Converts texture RGB values to intensity (gray) values");
1984 uiBlockEndAlign(block
);
1986 uiBlockBeginAlign(block
);
1987 uiDefButF(block
, COL
, B_WORLDPRV
, "", 10,100,135,19, &(mtex
->r
), 0, 0, 0, B_MTEXCOL
, "");
1988 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "R ", 10,80,135,19, &(mtex
->r
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
1989 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "G ", 10,60,135,19, &(mtex
->g
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
1990 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "B ", 10,40,135,19, &(mtex
->b
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
1991 uiBlockEndAlign(block
);
1992 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "DVar ", 10,10,135,19, &(mtex
->def_var
), 0.0, 1.0, 0, 0, "The default value for textures to mix with values (not RGB)");
1993 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "Ang ", 155, 40, 155, 19, &(wrld
->add_angle
), -30.0, 30.0, 0, 0, "Additional angle in degs under horizon");
1996 uiBlockBeginAlign(block
);
1997 uiDefButBitS(block
, TOG
, WOMAP_BLEND
, B_WORLDPRV
, "Blend", 10,180,75,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the color progression of the background");
1998 uiDefButBitS(block
, TOG
, WOMAP_HORIZ
, B_WORLDPRV
, "Hori", 85,180,75,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the color of the horizon");
1999 uiDefButBitS(block
, TOG
, WOMAP_ZENUP
, B_WORLDPRV
, "ZenUp", 160,180,75,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the color of the zenith above");
2000 uiDefButBitS(block
, TOG
, WOMAP_ZENDOWN
, B_WORLDPRV
, "ZenDo", 235,180,75,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the color of the zenith below");
2001 uiBlockEndAlign(block
);
2003 uiBlockBeginAlign(block
);
2004 uiDefButS(block
, MENU
, B_WORLDPRV
, mapto_blendtype_pup(),155,125,155,19, &(mtex
->blendtype
), 0, 0, 0, 0, "Texture blending mode");
2005 uiBlockEndAlign(block
);
2007 uiBlockBeginAlign(block
);
2008 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "Col ", 155,100,155,19, &(mtex
->colfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture affects color values");
2009 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "Nor ", 155,80,155,19, &(mtex
->norfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture affects normal values");
2010 uiDefButF(block
, NUMSLI
, B_WORLDPRV
, "Var ", 155,60,155,19, &(mtex
->varfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
2014 static void world_panel_texture(World
*wrld
)
2020 char str
[64], *strp
;
2022 block
= uiNewBlock(&curarea
->uiblocks
, "world_panel_texture", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2023 if(uiNewPanel(curarea
, block
, "Texture and Input", "World", 960, 0, 318, 204)==0) return;
2025 uiSetButLock(wrld
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2028 uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
2029 uiBlockBeginAlign(block
);
2030 for(a
= 0; a
<MAX_MTEX
; a
++) {
2031 mtex
= wrld
->mtex
[a
];
2032 if(mtex
&& mtex
->tex
) splitIDname(mtex
->tex
->id
.name
+2, str
, &loos
);
2033 else strcpy(str
, "");
2035 uiDefButS(block
, ROW
, REDRAWBUTSSHADING
, str
,10, 160-18*a
, 80, 20, &(wrld
->texact
), 3.0, (float)a
, 0, 0, "Texture channel");
2037 uiBlockEndAlign(block
);
2039 mtex
= wrld
->mtex
[ wrld
->texact
];
2043 mtex
->texco
= TEXCO_VIEW
;
2046 /* TEXTUREBLOCK SELECT */
2047 uiBlockSetCol(block
, TH_BUT_SETTING2
);
2048 id
= (ID
*)mtex
->tex
;
2049 IDnames_to_pupstring(&strp
, NULL
, "ADD NEW %x 32767", &(G
.main
->tex
), id
, &(G
.buts
->texnr
));
2050 uiDefButS(block
, MENU
, B_WTEXBROWSE
, strp
, 100,140,20,19, &(G
.buts
->texnr
), 0, 0, 0, 0, "Selects an existing texture or creates new");
2054 uiDefBut(block
, TEX
, B_IDNAME
, "TE:", 100,160,200,19, id
->name
+2, 0.0, 21.0, 0, 0, "Displays name of the texture block: click to change");
2055 sprintf(str
, "%d", id
->us
);
2056 uiDefBut(block
, BUT
, 0, str
, 196,140,21,19, 0, 0, 0, 0, 0, "Displays number of users of texture: click to make single user");
2057 uiDefIconBut(block
, BUT
, B_AUTOTEXNAME
, ICON_AUTO
, 220,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture");
2059 if(wrld
->id
.lib
) uiDefIconBut(block
, BUT
, 0, ICON_DATALIB
, 219,140,21,19, 0, 0, 0, 0, 0, "");
2060 else uiDefIconBut(block
, BUT
, 0, ICON_PARLIB
, 219,140,21,19, 0, 0, 0, 0, 0, "");
2062 uiBlockSetCol(block
, TH_AUTO
);
2063 uiDefBut(block
, BUT
, B_TEXCLEARWORLD
, "Clear", 122, 140, 72, 19, 0, 0, 0, 0, 0, "Erases link to texture");
2066 uiDefButS(block
, TOG
, B_WTEXBROWSE
, "Add New" ,100, 160, 200, 19, &(G
.buts
->texnr
), -1.0, 32767.0, 0, 0, "Adds a new texture datablock");
2068 uiBlockSetCol(block
, TH_AUTO
);
2071 uiBlockBeginAlign(block
);
2072 uiDefIconBut(block
, BUT
, B_WMTEXCOPY
, ICON_COPYUP
, 250,140,25,19, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer");
2073 uiDefIconBut(block
, BUT
, B_WMTEXPASTE
, ICON_PASTEUP
,275,140,25,19, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer");
2076 uiBlockBeginAlign(block
);
2077 uiDefButS(block
, ROW
, B_WORLDPRV
, "View", 100,110,100,20, &(mtex
->texco
), 4.0, (float)TEXCO_VIEW
, 0, 0, "Uses view vector for the texture coordinates");
2078 uiDefButS(block
, ROW
, B_WORLDPRV
, "Global", 200,110,100,20, &(mtex
->texco
), 4.0, (float)TEXCO_GLOB
, 0, 0, "Uses global coordinates for the texture coordinates (interior mist)");
2080 uiDefButS(block
, ROW
, B_WORLDPRV
, "AngMap", 100,90,70,20, &(mtex
->texco
), 4.0, (float)TEXCO_ANGMAP
, 0, 0, "Uses 360 degree angular coordinates, e.g. for spherical light probes");
2081 uiDefButS(block
, ROW
, B_WORLDPRV
, "Sphere", 170,90,65,20, &(mtex
->texco
), 4.0, (float)TEXCO_H_SPHEREMAP
, 0, 0, "For 360 degree panorama sky, spherical mapped, only top half");
2082 uiDefButS(block
, ROW
, B_WORLDPRV
, "Tube", 235,90,65,20, &(mtex
->texco
), 4.0, (float)TEXCO_H_TUBEMAP
, 0, 0, "For 360 degree panorama sky, cylindrical mapped, only top half");
2084 uiDefButS(block
, ROW
, B_WORLDPRV
, "Object", 100,70,70,20, &(mtex
->texco
), 4.0, (float)TEXCO_OBJECT
, 0, 0, "Uses linked object's coordinates for texture coordinates");
2085 uiDefIDPoinBut(block
, test_obpoin_but
, ID_OB
, B_WORLDPRV
, "OB:", 170,70,130,20, &(mtex
->object
), "Object name to use for mapping");
2087 uiBlockBeginAlign(block
);
2088 uiDefButF(block
, NUM
, B_WORLDPRV
, "dX", 100,40,100,19, mtex
->ofs
, -20.0, 20.0, 10, 0, "Fine tunes texture mapping X coordinate");
2089 uiDefButF(block
, NUM
, B_WORLDPRV
, "dY", 100,20,100,19, mtex
->ofs
+1, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Y coordinate");
2090 uiDefButF(block
, NUM
, B_WORLDPRV
, "dZ", 100, 0,100,19, mtex
->ofs
+2, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Z coordinate");
2091 uiBlockBeginAlign(block
);
2092 uiDefButF(block
, NUM
, B_WORLDPRV
, "sizeX", 200,40,100,19, mtex
->size
, -200.0, 200.0, 10, 0, "Sets scaling for the texture's X size");
2093 uiDefButF(block
, NUM
, B_WORLDPRV
, "sizeY", 200,20,100,19, mtex
->size
+1, -200.0, 200.0, 10, 0, "Sets scaling for the texture's Y size");
2094 uiDefButF(block
, NUM
, B_WORLDPRV
, "sizeZ", 200, 0,100,19, mtex
->size
+2, -200.0, 200.0, 10, 0, "Sets scaling for the texture's Z size");
2098 static void world_panel_mistaph(World
*wrld
)
2102 block
= uiNewBlock(&curarea
->uiblocks
, "world_panel_mistaph", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2103 if(uiNewPanel(curarea
, block
, "Mist / Stars / Physics", "World", 640, 0, 318, 204)==0) return;
2105 uiSetButLock(wrld
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2107 #if GAMEBLENDER == 1
2108 uiDefButI(block
, MENU
, 1,
2110 "Physics %t|None %x0|Sumo %x2|Ode %x4 |Bullet %x5",
2112 //"Physics %t|None %x0|Sumo %x2|Bullet %x5", //disable Sumo, until too many people complain ;-)
2113 "Physics %t|None %x0|Sumo (deprecated) %x2|Bullet %x5",
2115 10,180,140,19, &wrld
->physicsEngine
, 0, 0, 0, 0,
2118 /* Gravitation for the game worlds */
2119 uiDefButF(block
, NUMSLI
,0, "Grav ", 150,180,150,19, &(wrld
->gravity
), 0.0, 25.0, 0, 0, "Sets the gravitation constant of the game world");
2122 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2123 uiDefButBitS(block
, TOG
, WO_MIST
, B_WORLDPRV2
,"Mist", 10,120,140,19, &wrld
->mode
, 0, 0, 0, 0, "Toggles mist simulation");
2124 uiBlockSetCol(block
, TH_AUTO
);
2126 uiBlockBeginAlign(block
);
2127 uiDefButS(block
, ROW
, B_WORLDPRV2
, "Qua", 10, 90, 40, 19, &wrld
->mistype
, 1.0, 0.0, 0, 0, "Mist uses quadratic progression");
2128 uiDefButS(block
, ROW
, B_WORLDPRV2
, "Lin", 50, 90, 50, 19, &wrld
->mistype
, 1.0, 1.0, 0, 0, "Mist uses linear progression");
2129 uiDefButS(block
, ROW
, B_WORLDPRV2
, "Sqr", 100, 90, 50, 19, &wrld
->mistype
, 1.0, 2.0, 0, 0, "Mist uses inverse quadratic progression");
2130 uiBlockBeginAlign(block
);
2131 uiDefButF(block
, NUM
,B_WORLDPRV2
, "Sta:",10,70,140,19, &wrld
->miststa
, 0.0, 10000.0, 10, 0, "Specifies the starting distance of the mist");
2132 uiDefButF(block
, NUM
,B_WORLDPRV2
, "Di:",10,50,140,19, &wrld
->mistdist
, 0.0,10000.0, 10, 00, "Specifies the depth of the mist");
2133 uiDefButF(block
, NUM
,B_WORLDPRV2
,"Hi:", 10,30,140,19, &wrld
->misthi
,0.0,100.0, 10, 0, "Specifies the factor for a less dense mist with increasing height");
2134 uiDefButF(block
, NUMSLI
, B_WORLDPRV2
, "Misi ", 10,10,140,19, &(wrld
->misi
), 0., 1.0, 0, 0, "Sets the mist intensity");
2135 uiBlockEndAlign(block
);
2137 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2138 uiDefButBitS(block
, TOG
, WO_STARS
, B_WORLDPRV2
, "Stars",160,120,140,19, &wrld
->mode
, 0, 0, 0, 0, "Toggles starfield generation");
2139 uiBlockSetCol(block
, TH_AUTO
);
2141 uiBlockBeginAlign(block
);
2142 uiDefButF(block
, NUM
,B_WORLDPRV2
,"StarDist:", 160,70,140,19, &(wrld
->stardist
), 2.0, 1000.0, 100, 0, "Specifies the average distance between any two stars");
2143 uiDefButF(block
, NUM
,B_WORLDPRV2
,"MinDist:", 160,50,140,19, &(wrld
->starmindist
), 0.0, 1000.0, 100, 0, "Specifies the minimum distance to the camera for stars");
2144 uiDefButF(block
, NUMSLI
,B_WORLDPRV2
,"Size:", 160,30,140,19, &(wrld
->starsize
), 0.0, 10.0, 10, 0, "Specifies the average screen dimension of stars");
2145 uiDefButF(block
, NUMSLI
,B_WORLDPRV2
,"Colnoise:", 160,10,140,19, &(wrld
->starcolnoise
), 0.0, 1.0, 100, 0, "Randomizes star color");
2146 uiBlockEndAlign(block
);
2150 static void world_panel_amb_occ(World
*wrld
)
2154 block
= uiNewBlock(&curarea
->uiblocks
, "world_panel_amb_oc", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2155 uiNewPanelTabbed("Mist / Stars / Physics", "World");
2156 if(uiNewPanel(curarea
, block
, "Amb Occ", "World", 320, 0, 318, 204)==0) return;
2158 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2159 uiDefButBitS(block
, TOG
, WO_AMB_OCC
, B_REDR
, "Ambient Occlusion",10,150,300,19, &wrld
->mode
, 0, 0, 0, 0, "Toggles ambient occlusion (soft shadows)");
2160 uiBlockSetCol(block
, TH_AUTO
);
2162 if(wrld
->mode
& WO_AMB_OCC
) {
2164 /* aolight: samples */
2165 uiDefButS(block
, MENU
, B_REDR
, "Constant QMC %x2|Adaptive QMC %x1|Constant Jittered %x0",
2166 10, 120, 145, 19, &wrld
->ao_samp_method
, 0, 0, 0, 0, "Method for generating shadow samples: Constant QMC: best quality, Adaptive QMC: fast in high contrast areas");
2167 uiDefButS(block
, NUM
, B_REDR
, "Samples:",
2168 165, 120, 145, 19, &wrld
->aosamp
, 1.0, 32.0, 100, 0, "Sets the number of samples used for AO (actual number: squared)");
2170 if (wrld
->ao_samp_method
== WO_AOSAMP_HALTON
) {
2171 uiDefButF(block
, NUM
, B_REDR
, "Threshold:",
2172 10, 95, 145, 19, &wrld
->ao_adapt_thresh
, 0.0, 1.0, 100, 0, "Samples below this threshold will be considered fully shadowed/unshadowed and skipped");
2174 uiDefButF(block
, NUM
, B_REDR
, "Dist:",
2175 165, 95, 145, 19, &wrld
->aodist
, 0.001, 5000.0, 100, 0, "Sets length of AO rays, defines how far away other faces give occlusion effect");
2177 uiBlockBeginAlign(block
);
2178 uiDefButBitS(block
, TOG
, WO_AODIST
, B_AO_DISTANCES
, "Use Distances", 10, 70, 150, 19, &wrld
->aomode
, 0, 0, 0, 0, "When enabled, distances to objects will be used to attenuate shadows. Only for Plain AO.");
2179 /* distance attenuation factor */
2180 if (wrld
->aomode
& WO_AODIST
)
2181 uiDefButF(block
, NUM
, B_REDR
, "DistF:", 160, 70, 150, 19, &wrld
->aodistfac
, 0.00001, 10.0, 100, 0, "Distance factor, the higher, the 'shorter' the shadows");
2183 /* result mix modes */
2184 uiBlockBeginAlign(block
);
2185 uiDefButS(block
, ROW
, B_REDR
, "Add", 10, 45, 100, 20, &wrld
->aomix
, 1.0, (float)WO_AOADD
, 0, 0, "adds light/shadows");
2186 uiDefButS(block
, ROW
, B_REDR
, "Sub", 110, 45, 100, 20, &wrld
->aomix
, 1.0, (float)WO_AOSUB
, 0, 0, "subtracts light/shadows (needs at least one normal light to make anything visible)");
2187 uiDefButS(block
, ROW
, B_REDR
, "Both", 210, 45, 100, 20, &wrld
->aomix
, 1.0, (float)WO_AOADDSUB
, 0, 0, "both lightens & darkens");
2189 /* color treatment */
2190 uiBlockBeginAlign(block
);
2191 uiDefButS(block
, ROW
, B_REDR
, "Plain", 10, 25, 100, 20, &wrld
->aocolor
, 2.0, (float)WO_AOPLAIN
, 0, 0, "Plain diffuse energy (white)");
2192 uiDefButS(block
, ROW
, B_REDR
, "Sky Color", 110, 25, 100, 20, &wrld
->aocolor
, 2.0, (float)WO_AOSKYCOL
, 0, 0, "Use horizon and zenith color for diffuse energy");
2193 uiDefButS(block
, ROW
, B_REDR
, "Sky Texture", 210, 25, 100, 20, &wrld
->aocolor
, 2.0, (float)WO_AOSKYTEX
, 0, 0, "Does full Sky texture render for diffuse energy");
2195 uiBlockBeginAlign(block
);
2196 uiDefButF(block
, NUMSLI
, B_REDR
, "Energy:", 10, 0, 150, 19, &wrld
->aoenergy
, 0.01, 3.0, 100, 0, "Sets global energy scale for AO");
2197 if (wrld
->ao_samp_method
== WO_AOSAMP_CONSTANT
)
2198 uiDefButF(block
, NUMSLI
, B_REDR
, "Bias:", 160, 0, 150, 19, &wrld
->aobias
, 0.0, 0.5, 10, 0, "Sets bias to prevent smoothed faces to show banding (in radians)");
2203 static void world_panel_world(World
*wrld
)
2207 block
= uiNewBlock(&curarea
->uiblocks
, "world_panel_world", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2208 if(uiNewPanel(curarea
, block
, "World", "World", 320, 0, 318, 204)==0) return;
2210 uiBlockSetCol(block
, TH_BUT_SETTING2
);
2211 std_libbuttons(block
, 10, 180, 0, NULL
, B_WORLDBROWSE
, ID_WO
, 0, (ID
*)wrld
, (ID
*)G
.scene
, &(G
.buts
->menunr
), B_WORLDALONE
, B_WORLDLOCAL
, B_WORLDDELETE
, 0, B_KEEPDATA
);
2213 if(wrld
==NULL
) return;
2215 uiSetButLock(wrld
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2216 uiBlockSetCol(block
, TH_AUTO
);
2218 uiBlockBeginAlign(block
);
2219 uiDefButF(block
, COL
, B_WORLDPRV
, "", 10,150,145,19, &wrld
->horr
, 0, 0, 0, B_COLHOR
, "");
2220 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"HoR ", 10,130,145,19, &(wrld
->horr
), 0.0, 1.0, B_COLHOR
,0, "Sets the amount of red color at the horizon");
2221 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"HoG ", 10,110,145,19, &(wrld
->horg
), 0.0, 1.0, B_COLHOR
,0, "Sets the amount of green color at the horizon");
2222 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"HoB ", 10,90,145,19, &(wrld
->horb
), 0.0, 1.0, B_COLHOR
,0, "Sets the amount of blue color at the horizon");
2224 uiBlockBeginAlign(block
);
2225 uiDefButF(block
, COL
, B_WORLDPRV
, "", 160,150,145,19, &wrld
->zenr
, 0, 0, 0, B_COLZEN
, "");
2226 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"ZeR ", 160,130,145,19, &(wrld
->zenr
), 0.0, 1.0, B_COLZEN
,0, "Sets the amount of red color at the zenith");
2227 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"ZeG ", 160,110,145,19, &(wrld
->zeng
), 0.0, 1.0, B_COLZEN
,0, "Sets the amount of green color at the zenith");
2228 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"ZeB ", 160,90,145,19, &(wrld
->zenb
), 0.0, 1.0, B_COLZEN
,0, "Sets the amount of blue color at the zenith");
2230 uiBlockBeginAlign(block
);
2231 uiDefButF(block
, COL
, B_WORLDPRV
, "", 10,70,145,19, &wrld
->ambr
, 0, 0, 0, 0, "");
2232 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"AmbR ", 10,50,145,19, &(wrld
->ambr
), 0.0, 1.0 ,0,0, "Sets the amount of red ambient color");
2233 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"AmbG ", 10,30,145,19, &(wrld
->ambg
), 0.0, 1.0 ,0,0, "Sets the amount of green ambient color");
2234 uiDefButF(block
, NUMSLI
,B_WORLDPRV
,"AmbB ", 10,10,145,19, &(wrld
->ambb
), 0.0, 1.0 ,0,0, "Sets the amount of blue ambient color");
2236 uiBlockBeginAlign(block
);
2237 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2238 uiDefButF(block
, NUMSLI
,B_WORLDPRV
, "Exp ", 160,30,145,19, &(wrld
->exp
), 0.0, 1.0, 0, 2, "Sets amount of exponential color correction for light");
2239 uiDefButF(block
, NUMSLI
,B_WORLDPRV
, "Range ", 160,10,145,19, &(wrld
->range
), 0.2, 5.0, 0, 2, "Sets the color amount that will be mapped on color 1.0");
2244 static void world_panel_preview(World
*wrld
)
2248 /* name "Preview" is abused to detect previewrender offset panel */
2249 block
= uiNewBlock(&curarea
->uiblocks
, "world_panel_preview", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2250 if(uiNewPanel(curarea
, block
, "Preview", "World", 0, 0, 318, 204)==0) return;
2252 if(wrld
==NULL
) return;
2254 uiSetButLock(wrld
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2256 uiBlockSetDrawExtraFunc(block
, BIF_previewdraw
);
2258 // label to force a boundbox for buttons not to be centered
2259 uiDefBut(block
, LABEL
, 0, " ", 20,20,10,10, 0, 0, 0, 0, 0, "");
2261 uiBlockBeginAlign(block
);
2262 uiDefButBitS(block
, TOG
, WO_SKYREAL
, B_WORLDPRV
,"Real", 200,175,80,25, &wrld
->skytype
, 0, 0, 0, 0, "Renders background with a real horizon");
2263 uiDefButBitS(block
, TOG
, WO_SKYBLEND
, B_WORLDPRV
,"Blend",200,150,80,25, &wrld
->skytype
, 0, 0, 0, 0, "Renders background with natural progression from horizon to zenith");
2264 uiDefButBitS(block
, TOG
,WO_SKYPAPER
, B_WORLDPRV
,"Paper",200,125,80,25, &wrld
->skytype
, 0, 0, 0, 0, "Flattens blend or texture coordinates");
2265 uiBlockEndAlign(block
);
2269 /* ************************ LAMP *************************** */
2271 void do_lampbuts(unsigned short event
)
2273 static short mtexcopied
=0;
2274 static MTex mtexcopybuf
;
2280 BIF_preview_changed(ID_LA
);
2281 allqueue(REDRAWVIEW3D
, 0);
2282 allqueue(REDRAWBUTSSHADING
, 0);
2284 case B_TEXCLEARLAMP
:
2285 la
= G
.buts
->lockpoin
;
2286 mtex
= la
->mtex
[ la
->texact
];
2288 if(mtex
->tex
) mtex
->tex
->id
.us
--;
2290 la
->mtex
[ la
->texact
]= 0;
2291 BIF_undo_push("Unlink world texture");
2292 allqueue(REDRAWBUTSSHADING
, 0);
2293 allqueue(REDRAWOOPS
, 0);
2294 BIF_preview_changed(ID_LA
);
2298 la
= G
.buts
->lockpoin
;
2299 la
->bufsize
= la
->bufsize
&=(~15);
2300 allqueue(REDRAWBUTSSHADING
, 0);
2301 allqueue(REDRAWOOPS
, 0);
2304 la
= G
.buts
->lockpoin
;
2305 la
->mode
&= ~LA_SHAD_RAY
;
2306 allqueue(REDRAWBUTSSHADING
, 0);
2307 allqueue(REDRAWVIEW3D
, 0);
2310 la
= G
.buts
->lockpoin
;
2311 la
->mode
&= ~LA_SHAD_BUF
;
2312 /* yafray: 'softlight' uses it's own shadbuf. flag.
2313 Must be cleared here too when switching from ray shadow */
2314 la
->mode
&= ~LA_YF_SOFT
;
2315 allqueue(REDRAWBUTSSHADING
, 0);
2316 allqueue(REDRAWVIEW3D
, 0);
2319 la
= G
.buts
->lockpoin
;
2320 if(la
&& la
->mtex
[(int)la
->texact
] ) {
2321 mtex
= la
->mtex
[(int)la
->texact
];
2322 if(mtex
->tex
==NULL
) {
2323 error("No texture available");
2326 memcpy(&mtexcopybuf
, la
->mtex
[(int)la
->texact
], sizeof(MTex
));
2332 la
= G
.buts
->lockpoin
;
2333 if(la
&& mtexcopied
&& mtexcopybuf
.tex
) {
2334 if(la
->mtex
[(int)la
->texact
]==NULL
)
2335 la
->mtex
[(int)la
->texact
]= MEM_mallocN(sizeof(MTex
), "mtex");
2336 else if(la
->mtex
[(int)la
->texact
]->tex
)
2337 la
->mtex
[(int)la
->texact
]->tex
->id
.us
--;
2339 memcpy(la
->mtex
[(int)la
->texact
], &mtexcopybuf
, sizeof(MTex
));
2341 id_us_plus((ID
*)mtexcopybuf
.tex
);
2342 BIF_undo_push("Paste mapping settings");
2343 BIF_preview_changed(ID_LA
);
2344 scrarea_queue_winredraw(curarea
);
2347 case B_LFALLOFFCHANGED
:
2348 la
= G
.buts
->lockpoin
;
2349 curvemapping_changed(la
->curfalloff
, 1);
2350 BIF_undo_push("Edit Lamp falloff curve");
2351 BIF_preview_changed(ID_LA
);
2352 scrarea_queue_winredraw(curarea
);
2359 static void lamp_panel_mapto(Object
*ob
, Lamp
*la
)
2364 block
= uiNewBlock(&curarea
->uiblocks
, "lamp_panel_mapto", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2365 uiNewPanelTabbed("Texture and Input", "Lamp");
2366 if(uiNewPanel(curarea
, block
, "Map To", "Lamp", 1280, 0, 318, 204)==0) return;
2368 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2370 mtex
= la
->mtex
[ la
->texact
];
2374 mtex
->texco
= TEXCO_VIEW
;
2377 /* TEXTURE OUTPUT */
2378 uiBlockBeginAlign(block
);
2379 uiDefButBitS(block
, TOG
, MTEX_STENCIL
, B_LAMPPRV
, "Stencil", 10,125,45,19, &(mtex
->texflag
), 0, 0, 0, 0, "Sets the texture mapping to stencil mode");
2380 uiDefButBitS(block
, TOG
, MTEX_NEGATIVE
, B_LAMPPRV
, "Neg", 55,125,30,19, &(mtex
->texflag
), 0, 0, 0, 0, "Inverts the values of the texture to reverse its effect");
2381 uiDefButBitS(block
, TOG
, MTEX_RGBTOINT
, B_LAMPPRV
, "No RGB", 85,125,60,19, &(mtex
->texflag
), 0, 0, 0, 0, "Converts texture RGB values to intensity (gray) values");
2382 uiBlockEndAlign(block
);
2384 uiBlockBeginAlign(block
);
2385 uiDefButF(block
, COL
, B_LAMPPRV
, "", 10,100,135,19, &(mtex
->r
), 0, 0, 0, B_MTEXCOL
, "");
2386 uiDefButF(block
, NUMSLI
, B_LAMPPRV
, "R ", 10,80,135,19, &(mtex
->r
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
2387 uiDefButF(block
, NUMSLI
, B_LAMPPRV
, "G ", 10,60,135,19, &(mtex
->g
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
2388 uiDefButF(block
, NUMSLI
, B_LAMPPRV
, "B ", 10,40,135,19, &(mtex
->b
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
2389 uiBlockEndAlign(block
);
2390 uiDefButF(block
, NUMSLI
, B_LAMPPRV
, "DVar ", 10,10,135,19, &(mtex
->def_var
), 0.0, 1.0, 0, 0, "The default value the textures uses to mix with");
2393 uiDefButBitS(block
, TOG
, MAP_COL
, B_LAMPPRV
, "Col", 10,180,135,19, &(mtex
->mapto
), 0, 0, 0, 0, "Lets the texture affect the basic color of the lamp");
2395 uiBlockBeginAlign(block
);
2396 uiDefButS(block
, MENU
, B_LAMPPRV
, mapto_blendtype_pup(),155,125,155,19, &(mtex
->blendtype
), 0, 0, 0, 0, "Texture blending mode");
2397 uiBlockEndAlign(block
);
2399 uiDefButF(block
, NUMSLI
, B_LAMPPRV
, "Col ", 155,100,155,19, &(mtex
->colfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture affects color values");
2404 static void lamp_panel_texture(Object
*ob
, Lamp
*la
)
2410 char *strp
, str
[64];
2412 block
= uiNewBlock(&curarea
->uiblocks
, "lamp_panel_texture", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2413 if(uiNewPanel(curarea
, block
, "Texture and Input", "Lamp", 960, 0, 318, 204)==0) return;
2415 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2418 uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
2419 uiBlockBeginAlign(block
);
2420 for(a
= 0; a
<MAX_MTEX
; a
++) {
2422 if(mtex
&& mtex
->tex
) splitIDname(mtex
->tex
->id
.name
+2, str
, &loos
);
2423 else strcpy(str
, "");
2425 uiDefButS(block
, ROW
, B_REDR
, str
, 10, 160-18*a
, 80, 20, &(la
->texact
), 3.0, (float)a
, 0, 0, "");
2427 uiBlockEndAlign(block
);
2429 mtex
= la
->mtex
[ la
->texact
];
2433 mtex
->texco
= TEXCO_VIEW
;
2436 /* TEXTUREBLOK SELECT */
2437 uiBlockSetCol(block
, TH_BUT_SETTING2
);
2438 id
= (ID
*)mtex
->tex
;
2439 IDnames_to_pupstring(&strp
, NULL
, "ADD NEW %x 32767", &(G
.main
->tex
), id
, &(G
.buts
->texnr
));
2441 /* doesnt work, because lockpoin points to lamp, not to texture */
2442 uiDefButS(block
, MENU
, B_LTEXBROWSE
, strp
, 100,140,20,19, &(G
.buts
->texnr
), 0, 0, 0, 0, "Selects an existing texture or creates new");
2446 uiDefBut(block
, TEX
, B_IDNAME
, "TE:", 100,160,200,19, id
->name
+2, 0.0, 21.0, 0, 0, "Displays name of the texture block: click to change");
2447 sprintf(str
, "%d", id
->us
);
2448 uiDefBut(block
, BUT
, 0, str
, 196,140,21,19, 0, 0, 0, 0, 0, "Displays number of users of texture: click to make single user");
2449 uiDefIconBut(block
, BUT
, B_AUTOTEXNAME
, ICON_AUTO
, 221,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture");
2451 if(la
->id
.lib
) uiDefIconBut(block
, BUT
, 0, ICON_DATALIB
, 219,140,21,19, 0, 0, 0, 0, 0, "");
2452 else uiDefIconBut(block
, BUT
, 0, ICON_PARLIB
, 219,140,21,19, 0, 0, 0, 0, 0, "");
2454 uiBlockSetCol(block
, TH_AUTO
);
2455 uiDefBut(block
, BUT
, B_TEXCLEARLAMP
, "Clear", 122, 140, 72, 19, 0, 0, 0, 0, 0, "Erases link to texture");
2458 uiDefButS(block
, TOG
, B_LTEXBROWSE
, "Add New" ,100, 160, 200, 19, &(G
.buts
->texnr
), -1.0, 32767.0, 0, 0, "Adds a new texture datablock");
2461 uiBlockBeginAlign(block
);
2462 uiDefIconBut(block
, BUT
, B_LMTEXCOPY
, ICON_COPYUP
, 250,140,25,19, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer");
2463 uiDefIconBut(block
, BUT
, B_LMTEXPASTE
, ICON_PASTEUP
, 275,140,25,19, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer");
2466 uiBlockSetCol(block
, TH_AUTO
);
2467 uiBlockBeginAlign(block
);
2468 uiDefButS(block
, ROW
, B_LAMPPRV
, "Glob", 100,110,60,20, &(mtex
->texco
), 4.0, (float)TEXCO_GLOB
, 0, 0, "Uses global coordinates for the texture coordinates");
2469 uiDefButS(block
, ROW
, B_LAMPPRV
, "View", 160,110,70,20, &(mtex
->texco
), 4.0, (float)TEXCO_VIEW
, 0, 0, "Uses view coordinates for the texture coordinates");
2470 uiDefButS(block
, ROW
, B_LAMPPRV
, "Object", 230,110,70,20, &(mtex
->texco
), 4.0, (float)TEXCO_OBJECT
, 0, 0, "Uses linked object's coordinates for texture coordinates");
2471 uiDefIDPoinBut(block
, test_obpoin_but
, ID_OB
, B_LAMPPRV
, "", 100,90,200,20, &(mtex
->object
), "");
2473 uiBlockBeginAlign(block
);
2474 uiDefButF(block
, NUM
, B_LAMPPRV
, "dX", 100,50,100,18, mtex
->ofs
, -20.0, 20.0, 10, 0, "Fine tunes texture mapping X coordinate");
2475 uiDefButF(block
, NUM
, B_LAMPPRV
, "dY", 100,30,100,18, mtex
->ofs
+1, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Y coordinate");
2476 uiDefButF(block
, NUM
, B_LAMPPRV
, "dZ", 100,10,100,18, mtex
->ofs
+2, -20.0, 20.0, 10, 0, "Fine tunes texture mapping Z coordinate");
2477 uiBlockBeginAlign(block
);
2478 uiDefButF(block
, NUM
, B_LAMPPRV
, "sizeX", 200,50,100,18, mtex
->size
, -10.0, 10.0, 10, 0, "Sets scaling for the texture's X size");
2479 uiDefButF(block
, NUM
, B_LAMPPRV
, "sizeY", 200,30,100,18, mtex
->size
+1, -10.0, 10.0, 10, 0, "Sets scaling for the texture's Y size");
2480 uiDefButF(block
, NUM
, B_LAMPPRV
, "sizeZ", 200,10,100,18, mtex
->size
+2, -10.0, 10.0, 10, 0, "Sets scaling for the texture's Z size");
2481 uiBlockEndAlign(block
);
2484 static void lamp_panel_spot(Object
*ob
, Lamp
*la
)
2489 block
= uiNewBlock(&curarea
->uiblocks
, "lamp_panel_spot", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2490 if(uiNewPanel(curarea
, block
, "Shadow and Spot", "Lamp", 640, 0, 318, 204)==0) return;
2492 /* hemis and ray shadow dont work at all... */
2493 /* yafray: ignore photonlight as well */
2494 if ((la
->type
==LA_HEMI
) || (la
->type
==LA_YF_PHOTON
)) return;
2496 if(G
.vd
) grid
= G
.vd
->grid
;
2497 if(grid
<1.0) grid
= 1.0;
2499 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2501 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2502 uiBlockBeginAlign(block
);
2503 uiDefButBitS(block
, TOG
, LA_SHAD_RAY
, B_SHADRAY
,"Ray Shadow",10,180,80,19,&la
->mode
, 0, 0, 0, 0, "Use ray tracing for shadow");
2504 if(la
->type
==LA_SPOT
) {
2505 uiDefButBitS(block
, TOG
, LA_SHAD_BUF
, B_SHADBUF
, "Buf.Shadow",10,160,80,19,&la
->mode
, 0, 0, 0, 0, "Lets spotlight produce shadows using shadow buffer");
2506 if(la
->mode
& LA_SHAD_BUF
) {
2507 char *tip
= "Regular buffer type";
2508 if(la
->buftype
==LA_SHADBUF_IRREGULAR
)
2509 tip
= "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing";
2510 else if(la
->buftype
==LA_SHADBUF_HALFWAY
)
2511 tip
= "Regular buffer, averaging the closest and 2nd closest Z value for reducing biasing";
2513 uiDefButC(block
, MENU
, B_REDR
, "Classical %x0|Classic-Halfway %x2|Irregular %x1", 10,140,80,19,&la
->buftype
, 0, 0, 0, 0, tip
);
2516 uiBlockEndAlign(block
);
2518 uiDefButBitS(block
, TOG
, LA_ONLYSHADOW
, B_LAMPPRV
,"OnlyShadow", 10,110,80,19,&la
->mode
, 0, 0, 0, 0, "Causes light to cast shadows only without illuminating objects");
2520 if(la
->type
==LA_SPOT
) {
2521 uiBlockBeginAlign(block
);
2522 uiDefButBitS(block
, TOG
, LA_SQUARE
, B_LAMPREDRAW
,"Square", 10,60,80,19,&la
->mode
, 0, 0, 0, 0, "Sets square spotbundles");
2523 uiDefButBitS(block
, TOG
, LA_HALO
, B_LAMPREDRAW
,"Halo", 10,40,80,19,&la
->mode
, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
2525 uiBlockBeginAlign(block
);
2526 uiDefButF(block
, NUMSLI
,B_LAMPREDRAW
,"SpotSi ", 100,180,200,19,&la
->spotsize
, 1.0, 180.0, 0, 0, "Sets the angle of the spotlight beam in degrees");
2527 uiDefButF(block
, NUMSLI
,B_LAMPREDRAW
,"SpotBl ", 100,160,200,19,&la
->spotblend
, 0.0, 1.0, 0, 0, "Sets the softness of the spotlight edge");
2528 uiBlockEndAlign(block
);
2530 uiDefButF(block
, NUMSLI
,B_LAMPREDRAW
,"HaloInt ", 100,135,200,19,&la
->haint
, 0.0, 5.0, 0, 0, "Sets the intensity of the spotlight halo");
2532 if(la
->mode
& LA_SHAD_BUF
) {
2533 if(ELEM(la
->buftype
, LA_SHADBUF_REGULAR
, LA_SHADBUF_HALFWAY
)) {
2534 uiBlockBeginAlign(block
);
2535 uiDefButS(block
, NUM
,B_SBUFF
,"ShadowBufferSize:", 100,110,200,19, &la
->bufsize
,512,10240, 0, 0, "Sets the size of the shadow buffer to nearest multiple of 16");
2536 uiDefButS(block
, ROW
,B_NOP
, "Box", 100,90,65,19, &la
->filtertype
, 0.0, LA_SHADBUF_BOX
, 0, 0, "Apply Box filter for shadowbuffer samples");
2537 uiDefButS(block
, ROW
,B_NOP
, "Tent", 165,90,65,19, &la
->filtertype
, 0.0, LA_SHADBUF_TENT
, 0, 0, "Apply Tent filter for shadowbuffer samples");
2538 uiDefButS(block
, ROW
,B_NOP
, "Gauss", 230,90,70,19, &la
->filtertype
, 0.0, LA_SHADBUF_GAUSS
, 0, 0, "Apply Gauss filter for shadowbuffer samples");
2540 // uiDefButS(block, ROW,B_NOP,"SubSamples: 1", 100,90,140,19, &la->buffers, 1.0, 1.0, 0, 0, "Amount of lampbuffer subsamples, a value of larger than 1 halves the shadowbuffer size");
2541 // uiDefButS(block, ROW,B_NOP,"4", 240,90,30,19, &la->buffers, 1.0, 4.0, 0, 0, "Amount of lampbuffer subsamples, this halves the actual shadowbuffer size");
2542 // uiDefButS(block, ROW,B_NOP,"9", 270,90,30,19, &la->buffers, 1.0, 9.0, 0, 0, "Amount of lampbuffer subsamples, this halves the shadowbuffer size");
2544 uiBlockBeginAlign(block
);
2545 uiDefButS(block
, NUM
,B_LAMPREDRAW
,"Samples:", 100,60,100,19, &la
->samp
,1.0,16.0, 0, 0, "Sets the number of shadow map samples");
2546 uiDefButS(block
, NUM
,B_NOP
,"Halo step:", 200,60,100,19, &la
->shadhalostep
, 0.0, 12.0, 0, 0, "Sets the volumetric halo sampling frequency");
2547 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"Bias:", 100,40,100,19, &la
->bias
, 0.001, 5.0, 1, 0, "Sets the shadow map sampling bias");
2548 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"Soft:", 200,40,100,19, &la
->soft
,1.0,100.0, 100, 0, "Sets the size of the shadow sample area");
2550 else { /* LA_SHADBUF_IRREGULAR */
2551 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"Bias:", 100,40,100,19, &la
->bias
, 0.01, 5.0, 1, 0, "Sets the shadow map sampling bias");
2554 uiBlockBeginAlign(block
);
2555 uiDefIconButBitC(block
, TOG
, LA_SHADBUF_AUTO_START
, B_REDR
, ICON_AUTO
, 10, 10, 25, 19, &la
->bufflag
, 0.0, 0.0, 0, 0, "Automatic calculation of clipping-start, based on visible vertices");
2556 if(la
->bufflag
& LA_SHADBUF_AUTO_START
)
2557 uiDefBut(block
, LABEL
, B_NOP
, "ClipSta: Auto", 35,10,115,19, NULL
, 0, 0, 0, 0, "");
2559 uiDefButF(block
, NUM
,REDRAWVIEW3D
,"ClipSta:", 35,10,115,19, &la
->clipsta
, 0.1*grid
,1000.0*grid
, 10, 0, "Sets the shadow map clip start: objects closer will not generate shadows");
2560 uiDefIconButBitC(block
, TOG
, LA_SHADBUF_AUTO_END
, B_REDR
, ICON_AUTO
, 160, 10, 25, 19, &la
->bufflag
, 0.0, 0.0, 0, 0, "Automatic calculation of clipping-end, based on visible vertices");
2561 if(la
->bufflag
& LA_SHADBUF_AUTO_END
)
2562 uiDefBut(block
, LABEL
,B_NOP
, "ClipEnd: Auto", 185,10,115,19, NULL
, 0, 0, 0, 0, "");
2564 uiDefButF(block
, NUM
,REDRAWVIEW3D
,"ClipEnd:", 185,10,115,19,&la
->clipend
, 1.0, 5000.0*grid
, 100, 0, "Sets the shadow map clip end beyond which objects will not generate shadows");
2565 uiBlockEndAlign(block
);
2569 if(ELEM4(la
->type
, LA_AREA
, LA_SPOT
, LA_SUN
, LA_LOCAL
) && (la
->mode
& LA_SHAD_RAY
)) {
2571 if (ELEM3(la
->type
, LA_SPOT
, LA_SUN
, LA_LOCAL
)) {
2572 if (la
->ray_samp_method
== LA_SAMP_CONSTANT
) la
->ray_samp_method
= LA_SAMP_HALTON
;
2574 uiDefButS(block
, MENU
, B_REDR
, "Adaptive QMC %x1|Constant QMC %x2",
2575 100,110,200,19, &la
->ray_samp_method
, 0, 0, 0, 0, "Method for generating shadow samples: Adaptive QMC is fastest, Constant QMC is less noisy but slower");
2577 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"Soft Size", 100,80,200,19, &la
->area_size
, 0.01, 100.0, 10, 0, "Area light size, doesn't affect energy amount");
2579 uiDefButS(block
, NUM
,0,"Samples:", 100,60,200,19, &la
->ray_samp
, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp)");
2580 uiDefButF(block
, NUM
,0,"Threshold:", 100,40,200,19, &la
->adapt_thresh
, 0.0, 1.0, 100, 0, "Threshold for adaptive sampling, to control what level is considered already in shadow");
2582 else if (la
->type
== LA_AREA
) {
2583 uiDefButS(block
, MENU
, B_REDR
, "Adaptive QMC %x1|Constant QMC %x2|Constant Jittered %x0",
2584 100,180,200,19, &la
->ray_samp_method
, 0, 0, 0, 0, "Method for generating shadow samples: Adaptive QMC is fastest");
2586 if(la
->area_shape
==LA_AREA_SQUARE
)
2587 uiDefButS(block
, NUM
,0,"Samples:", 100,150,200,19, &la
->ray_samp
, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp)");
2588 else if(la
->area_shape
==LA_AREA_CUBE
)
2589 uiDefButS(block
, NUM
,0,"Samples:", 100,130,200,19, &la
->ray_samp
, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp x samp)");
2591 if (ELEM(la
->area_shape
, LA_AREA_RECT
, LA_AREA_BOX
)) {
2592 uiDefButS(block
, NUM
,0,"SamplesX:", 100,150,200,19, &la
->ray_samp
, 1.0, 16.0, 100, 0, "Sets the amount of X samples taken extra");
2593 uiDefButS(block
, NUM
,0,"SamplesY:", 100,130,200,19, &la
->ray_sampy
, 1.0, 16.0, 100, 0, "Sets the amount of Y samples taken extra");
2594 if(la
->area_shape
==LA_AREA_BOX
)
2595 uiDefButS(block
, NUM
,0,"SamplesZ:", 100,110,200,19, &la
->ray_sampz
, 1.0, 8.0, 100, 0, "Sets the amount of Z samples taken extra");
2598 if (la
->ray_samp_method
== LA_SAMP_CONSTANT
) {
2599 uiBlockBeginAlign(block
);
2600 uiDefButBitS(block
, TOG
, LA_SAMP_UMBRA
, 0,"Umbra", 100,90,200,19,&la
->ray_samp_type
, 0, 0, 0, 0, "Emphasis parts that are fully shadowed");
2601 uiDefButBitS(block
, TOG
, LA_SAMP_DITHER
, 0,"Dither", 100,70,100,19,&la
->ray_samp_type
, 0, 0, 0, 0, "Use 2x2 dithering for sampling");
2602 uiDefButBitS(block
, TOG
, LA_SAMP_JITTER
, 0,"Noise", 200,70,100,19,&la
->ray_samp_type
, 0, 0, 0, 0, "Use noise for sampling");
2603 } else if (la
->ray_samp_method
== LA_SAMP_HALTON
) {
2604 uiDefButF(block
, NUM
,0,"Threshold:", 100,90,200,19, &la
->adapt_thresh
, 0.0, 1.0, 100, 0, "Threshold for adaptive sampling, to control what level is considered already in shadow");
2610 else uiDefBut(block
, LABEL
,0," ", 100,180,200,19,NULL
, 0, 0, 0, 0, "");
2614 /* yafray: adaptation of lamp_panel_spot above with yafray specific parameters */
2615 static void lamp_panel_yafray(Object
*ob
, Lamp
*la
)
2619 block
= uiNewBlock(&curarea
->uiblocks
, "lamp_panel_yafray", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2620 if(uiNewPanel(curarea
, block
, "Yafray: Shadow and Photons", "Lamp", 640, 0, 318, 204)==0) return;
2622 /* hemis not used in yafray */
2623 if(la
->type
==LA_HEMI
) return;
2625 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2627 /* photonlight params */
2628 if (la
->type
==LA_YF_PHOTON
) {
2629 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2630 uiDefButBitS(block
, TOG
, 1, B_DIFF
,"Use QMC",10,180,80,19,&la
->YF_useqmc
, 0, 0, 0, 0, "Use QMC sampling (sometimes visible patterns)");
2631 uiBlockSetCol(block
, TH_AUTO
);
2632 uiDefButF(block
, NUMSLI
,B_LAMPREDRAW
,"Angle ", 100,180,200,19,&la
->spotsize
, 1.0, 180.0, 0, 0, "Sets the angle of the photonlight beam in degrees");
2633 uiDefButI(block
, NUM
,B_DIFF
,"photons:", 10,150,290,19, &la
->YF_numphotons
, 10000, 100000000, 0, 0, "Maximum number of photons to shoot");
2634 uiDefButI(block
, NUM
,B_DIFF
,"search:", 10,130,290,19, &la
->YF_numsearch
, 100, 1000, 0, 0, "Number of photons to mix (blur)");
2635 uiDefButS(block
, NUM
,B_DIFF
,"depth:", 10,100,290,19, &la
->YF_phdepth
, 1, 100, 0, 0, "Maximum caustic bounce depth");
2636 uiDefButF(block
, NUM
,B_DIFF
,"Blur:", 10,70,290,19, &la
->YF_causticblur
, 0.01, 1.0, 1, 0, "Amount of caustics blurring (also depends on search)");
2640 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2642 /* in yafray arealights always cast shadows, so ray shadow flag not needed */
2643 /* ray shadow also not used when halo for spot enabled */
2644 if ((la
->type
!=LA_AREA
) && (!((la
->type
==LA_SPOT
) && (la
->mode
& LA_HALO
))))
2645 uiDefButBitS(block
, TOG
, LA_SHAD_RAY
, B_SHADRAY
,"Ray Shadow",10,180,80,19,&la
->mode
, 0, 0, 0, 0, "Use ray tracing for shadow");
2647 /* in yafray the regular lamp can use shadowbuffers (softlight), used by spot with halo as well */
2648 /* to prevent clash with blender shadowbuf flag, a special flag is used for yafray */
2649 if (la
->type
==LA_LOCAL
) {
2650 uiDefButBitS(block
, TOG
, LA_YF_SOFT
, B_SHADBUF
, "Buf.Shadow",10,160,80,19,&la
->mode
, 0, 0, 0, 0, "Lets light produce shadows using shadow buffer");
2651 uiDefButF(block
, NUM
, B_DIFF
, "GloInt:", 100,155,200,19, &la
->YF_glowint
, 0.0, 1.0, 1, 0, "Sets light glow intensity, 0 is off");
2652 uiDefButF(block
, NUM
, B_DIFF
, "GloOfs:", 100,135,100,19, &la
->YF_glowofs
, 0.0, 2.0, 1, 0, "Sets light glow offset, the higher, the less 'peaked' the glow");
2653 uiDefButS(block
, NUM
, B_DIFF
, "GlowType:", 200,135,100,19, &la
->YF_glowtype
, 0, 1, 1, 0, "Sets light glow type");
2656 /* shadowbuffers used only for 'softlight' & spotlight with halo */
2657 if (((la
->type
==LA_LOCAL
) && (la
->mode
& LA_YF_SOFT
)) || ((la
->type
==LA_SPOT
) && (la
->mode
& LA_HALO
))) {
2658 /* Shadow buffer size can be anything in yafray, but reasonable minimum is 128 */
2659 /* Maximum is 1024, since zbuf in yafray is float, no multiple of 16 restriction */
2660 uiDefButS(block
, NUM
,B_DIFF
,"ShadowBufferSize:", 100,110,200,19, &la
->YF_bufsize
, 128, 1024, 0, 0, "Sets the size of the shadow buffer");
2662 /* samples & halostep params only used for spotlight with halo */
2663 if ((la
->type
==LA_SPOT
) && (la
->mode
& LA_HALO
)) {
2664 uiDefButS(block
, NUM
,B_DIFF
,"Samples:", 100,30,100,19, &la
->samp
,1.0,16.0, 0, 0, "Sets the number of shadow map samples");
2665 uiDefButS(block
, NUM
,B_DIFF
,"Halo step:", 200,30,100,19, &la
->shadhalostep
, 0.0, 12.0, 0, 0, "Sets the volumetric halo sampling frequency");
2667 uiDefButF(block
, NUM
,B_DIFF
,"Bias:", 100,10,100,19, &la
->bias
, 0.01, 5.0, 1, 0, "Sets the shadow map sampling bias");
2668 /* here can use the Blender soft param, since for yafray it has the same function as in Blender */
2669 uiDefButF(block
, NUM
,B_DIFF
,"Soft:", 200,10,100,19, &la
->soft
,1.0,100.0, 100, 0, "Sets the size of the shadow sample area");
2671 else if ((la
->type
==LA_LOCAL
) && (la
->mode
& LA_SHAD_RAY
)) {
2672 /* for spherelight, light radius */
2673 uiDefButF(block
, NUM
,B_DIFF
,"Radius:", 200,10,100,19, &la
->YF_ltradius
, 0.0,100.0, 100, 0, "Sets the radius of the lightsource, 0 is same as pointlight");
2676 if (la
->type
==LA_SPOT
) {
2678 uiDefButBitS(block
, TOG
, LA_HALO
, B_LAMPREDRAW
,"Halo", 10,50,80,19,&la
->mode
, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
2680 uiBlockSetCol(block
, TH_AUTO
);
2681 uiBlockBeginAlign(block
);
2682 uiDefButF(block
, NUMSLI
,B_LAMPREDRAW
,"SpotSi ", 100,180,200,19,&la
->spotsize
, 1.0, 180.0, 0, 0, "Sets the angle of the spotlight beam in degrees");
2683 uiDefButF(block
, NUMSLI
,B_LAMPREDRAW
,"SpotBl ", 100,160,200,19,&la
->spotblend
, 0.0, 1.0, 0, 0, "Sets the softness of the spotlight edge");
2684 uiBlockEndAlign(block
);
2686 if (la
->mode
& LA_HALO
) uiDefButF(block
, NUMSLI
,0,"HaloInt ", 100,135,200,19,&la
->haint
, 0.0, 5.0, 0, 0, "Sets the intensity of the spotlight halo");
2688 else if ((la
->type
==LA_AREA
) || ((la
->type
==LA_LOCAL
) && (la
->mode
& LA_SHAD_RAY
))) {
2689 /* area samples param also used for 'spherelight' */
2690 uiBlockBeginAlign(block
);
2691 uiBlockSetCol(block
, TH_AUTO
);
2693 uiDefButS(block
, NUM
,B_DIFF
,"Samples:", 100,180,200,19, &la
->ray_samp
, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp)");
2695 /* shadow sampling types not used in yafray, removed */
2697 else uiDefBut(block
, LABEL
,0," ", 100,180,200,19,NULL
, 0, 0, 0, 0, "");
2701 FILE *temp_lamp_file ( void )
2707 home
= getenv ("HOME");
2708 s
= strrchr (G
.main
->name
, '/');
2712 sprintf (name
, "%s/Desktop/%s.lamp", home
, s
);
2714 sprintf (name
, "%s/Desktop/untitle.lamp", home
);
2718 sprintf (name
, "%s/Desktop/untitle.lamp", home
);
2720 fp
= fopen (name
, "a");
2722 sprintf (name
, "%s/Desktop/untitle.lamp", home
);
2723 fp
= fopen (name
, "a");
2725 error ("Error: Can't save lamp RGB value to file!!!");
2729 fprintf (fp
, "=====>\n");
2733 static void temp_lamp_add(char *name
, float r
, float g
, float b
)
2740 if(!strcmp(l
->name
, name
))
2745 fp
= temp_lamp_file ();
2747 fprintf (fp
, "Scene: %s\n", G
.scene
->id
.name
);
2748 fprintf (fp
, "Lamp: %s\n", name
);
2749 fprintf (fp
, "Red: %f\nGreen: %f\nBlue: %f\n", r
, g
, b
);
2750 fprintf (fp
, "<=====\n");
2754 l
= (TempLamp
*) MEM_mallocN(sizeof(TempLamp
), "temp_lamp_add");
2755 strcpy(l
->name
, name
);
2760 l
->prev
= G
.lamp_off
.last
;
2761 if(!G
.lamp_off
.list
)
2764 G
.lamp_off
.last
->next
= l
;
2766 printf("Add lamp: %s\n", l
->name
);
2769 TempLamp
*temp_lamp_remove(char *name
)
2775 if(!strcmp(p
->name
, name
)) {
2777 p
->next
->prev
= p
->prev
;
2779 G
.lamp_off
.last
= p
->prev
;
2781 p
->prev
->next
= p
->next
;
2783 G
.lamp_off
.list
= p
->next
;
2784 printf("Del lamp: %s\n", p
->name
);
2794 static void lamp_save_state(void)
2799 ob
= G
.main
->object
.first
;
2801 if(ob
->type
==OB_LAMP
) {
2802 l
= (Lamp
*) ob
->data
;
2803 temp_lamp_add(l
->id
.name
, l
->r
, l
->g
, l
->b
);
2812 static void lamp_restore_state(void)
2818 ob
= G
.main
->object
.first
;
2820 if(ob
->type
==OB_LAMP
) {
2821 l
= (Lamp
*) ob
->data
;
2822 tl
= temp_lamp_remove(l
->id
.name
);
2834 static void lamp_turn_off(void *argv1
, void *argv2
)
2836 if(G
.lamp_off
.flag
& G_LA_OFF_ALL
)
2839 lamp_restore_state();
2840 allqueue(REDRAWVIEW3D
, 0);
2843 static void lamp_panel_falloff(Object
*ob
, Lamp
*la
)
2847 short yco
=PANEL_YMAX
;
2850 /* name "Preview" is abused to detect previewrender offset panel */
2851 block
= uiNewBlock(&curarea
->uiblocks
, "lamp_panel_falloff", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2852 uiNewPanelTabbed("Lamp", "Lamp");
2853 if(uiNewPanel(curarea
, block
, "Falloff Curve", "Lamp", PANELX
, PANELY
, PANELW
, PANELH
)==0) return;
2855 if(G
.vd
) grid
= G
.vd
->grid
;
2856 if(grid
<1.0) grid
= 1.0;
2858 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2860 BLI_init_rctf(&butr
, 10.0, 310.0, 10.0, (float)yco
);
2861 curvemap_buttons(block
, la
->curfalloff
, 's', B_LFALLOFFCHANGED
, B_LAMPREDRAW
, &butr
);
2865 static void lamp_panel_lamp(Object
*ob
, Lamp
*la
)
2871 block
= uiNewBlock(&curarea
->uiblocks
, "lamp_panel_lamp", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2872 if(uiNewPanel(curarea
, block
, "Lamp", "Lamp", 320, 0, 318, 204)==0) return;
2874 if(G
.vd
) grid
= G
.vd
->grid
;
2875 if(grid
<1.0) grid
= 1.0;
2877 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2879 uiBlockSetCol(block
, TH_BUT_SETTING2
);
2880 xco
= std_libbuttons(block
, 8, 180, 0, NULL
, B_LAMPBROWSE
, ID_LA
, 0, (ID
*)la
, (ID
*)ob
, &(G
.buts
->menunr
), B_LAMPALONE
, B_LAMPLOCAL
, 0, 0, 0);
2882 uiBlockSetCol(block
, TH_AUTO
);
2883 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"Dist:", xco
,180,300-xco
,20,&la
->dist
, 0.01, 5000.0*grid
, 100, 0, "Sets the distance value at which light intensity is half");
2885 uiBlockBeginAlign(block
);
2886 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2887 if(la
->type
==LA_AREA
) {
2888 //uiDefButS(block, MENU, B_LAMPREDRAW, "Shape %t|Square %x0|Rect %x1|Cube %x2|Box %x3",
2889 uiDefButS(block
, MENU
, B_LAMPREDRAW
, "Shape %t|Square %x0|Rect %x1",
2890 10, 150, 100, 19, &la
->area_shape
, 0,0,0,0, "Sets area light shape");
2891 if (ELEM(la
->area_shape
, LA_AREA_RECT
, LA_AREA_BOX
)){
2892 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"SizeX ", 10,130,100,19, &la
->area_size
, 0.01, 100.0, 10, 0, "Area light size X, doesn't affect energy amount");
2893 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"SizeY ", 10,110,100,19, &la
->area_sizey
, 0.01, 100.0, 10, 0, "Area light size Y, doesn't affect energy amount");
2895 if(la
->area_shape
==LA_AREA_BOX
)
2896 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"SizeZ ", 10,90,100,19, &la
->area_sizez
, 0.01, 100.0, 10, 0, "Area light size Z, doesn't affect energy amount");
2897 if (ELEM(la
->area_shape
, LA_AREA_SQUARE
, LA_AREA_CUBE
))
2898 uiDefButF(block
, NUM
,B_LAMPREDRAW
,"Size ", 10,130,100,19, &la
->area_size
, 0.01, 100.0, 10, 0, "Area light size, doesn't affect energy amount");
2900 else if( ELEM(la
->type
, LA_LOCAL
, LA_SPOT
)) {
2901 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2902 uiDefButS(block
, MENU
, B_LAMPREDRAW
, "Falloff %t|Constant %x0|Inverse Linear %x1|Inverse Square %x2|Custom Curve %x3|Lin/Quad Weighted %x4|",
2903 10,150,100,19, &la
->falloff_type
, 0,0,0,0, "Lamp falloff - intensity decay with distance");
2904 uiDefButBitS(block
, TOG
, LA_SPHERE
, REDRAWVIEW3D
,"Sphere", 10,130,100,19,&la
->mode
, 0, 0, 0, 0, "Sets light intensity to zero for objects beyond the distance value");
2907 uiBlockBeginAlign(block
);
2908 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2909 uiDefButBitS(block
, TOG
, LA_LAYER
, 0,"Layer", 10,70,100,19,&la
->mode
, 0, 0, 0, 0, "Illuminates objects in the same layer as the lamp only");
2910 uiDefButBitS(block
, TOG
, LA_NEG
, B_LAMPPRV
,"Negative", 10,50,100,19,&la
->mode
, 0, 0, 0, 0, "Sets lamp to cast negative light");
2911 uiDefButBitS(block
, TOG
, LA_NO_DIFF
, 0,"No Diffuse", 10,30,100,19,&la
->mode
, 0, 0, 0, 0, "Disables diffuse shading of material illuminated by this lamp");
2912 uiDefButBitS(block
, TOG
, LA_NO_SPEC
, 0,"No Specular", 10,10,100,19,&la
->mode
, 0, 0, 0, 0, "Disables specular shading of material illuminated by this lamp");
2913 uiBlockEndAlign(block
);
2915 uiBlockSetCol(block
, TH_AUTO
);
2916 uiDefButF(block
, NUMSLI
,B_LAMPPRV
,"Energy ", 120,150,180,20, &(la
->energy
), 0.0, 10.0, 0, 0, "Sets the intensity of the light");
2918 uiBlockBeginAlign(block
);
2919 uiDefButF(block
, NUMSLI
,B_LAMPPRV
,"R ", 120,120,180,20,&la
->r
, 0.0, 1.0, B_COLLAMP
, 0, "Sets the red component of the light");
2920 uiDefButF(block
, NUMSLI
,B_LAMPPRV
,"G ", 120,100,180,20,&la
->g
, 0.0, 1.0, B_COLLAMP
, 0, "Sets the green component of the light");
2921 uiDefButF(block
, NUMSLI
,B_LAMPPRV
,"B ", 120,80,180,20,&la
->b
, 0.0, 1.0, B_COLLAMP
, 0, "Sets the blue component of the light");
2922 uiBlockEndAlign(block
);
2924 uiDefButF(block
, COL
, B_LAMPPRV
, "", 120,52,180,24, &la
->r
, 0, 0, 0, B_COLLAMP
, "");
2926 uiBlockBeginAlign(block
);
2927 if (ELEM(la
->type
, LA_LOCAL
, LA_SPOT
) && (la
->falloff_type
== LA_FALLOFF_SLIDERS
)) {
2928 uiDefButF(block
, NUMSLI
,B_LAMPPRV
,"Linear ", 120,30,180,19,&la
->att1
, 0.0, 1.0, 0, 0, "Set the linear distance attenuatation for a quad lamp");
2929 uiDefButF(block
, NUMSLI
,B_LAMPPRV
,"Quad ", 120,10,180,19,&la
->att2
, 0.0, 1.0, 0, 0, "Set the quadratic distance attenuatation for a quad lamp");
2931 else if(la
->type
==LA_AREA
) {
2932 if(la
->k
==0.0) la
->k
= 1.0;
2933 uiDefButF(block
, NUMSLI
,0,"Gamma ", 120,10,180,19,&la
->k
, 0.001, 2.0, 100, 0, "Set the light gamma correction value");
2938 static void lamp_panel_preview(Object
*ob
, Lamp
*la
)
2943 /* name "Preview" is abused to detect previewrender offset panel */
2944 block
= uiNewBlock(&curarea
->uiblocks
, "lamp_panel_preview", UI_EMBOSS
, UI_HELV
, curarea
->win
);
2945 if(uiNewPanel(curarea
, block
, "Preview", "Lamp", 0, 0, 318, 204)==0) return;
2947 uiSetButLock(la
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
2949 uiBlockSetDrawExtraFunc(block
, BIF_previewdraw
);
2951 // label to force a boundbox for buttons not to be centered
2952 uiDefBut(block
, LABEL
, 0, " ", 20,20,10,10, 0, 0, 0, 0, 0, "");
2953 uiBlockBeginAlign(block
);
2954 uiDefButS(block
, ROW
,B_LAMPREDRAW
,"Lamp", 200,175,80,25,&la
->type
,1.0,(float)LA_LOCAL
, 0, 0, "Creates an omnidirectional point light source");
2955 uiDefButS(block
, ROW
,B_LAMPREDRAW
,"Area", 200,150,80,25,&la
->type
,1.0,(float)LA_AREA
, 0, 0, "Creates a directional area light source");
2956 uiDefButS(block
, ROW
,B_LAMPREDRAW
,"Spot", 200,125,80,25,&la
->type
,1.0,(float)LA_SPOT
, 0, 0, "Creates a directional cone light source");
2957 uiDefButS(block
, ROW
,B_LAMPREDRAW
,"Sun", 200,100,80,25,&la
->type
,1.0,(float)LA_SUN
, 0, 0, "Creates a constant direction parallel ray light source");
2958 uiDefButS(block
, ROW
,B_LAMPREDRAW
,"Hemi", 200,75,80,25,&la
->type
,1.0,(float)LA_HEMI
, 0, 0, "Creates a 180 degree constant light source");
2959 /* yafray: extra type, photonlight */
2960 if (G
.scene
->r
.renderer
==R_YAFRAY
)
2961 uiDefButS(block
, ROW
,B_LAMPREDRAW
,"Photon", 200,50,80,25,&la
->type
,1.0,(float)LA_YF_PHOTON
, 0, 0, "Creates a special caustics photon 'light', not a real lightsource, use with other lights");
2963 uiBlockBeginAlign(block
);
2964 uiBlockSetCol(block
, TH_BUT_SETTING1
);
2965 uiDefButBitS(block
, TOG
, LA_DRAW_COLOR
, REDRAWVIEW3D
, "Draw Color", 200, 20, 80, 19, &la
->mode
, 0, 0, 0, 0, "Draws the color of the lamp in the 3D View");
2967 uiBlockBeginAlign(block
);
2968 if(G
.lamp_off
.flag
& G_LA_OFF_ALL
)
2969 but
= uiDefButBitS(block
, TOG
, G_LA_OFF_ALL
, 0, "Lamps Off", 200, 40, 80, 19, &G
.lamp_off
.flag
, 0, 0, 0, 0, "Restore RGB for all lamps");
2971 but
= uiDefButBitS(block
, TOG
, G_LA_OFF_ALL
, 0, "Lamps On", 200, 40, 80, 19, &G
.lamp_off
.flag
, 0, 0, 0, 0, "Set RGB white for all lamps");
2972 uiButSetFunc(but
, lamp_turn_off
, NULL
, NULL
);
2973 uiBlockEndAlign(block
);
2977 /* ****************** MATERIAL ***************** */
2980 void do_matbuts(unsigned short event
)
2982 static short mtexcopied
=0;
2983 static MTex mtexcopybuf
;
2987 /* all operations default on active material layer here */
2988 /* but this also gets called for lamp and world... */
2989 ma
= G
.buts
->lockpoin
;
2990 if(ma
&& GS(ma
->id
.name
)==ID_MA
)
2991 ma
= editnode_get_active_material(ma
);
2996 case B_MAT_YF_PRESET
: {
2997 switch (ma
->YF_preset
) {
2999 /* normal mode, no reflection/refraction */
3001 ma
->mode
&= ~(MA_RAYMIRROR
+MA_RAYTRANSP
+MA_ZTRA
);
3007 ma
->fresnel_mir_i
= 5;
3008 ma
->mode
|= (MA_RAYMIRROR
+MA_RAYTRANSP
);
3009 ma
->mode
&= ~MA_ZTRA
;
3018 ma
->fresnel_mir_i
= 5;
3019 ma
->mode
|= (MA_RAYMIRROR
+MA_RAYTRANSP
);
3020 ma
->mode
&= ~MA_ZTRA
;
3026 /* uniform reflect */
3029 ma
->fresnel_mir_i
= 1;
3030 ma
->mode
|= MA_RAYMIRROR
;
3031 ma
->mode
&= ~(MA_RAYTRANSP
+MA_ZTRA
);
3035 /* fresnel reflect */
3038 ma
->fresnel_mir_i
= 5;
3039 ma
->mode
|= MA_RAYMIRROR
;
3040 ma
->mode
&= ~(MA_RAYTRANSP
+MA_ZTRA
);
3045 BIF_preview_changed(ID_MA
);
3046 allqueue(REDRAWBUTSSHADING
, 0);
3047 shade_buttons_change_3d();
3051 scrarea_queue_headredraw(curarea
);
3052 allqueue(REDRAWBUTSSHADING
, 0);
3053 allqueue(REDRAWIPO
, 0);
3054 allqueue(REDRAWOOPS
, 0);
3055 BIF_preview_changed(ID_MA
);
3058 scrarea_queue_headredraw(curarea
);
3059 allqueue(REDRAWBUTSSHADING
, 0);
3060 allqueue(REDRAWOOPS
, 0);
3061 // BIF_previewdraw(); push/pop!
3064 if(ma
) end_render_material(ma
); /// temporal... 3d preview
3065 BIF_preview_changed(ID_MA
);
3066 allqueue(REDRAWBUTSSHADING
, 0);
3067 shade_buttons_change_3d();
3070 BIF_preview_changed(ID_LA
);
3071 allqueue(REDRAWBUTSSHADING
, 0);
3072 shade_buttons_change_3d();
3075 BIF_preview_changed(ID_WO
);
3076 allqueue(REDRAWBUTSSHADING
, 0);
3079 BIF_preview_changed(ID_WO
);
3080 allqueue(REDRAWBUTSSHADING
, 0);
3081 allqueue(REDRAWVIEW3D
, 0);
3084 /* when halo is disabled, clear star flag, this is the same as MA_FACETEXTURE <blush> */
3085 /* same for 'xtreme alpha' which is 'only shadow' */
3087 if((ma
->mode
& MA_HALO
)==0) {
3088 ma
->mode
&= ~(MA_STAR
|MA_HALO_XALPHA
|MA_ZINV
|MA_ENV
);
3090 BIF_preview_changed(ID_MA
);
3091 allqueue(REDRAWBUTSSHADING
, 0);
3092 shade_buttons_change_3d();
3096 mtex
= ma
->mtex
[(int) ma
->texact
];
3098 if(mtex
->tex
) mtex
->tex
->id
.us
--;
3100 ma
->mtex
[ (int) ma
->texact
]= 0;
3101 BIF_undo_push("Unlink material texture");
3102 if(ma
) end_render_material(ma
); /// temporal... 3d preview
3103 allqueue(REDRAWBUTSSHADING
, 0);
3104 allqueue(REDRAWOOPS
, 0);
3105 BIF_preview_changed(ID_MA
);
3113 int i0
= ma
->texact
;
3114 int i1
= ma
->texact
+ (event
==B_MTEXUP
?-1:1);
3116 if( (event
==B_MTEXUP
)?(i0
== 0):(i0
== MAX_MTEX
-1) ) break;
3117 if( ma
->mtex
[i0
] || ma
->mtex
[i1
] )
3119 /* swap visibility settings */
3120 int sti0
= ma
->septex
& (1<<i0
);
3121 int sti1
= ma
->septex
& (1<<i1
);
3123 if(sti0
) ma
->septex
|= (1<<i1
); else ma
->septex
&= ~(1<<i1
);
3124 if(sti1
) ma
->septex
|= (1<<i0
); else ma
->septex
&= ~(1<<i0
);
3129 ma
->mtex
[i0
] = ma
->mtex
[i1
];
3132 else if(!ma
->mtex
[i1
])
3134 ma
->mtex
[i1
] = ma
->mtex
[i0
];
3139 memcpy(&mtexcopybuf
, ma
->mtex
[ i1
], sizeof(MTex
));
3140 memcpy(ma
->mtex
[ i1
], ma
->mtex
[ i0
], sizeof(MTex
));
3141 memcpy(ma
->mtex
[ i0
], &mtexcopybuf
, sizeof(MTex
));
3144 ma
->texact
+= (event
==B_MTEXUP
)?-1:1;
3146 BIF_preview_changed(ID_MA
);
3147 scrarea_queue_winredraw(curarea
);
3152 if(ma
&& ma
->mtex
[(int)ma
->texact
] ) {
3153 mtex
= ma
->mtex
[(int)ma
->texact
];
3154 if(mtex
->tex
==NULL
) {
3155 error("No texture available");
3158 memcpy(&mtexcopybuf
, ma
->mtex
[(int)ma
->texact
], sizeof(MTex
));
3164 if(ma
&& mtexcopied
&& mtexcopybuf
.tex
) {
3165 if(ma
->mtex
[(int)ma
->texact
]==NULL
)
3166 ma
->mtex
[(int)ma
->texact
]= MEM_mallocN(sizeof(MTex
), "mtex");
3167 else if(ma
->mtex
[(int)ma
->texact
]->tex
)
3168 ma
->mtex
[(int)ma
->texact
]->tex
->id
.us
--;
3170 memcpy(ma
->mtex
[(int)ma
->texact
], &mtexcopybuf
, sizeof(MTex
));
3172 id_us_plus((ID
*)mtexcopybuf
.tex
);
3173 BIF_undo_push("Paste mapping settings");
3174 BIF_preview_changed(ID_MA
);
3175 scrarea_queue_winredraw(curarea
);
3180 ma
->mode
&= ~MA_RAYTRANSP
;
3181 //BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); /// temporal... 3d preview
3182 allqueue(REDRAWBUTSSHADING
, 0);
3183 BIF_preview_changed(ID_MA
);
3186 case B_MATRAYTRANSP
:
3188 ma
->mode
&= ~MA_ZTRA
;
3189 if(ma
) end_render_material(ma
); /// temporal... 3d preview
3190 allqueue(REDRAWBUTSSHADING
, 0);
3191 BIF_preview_changed(ID_MA
);
3194 case B_MATCOLORBAND
:
3196 if(ma
->mode
& MA_RAMP_COL
)
3197 if(ma
->ramp_col
==NULL
) ma
->ramp_col
= add_colorband(0);
3198 if(ma
->mode
& MA_RAMP_SPEC
)
3199 if(ma
->ramp_spec
==NULL
) ma
->ramp_spec
= add_colorband(0);
3201 if(ma
) end_render_material(ma
); /// temporal... 3d preview
3202 allqueue(REDRAWBUTSSHADING
, 0);
3203 BIF_preview_changed(ID_MA
);
3204 shade_buttons_change_3d();
3207 case B_MAT_USENODES
:
3208 ma
= G
.buts
->lockpoin
; /* use base material instead */
3210 if(ma
->use_nodes
&& ma
->nodetree
==NULL
) {
3211 node_shader_default(ma
);
3213 if(ma
) end_render_material(ma
); /// temporal... 3d preview
3214 BIF_preview_changed(ID_MA
);
3215 allqueue(REDRAWNODE
, 0);
3216 allqueue(REDRAWBUTSSHADING
, 0);
3217 allqueue(REDRAWIPO
, 0);
3220 case B_MAT_VCOL_PAINT
:
3222 ma
->mode
&= ~MA_VERTEXCOL
;
3223 BIF_preview_changed(ID_MA
);
3224 allqueue(REDRAWBUTSSHADING
, 0);
3227 case B_MAT_VCOL_LIGHT
:
3229 ma
->mode
&= ~MA_VERTEXCOLP
;
3230 BIF_preview_changed(ID_MA
);
3231 allqueue(REDRAWBUTSSHADING
, 0);
3239 /* if from nodes, hide options that are not available */
3240 static void material_panel_map_to(Material
*ma
, int from_nodes
)
3245 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_map_to", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3246 uiNewPanelTabbed("Texture", "Material");
3247 if(uiNewPanel(curarea
, block
, "Map To", "Material", 1600, 0, 318, 204)==0) return;
3249 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3251 mtex
= ma
->mtex
[ ma
->texact
];
3257 /* TEXTURE OUTPUT */
3258 uiBlockBeginAlign(block
);
3259 uiDefButBitS(block
, TOG
, MTEX_STENCIL
, B_MATPRV
, "Stencil", 10,125,45,19, &(mtex
->texflag
), 0, 0, 0, 0, "Sets the texture mapping to stencil mode");
3260 uiDefButBitS(block
, TOG
, MTEX_NEGATIVE
, B_MATPRV
, "Neg", 55,125,30,19, &(mtex
->texflag
), 0, 0, 0, 0, "Inverts the values of the texture to reverse its effect");
3261 uiDefButBitS(block
, TOG
,MTEX_RGBTOINT
, B_MATPRV
, "No RGB", 85,125,60,19, &(mtex
->texflag
), 0, 0, 0, 0, "Converts texture RGB values to intensity (gray) values");
3262 uiBlockEndAlign(block
);
3264 uiBlockBeginAlign(block
);
3265 uiDefButF(block
, COL
, B_MATPRV
, "", 10,100,135,19, &(mtex
->r
), 0, 0, 0, B_MTEXCOL
, "");
3267 if(ma
->colormodel
==MA_HSV
) {
3268 uiBlockSetCol(block
, TH_BUT_SETTING1
);
3269 uiDefButF(block
, HSVSLI
, B_MATPRV
, "H ", 10,80,135,19, &(mtex
->r
), 0.0, 0.9999, B_MTEXCOL
, 0, "");
3270 uiDefButF(block
, HSVSLI
, B_MATPRV
, "S ", 10,60,135,19, &(mtex
->r
), 0.0001, 1.0, B_MTEXCOL
, 0, "");
3271 uiDefButF(block
, HSVSLI
, B_MATPRV
, "V ", 10,40,135,19, &(mtex
->r
), 0.0001, 1.0, B_MTEXCOL
, 0, "");
3272 uiBlockSetCol(block
, TH_AUTO
);
3275 uiDefButF(block
, NUMSLI
, B_MATPRV
, "R ", 10,80,135,19, &(mtex
->r
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
3276 uiDefButF(block
, NUMSLI
, B_MATPRV
, "G ", 10,60,135,19, &(mtex
->g
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
3277 uiDefButF(block
, NUMSLI
, B_MATPRV
, "B ", 10,40,135,19, &(mtex
->b
), 0.0, 1.0, B_MTEXCOL
, 0, "The default color for textures that don't return RGB");
3279 uiBlockEndAlign(block
);
3281 uiDefButF(block
, NUMSLI
, B_MATPRV
, "DVar ", 10,10,135,19, &(mtex
->def_var
), 0.0, 1.0, 0, 0, "The default value the texture uses to mix with (not RGB)");
3284 uiBlockBeginAlign(block
);
3285 uiDefButBitS(block
, TOG
, MAP_COL
, B_MATPRV
, "Col", 10,180,40,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect basic color of the material");
3286 uiDefButBitS(block
, TOG3
, MAP_NORM
, B_MATPRV
, "Nor", 50,180,40,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the rendered normal");
3287 uiDefButBitS(block
, TOG
, MAP_COLSPEC
, B_MATPRV
, "Csp", 90,180,40,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the specularity color");
3288 uiDefButBitS(block
, TOG
, MAP_COLMIR
, B_MATPRV
, "Cmir", 130,180,50,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the mirror color");
3289 uiDefButBitS(block
, TOG3
, MAP_REF
, B_MATPRV
, "Ref", 180,180,40,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the value of the materials reflectivity");
3290 uiDefButBitS(block
, TOG3
, MAP_SPEC
, B_MATPRV
, "Spec", 220,180,50,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the value of specularity");
3291 uiDefButBitS(block
, TOG3
, MAP_AMB
, B_MATPRV
, "Amb", 270,180,40,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the value of ambient");
3293 uiDefButBitS(block
, TOG3
, MAP_HAR
, B_MATPRV
, "Hard", 10,160,50,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the hardness value");
3294 uiDefButBitS(block
, TOG3
, MAP_RAYMIRR
, B_MATPRV
, "RayMir", 60,160,50,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the ray-mirror value");
3295 uiDefButBitS(block
, TOG3
, MAP_ALPHA
, B_MATPRV
, "Alpha", 110,160,50,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the alpha value");
3296 uiDefButBitS(block
, TOG3
, MAP_EMIT
, B_MATPRV
, "Emit", 160,160,45,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the emit value");
3297 uiDefButBitS(block
, TOG3
, MAP_TRANSLU
, B_MATPRV
, "TransLu", 205,160,60,19, &(mtex
->mapto
), 0, 0, 0, 0, "Causes the texture to affect the layer blending value");
3299 uiDefButBitS(block
, TOG3
, MAP_DISPLACE
, B_MATPRV
, "Disp", 265,160,45,19, &(mtex
->mapto
), 0, 0, 0, 0, "Let the texture displace the surface");
3300 uiBlockEndAlign(block
);
3302 uiBlockBeginAlign(block
);
3303 uiDefButS(block
, MENU
, B_MATPRV
, mapto_blendtype_pup(),155,125,155,19, &(mtex
->blendtype
), 0, 0, 0, 0, "Texture blending mode");
3304 uiBlockEndAlign(block
);
3306 uiBlockBeginAlign(block
);
3307 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Col ", 155,100,155,19, &(mtex
->colfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture affects color values");
3308 /* newnoise: increased range to 25, the constant offset for bumpmapping quite often needs a higher nor setting */
3309 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Nor ", 155,80,155,19, &(mtex
->norfac
), 0.0, 25.0, 0, 0, "Sets the amount the texture affects normal values");
3310 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Var ", 155,60,155,19, &(mtex
->varfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
3311 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Disp ", 155,40,155,19, &(mtex
->dispfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture displaces the surface");
3313 uiBlockBeginAlign(block
);
3314 uiDefButBitS(block
, TOG
, MAP_WARP
, B_MATPRV
, "Warp", 155,10,40,19, &(mtex
->mapto
), 0, 0, 0, 0, "Let the texture warp texture coordinates of next channels");
3315 uiDefButF(block
, NUMSLI
, B_MATPRV
, "fac ", 195,10,115,19, &(mtex
->warpfac
), 0.0, 1.0, 0, 0, "Sets the amount the texture affects texture coordinates of next channels");
3318 /* autocomplete callback for buttons */
3319 void autocomplete_uv(char *str
, void *arg_v
)
3322 CustomDataLayer
*layer
;
3323 AutoComplete
*autocpl
;
3329 autocpl
= autocomplete_begin(str
, 32);
3331 /* search if str matches the beginning of name */
3332 for(me
= G
.main
->mesh
.first
; me
; me
=me
->id
.next
)
3333 for(a
=0, layer
= me
->fdata
.layers
; a
<me
->fdata
.totlayer
; a
++, layer
++)
3334 if(layer
->type
== CD_MTFACE
)
3335 autocomplete_do_name(autocpl
, layer
->name
);
3337 autocomplete_end(autocpl
, str
);
3340 int verify_valid_uv_name(char *str
)
3343 CustomDataLayer
*layer
;
3349 /* search if str matches the name */
3350 for(me
= G
.main
->mesh
.first
; me
; me
=me
->id
.next
)
3351 for(a
=0, layer
= me
->fdata
.layers
; a
<me
->fdata
.totlayer
; a
++, layer
++)
3352 if(layer
->type
== CD_MTFACE
)
3353 if(strcmp(layer
->name
, str
)==0)
3359 static void material_panel_map_input(Object
*ob
, Material
*ma
)
3366 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_map_input", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3367 uiNewPanelTabbed("Texture", "Material");
3368 if(uiNewPanel(curarea
, block
, "Map Input", "Material", 1280, 0, 318, 204)==0) return;
3370 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3372 mtex
= ma
->mtex
[ ma
->texact
];
3379 uiBlockBeginAlign(block
);
3380 uiDefButS(block
, ROW
, B_MATPRV
, "Glob", 630,180,45,18, &(mtex
->texco
), 4.0, (float)TEXCO_GLOB
, 0, 0, "Uses global coordinates for the texture coordinates");
3381 uiDefButS(block
, ROW
, B_MATPRV
, "Object", 675,180,75,18, &(mtex
->texco
), 4.0, (float)TEXCO_OBJECT
, 0, 0, "Uses linked object's coordinates for texture coordinates");
3382 if(mtex
->texco
== TEXCO_UV
) {
3383 if(!verify_valid_uv_name(mtex
->uvname
))
3384 uiBlockSetCol(block
, TH_REDALERT
);
3385 but
=uiDefBut(block
, TEX
, B_MATPRV
, "UV:", 750,180,158,18, mtex
->uvname
, 0, 31, 0, 0, "Set name of UV layer to use, default is active UV layer");
3386 uiButSetCompleteFunc(but
, autocomplete_uv
, NULL
);
3387 uiBlockSetCol(block
, TH_AUTO
);
3390 uiDefIDPoinBut(block
, test_obpoin_but
, ID_OB
, B_MATPRV
, "Ob:",750,180,158,18, &(mtex
->object
), "");
3392 uiDefButS(block
, ROW
, B_MATPRV
, "UV", 630,160,40,18, &(mtex
->texco
), 4.0, (float)TEXCO_UV
, 0, 0, "Uses UV coordinates for texture coordinates");
3393 uiDefButS(block
, ROW
, B_MATPRV
, "Orco", 670,160,55,18, &(mtex
->texco
), 4.0, (float)TEXCO_ORCO
, 0, 0, "Uses the original undeformed coordinates of the object");
3394 if( give_parteff(ob
) )
3395 uiDefButS(block
, ROW
, B_MATPRV
, "Strand", 725,160,50,18, &(mtex
->texco
), 4.0, (float)TEXCO_STRAND
, 0, 0, "Uses normalized strand texture coordinate (1D)");
3397 uiDefButS(block
, ROW
, B_MATPRV
, "Stick", 725,160,50,18, &(mtex
->texco
), 4.0, (float)TEXCO_STICKY
, 0, 0, "Uses mesh's sticky coordinates for the texture coordinates");
3398 uiDefButS(block
, ROW
, B_MATPRV
, "Win", 775,160,45,18, &(mtex
->texco
), 4.0, (float)TEXCO_WINDOW
, 0, 0, "Uses screen coordinates as texture coordinates");
3399 uiDefButS(block
, ROW
, B_MATPRV
, "Nor", 820,160,44,18, &(mtex
->texco
), 4.0, (float)TEXCO_NORM
, 0, 0, "Uses normal vector as texture coordinates");
3400 uiDefButS(block
, ROW
, B_MATPRV
, "Refl", 864,160,44,18, &(mtex
->texco
), 4.0, (float)TEXCO_REFL
, 0, 0, "Uses reflection vector as texture coordinates");
3402 uiDefButS(block
, ROW
, B_MATPRV
, "Stress", 630,140,70,18, &(mtex
->texco
), 4.0, (float)TEXCO_STRESS
, 0, 0, "Uses the difference of edge lengths compared to original coordinates of the mesh");
3403 uiDefButS(block
, ROW
, B_MATPRV
, "Tangent", 700,140,70,18, &(mtex
->texco
), 4.0, (float)TEXCO_TANGENT
, 0, 0, "Uses the optional tangent vector as texture coordinates");
3406 uiBlockBeginAlign(block
);
3407 uiDefButC(block
, ROW
, B_MATPRV
, "Flat", 630,115,48,19, &(mtex
->mapping
), 5.0, (float)MTEX_FLAT
, 0, 0, "Maps X and Y coordinates directly");
3408 uiDefButC(block
, ROW
, B_MATPRV
, "Cube", 681,115,50,19, &(mtex
->mapping
), 5.0, (float)MTEX_CUBE
, 0, 0, "Maps using the normal vector");
3409 uiDefButC(block
, ROW
, B_MATPRV
, "Tube", 630,95,48,19, &(mtex
->mapping
), 5.0, (float)MTEX_TUBE
, 0, 0, "Maps with Z as central axis (tube-like)");
3410 uiDefButC(block
, ROW
, B_MATPRV
, "Sphe", 681,95,50,19, &(mtex
->mapping
), 5.0, (float)MTEX_SPHERE
, 0, 0, "Maps with Z as central axis (sphere-like)");
3412 uiBlockBeginAlign(block
);
3413 for(b
=0; b
<3; b
++) {
3415 if(b
==0) cp
= &(mtex
->projx
);
3416 else if(b
==1) cp
= &(mtex
->projy
);
3417 else cp
= &(mtex
->projz
);
3419 uiDefButC(block
, ROW
, B_MATPRV
, "", 630, 50-20*b
, 24, 18, cp
, 6.0+b
, 0.0, 0, 0, "");
3420 uiDefButC(block
, ROW
, B_MATPRV
, "X", 656, 50-20*b
, 24, 18, cp
, 6.0+b
, 1.0, 0, 0, "");
3421 uiDefButC(block
, ROW
, B_MATPRV
, "Y", 682, 50-20*b
, 24, 18, cp
, 6.0+b
, 2.0, 0, 0, "");
3422 uiDefButC(block
, ROW
, B_MATPRV
, "Z", 708, 50-20*b
, 24, 18, cp
, 6.0+b
, 3.0, 0, 0, "");
3425 uiBlockBeginAlign(block
);
3426 uiDefButF(block
, NUM
, B_MATPRV
, "ofsX", 778,115,130,19, mtex
->ofs
, -10.0, 10.0, 10, 0, "Fine tunes texture mapping X coordinate");
3427 uiDefButF(block
, NUM
, B_MATPRV
, "ofsY", 778,95,130,19, mtex
->ofs
+1, -10.0, 10.0, 10, 0, "Fine tunes texture mapping Y coordinate");
3428 uiDefButF(block
, NUM
, B_MATPRV
, "ofsZ", 778,75,130,19, mtex
->ofs
+2, -10.0, 10.0, 10, 0, "Fine tunes texture mapping Z coordinate");
3429 uiBlockBeginAlign(block
);
3430 uiDefButF(block
, NUM
, B_MATPRV
, "sizeX", 778,50,130,19, mtex
->size
, -100.0, 100.0, 10, 0, "Sets scaling for the texture's X size");
3431 uiDefButF(block
, NUM
, B_MATPRV
, "sizeY", 778,30,130,19, mtex
->size
+1, -100.0, 100.0, 10, 0, "Sets scaling for the texture's Y size");
3432 uiDefButF(block
, NUM
, B_MATPRV
, "sizeZ", 778,10,130,19, mtex
->size
+2, -100.0, 100.0, 10, 0, "Sets scaling for the texture's Z size");
3433 uiBlockEndAlign(block
);
3438 static void material_panel_texture(Material
*ma
)
3445 char str
[64], *strp
;
3447 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_texture", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3448 if(uiNewPanel(curarea
, block
, "Texture", "Material", 960, 0, 318, 204)==0) return;
3452 uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
3454 uiBlockBeginAlign(block
);
3455 for(a
= 0; a
<MAX_MTEX
; a
++) {
3457 if(mtex
&& mtex
->tex
) splitIDname(mtex
->tex
->id
.name
+2, str
, &loos
);
3458 else strcpy(str
, "");
3460 uiDefButC(block
, ROW
, B_TEXCHANNEL
, str
, 10, 180-18*a
, 70, 20, &(ma
->texact
), 3.0, (float)a
, 0, 0, "");
3462 uiBlockEndAlign(block
);
3464 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3467 uiBlockSetCol(block
, TH_AUTO
);
3469 for(a
= 0; a
<MAX_MTEX
; a
++) {
3471 if(mtex
&& mtex
->tex
) {
3472 uiDefIconButBitS(block
, ICONTOGN
, 1<<a
, B_MATPRV
, ICON_CHECKBOX_HLT
-1, -20, 180-18*a
, 28, 20, &ma
->septex
, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
3475 uiBlockBeginAlign(block
);
3476 uiDefIconBut(block
, BUT
, B_MTEXCOPY
, ICON_COPYUP
, 100,180,23,21, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer");
3477 uiDefIconBut(block
, BUT
, B_MTEXPASTE
, ICON_PASTEUP
, 125,180,23,21, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer");
3478 uiBlockEndAlign(block
);
3479 uiBlockBeginAlign(block
);
3480 uiDefIconBut(block
, BUT
, B_MTEXUP
, VICON_MOVE_UP
, 175,180,23,21, 0, 0, 0, 0, 0, "Moves the texture up one place");
3481 uiDefIconBut(block
, BUT
, B_MTEXDOWN
, VICON_MOVE_DOWN
, 200,180,23,21, 0, 0, 0, 0, 0, "Moves the texture down one place");
3482 uiBlockEndAlign(block
);
3483 uiBlockSetCol(block
, TH_AUTO
);
3485 mtex
= ma
->mtex
[ ma
->texact
];
3491 /* TEXTUREBLOK SELECT */
3492 uiBlockSetCol(block
, TH_BUT_SETTING2
);
3493 if(G
.main
->tex
.first
==NULL
)
3496 id
= (ID
*) mtex
->tex
;
3497 IDnames_to_pupstring(&strp
, NULL
, "ADD NEW %x32767", &(G
.main
->tex
), id
, &(G
.buts
->texnr
));
3498 uiDefButS(block
, MENU
, B_EXTEXBROWSE
, strp
, 100,130,20,20, &(G
.buts
->texnr
), 0, 0, 0, 0, "Selects an existing texture or creates new");
3502 uiDefBut(block
, TEX
, B_IDNAME
, "TE:", 100,150,163,20, id
->name
+2, 0.0, 21.0, 0, 0, "Displays name of the texture block: click to change");
3503 sprintf(str
, "%d", id
->us
);
3504 uiDefBut(block
, BUT
, 0, str
, 196,130,21,20, 0, 0, 0, 0, 0, "Displays number of users of texture");
3505 uiDefIconBut(block
, BUT
, B_AUTOTEXNAME
, ICON_AUTO
, 241,130,21,20, 0, 0, 0, 0, 0, "Auto-assigns name to texture");
3507 if(ma
->id
.lib
) uiDefIconBut(block
, BUT
, 0, ICON_DATALIB
, 219,130,21,20, 0, 0, 0, 0, 0, "");
3508 else uiDefIconBut(block
, BUT
, 0, ICON_PARLIB
, 219,130,21,20, 0, 0, 0, 0, 0, "");
3510 uiBlockSetCol(block
, TH_AUTO
);
3511 uiDefBut(block
, BUT
, B_TEXCLEAR
, "Clear", 122, 130, 72, 20, 0, 0, 0, 0, 0, "Erases link to texture");
3515 uiDefButS(block
, TOG
, B_EXTEXBROWSE
, "Add New" ,100, 150, 163, 20, &(G
.buts
->texnr
), -1.0, 32767.0, 0, 0, "Adds a new texture datablock");
3517 // force no centering
3518 uiDefBut(block
, LABEL
, 0, " ", 250, 10, 25, 20, 0, 0, 0, 0, 0, "");
3520 uiBlockSetCol(block
, TH_AUTO
);
3523 static void material_panel_tramir(Material
*ma
)
3526 short yco
=PANEL_YMAX
;
3528 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_tramir", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3529 uiNewPanelTabbed("Shaders", "Material");
3530 if(uiNewPanel(curarea
, block
, "Mirror Transp", "Material", PANELX
, PANELY
, PANELW
, PANELH
+80)==0) return;
3532 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3534 uiDefButBitI(block
, TOG
, MA_RAYMIRROR
, B_MATPRV
, "Ray Mirror",
3535 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->mode
), 0, 0, 0, 0, "Enables raytracing for mirror reflection rendering");
3539 uiBlockBeginAlign(block
);
3540 uiDefButF(block
, NUMSLI
, B_MATPRV
, "RayMir: ",
3541 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->ray_mirror
), 0.0, 1.0, 100, 2, "Sets the amount mirror reflection for raytrace");
3542 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Fresnel: ",
3543 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->fresnel_mir
), 0.0, 5.0, 10, 2, "Power of Fresnel for mirror reflection");
3544 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Fac: ",
3545 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->fresnel_mir_i
), 1.0, 5.0, 10, 2, "Blending factor for Fresnel");
3546 uiBlockEndAlign(block
);
3550 uiBlockBeginAlign(block
);
3551 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Gloss: ",
3552 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->gloss_mir
), 0.0, 1.0, 100, 0, "The shininess of the reflection. Values < 1.0 give diffuse, blurry reflections ");
3553 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Aniso: ",
3554 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->aniso_gloss_mir
), 0.0, 1.0, 100, 0, "The shape of the reflection, from 0. (circular) to 1.0 (fully stretched along the tangent)");
3555 uiDefButS(block
, NUM
, B_MATPRV
, "Samples:",
3556 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->samp_gloss_mir
), 1.0, 1024.0, 100, 0, "Number of cone samples averaged for blurry reflections");
3557 uiDefButF(block
, NUM
, B_MATPRV
, "Thresh: ",
3558 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->adapt_thresh_mir
), 0.0, 1.0, 100, 0, "Threshold for adaptive sampling. If a sample contributes less than this amount (as a percentage), sampling is stopped");
3559 uiBlockEndAlign(block
);
3562 uiDefButS(block
, NUM
, B_MATPRV
, "Depth:",
3563 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->ray_depth
), 0.0, 10.0, 100, 0, "Maximum allowed number of light inter-reflections");
3566 uiBlockBeginAlign(block
);
3567 uiDefButF(block
, NUM
, B_MATPRV
, "Max Dist:",
3568 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->dist_mir
), 0.0, 10000.0, 100, 0, "Maximum distance of reflected rays. Reflections further than this range fade to sky color");
3569 uiDefButS(block
, MENU
, B_MATPRV
, "Ray end fade-out: %t|Fade to Sky Color %x0|Fade to Material Color %x1",
3570 X2CLM1
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->fadeto_mir
), 0, 0, 0, 0, "The color that rays with no intersection within the Max Distance take. Material color can be best for indoor scenes, sky color for outdoor.");
3571 uiBlockEndAlign(block
);
3575 uiDefButBitI(block
, TOG
, MA_RAYTRANSP
, B_MATRAYTRANSP
,"Ray Transp",
3576 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->mode
), 0, 0, 0, 0, "Enables raytracing for transparent refraction rendering");
3580 uiBlockBeginAlign(block
);
3581 uiDefButF(block
, NUMSLI
, B_MATPRV
, "IOR: ",
3582 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->ang
), 1.0, 3.0, 100, 2, "Sets angular index of refraction for raytraced refraction");
3583 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Fresnel: ",
3584 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->fresnel_tra
), 0.0, 5.0, 10, 2, "Power of Fresnel for mirror reflection");
3585 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Fac: ",
3586 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->fresnel_tra_i
), 1.0, 5.0, 10, 2, "Blending factor for Fresnel");
3587 uiBlockEndAlign(block
);
3591 uiBlockBeginAlign(block
);
3592 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Gloss: ",
3593 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->gloss_tra
), 0.0, 1.0, 100, 0, "The clarity of the refraction. Values < 1.0 give diffuse, blurry refractions");
3594 uiDefButS(block
, NUM
, B_MATPRV
, "Samples:",
3595 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->samp_gloss_tra
), 0.0, 1024.0, 100, 0, "Number of cone samples averaged for blurry refractions");
3596 uiDefButF(block
, NUM
, B_MATPRV
, "Thresh: ",
3597 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->adapt_thresh_tra
), 0.0, 1.0, 100, 0, "Threshold for adaptive sampling. If a sample contributes less than this amount (as a percentage), sampling is stopped");
3598 uiBlockEndAlign(block
);
3602 uiDefButS(block
, NUM
, B_MATPRV
, "Depth:",
3603 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->ray_depth_tra
), 0.0, 10.0, 100, 0, "Maximum allowed number of light inter-refractions");
3607 uiBlockBeginAlign(block
);
3608 uiDefButF(block
, NUM
, B_MATPRV
, "Filter:",
3609 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->filter
), 0.0, 1.0, 10, 0, "Amount to blend in the material's diffuse colour in raytraced transparency (simulating absorption)");
3610 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Limit: ",
3611 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->tx_limit
), 0.0, 100.0, 10, 2, "Maximum depth for light to travel through the transparent material before becoming fully filtered (0.0 is disabled)");
3612 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Falloff: ",
3613 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->tx_falloff
), 0.1, 10.0, 10, 2, "Falloff power for transmissivity filter effect (1.0 is linear)");
3614 uiBlockEndAlign(block
);
3618 uiDefButF(block
, NUMSLI
, B_MATPRV
, "SpecTra: ",
3619 X2CLM2
, yco
-=BUTH
, BUTW2
, BUTH
, &(ma
->spectra
), 0.0, 1.0, 0, 0, "Makes specular areas opaque on transparent materials");
3622 /* yafray: adapted version of Blender's tramir panel.
3623 * Only removed the buttons not needed, so only the ones that are important for yafray are left.
3624 * Also re-arranged buttons for more room for extra parameters.
3625 * With the exception of the material preset menu and the new parameters,
3626 * most of blender's parameters are re-used without interfering with them.
3628 static void material_panel_tramir_yafray(Material
*ma
)
3631 char *mstr
= "Material presets %t|No Reflect/Transmit %x0|Clear Glass %x1|Color Glass %x2|Uniform Reflect %x3|Fresnel Reflect %x4";
3633 /* better to use same name as original panel */
3634 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_tramir", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3635 uiNewPanelTabbed("Shaders", "Material");
3636 if(uiNewPanel(curarea
, block
, "Mirror Transp", "Material", 640, 0, 318, 204)==0) return;
3638 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3640 /* material preset menu */
3641 uiDefBut(block
, LABEL
, 0, "Mat.Preset", 20, 182, 100, 20, 0, 0.0, 0.0, 0, 0, "");
3642 uiDefButI(block
, MENU
, B_MAT_YF_PRESET
, mstr
, 110, 182, 200, 20, &ma
->YF_preset
, 0.0, 0.0, 0, 0, "Basic material presets to start with");
3644 uiDefButBitI(block
, TOG
, MA_RAYMIRROR
, B_MATPRV
,"Ray Mirror", 10,160,100,20, &(ma
->mode
), 0, 0, 0, 0, "Enables raytracing for mirror reflection rendering");
3645 uiDefButBitI(block
, TOG
, MA_RAYTRANSP
, B_MATRAYTRANSP
,"Ray Transp", 110,160,100,20, &(ma
->mode
), 0, 0, 0, 0, "Enables raytracing for transparency rendering");
3646 uiDefButBitI(block
, TOG
, MA_ZTRA
, B_MATZTRANSP
,"ZTransp", 210,160,100,20, &(ma
->mode
), 0, 0, 0, 0, "Use for objects with alphamap textures");
3648 uiDefButF(block
, NUMSLI
, B_MATPRV
, "rayMir ", 10,140,150,20, &(ma
->ray_mirror
), 0.0, 1.0, 100, 2, "Sets the amount mirror reflection for raytrace");
3649 uiDefButF(block
, NUMSLI
, B_MATPRV
, "frsOfs ", 160,140,150,20, &(ma
->fresnel_mir_i
), 1.0, 5.0, 10, 2, "Fresnel offset, 1 is uniform mirror, 5 is fresnel mirror (IOR>1)");
3651 /* ior has extended range up to 30, for use with total fresnel reflection */
3652 uiDefButF(block
, NUMSLI
, B_MATPRV
, "IOR ", 10,115,150,20, &(ma
->ang
), 1.0, 30.0, 100, 2, "Sets the angular index of refraction for raytrace");
3654 // parameters only used in ray_transp mode
3655 if(ma
->mode
& MA_RAYTRANSP
) {
3657 uiDefButF(block
, NUM
, B_MATPRV
, "Filt:", 160,115,150,20, &(ma
->filter
), 0.0, 1.0, 10, 0, "Amount of filtering for transparent raytrace");
3659 /* absorption color */
3660 uiDefBut(block
, LABEL
, 0, "Absorption Color", 10, 98, 150, 18, 0, 0.0, 0.0, 0, 0, "");
3661 uiDefButF(block
, COL
, B_MATPRV
, "", 10, 38, 30, 58, &ma
->YF_ar
, 0, 0, 0, B_MATCOL
, "transmit absorption color, white is no absorption");
3662 uiDefButF(block
, NUMSLI
, B_MATPRV
, "aR ", 40, 78, 120, 18, &ma
->YF_ar
, 1e-7f
, 1.0, B_MATCOL
, 0, "");
3663 uiDefButF(block
, NUMSLI
, B_MATPRV
, "aG ", 40, 58, 120, 18, &ma
->YF_ag
, 1e-7f
, 1.0, B_MATCOL
, 0, "");
3664 uiDefButF(block
, NUMSLI
, B_MATPRV
, "aB ", 40, 38, 120, 18, &ma
->YF_ab
, 1e-7f
, 1.0, B_MATCOL
, 0, "");
3665 uiDefButF(block
, NUM
, B_MATPRV
, "Ds", 10, 18, 150, 18, &ma
->YF_dscale
, 1e-7f
, 100.0, 10.0, 0, "absorption distance scale, 1 is one blender (world) unit of distance");
3667 /* disperions parameters */
3668 uiDefBut(block
, LABEL
, 0, "Dispersion", 160, 98, 150, 18, 0, 0.0, 0.0, 0, 0, "");
3669 uiDefButF(block
, NUM
, B_MATPRV
, "Pwr ", 160, 78, 150, 18, &ma
->YF_dpwr
, 0.0, 1.0, 0.25, 0, "Dispersion power, the higher, the more dispersion, 0 is no dispersion");
3670 uiDefButI(block
, NUM
, B_MATPRV
, "Samples ", 160, 58, 150, 18, &ma
->YF_dsmp
, 1.0, 100.0, 0, 0, "Dispersion samples, minimum at least 10, unless using jitter ");
3671 uiDefButBitI(block
, TOG
, 1, B_MATPRV
, "Jitter", 160, 38, 150, 18, &ma
->YF_djit
, 0.0, 1.0, 0, 0, "Enable jittering of wavelenghts, adds noise");
3676 static void material_sss_preset_cb(void *material_v
, void *unused_v
)
3678 static const float presets
[11][7] = {
3679 {0.909578, 0.905931, 0.665691, 6.961082, 6.400181, 1.895899, 1.300000},
3680 {0.429632, 0.210025, 0.167767, 11.605177, 3.883766, 1.754386, 1.300000},
3681 {0.439300, 0.216000, 0.141027, 9.435642, 3.347647, 1.790287, 1.300000},
3682 {0.986552, 0.942637, 0.827285, 15.027623, 4.663968, 2.541380, 1.300000},
3683 {0.221636, 0.007505, 0.002154, 4.761743, 0.574827, 0.394116, 1.300000},
3684 {0.925008, 0.905025, 0.884275, 8.509412, 5.566180, 3.951266, 1.500000},
3685 {0.855344, 0.740311, 0.291994, 14.266395, 7.227615, 2.036157, 1.300000},
3686 {0.889319, 0.888034, 0.795811, 18.424364, 10.443473, 3.501882, 1.300000},
3687 {0.573652, 0.312750, 0.174289, 3.673294, 1.366534, 0.682693, 1.300000},
3688 {0.748679, 0.570766, 0.467133, 4.821475, 1.693699, 1.089971, 1.300000},
3689 {0.947235, 0.931028, 0.851872, 10.898815, 6.575351, 2.508417, 1.300000}};
3691 Material
*ma
= (Material
*)material_v
;
3693 if(ma
->sss_preset
==0) return;
3695 ma
->sss_col
[0]= presets
[ma
->sss_preset
][0];
3696 ma
->sss_col
[1]= presets
[ma
->sss_preset
][1];
3697 ma
->sss_col
[2]= presets
[ma
->sss_preset
][2];
3698 ma
->sss_radius
[0]= presets
[ma
->sss_preset
][3];
3699 ma
->sss_radius
[1]= presets
[ma
->sss_preset
][4];
3700 ma
->sss_radius
[2]= presets
[ma
->sss_preset
][5];
3701 ma
->sss_ior
= presets
[ma
->sss_preset
][6];
3704 static void material_sss_custom_set_cb(void *material_v
, void *unused_v
)
3706 Material
*ma
= (Material
*)material_v
;
3709 allqueue(REDRAWNODE
, 0);
3712 static void material_panel_sss(Material
*ma
)
3717 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_sss", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3718 uiNewPanelTabbed("Mirror Transp", "Material");
3719 if(uiNewPanel(curarea
, block
, "SSS", "Material", 640, 0, 318, 204)==0) return;
3721 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3723 uiDefButBitS(block
, TOG
, MA_DIFF_SSS
, B_MATPRV
,"Subsurface Scattering",10,180,180,20, &(ma
->sss_flag
), 0, 0, 0, 0, "Enables diffuse subsurface scattering");
3725 bt
=uiDefButS(block
, MENU
, B_MATPRV
, "Apple %x1|Chicken %x2|Cream %x3|Ketchup %x4|Marble %x5|Potato %x6|Skim Milk %x7|Skin 1 %x8|Skin 2 %x9|Whole Milk %x10|Custom %x0",
3726 200,180,110,20, &ma
->sss_preset
, 0, 0, 0, 0, "");
3727 uiButSetFunc(bt
, material_sss_preset_cb
, ma
, NULL
);
3729 uiBlockBeginAlign(block
);
3730 uiDefButF(block
, NUM
, B_MATPRV
, "Scale:", 10,150,145,20,
3731 &ma
->sss_scale
, 0.001, 1000, 1, 3, "Object scale");
3732 bt
=uiDefButF(block
, NUM
, B_MATPRV
, "Radius R", 10,130,145,20,
3733 &ma
->sss_radius
[0], 0.0001, 10000, 1, 3,
3734 "Mean red scattering path length");
3735 uiButSetFunc(bt
, material_sss_custom_set_cb
, ma
, NULL
);
3736 bt
=uiDefButF(block
, NUM
, B_MATPRV
, "Radius G", 10,110,145,20,
3737 &ma
->sss_radius
[1], 0.0001, 10000, 1, 3,
3738 "Mean green scattering path length");
3739 uiButSetFunc(bt
, material_sss_custom_set_cb
, ma
, NULL
);
3740 bt
=uiDefButF(block
, NUM
, B_MATPRV
, "Radius B", 10,90,145,20,
3741 &ma
->sss_radius
[2], 0.0001, 10000, 1, 3,
3742 "Mean blue scattering path length");
3743 uiButSetFunc(bt
, material_sss_custom_set_cb
, ma
, NULL
);
3744 uiBlockEndAlign(block
);
3746 bt
=uiDefButF(block
, NUM
, B_MATPRV
, "IOR:", 10,60,145,20,
3747 &ma
->sss_ior
, 0.1, 2, 1, 3, "Index of refraction (higher values are denser)");
3748 uiButSetFunc(bt
, material_sss_custom_set_cb
, ma
, NULL
);
3750 uiBlockBeginAlign(block
);
3751 uiDefButF(block
, NUM
, B_MATPRV
, "Error:", 10,30,145,20,
3752 &ma
->sss_error
, 0.0001, 10, 1, 3, "Error tolerance (low values are slower and higher quality)");
3753 uiBlockEndAlign(block
);
3755 uiBlockBeginAlign(block
);
3756 bt
=uiDefButF(block
, COL
, B_MATPRV
, "", 165,150,145,20,
3757 &ma
->sss_col
[0], 0.0, 1.0, 0, 0,
3758 "Scattering color");
3759 uiButSetFunc(bt
, material_sss_custom_set_cb
, ma
, NULL
);
3760 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Col ", 165,130,145,20,
3761 &ma
->sss_colfac
, 0.0, 1.0, 0, 0,
3762 "Blend factor for SSS colors");
3763 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Tex ", 165,110,145,20,
3764 &ma
->sss_texfac
, 0.0, 1.0, 0, 0,
3765 "Texture scattering factor");
3766 uiBlockEndAlign(block
);
3768 uiBlockBeginAlign(block
);
3769 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Front ", 165,80,145,20,
3770 &ma
->sss_front
, 0.0, 2.0, 0, 0,
3771 "Front scattering weight");
3772 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Back ", 165,60,145,20,
3773 &ma
->sss_back
, 0.0, 10.0, 0, 0,
3774 "Back scattering weight");
3775 uiBlockEndAlign(block
);
3778 static void material_panel_shading(Material
*ma
)
3782 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_shading", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3783 if(uiNewPanel(curarea
, block
, "Shaders", "Material", 640, 0, 318, 204)==0) return;
3785 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3787 if(ma
->mode
& MA_HALO
) {
3788 uiDefButF(block
, NUM
, B_MATPRV
, "HaloSize: ", 10,155,190,18, &(ma
->hasize
), 0.0, 100.0, 10, 3, "Sets the dimension of the halo");
3789 uiDefButS(block
, NUMSLI
, B_MATPRV
, "Hard ", 10,135,190,18, &(ma
->har
), 1.0, 127.0, 0, 0, "Sets the hardness of the halo");
3790 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Add ", 10,115,190,18, &(ma
->add
), 0.0, 1.0, 0, 0, "Sets the strength of the add effect");
3792 uiDefButS(block
, NUM
, B_MATPRV
, "Rings: ", 10,90,90,18, &(ma
->ringc
), 0.0, 24.0, 0, 0, "Sets the number of rings rendered over the halo");
3793 uiDefButS(block
, NUM
, B_MATPRV
, "Lines: ", 100,90,100,18, &(ma
->linec
), 0.0, 250.0, 0, 0, "Sets the number of star shaped lines rendered over the halo");
3794 uiDefButS(block
, NUM
, B_MATPRV
, "Star: ", 10,70,90,18, &(ma
->starc
), 3.0, 50.0, 0, 0, "Sets the number of points on the star shaped halo");
3795 uiDefButC(block
, NUM
, B_MATPRV
, "Seed: ", 100,70,100,18, &(ma
->seed1
), 0.0, 255.0, 0, 0, "Randomizes ring dimension and line location");
3796 if(ma
->mode
& MA_HALO_FLARE
) {
3797 uiDefButF(block
, NUM
, B_MATPRV
, "FlareSize: ", 10,50,95,18, &(ma
->flaresize
), 0.1, 25.0, 10, 3, "Sets the factor by which the flare is larger than the halo");
3798 uiDefButF(block
, NUM
, B_MATPRV
, "Sub Size: ", 100,50,100,18, &(ma
->subsize
), 0.1, 25.0, 10, 3, "Sets the dimension of the subflares, dots and circles");
3799 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Boost: ", 10,30,190,18, &(ma
->flareboost
), 0.1, 10.0, 10, 3, "Gives the flare extra strength");
3800 uiDefButC(block
, NUM
, B_MATPRV
, "Fl.seed: ", 10,10,90,18, &(ma
->seed2
), 0.0, 255.0, 0, 0, "Specifies an offset in the flare seed table");
3801 uiDefButS(block
, NUM
, B_MATPRV
, "Flares: ", 100,10,100,18, &(ma
->flarec
), 1.0, 32.0, 0, 0, "Sets the number of subflares");
3803 uiBlockSetCol(block
, TH_BUT_SETTING1
);
3805 uiBlockBeginAlign(block
);
3806 uiDefButBitI(block
, TOG
, MA_HALO_FLARE
, B_MATPRV
, "Flare",245,142,65,28, &(ma
->mode
), 0, 0, 0, 0, "Renders halo as a lensflare");
3807 uiDefButBitI(block
, TOG
, MA_HALO_RINGS
, B_MATPRV
, "Rings", 245,123,65, 18, &(ma
->mode
), 0, 0, 0, 0, "Renders rings over halo");
3808 uiDefButBitI(block
, TOG
, MA_HALO_LINES
, B_MATPRV
, "Lines", 245,104,65, 18, &(ma
->mode
), 0, 0, 0, 0, "Renders star shaped lines over halo");
3809 uiDefButBitI(block
, TOG
, MA_STAR
, B_MATPRV
, "Star", 245,85,65, 18, &(ma
->mode
), 0, 0, 0, 0, "Renders halo as a star");
3810 uiDefButBitI(block
, TOG
, MA_HALOTEX
, B_MATPRV
, "HaloTex", 245,66,65, 18, &(ma
->mode
), 0, 0, 0, 0, "Gives halo a texture");
3811 uiDefButBitI(block
, TOG
, MA_HALOPUNO
, B_MATPRV
, "HaloPuno", 245,47,65, 18, &(ma
->mode
), 0, 0, 0, 0, "Uses the vertex normal to specify the dimension of the halo");
3812 uiDefButBitI(block
, TOG
, MA_HALO_XALPHA
, B_MATPRV
, "X Alpha", 245,28,65, 18, &(ma
->mode
), 0, 0, 0, 0, "Uses extreme alpha");
3813 uiDefButBitI(block
, TOG
, MA_HALO_SHADE
, B_MATPRV
, "Shaded", 245,9,65, 18, &(ma
->mode
), 0, 0, 0, 0, "Lets halo receive light and shadows");
3814 uiBlockEndAlign(block
);
3817 char *str1
= "Diffuse Shader%t|Lambert %x0|Oren-Nayar %x1|Toon %x2|Minnaert %x3|Fresnel %x4";
3818 char *str2
= "Specular Shader%t|CookTorr %x0|Phong %x1|Blinn %x2|Toon %x3|WardIso %x4";
3820 /* diff shader buttons */
3821 uiDefButS(block
, MENU
, B_MATPRV
, str1
, 9, 180,78,19, &(ma
->diff_shader
), 0.0, 0.0, 0, 0, "Creates a diffuse shader");
3823 uiBlockBeginAlign(block
);
3824 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Ref ", 90,180,150,19, &(ma
->ref
), 0.0, 1.0, 0, 0, "Sets the amount of reflection");
3825 if(ma
->diff_shader
==MA_DIFF_ORENNAYAR
)
3826 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Rough:",90,160, 150,19, &(ma
->roughness
), 0.0, 3.14, 0, 0, "Sets Oren Nayar Roughness");
3827 else if(ma
->diff_shader
==MA_DIFF_TOON
) {
3828 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Size:", 90, 160,150,19, &(ma
->param
[0]), 0.0, 3.14, 0, 0, "Sets size of diffuse toon area");
3829 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Smooth:",90,140,150,19, &(ma
->param
[1]), 0.0, 1.0, 0, 0, "Sets smoothness of diffuse toon area");
3831 else if(ma
->diff_shader
==MA_DIFF_MINNAERT
)
3832 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Dark:",90,160, 150,19, &(ma
->darkness
), 0.0, 2.0, 0, 0, "Sets Minnaert darkness");
3833 else if(ma
->diff_shader
==MA_DIFF_FRESNEL
) {
3834 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Fresnel:", 90, 160,150,19, &(ma
->param
[1]), 0.0, 5.0, 0, 0, "Power of Fresnel");
3835 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Fac:",90,140,150,19, &(ma
->param
[0]), 1.0, 5.0, 0, 0, "Blending factor");
3837 uiBlockEndAlign(block
);
3839 /* spec shader buttons */
3840 uiDefButS(block
, MENU
, B_MATPRV
, str2
, 9,120,77,19, &(ma
->spec_shader
), 0.0, 0.0, 0, 0, "Creates a specular shader");
3842 uiBlockBeginAlign(block
);
3843 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Spec ", 90,120,150,19, &(ma
->spec
), 0.0, 2.0, 0, 0, "Sets the degree of specularity");
3844 if ELEM3(ma
->spec_shader
, MA_SPEC_COOKTORR
, MA_SPEC_PHONG
, MA_SPEC_BLINN
) {
3845 uiDefButS(block
, NUMSLI
, B_MATPRV
, "Hard:", 90, 100, 150,19, &(ma
->har
), 1.0, 511, 0, 0, "Sets the hardness of the specularity");
3847 if(ma
->spec_shader
==MA_SPEC_BLINN
)
3848 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Refr:", 90, 80,150,19, &(ma
->refrac
), 1.0, 10.0, 0, 0, "Sets the material's Index of Refraction");
3849 if(ma
->spec_shader
==MA_SPEC_TOON
) {
3850 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Size:", 90, 100,150,19, &(ma
->param
[2]), 0.0, 1.53, 0, 0, "Sets the size of specular toon area");
3851 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Smooth:",90, 80,150,19, &(ma
->param
[3]), 0.0, 1.0, 0, 0, "Sets the smoothness of specular toon area");
3853 if(ma
->spec_shader
==MA_SPEC_WARDISO
)
3854 uiDefButF(block
, NUMSLI
, B_MATPRV
, "rms:", 90, 100,150,19, &(ma
->rms
), 0.0, 0.4, 0, 0, "Sets the standard deviation of surface slope");
3855 /* default shading variables */
3856 uiBlockBeginAlign(block
);
3857 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Tralu ", 9,30,150,19, &(ma
->translucency
), 0.0, 1.0, 100, 2, "Translucency, amount of diffuse shading of the back side");
3858 uiDefButF(block
, NUMSLI
, B_MATPRV
, "SBias ", 159,30,151,19, &(ma
->sbias
), 0.0, 0.25, 10, 2, "Shadow bias, to prevent terminator problems on shadow boundary");
3859 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Amb ", 9,10,150,19, &(ma
->amb
), 0.0, 1.0, 0, 0, "Sets the amount of global ambient color the material receives");
3860 uiDefButF(block
, NUMSLI
, B_MATPRV
, "Emit ", 159,10,151,19, &(ma
->emit
), 0.0, 2.0, 0, 0, "Sets the amount of light the material emits");
3861 uiBlockEndAlign(block
);
3863 uiBlockSetCol(block
, TH_BUT_SETTING1
);
3864 uiDefButBitI(block
, TOG
, MA_TANGENT_V
, B_MATPRV
, "Tangent V", 245,180,65,19, &(ma
->mode
), 0, 0, 0, 0, "Use the tangent vector in V direction for shading");
3866 /* qdn: normalmap tangents separated from shading */
3867 uiDefButBitI(block
, TOG
, MA_NORMAP_TANG
, B_MATPRV
, "NMap TS", 245,160,65,19, &(ma
->mode
), 0, 0, 0, 0, "Enable Tangent Space normal mapping");
3869 uiBlockBeginAlign(block
);
3870 uiDefButBitI(block
, TOG
, MA_SHADOW
, B_MATPRV
, "Shadow", 245,140,65,19, &(ma
->mode
), 0, 0, 0, 0, "Makes material receive shadows");
3871 uiDefButBitI(block
, TOG
, MA_SHADOW_TRA
, B_MATPRV
, "TraShadow", 245,120,65,19, &(ma
->mode
), 0, 0, 0, 0, "Receives transparent shadows based at material color and alpha");
3872 uiDefButBitI(block
, TOG
, MA_ONLYSHADOW
, B_MATPRV
, "OnlyShad", 245,100,65,20, &(ma
->mode
), 0, 0, 0, 0, "Renders shadows on material as Alpha value");
3873 uiDefButBitS(block
, TOG
, MA_CUBIC
, B_MATPRV
, "Cubic", 245,80,65,19, &(ma
->shade_flag
), 0, 0, 0, 0, "Use Cubic interpolation of diffuse values, for smoother transitions)");
3874 uiDefButBitI(block
, TOG
, MA_RAYBIAS
, B_MATPRV
, "Bias", 245,60,65,19, &(ma
->mode
), 0, 0, 0, 0, "Prevents ray traced shadow errors with phong interpolated normals (terminator problem)");
3876 uiBlockBeginAlign(block
);
3877 uiDefIDPoinBut(block
, test_grouppoin_but
, ID_GR
, B_MATPRV
, "GR:", 9, 55, 150, 19, &ma
->group
, "Limit Lighting to Lamps in this Group");
3878 uiDefButBitI(block
, TOG
, MA_GROUP_NOLAY
, B_MATPRV
, "Exclusive", 159,55, 85,20, &(ma
->mode
), 0, 0, 0, 0, "Material uses Lights in this group exclusively, they get excluded from the Scene lighting");
3882 static void material_panel_ramps(Material
*ma
)
3887 char *inputc
, *methodc
;
3889 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_ramps", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3890 uiNewPanelTabbed("Material", "Material");
3891 if(uiNewPanel(curarea
, block
, "Ramps", "Material", 640, 0, 318, 204)==0) return;
3893 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3895 uiBlockBeginAlign(block
);
3896 uiBlockSetCol(block
, TH_BUT_SETTING1
);
3897 uiDefButS(block
, ROW
, B_REDR
, "Show Col Ramp",10,180,150,20, &ma
->ramp_show
, 0, 0, 0, 0, "Show ramp buttons for material diffuse color");
3898 uiDefButS(block
, ROW
, B_REDR
, "Show Spec Ramp",160,180,150,20, &ma
->ramp_show
, 0, 1, 0, 0, "Show ramp buttons for material specular color");
3899 uiBlockSetCol(block
, TH_AUTO
);
3902 uiBlockBeginAlign(block
);
3903 uiDefButBitI(block
, TOG
, ma
->ramp_show
?MA_RAMP_SPEC
:MA_RAMP_COL
, B_MATCOLORBAND
, "Colorband",10,145,80,20, &ma
->mode
, 0, 0, 0, 0, "Toggles colorband ramp operations");
3905 if(ma
->mode
& (ma
->ramp_show
?MA_RAMP_SPEC
:MA_RAMP_COL
)) {
3906 if(ma
->ramp_show
==0) {
3908 inputc
= &ma
->rampin_col
;
3909 methodc
= &ma
->rampblend_col
;
3910 facp
= &ma
->rampfac_col
;
3913 coba
= ma
->ramp_spec
;
3914 inputc
= &ma
->rampin_spec
;
3915 methodc
= &ma
->rampblend_spec
;
3916 facp
= &ma
->rampfac_spec
;
3918 draw_colorband_buts(block
, coba
, 10, 50, B_MATPRV
); // aligns with previous button
3920 uiDefBut(block
, LABEL
, 0, "Input",10,30,90,20, NULL
, 0, 0, 0, 0, "");
3921 uiDefBut(block
, LABEL
, 0, "Method",100,30,90,20, NULL
, 0, 0, 0, 0, "");
3922 uiDefBut(block
, LABEL
, 0, "Factor",190,30,120,20, NULL
, 0, 0, 0, 0, "");
3923 uiBlockBeginAlign(block
);
3924 uiDefButC(block
, MENU
, B_MATPRV
, "Shader %x0|Energy %x1|Normal %x2|Result %x3",10,10,90,20, inputc
, 0, 0, 0, 0, "Input for Ramp");
3925 uiDefButC(block
, MENU
, B_MATPRV
, "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",110,10,90,20, methodc
, 0, 0, 0, 0, "Blending method for Ramp (uses alpha in Colorband)");
3926 uiDefButF(block
, NUMSLI
, B_MATPRV
, "", 190,10,120,20, facp
, 0.0, 1.0, 100, 0, "Blending factor (also uses alpha in Colorband)");
3930 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
3931 static uiBlock
*strand_menu(void *mat_v
)
3933 Material
*ma
= mat_v
;
3936 block
= uiNewBlock(&curarea
->uiblocks
, "strand menu", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3938 /* use this for a fake extra empy space around the buttons */
3939 uiDefBut(block
, LABEL
, 0, "", 0, 0, 250, 100, NULL
, 0, 0, 0, 0, "");
3941 uiBlockBeginAlign(block
);
3942 /* event return 0, to prevent menu to close */
3943 uiDefButBitI(block
, TOG
, MA_TANGENT_STR
, 0, "Use Tangent Shading", 10,70,230,20, &(ma
->mode
), 0, 0, 0, 0, "Uses direction of strands as normal for tangent-shading");
3944 uiDefButF(block
, NUMSLI
, 0, "Start ", 10, 50, 230,20, &ma
->strand_sta
, 0.25, 20.0, 2, 0, "Start size of strands in pixels");
3945 uiDefButF(block
, NUMSLI
, 0, "End ", 10, 30, 230,20, &ma
->strand_end
, 0.25, 10.0, 2, 0, "End size of strands in pixels");
3946 uiDefButF(block
, NUMSLI
, 0, "Shape ", 10, 10, 230,20, &ma
->strand_ease
, -0.9, 0.9, 2, 0, "Shape of strands, positive value makes it rounder, negative makes it spiky");
3948 uiBlockSetDirection(block
, UI_TOP
);
3949 BIF_preview_changed(ID_MA
);
3954 static void material_panel_material(Material
*ma
)
3957 float *colpoin
= NULL
;
3960 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_material", UI_EMBOSS
, UI_HELV
, curarea
->win
);
3961 if(uiNewPanel(curarea
, block
, "Material", "Material", 320, 0, 318, 204)==0) return;
3963 /* TODO, check for ob->id.lib */
3965 uiDefButS(block
, NUM
, B_NOP
, "PassIndex:", 8, 200, 148, YIC
, &ma
->index
, 0.0, 1000.0, 0, 0, "Index # for the IndexMat render pass.");
3967 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
3968 uiBlockBeginAlign(block
);
3969 uiDefIconBut(block
, BUT
, B_MATCOPY
, ICON_COPYUP
, 262,200,XIC
,YIC
, 0, 0, 0, 0, 0, "Copies Material to the buffer");
3970 uiDefIconBut(block
, BUT
, B_MATPASTE
, ICON_PASTEUP
, 283,200,XIC
,YIC
, 0, 0, 0, 0, 0, "Pastes Material from the buffer");
3971 uiBlockEndAlign(block
);
3972 if(ma
->dynamode
& MA_DRAW_DYNABUTS
) {
3973 uiBlockBeginAlign(block
);
3974 uiDefButF(block
, NUMSLI
, B_DIFF
, "Restitut ", 128,120,175,20, &ma
->reflect
, 0.0, 1.0, 0, 0, "Elasticity of collisions");
3975 uiDefButF(block
, NUMSLI
, B_DIFF
, "Friction ", 128,100 ,175,20, &ma
->friction
, 0.0, 100.0, 0, 0, "Coulomb friction coefficient");
3976 uiDefButF(block
, NUMSLI
, B_DIFF
, "Fh Force ", 128,80 ,175,20, &ma
->fh
, 0.0, 1.0, 0, 0, "Upward spring force within the Fh area");
3977 uiBlockBeginAlign(block
);
3978 uiDefButF(block
, NUM
, B_NOP
, "Fh Damp ", 8,120,100,20, &ma
->xyfrict
, 0.0, 1.0, 10, 0, "Damping of the Fh spring force");
3979 uiDefButF(block
, NUM
, B_NOP
, "Fh Dist ", 8,100 ,100,20, &ma
->fhdist
, 0.0, 20.0, 10, 0, "Height of the Fh area");
3980 uiDefButBitS(block
, TOG
, MA_FH_NOR
, 0, "Fh Norm", 8,80 ,100,20, &ma
->dynamode
, 0.0, 0.0, 0, 0, "Add a horizontal spring force on slopes");
3983 if(!(ma
->mode
& MA_HALO
)) {
3984 uiBlockBeginAlign(block
);
3985 uiBlockSetCol(block
, TH_BUT_SETTING1
);
3986 uiDefButBitI(block
, TOG
, MA_VERTEXCOL
, B_MAT_VCOL_LIGHT
, "VCol Light", 8,166,74,20, &(ma
->mode
), 0, 0, 0, 0, "Adds vertex colors as extra light");
3987 uiDefButBitI(block
, TOG
, MA_VERTEXCOLP
, B_MAT_VCOL_PAINT
, "VCol Paint", 82,166,74,20, &(ma
->mode
), 0, 0, 0, 0, "Replaces material's colors with vertex colors");
3988 uiDefButBitI(block
, TOG
, MA_FACETEXTURE
, B_REDR
, "TexFace", 156,166,64,20, &(ma
->mode
), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
3989 if (ma
->mode
& MA_FACETEXTURE
) uiDefButBitI(block
, TOG
, MA_FACETEXTURE_ALPHA
, B_REDR
, "A", 220,166,20,20, &(ma
->mode
), 0, 0, 0, 0, "Use alpha channel in 'TexFace' assigned images");
3990 uiDefButBitI(block
, TOG
, MA_SHLESS
, B_MATPRV
, "Shadeless", 240,166,63,20, &(ma
->mode
), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
3992 uiDefButBitI(block
, TOG
, MA_NOMIST
, B_NOP
, "No Mist", 8,146,74,20, &(ma
->mode
), 0, 0, 0, 0, "Sets the material to ignore mist values");
3993 uiDefButBitI(block
, TOG
, MA_ENV
, B_MATPRV
, "Env", 82,146,74,20, &(ma
->mode
), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through (only for solid faces)");
3994 uiDefButF(block
, NUM
, B_NOP
, "Shad A ", 156,146,147,19, &ma
->shad_alpha
, 0.001, 1.0f
, 100, 0, "Shadow casting alpha, only in use for Irregular Shadowbuffer");
3996 uiBlockSetCol(block
, TH_AUTO
);
3997 uiBlockBeginAlign(block
);
3998 uiDefButF(block
, COL
, B_MATPRV
, "", 8,97,72,20, &(ma
->r
), 0, 0, 0, B_MATCOL
, "");
3999 uiDefButF(block
, COL
, B_MATPRV
, "", 8,77,72,20, &(ma
->specr
), 0, 0, 0, B_SPECCOL
, "");
4000 uiDefButF(block
, COL
, B_MATPRV
, "", 8,57,72,20, &(ma
->mirr
), 0, 0, 0, B_MIRCOL
, "");
4002 uiBlockBeginAlign(block
);
4003 if(ma
->mode
& MA_HALO
) {
4004 uiDefButC(block
, ROW
, REDRAWBUTSSHADING
, "Halo", 83,97,40,20, &(ma
->rgbsel
), 2.0, 0.0, 0, 0, "Sets the color of the halo with the RGB sliders");
4005 uiDefButC(block
, ROW
, REDRAWBUTSSHADING
, "Line", 83,77,40,20, &(ma
->rgbsel
), 2.0, 1.0, 0, 0, "Sets the color of the lines with the RGB sliders");
4006 uiDefButC(block
, ROW
, REDRAWBUTSSHADING
, "Ring", 83,57,40,20, &(ma
->rgbsel
), 2.0, 2.0, 0, 0, "Sets the color of the rings with the RGB sliders");
4009 uiDefButC(block
, ROW
, REDRAWBUTSSHADING
, "Col", 83,97,40,20, &(ma
->rgbsel
), 2.0, 0.0, 0, 0, "Sets the diffuse color of the material");
4010 uiDefButC(block
, ROW
, REDRAWBUTSSHADING
, "Spe", 83,77,40,20, &(ma
->rgbsel
), 2.0, 1.0, 0, 0, "Sets the specular color of the material");
4011 uiDefButC(block
, ROW
, REDRAWBUTSSHADING
, "Mir", 83,57,40,20, &(ma
->rgbsel
), 2.0, 2.0, 0, 0, "Sets the mirror color of the material");
4014 if(ma
->rgbsel
==0) {colpoin
= &(ma
->r
); rgbsel
= B_MATCOL
;}
4015 else if(ma
->rgbsel
==1) {colpoin
= &(ma
->specr
); rgbsel
= B_SPECCOL
;}
4016 else if(ma
->rgbsel
==2) {colpoin
= &(ma
->mirr
); rgbsel
= B_MIRCOL
;}
4018 if(ma
->rgbsel
==0 && (ma
->mode
& (MA_VERTEXCOLP
|MA_FACETEXTURE
) && !(ma
->mode
& MA_HALO
)));
4019 else if(ma
->colormodel
==MA_HSV
) {
4020 uiBlockSetCol(block
, TH_BUT_SETTING1
);
4021 uiBlockBeginAlign(block
);
4022 uiDefButF(block
, HSVSLI
, B_MATPRV
, "H ", 128,97,175,19, colpoin
, 0.0, 0.9999, rgbsel
, 0, "");
4023 uiDefButF(block
, HSVSLI
, B_MATPRV
, "S ", 128,77,175,19, colpoin
, 0.0001, 1.0, rgbsel
, 0, "");
4024 uiDefButF(block
, HSVSLI
, B_MATPRV
, "V ", 128,57,175,19, colpoin
, 0.0001, 1.0, rgbsel
, 0, "");
4025 uiBlockSetCol(block
, TH_AUTO
);
4028 uiBlockBeginAlign(block
);
4029 uiDefButF(block
, NUMSLI
, B_MATPRV
, "R ", 128,97,175,19, colpoin
, 0.0, 1.0, rgbsel
, 0, "");
4030 uiDefButF(block
, NUMSLI
, B_MATPRV
, "G ", 128,77,175,19, colpoin
+1, 0.0, 1.0, rgbsel
, 0, "");
4031 uiDefButF(block
, NUMSLI
, B_MATPRV
, "B ", 128,57,175,19, colpoin
+2, 0.0, 1.0, rgbsel
, 0, "");
4033 uiBlockEndAlign(block
);
4034 if (ma
->mode
& (MA_FACETEXTURE
) && ma
->mode
& (MA_FACETEXTURE_ALPHA
)) ;
4035 else uiDefButF(block
, NUMSLI
, B_MATPRV
, "A ", 128,30,175,19, &ma
->alpha
, 0.0, 1.0, 0, 0, "Alpha");
4038 uiBlockBeginAlign(block
);
4039 uiDefButS(block
, ROW
, REDRAWBUTSSHADING
, "RGB", 8,30,38,19, &(ma
->colormodel
), 1.0, (float)MA_RGB
, 0, 0, "Creates color using red, green and blue");
4040 uiDefButS(block
, ROW
, REDRAWBUTSSHADING
, "HSV", 46,30,38,19, &(ma
->colormodel
), 1.0, (float)MA_HSV
, 0, 0, "Creates color using hue, saturation and value");
4041 uiDefButBitS(block
, TOG
, MA_DRAW_DYNABUTS
, REDRAWBUTSSHADING
, "DYN", 84,30,39,19, &(ma
->dynamode
), 0.0, 0.0, 0, 0, "Adjusts parameters for dynamics options");
4045 static void material_panel_nodes(Material
*ma
)
4050 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_nodes", UI_EMBOSS
, UI_HELV
, curarea
->win
);
4051 uiNewPanelTabbed("Links and Pipeline", "Material");
4052 if(uiNewPanel(curarea
, block
, "Nodes", "Material", 640, 0, 318, 204)==0) return;
4054 node
= editnode_get_active(ma
->nodetree
);
4055 if(node
==NULL
) return;
4056 /* we dont display the buttons here for the active material, is in links panel */
4057 if(node
==editnode_get_active_idnode(ma
->nodetree
, ID_MA
)) return;
4059 if(node
->typeinfo
->butfunc
) {
4060 /* we use butfunc to retrieve height for the butrect, but node->width is
4061 used to calculate that too. Could be done smarter once */
4064 rct
.xmax
= rct
.xmin
+node
->width
-NODE_DY
;
4066 rct
.ymin
= rct
.ymax
- (float)node
->typeinfo
->butfunc(NULL
, NULL
, node
, NULL
);
4067 node
->typeinfo
->butfunc(block
, ma
->nodetree
, node
, &rct
);
4071 static void material_panel_links(Object
*ob
, Material
*ma
)
4075 ID
*id
, *idn
, *idfrom
;
4081 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_links", UI_EMBOSS
, UI_HELV
, curarea
->win
);
4082 /* 310 makes sorting code to put it right after preview panel */
4083 if(uiNewPanel(curarea
, block
, "Links and Pipeline", "Material", 310, 0, 318, 204)==0) return;
4085 /* Links from object to material/nodes */
4086 uiDefBut(block
, ROUNDBOX
, 0, "", 5, 90, 310, 110, NULL
, 7.0, 0.0, 15 , 20, "");
4087 uiDefBut(block
, LABEL
, B_DIFF
, "Link to Object", 10, 180, 300, 20, 0, 0, 0, 0, 0, "");
4089 /* the main material browse but */
4090 buttons_active_id(&id
, &idfrom
); /* base material! */
4092 uiBlockSetCol(block
, TH_BUT_SETTING2
);
4093 xco
= std_libbuttons(block
, 10, 160, 0, NULL
, B_MATBROWSE
, ID_MA
, 0, id
, idfrom
, &(G
.buts
->menunr
), B_MATALONE
, B_MATLOCAL
, B_MATDELETE
, B_AUTOMATNAME
, B_KEEPDATA
);
4095 if(ma
) uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
4098 uiDefButC(block
, TOG
, B_MAT_USENODES
, "Nodes", xco
+5,160,300-xco
-5,20, &ma
->use_nodes
, 0.0f
, 0.0f
, 0, 0, "");
4100 if(ob
->actcol
==0) ob
->actcol
= 1; /* because of TOG|BIT button */
4102 uiBlockBeginAlign(block
);
4104 /* id is the block from which the material is used */
4105 if( BTST(ob
->colbits
, ob
->actcol
-1) ) id
= (ID
*)ob
;
4108 /* indicate which one is linking a material */
4111 uiSetButLock(1, ERROR_LIBDATA_MESSAGE
);
4115 strncpy(str
, id
->name
, 2);
4116 str
[2]= ':'; str
[3]= 0;
4117 but
= uiDefBut(block
, TEX
, B_IDNAME
, str
, 10,135,115,20, id
->name
+2, 0.0, 21.0, 0, 0, "Shows the block the material is linked to");
4118 uiButSetFunc(but
, test_idbutton_cb
, id
->name
, NULL
);
4121 uiBlockSetCol(block
, TH_BUT_ACTION
);
4122 uiDefButBitS(block
, TOG
, 1<<(ob
->actcol
-1), B_MATFROM
, "OB", 125,135,32,20, &ob
->colbits
, 0, 0, 0, 0, "Links material to object");
4124 strncpy(str
, idn
->name
, 2);
4126 uiBlockSetCol(block
, TH_BUT_SETTING
);
4127 uiDefButBitS(block
, TOGN
, 1<<(ob
->actcol
-1), B_MATFROM
, str
, 158,135,32,20, &ob
->colbits
, 0, 0, 0, 0, "Shows the block the material is linked to");
4128 uiBlockSetCol(block
, TH_AUTO
);
4130 sprintf(str
, "%d Mat", ob
->totcol
);
4131 if(ob
->totcol
) min
= 1.0; else min
= 0.0;
4132 uiDefButC(block
, NUM
, B_ACTCOL
, str
, 190,135,110,20, &(ob
->actcol
), min
, (float)ob
->totcol
, 0, 0, "Shows the number of materials on object and the active material");
4133 uiBlockEndAlign(block
);
4135 if(ma
==NULL
) return;
4136 uiSetButLock(ma
->id
.lib
!=NULL
, ERROR_LIBDATA_MESSAGE
);
4138 /* Active material node */
4140 uiDefBut(block
, LABEL
, B_DIFF
, "Active Material Node", 10, 115, 300, 20, 0, 0, 0, 0, 0, "");
4142 if(ma
) node
= editnode_get_active_idnode(ma
->nodetree
, ID_MA
);
4144 node
= editnode_get_active(ma
->nodetree
);
4145 if(node
&& node
->type
!=SH_NODE_MATERIAL
)
4154 node
->typeinfo
->butfunc(block
, ma
->nodetree
, node
, &rct
);
4158 /* main render pipeline settings */
4159 uiDefBut(block
, LABEL
, B_DIFF
, "Render Pipeline", 10, 70, 300, 20, 0, 0, 0, 0, 0, "");
4161 uiBlockBeginAlign(block
);
4162 uiDefButBitI(block
, TOG
, MA_HALO
, B_MATHALO
, "Halo", 10,50,100,19, &(ma
->mode
), 0, 0, 0, 0, "Renders material as a halo");
4163 uiDefButBitI(block
, TOG
, MA_ZTRA
, B_MATZTRANSP
,"ZTransp", 110,50,100,19, &(ma
->mode
), 0, 0, 0, 0, "Enables Z-Buffering of transparent faces");
4164 uiDefButF(block
, NUM
, B_DIFF
, "Zoffs:", 210,50,100,19, &(ma
->zoffs
), 0.0, 100.0, 100, 0, "Gives faces an artificial offset in the Z buffer for Ztransp option");
4166 uiDefButBitI(block
, TOG
, MA_FULL_OSA
, 0, "Full Osa", 10,30,75,19, &(ma
->mode
), 0.0, 10.0, 0, 0, "Forces to render all OSA samples, for shading and texture antialiasing");
4167 uiDefButBitI(block
, TOG
, MA_WIRE
, B_MATPRV
, "Wire", 85,30,75,19, &(ma
->mode
), 0, 0, 0, 0, "Renders only the edges of faces as a wireframe");
4168 uiDefBlockBut(block
, strand_menu
, ma
, "Strands", 160,30,75, 19, "Display strand settings for static particles");
4169 uiDefButBitI(block
, TOG
, MA_ZINV
, B_MATPRV
, "ZInvert", 236,30,75,19, &(ma
->mode
), 0, 0, 0, 0, "Renders material's faces with inverted Z Buffer");
4171 uiDefButBitI(block
, TOG
, MA_RADIO
, B_NOP
, "Radio", 10,10,75,19, &(ma
->mode
), 0, 0, 0, 0, "Enables radiosity rendering for material");
4172 uiDefButBitI(block
, TOG
, MA_ONLYCAST
, B_MATPRV
,"OnlyCast", 85,10,75,19, &(ma
->mode
), 0, 0, 0, 0, "Makes faces cast shadows only, not rendered");
4173 uiDefButBitI(block
, TOG
, MA_TRACEBLE
, B_NOP
,"Traceable", 160,10,75,19, &(ma
->mode
), 0, 0, 0, 0, "Makes material detectable by ray tracing");
4174 uiDefButBitI(block
, TOG
, MA_SHADBUF
, B_MATPRV
, "Shadbuf", 235,10,75,19, &(ma
->mode
), 0, 0, 0, 0, "Makes material cast shadows from shadow buffer lamps");
4179 static void material_panel_preview(Material
*ma
)
4183 /* name "Preview" is abused to detect previewrender offset panel */
4184 block
= uiNewBlock(&curarea
->uiblocks
, "material_panel_preview", UI_EMBOSS
, UI_HELV
, curarea
->win
);
4185 if(uiNewPanel(curarea
, block
, "Preview", "Material", 0, 0, 318, 204)==0) return;
4188 G
.buts
->lockpoin
= ma
; /* BIF_previewdraw callback will read it */
4190 uiBlockSetDrawExtraFunc(block
, BIF_previewdraw
);
4192 // label to force a boundbox for buttons not to be centered
4193 uiDefBut(block
, LABEL
, 0, " ", 20,20,10,10, 0, 0, 0, 0, 0, "");
4194 uiBlockSetCol(block
, TH_BUT_NEUTRAL
);
4195 uiBlockBeginAlign(block
);
4196 uiDefIconButC(block
, ROW
, B_MATPRV
, ICON_MATPLANE
, 210,180,25,22, &(ma
->pr_type
), 10, MA_FLAT
, 0, 0, "Preview type: Flat XY plane");
4197 uiDefIconButC(block
, ROW
, B_MATPRV
, ICON_MATSPHERE
, 210,158,25,22, &(ma
->pr_type
), 10, MA_SPHERE
, 0, 0, "Preview type: Sphere");
4198 uiDefIconButC(block
, ROW
, B_MATPRV
, ICON_MATCUBE
, 210,136,25,22, &(ma
->pr_type
), 10, MA_CUBE
, 0, 0, "Preview type: Cube");
4199 uiDefIconButC(block
, ROW
, B_MATPRV
, ICON_MONKEY
, 210,114,25,22, &(ma
->pr_type
), 10, MA_MONKEY
, 0, 0, "Preview type: Monkey");
4200 uiDefIconButC(block
, ROW
, B_MATPRV
, ICON_HAIR
, 210, 92,25,22, &(ma
->pr_type
), 10, MA_HAIR
, 0, 0, "Preview type: Hair strands");
4201 uiDefIconButC(block
, ROW
, B_MATPRV
, ICON_MATSPHERE
, 210, 70,25,22, &(ma
->pr_type
), 10, MA_SPHERE_A
, 0, 0, "Preview type: Large sphere with sky");
4202 uiBlockEndAlign(block
);
4204 uiDefIconButBitC(block
, TOG
, SB_PRV_OSA
, B_MATPRV
, ICON_RING
, 210, 10,25,22, &(G
.buts
->flag
), 0, 0, 0, 0, "Preview uses OSA (oversampling)");
4208 void material_panels()
4214 if(ob
==NULL
) return;
4216 // type numbers are ordered
4217 if((ob
->type
<OB_LAMP
) && ob
->type
) {
4220 ma
= give_current_material(ob
, ob
->actcol
);
4222 // always draw first 2 panels
4223 material_panel_preview(ma
);
4224 material_panel_links(ob
, ma
);
4226 if(ma
&& ma
->use_nodes
) {
4227 material_panel_nodes(ma
);
4231 ma
= editnode_get_active_material(ma
);
4233 material_panel_material(ma
);
4234 material_panel_ramps(ma
);
4235 material_panel_shading(ma
);
4237 if (G
.scene
->r
.renderer
==R_INTERN
)
4238 material_panel_tramir(ma
);
4240 if(ma
->YF_ar
==0.f
) {
4241 ma
->YF_ar
= ma
->YF_ag
= ma
->YF_ab
= 1;
4244 material_panel_tramir_yafray(ma
);
4247 material_panel_sss(ma
);
4248 material_panel_texture(ma
);
4250 mtex
= ma
->mtex
[ ma
->texact
];
4251 if(mtex
&& mtex
->tex
) {
4252 material_panel_map_input(ob
, ma
);
4253 material_panel_map_to(ma
, from_nodes
);
4264 if(ob
==NULL
|| ob
->type
!= OB_LAMP
) return;
4267 lamp_panel_preview(ob
, ob
->data
);
4268 lamp_panel_lamp(ob
, ob
->data
);
4270 if (ELEM(la
->type
, LA_SPOT
, LA_LOCAL
) && (la
->falloff_type
== LA_FALLOFF_CURVE
))
4271 lamp_panel_falloff(ob
, ob
->data
);
4273 /* switch to yafray lamp panel if yafray enabled */
4274 if (G
.scene
->r
.renderer
==R_INTERN
)
4275 lamp_panel_spot(ob
, ob
->data
);
4278 if (la
->YF_numphotons
==0) la
->YF_numphotons
=1000;
4279 if (la
->YF_numsearch
==0) la
->YF_numsearch
=10;
4280 if (la
->YF_phdepth
==0) la
->YF_phdepth
=1;
4281 if (la
->YF_causticblur
==0.0) la
->YF_causticblur
=0.001;
4282 if (la
->YF_bufsize
==0) la
->YF_bufsize
=128;
4283 /* spherelight radius default is zero, so nothing to do */
4284 lamp_panel_yafray(ob
, la
);
4286 lamp_panel_texture(ob
, ob
->data
);
4287 lamp_panel_mapto(ob
, ob
->data
);
4295 wrld
= G
.scene
->world
;
4297 world_panel_preview(wrld
);
4298 world_panel_world(wrld
);
4301 world_panel_mistaph(wrld
);
4302 world_panel_amb_occ(wrld
);
4303 world_panel_texture(wrld
);
4304 world_panel_mapto(wrld
);
4308 void texture_panels()
4312 SculptData
*sd
=NULL
;
4319 if(G
.buts
->texfrom
==0) {
4321 ma
= give_current_material(ob
, ob
->actcol
);
4323 if(ma
&& ma
->use_nodes
) {
4324 node
= editnode_get_active_idnode(ma
->nodetree
, ID_TE
);
4329 ma
= editnode_get_active_material(ma
);
4332 if(ma
) mtex
= ma
->mtex
[ ma
->texact
];
4335 else if(G
.buts
->texfrom
==1) {
4336 wrld
= G
.scene
->world
;
4337 if(wrld
) mtex
= wrld
->mtex
[ wrld
->texact
];
4339 else if(G
.buts
->texfrom
==2) {
4340 if(ob
&& ob
->type
==OB_LAMP
) {
4342 mtex
= la
->mtex
[ la
->texact
];
4345 else if(G
.buts
->texfrom
==3) {
4346 if(G
.f
& G_SCULPTMODE
) {
4347 sd
= &G
.scene
->sculptdata
;
4348 if(sd
->texact
!= -1)
4349 mtex
= sd
->mtex
[sd
->texact
];
4352 br
= G
.scene
->toolsettings
->imapaint
.brush
;
4353 if(br
) mtex
= br
->mtex
[br
->texact
];
4357 texture_panel_preview(mtex
, ma
|| wrld
|| la
|| br
|| node
|| sd
); // for 'from' buttons
4359 if(ma
|| wrld
|| la
|| br
|| node
|| sd
) {
4362 texture_panel_texture(mtex
, ma
, wrld
, la
, node
, br
, sd
);
4364 if(mtex
) tex
= mtex
->tex
;
4365 else if(node
) tex
= (Tex
*)node
->id
;
4368 texture_panel_colors(tex
);
4372 texture_panel_image(&tex
->ima
, &tex
->iuser
);
4373 texture_panel_image_map(tex
);
4376 texture_panel_envmap(tex
);
4379 texture_panel_clouds(tex
);
4382 texture_panel_clouds2(tex
);
4385 texture_panel_marble(tex
);
4388 texture_panel_stucci(tex
);
4391 texture_panel_wood(tex
);
4394 texture_panel_blend(tex
);
4397 texture_panel_magic(tex
);
4400 texture_panel_plugin(tex
);
4403 // no panel! (e: not really true, is affected by noisedepth param)
4405 /* newnoise: musgrave panels */
4407 texture_panel_musgrave(tex
);
4410 texture_panel_distnoise(tex
);
4412 /* newnoise: voronoi */
4414 texture_panel_voronoi(tex
);
4426 rad
= G
.scene
->radio
;
4429 rad
= G
.scene
->radio
;
4432 radio_panel_render(rad
);
4436 radio_panel_tool(rad
, flag
);
4437 if(flag
) radio_panel_calculation(rad
, flag
);