I'm not sure if this is the correct place to post this, or even if anyone is interested, but I've been messing about with the Blender python addon scripts re the material/texture nodes - just modifying the python files in the Blender addons directory for now - and I've created a utility node for IOR presets to plug into the glass material's IOR socket.
I've only put a few presets in it, at least until I find out if anyone wants me to continue, and because it's all in Python I've had to 'borrow' the export type definition of 'constfloat1' otherwise the binary complains about an unknown type.
I've run it in Blender 2.79a with version v2.0alpha3 OpenCL in Linux, and it seems to be working correctly - at least I'm not getting any errors in the console. Fair warning: I'm a mediocre programmer on a good day, so someone competent may look at it and fall off their chair laughing

And I haven't got a clue how to do anything with the C++ source code.
Anyway, if people want this I'll put in more presets and enable it for volume nodes as well. Then, of course, I'll have to find out how to formally submit it.
Implementing this required modifying the files 'addons/BlendLuxCore/nodes/materials/__init__.py' by inserting at line 130:
Code: Select all
NodeItem("LuxCoreNodeIORPresets", label="IOR Preset"),
and 'addons/BlendLuxCore/nodes/textures/__init__.py' by inserting at line 43:
Code: Select all
from .ior_presets import LuxCoreNodeIORPresets
and creating the file 'addons/BlendLuxCore/nodes/textures/ior_presets.py':
Code: Select all
from bpy.props import FloatProperty, EnumProperty
from .. import LuxCoreNodeTexture
ior_values = {}
ior_values["vacuum"] = ["Vacuum", 1]
ior_values["glass_pyrex"] = ["Glass, Pyrex", 1.470]
ior_values["water_20C"] = ["Water @ 20C", 1.330]
ior_values["air_stp"] = ["Air @ STP", 1.000277]
ior_values["diamond"] = ["Diamond", 2.417]
ior_values["ethanol"] = ["Ethanol", 1.36]
ior_values["liquid_helium"] = ["Liquid Helium", 1.025]
class LuxCoreNodeIORPresets(LuxCoreNodeTexture):
"""Selection of IOR preset values"""
bl_label = "IOR Preset"
value = FloatProperty(name="IOR", description="Index of Refraction Preset")
def update_preset(self, context):
enabled = self.preset == "air_stp"
ior_presets = []
for v in sorted(ior_values.keys()):
s = "{} ({:f})".format(ior_values[v][0], ior_values[v][1])
ior_presets.append((v, s, s))
preset = EnumProperty(name="IORPreset", items=ior_presets, default="air_stp", update=update_preset)
def init(self, context):
self.outputs.new("LuxCoreSocketIOR", "IOR")
def draw_buttons(self, context, layout):
layout.prop(self, "preset")
def export(self, props, luxcore_name=None):
definitions = {
"type": "constfloat1",
"value": ior_values[self.preset][1],
}
if self.preset != "air_stp":
definitions["preset"] = self.preset
return self.base_export(props, definitions, luxcore_name)