How to use IES files with sim3d.Light

I am trying to visualize the light distribution of an IES file using Simulink 3D Animation.
I created an object with sim3d.Light and specified the IES file in the IESFilePath property, but the light distribution displayed is that of a PointLight instead of the one defined in the IES file.
How can I ensure that the contents of the IES file are applied?
Below is the code comparing PointLight and SpotLight:
% Code to compare PointLight, SpotLight, and IES light distribution
% The lights illuminate the road surface from the left lane with PointLight, SpotLight, and IES (grid pattern).
% The sun altitude cannot be changed, so it is displayed during the day, but the lights are bright enough to be visible.
world = sim3d.World('Scene',"Straight road");
light1 = sim3d.Light(ActorName='Light1',Translation=[0,-6,1],Rotation=[0,0,0],LightType='PointLight');
light2 = sim3d.Light(ActorName='Light2',Translation=[0,-2,1],Rotation=[0,-pi/4,0],LightType='SpotLight');
light3 = sim3d.Light(ActorName='Light3',Translation=[0,2,1],Rotation=[0,0,0]);
light3.IESFilePath = "TestImg.IES";
world.add(light1);
world.add(light2);
world.add(light3);
viewport = createViewport(world);
viewport.Translation = [-3,-2,4.5];
viewport.Rotation = [0,-pi/4,0];
run(world,0.01,3)
delete(world);
I have attached the IES file used and a PNG showing the light distribution from this file.
The IES file is compressed in a zip archive as it cannot be uploaded directly.

2 Comments

For a better understanding of the problem, please provide the IES file you are using.
Thank you for pointing that out.
I was considering using a public resource, but instead, I created a grid pattern data for better clarity.

Sign in to comment.

 Accepted Answer

Nishan Nekoo
Nishan Nekoo on 6 Nov 2024
Hi Tanaka-san,
It seems like the IES file is not getting imported because of path issues. IESFilePath requires a full system path.
Using the following line should resolve the issue:
>> light3.IESFilePath = fullfile(pwd, "TestImg.IES");
Nishan

7 Comments

Hi Nishan,
Thank you for your response!
It seems like the file is now being recognized, as there has been a change in behavior.
However, an error is now being displayed, as shown in the attached image.
I have tried several IES files, but all of them result in the same issue.
It seems that the application works correctly without using IES files. Could this indicate an issue with the IES data processing?
Hi Kenichi,
I apologize that you are running into this issue and I am happy to look into it. I have tried replicating the above using the script you provided initially and the file you provided "TestImg.IES" but I am not running into the fatal error above. This is what I see:
Are you getting the fatal error using TestImg.IES as well or is it other IES files that is causing this?
Nishan
Hi Nishan,
Thank you for your response.
When I run the initial script, I see the above output, indicating that the IES file is not being read correctly.
After making the changes you suggested:
light3.IESFilePath = fullfile(pwd, "TestImg.IES");
I encounter a fatal error.
This error occurs with both the “TestImg.IES” file and other IES files.
Hi Kenichi,
If you make a slight modification to the Rotation field of light3 to ensure it is pointing directly at the pavement:
light3 = sim3d.Light(ActorName='Light3',Translation=[0,2,1],Rotation=[0,-pi/2,0]);
You will see the pattern from the IES file:
This seems to indicate that the file is being read correctly in this case. Are you able to replicate this?
However, this does not resolve the issue of the fatal error that you are seeing which I have been unable to replicate - can you clarify which version of MATLAB you are using? I have been testing on version R2024b.
Thanks,
Nishan
Hi Kenichi,
I actually did test the above in R2024a, and now I can replicate the issue of the file not being read, so I assume this is the version you are currently using. Thank you for bringing this to our attention and I will look into it.
In the meantime, if you were using R2024a, would you be able to try this in R2024b to see if the issues you are seeing with the fatal error still persists?
Thanks,
Nishan
Hi Nishan,
Thank you for your prompt response.
  • R2024b: The issue seems to be resolved in R2024b, as it works correctly according to the image you provided.
  • Fatal Error Cause:The fatal error occurs when the IES file path contains double-byte characters. This issue persists even in R2024b.
  • R2024a: Even when the fatal error does not occur, the file is not recognized in R2024a.
  • Lighting on the Road Surface: The brightness appears unusual. As it is a lighting fixture, it should only increase brightness, but this light seems to be able to make the environment darker. Additionally, it seems point lights are still enabled.
I see potential uses for this feature and hope it will display correctly.
Best regards,
Kenichi
Hi Kenichi,
Thank you so much for your valuable feedback. I am glad that you are seeing the issue be resolved in R2024b. However, as you noted, there are two more issues regarding the unusual brightness and the point light still being enabled. I agree that these are both issues and we will investigate them internally. In the meantime, I will also look into whether any workarounds are available and get back to you.
Nishan

Sign in to comment.

More Answers (0)

Categories

Find more on Communications Toolbox in Help Center and File Exchange

Products

Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!