Hi, I was looking at the blender wiki feature request page, and I found this one ( http://wiki.blender.org/index.php/Requests/UserInterfaceFeatures#Preset_IOR_values_at_your_fingertips ), and I thought that I could pull that off. I think I succeeded, but I’d like other people to test it to see if it works, and if you think it would be worth it to have it there. This is what it should look like:
I got the IOR values from this post ( http://blenderartists.org/forum/showthread.php?t=71202 ), if you look at my patch, you can see it wouldn’t be hard to add/remove/change values. just add a menu item, and add a ‘case’ statement in the callback. The patch was made on Windows against SVN rev-12614. Please note that this is my first patch, and I’d like feedback, thanks…
( if you don’t know how to apply a patch, what you need to do is download the blender source code from SVN (I don’t think they update their daily checkout anymore), then read the ‘How do I Apply Patches?’ section of this page ( http://www.blender.org/development/submit-a-patch/ ))
(patch):
Index: source/blender/src/buttons_shading.c
===================================================================
--- source/blender/src/buttons_shading.c (revision 12614)
+++ source/blender/src/buttons_shading.c (working copy)
@@ -3325,10 +3325,56 @@
uiBlockSetCol(block, TH_AUTO);
}
+void material_tramir_ior_preset_cb(Material *ma, short int *ior_switch)
+{
+ switch(*ior_switch)
+ {
+ case 0:
+ /* ior is still the staticly declared 0 */
+ break;
+ case 1:
+ /* bubble */
+ ma->ang = 1.100;
+ *ior_switch = 0;
+ break;
+ case 2:
+ /* water */
+ ma->ang = 1.333;
+ *ior_switch = 0;
+ break;
+ case 3:
+ /* ice (from water) */
+ ma->ang = 1.310;
+ *ior_switch = 0;
+ break;
+ case 4:
+ /* light glass */
+ ma->ang = 1.450;
+ *ior_switch = 0;
+ break;
+ case 5:
+ /* standard glass */
+ ma->ang = 1.520;
+ *ior_switch = 0;
+ break;
+ case 6:
+ /* heavy glass */
+ ma->ang = 1.650;
+ *ior_switch = 0;
+ break;
+ case 7:
+ /* crystal */
+ ma->ang = 1.870;
+ *ior_switch = 0;
+ break;
+ }
+}
+
static void material_panel_tramir(Material *ma)
{
uiBlock *block;
short yco=PANEL_YMAX;
+ static short int ior_switch = 0;
block= uiNewBlock(&curarea->uiblocks, "material_panel_tramir", UI_EMBOSS, UI_HELV, curarea->win);
uiNewPanelTabbed("Shaders", "Material");
@@ -3384,7 +3430,12 @@
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, B_MATPRV, "IOR: ",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->ang), 1.0, 3.0, 100, 2, "Sets angular index of refraction for raytraced refraction");
+ X2CLM2, yco-=BUTH, BUTW2 - 20, BUTH, &(ma->ang), 1.0, 3.0, 100, 2, "Sets angular index of refraction for raytraced refraction");
+ /* arrow menu that holds IOR presets */
+ uiDefButS(block, MENU, B_MATPRV, "IOR presets%t| Bubble%x1| Water%x2| Ice%x3| Light Glass%x4| Standard Glass%x5| Heavy Glass%x6| Crystal%x7",
+ X2CLM2 + (BUTW2 - 20), yco, 20, BUTH, &ior_switch, 0, 0, 0, 0, "IOR presets");
+ material_tramir_ior_preset_cb(ma, &ior_switch);
+
uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel: ",
X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->fresnel_tra), 0.0, 5.0, 10, 2, "Power of Fresnel for mirror reflection");
uiDefButF(block, NUMSLI, B_MATPRV, "Fac: ",
@@ -3434,6 +3485,7 @@
{
uiBlock *block;
char *mstr = "Material presets %t|No Reflect/Transmit %x0|Clear Glass %x1|Color Glass %x2|Uniform Reflect %x3|Fresnel Reflect %x4";
+ static short int ior_switch = 0;
/* better to use same name as original panel */
block= uiNewBlock(&curarea->uiblocks, "material_panel_tramir", UI_EMBOSS, UI_HELV, curarea->win);
@@ -3454,7 +3506,11 @@
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)");
/* ior has extended range up to 30, for use with total fresnel reflection */
- 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");
+ uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,115,130,20, &(ma->ang), 1.0, 30.0, 100, 2, "Sets the angular index of refraction for raytrace");
+ /* arrow menu that holds IOR presets */
+ uiDefButS(block, MENU, B_MATPRV, "IOR presets%t| Bubble%x1| Water%x2| Ice%x3| Light Glass%x4| Standard Glass%x5| Heavy Glass%x6| Crystal%x7",
+ 140, 115, 20, 20, &ior_switch, 0, 0, 0, 0, "IOR presets");
+ material_tramir_ior_preset_cb(ma, &ior_switch);
// parameters only used in ray_transp mode
if(ma->mode & MA_RAYTRANSP) {