Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting IES file to intensityDistribution parameter #582

Open
ArchlineXP opened this issue Jan 19, 2024 · 4 comments
Open

Converting IES file to intensityDistribution parameter #582

ArchlineXP opened this issue Jan 19, 2024 · 4 comments

Comments

@ArchlineXP
Copy link

Hi,

We are stuck with converting the IES files to intensityDistribution parameter. Can someone please send me an example how to do it?
We checked the https://www.ospray.org/documentation.html#photometric-lights document and found some information in Table 24, but couldn't figure out the conversion number.

@johguenther
Copy link
Contributor

OSPRay Studio can load EULUMDAT files (alternative file format to IES, there are many converter tools) and pass the data as intensityDistribution to OSPRay, see https://github.com/ospray/ospray_studio/blob/master/sg/scene/lights/Photometric.cpp. Maybe this helps?

@BruceCherniak
Copy link

If IES is the necessary file format, there is a simple header-only IES file loader https://github.com/fknfilewalker/tinyies that will parse the file into an intensity array, and then the code that @johguenther mentions above can help to create the OSPRay intensityDistribution array. Ultimately, that array gets sent to OSPRay here https://github.com/ospray/ospray_studio/blob/master/sg/scene/lights/Light.cpp#L75
createChildData("intensityDistribution", lamp.lid)

@ArchlineXP
Copy link
Author

ArchlineXP commented Feb 23, 2024

Thanks for the answers, it helped a lot. We have another question about the converter:

We implemented your suggestions, but the results are incorrect.
There are 5 lights in this scene, they all share the same .ldt data.

['A' image]
https://ieslibrary.com/browse#ies-0017df4b5e5cfef10c72a89afaadf02b
['B' image]
https://ieslibrary.com/browse#ies-006ea39eb1924d82436026bb68fff5f5
['C' image]
https://ieslibrary.com/browse#ies-021e7275e2d15cf3347d0299a955eb0f

Code:

phy_light = ospNewLight("spot");
CALVector3 pos = from; // float[3]
ospSetParam(phy_light, "position", OSP_VEC3F, pos);

CALVector3 t_ = To; // float[3]
t_.normalize();
ospSetParam(phy_light, "direction", OSP_VEC3F, t_);

OSPIntensityQuantity INTq = OSPIntensityQuantity::OSP_INTENSITY_QUANTITY_SCALE;
ospSetInt(phy_light, "intensityQuantity", INTq);
//ospSetParam(phy_light, "intensityQuantity", OSP_UINT, &INTq);
//ospSetParam(phy_light, "intensityQuantity", OSP_UCHAR, &INTq);

//	CALVector3 c0(0, 0, 1);
//	ospSetParam(phy_light, "c0", OSP_VEC3F, c0);
OSPData data_;

ospray::sg::Eulumdat lamp(R"(C:\......................\A.ldt)");
lamp.load();
float *pmData = new float[lamp.lid.size()];
for( int x = 0; x < lamp.lid.size(); x++)
	pmData[x] = lamp.lid[x];

data_ = ospNewSharedData1D(pmData, OSP_FLOAT, lamp.lid.size());

ospSetObject(phy_light, "intensityDistribution", data_);
ospCommit(phy_light);

I attached 3 pictures of the result. What can you suggest to make the final result of the IES lights good?

A

B

C

@johguenther
Copy link
Contributor

The IES data you use is 2D, but passed as 1D, thus what you see is the different slices/planes compressed within the illumination cone (showing as stripes).

Try changing to

data_ = ospNewSharedData2D(lamp.lid.data(), OSP_FLOAT, lamp.Ng, lamp.totalMc)

No need to copy the data into pmData, but then lamp needs to be kept alive to share the data with OSPRay (alternatively use ospCopyData2D to let OSPRay keep the data).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants