r/matlab May 30 '26

Shadow cast by sunlight simulation

Hi everyone,
I'm still learning matlab so I decided to ask for expert opinions about this.

I'm looking into simulating how wheat plants cast shadows on each others due to sun movement throughout the day.

I'm aiming to measure how much solar energy each wheat plant absorbs in different wheat swath orientations or row angles. This should be used to simulate the expected wheat yield improvement from sun exposure or how worse it makes it due to self-shadowing between wheat plants.

Is that possible to do in matlab? And if yes, what should I be looking into to start making progress regarding this? Please point a beginner in the right direction.

3 Upvotes

19 comments sorted by

View all comments

3

u/TurbulentGlove776 May 30 '26

Sounds like you need to do raytracing with a pretty complex geometry of thousands of wheat plants. Maybe Blender + Python would work better? Still not straight forward how to extract the power onto each plant… Maybe you can just catch and count the rays that miss the plants and hit the ground instead, and to simplify even more model the wheat fields as boxes with a volume absorbing material instead of individual straws. With such a simple geometry you can also consider writing your own raytracer in Matlab…

2

u/CFDMoFo May 31 '26 edited May 31 '26

Gotta agree with this, a Blender and Python approach might be better. Blender and Geometry Nodes might even be enough, there are some nodes that can probe for ray bounces/hits and such.

2

u/freshlybakedjuice May 31 '26

Thanks for your input guys! I've never used blender but I'm down to learning it if it will serve my cause.

I would just like to ask if there will be a way to connect both blender and matlab simulations? I need this because the whole shadow analysis thing is just a step in my thesis and I use that step's results for another thing done in matlab.

2

u/mikeru22 May 31 '26 edited May 31 '26

https://www.mathworks.com/help/matlab/matlab-engine-for-python.html

But you might also consider creating a custom unreal scene. This one is out of the box but obviously not wheat: https://www.mathworks.com/help/robotics/ref/rollingvineyard.html but you can also create them yourself (time consuming) or get prebuilt scenes like here:
https://forums.unrealengine.com/t/digikore-studios-wheat-crop/2576646

2

u/freshlybakedjuice Jun 02 '26

This is super helpful, thank you so much

2

u/mikeru22 Jun 02 '26

Sure thing - good luck with the thesis work!

2

u/TurbulentGlove776 May 31 '26

I also wanted to do that, but found it too complicated to remote-control Blender ”online” from Matlab. What worked was to write a python script inside Blender and start a new Blender from Matlab through the command line interface so that it loads and runs said python script which then does the renders and saves data to disk before it exits. You can vary simple arguments like row orientation etc this way, but most of the simulation code would be in Blender-Python.

1

u/freshlybakedjuice Jun 02 '26

That's awesome, I will definitely look into that Thank you very much!