Dinobird
|
  |
| Joined: 29 Apr 2009 |
| Total Posts: 213 |
|
|
| 02 Jun 2015 02:11 AM |
| How would I tell how much percent of the block is shaded? Also, how would I tell if a part would be blocking another from sunlight? |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 02:28 AM |
You can't tell unless you made some kind of shade script.
local surface_area = 25 local shaded = 12
local percent = math.floor((shaded/surface_area)*100) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Jun 2015 02:40 AM |
He's talking about the Roblox sun and another object. And it is possible to figure out, I just don't know how since math |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 03:06 AM |
| The best way to do this exactly would be with a polygon bit operation library. What are you going to use this for? |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 07:19 AM |
GetSunDirection Raycasting Brightness
Those might help. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 07:30 AM |
| From my thinking you would need the time of day, size of the block, position and angle of the sun, and lost of math. Of course some things I mentioned may be needed to calculated at any time of day at any points but that would require you have some way to calculate and plug in a lot of variables. In short, I cannot see any reason as to why you would want this, or why you would want to waste computation power. I suggest trying to find a different solution to the problem you are thinking about. Not to say its not possible but the work required to figure it out may not be worth it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Jun 2015 07:56 AM |
@warspyking
Good to know, but still no closer to having a solution. |
|
|
| Report Abuse |
|
|
Dinobird
|
  |
| Joined: 29 Apr 2009 |
| Total Posts: 213 |
|
|
| 02 Jun 2015 10:14 AM |
Thanks for all your replies, and what I could do is find the difference in angles and give it more energy if the angle is closer to 90 degrees (direct sunlight is easiest to get energy from)
What I'm working on is a virtual Darwinian evolution for flora. It works as things reproduce, but unrealistic results come into play, so I'm trying to make it as realistic as I can. |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 02 Jun 2015 11:32 AM |
| You could use the dot product of the surface normal of the surface and the vector between the sun and part to determine about how much the part is facing the sun. If the surface isn't visible to the sun, then it can be determined that it isn't visible to the sun. This is also known as back face culling and is used in 3D computer graphics. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:59 PM |
This is not called backface culling.
Culling is the act of not rendering a face of a polygon. Each polygon you draw in space has two sides. A front and a back. When drawing your polygon, specifying points matter because you are telling whether or not it is a front or back triangle. Counter clockwise means front, clockwise means back.. This is what determines if a polygon should be drawn.
If lighting was determined by DOT product then we would have an extra FPS * Vertex calls each second cycle. (Basically processing collision (which lags) all over again) |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 02 Jun 2015 01:38 PM |
| I really don't know what I meant by saying use backface culling anymore. lol |
|
|
| Report Abuse |
|
|
| |
|
T0W3R
|
  |
| Joined: 13 Jul 2011 |
| Total Posts: 384 |
|
|
| 03 Jun 2015 01:56 AM |
I'm quite curious in why you would need a 'percent shaded' script. If you could tell me that'd be great. |
|
|
| Report Abuse |
|
|
Dinobird
|
  |
| Joined: 29 Apr 2009 |
| Total Posts: 213 |
|
|
| 06 Aug 2015 01:00 PM |
| If you were wondering why I needed it, I'm making an artificial evolution script with plants. I would like to have an accurate shaded percent to determine how efficient the organism is at producing energy. I could use ray casting, but I would have to use multiple so that it detects parts that aren't directly between the leaf's center and the sun. |
|
|
| Report Abuse |
|
|