|
Post by tbird on Feb 3, 2021 13:04:13 GMT -6
I had a breakthrough this morning, I have not put into code yet. As I was feeding cows this morning, it came to me....if I want to make it more performant I tried to do a distance culling check with weird results as I was searching for the 2 points on the line (wall) to make a shadow, it occurred to me that this would apply better to an actual game with tiles or objects, which would result in easy checking for the points of the corners of each tile or object. Instead of checking a end of a line 600 pixels away to check for distance, I can be checking every 32 or 64 pixels, and if the colors and transparency match it would be invisible to the user when the shadow jumps from an in range tile or object to the next. That's my theory and hopefully try it out tonight/tomorrow. I will also integrate it into my engine as my collision engine is already monitoring every entities position on screen so it will be trivial to add.
|
|
|
Post by johnno56 on Feb 3, 2021 13:27:28 GMT -6
Sooo... Let me see if I follow you correctly... The more you feed your cows the quicker your project will finish? Cool.
Isn't inspiration wonderful?
|
|
|
Post by johnno56 on Feb 3, 2021 14:38:43 GMT -6
I went through the FB code and converted it to sdlbasic. Reason: sdlbasic uses paint() at the mouse pointer and produces the shadows with less coding. Unfortunately, the conversion to rcbasic overall was successful, except floodfill() caused a segmentation fault. Suspect that the floodfill() area is a bit too big. The sdl version uses filled squares instead of single 'walls'.
The problem, that is common to both, is that paint() and floodfill() do not play well with the floor pattern. Probably the reason why polyfill() was used instead. "walls" would be easier to use with polyfill as only 4 points need to be tracked. Ends of the wall and the 2 lines from the wall to the screen edge. Very clever by the way... Using squares would need to track 16 points. (possible impact to performance on older machines...)
This shadow / light coding is a little addictive is it not? lol Fun. A little frustrating at times. But fun.
If you are running your 'farm' by yourself then I am surprised that you manage to get any time for coding. Cudos.
|
|
|
Post by johnno56 on Feb 3, 2021 18:43:57 GMT -6
tbird, Found this link. ncase.me/sight-and-light/Not sure if it is helpful or whether or not the coding can be used but I did find it interesting...
|
|
|
Post by johnno56 on Feb 4, 2021 3:36:06 GMT -6
Here is an update of the freeBasic version. This is pretty much a direct conversion to RC. It kind of works as it is written to do. I managed to use floodfill() in a limited fashion. I calculated the maximum size of both rectangular and circular areas that floodfill will function without crashing. Just 'pretend' that the circular fill is full screen... lol If you decide not to use this I will not be offended... It was just a "see if I can" project... lol shadowsFB.zip (1.92 KB)
|
|
|
Post by tbird on Feb 4, 2021 11:08:31 GMT -6
I did the direct conversion as well and it basically killed my laptop lol, so thats why I went to an alternate method. Right now I am trying the same algorithm I use to detect the ground in my platformer and use it to detect closest wall so still technically basing the shadow off a line. If it works, the way I believe, should be fast.
|
|
|
Post by johnno56 on Feb 4, 2021 13:20:19 GMT -6
I think your approach of using filled polygons is a much better method, memory-wise, for older machines.
I spent most of the day researching Ray Tracing and Shadow tracing. Some nice demos, a few algorithms but not much in the way of full coding like freeBasic. Found some tutorials for Game Make and Unity , and the like, but converting those are beyond my skill-set... lol
Looking forward to your next iteration....
ps: May I ask which operating system you are using and the type of laptop? (Not judging. Just curious.)
|
|
|
Post by tbird on Feb 4, 2021 18:27:18 GMT -6
Lubuntu 18.04, really old Dell with 1st gen i3 380m 2.53ghz, 8gb ram. Its about 10 years old.
Gaming machine is Dell G3 with i7 9750h, 16gb ram, 500gb ssd, gtx 1660ti
|
|
|
Post by johnno56 on Feb 4, 2021 22:38:23 GMT -6
Lubuntu. Understood. Well... I am impressed. The fact that you can run shadow casting on a 10 year old laptop says a lot about your ability. Cudos.
|
|