Closed Theverat closed 6 years ago
LuxCore already support mesh and image maps inlining. For instance, you can find the code for writing an inlined image map here: https://github.com/LuxCoreRender/LuxCore/blob/2a869ba1728a3c6b24dba7823d6a3a2512ea3e0f/src/slg/imagemap/imagemap.cpp#L1063
Properties have a full support for storing "Blobs" so you can already store any data (i.e. an IES text definition) in a property: https://github.com/LuxCoreRender/LuxCore/blob/2a869ba1728a3c6b24dba7823d6a3a2512ea3e0f/samples/pyluxcoredemo/pyluxcoredemo.py#L77
I'm going to extend the light source ".iesfile" to support a string (i.e. a file name) and a Blob too.
I have added the support for .iesblob to use in place of .iesfile for light sources. For instance: https://github.com/LuxCoreRender/LuxCore/blob/master/scenes/bigmonkey/bigmonkey-mappointlight-blob.scn
Ok cool.
How do I convert a text file into this SUVTTkE6TE0tNjMtMjAwMg0...
stuff in python?
It is done by pyluxcore.Property for you (anyway it is a base64 encoded data). For instance:
david@i7-3930k:~/projects/luxcorerender/LuxCore/lib$ python3
Python 3.4.3 (default, Nov 28 2017, 16:41:13)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyluxcore
>>> pyluxcore.Init()
>>> from array import array
>>> txt = "bla bla bla"
>>> txtData = txt.encode("ascii")
>>> txtData
b'bla bla bla'
>>> prop = pyluxcore.Property("scene.l1.iesblob", [txtData])
>>> prop.ToString()
'scene.l1.iesblob = {[YmxhIGJsYSBibGE]}'
>>>
Hm, I'm getting RuntimeError: MapPoint light source (scene.lights.PointLAMPPOINT) is missing mapfile or iesfile property
These are the generated properties for the light:
scene.lights.PointLAMPPOINT.gain = 1 1 1
scene.lights.PointLAMPPOINT.samples = -1
scene.lights.PointLAMPPOINT.importance = 1
scene.lights.PointLAMPPOINT.type = "mappoint"
scene.lights.PointLAMPPOINT.flipz = 0
scene.lights.PointLAMPPOINT.iesblob = {[SUVTTkE6ClRJTFQ9Tk9ORQoxIDg1My4wMCAxIDkxIDEgMSAyIC0wLjA5MCAwLjAwMCAwLjAwMAoxLjAgMS4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mjg4NDBFKzAwMDAgCiA1LjA2MTA5NDE4NjQ3MTA2RSswMDAwICA0LjMzMzI0OTI3Njk4NjcwRSswMDAwICAzLjc2NTMwNDM5MDIzMzUyRSswMDAwICAzLjQ2MTQzMDk2MzQ4NDA2RSswMDAwICAzLjM2MjM4ODM2NTkxNDAzRSswMDAwIAogMy40MDY3NTczOTk2MDcwM0UrMDAwMCAgMy41NDg0Njk2NjkwMDgyN0UrMDAwMCAgMy43MzU3NDIwMTU5MDE2NEUrMDAwMCAgMy45MjU3Mjc1NDI2Nzc4OEUrMDAwMCAgNC4xMDIxNzM1Mzk2MDk1NkUrMDAwMCAKIDQuMjQ4MzgyNDQ0NzMwNTNFKzAwMDAgIDQuMzIwODgzNzc3MjU0ODdFKzAwMDAgIDQuMzE4NzY2MjIwOTEwMDdFKzAwMDAgIDQuMzAzMTUxMDY0NzkxOTBFKzAwMDAgIDMuOTkwNTg0OTI5NDgyODFFKzAwMDAgCiAzLjE4OTkzNjI4MjUyNDMxRSswMDAwIAo]}
scene.lights.PointLAMPPOINT.efficency = 0
scene.lights.PointLAMPPOINT.power = 0
scene.lights.PointLAMPPOINT.position = 0 0 0
scene.lights.PointLAMPPOINT.transformation = 1 0 0 0 0 1 0 0 0 0 1 0 -1.3458638191223145 0.87127572298049927 0.21273468434810638 1
This is the IES file I tested (it works if I specify it as filepath): Test1.txt
Are you sure to use the latest version of LuxCore ? This would happen if you were using a version without .iesblob support.
Damn I'm an idiot. It works now, thanks.
This would make IES file usage more portable (e.g. you could pack them in the .blend if you want to distribute it later - good for example scenes). Maybe we would need to add support for inlined text to the IES socket of LuxCore lights for this to work. Or we always save the text to a temp file on export.