Mutable World Demo / lighting problem

9 views
Skip to first unread message

joseph allen

unread,
Dec 22, 2013, 3:17:11 AM12/22/13
to gummw...@googlegroups.com
I have been looking Mutable World Demo for some tips / guide on using python. As a new person to python I find some of the OO style hard to work out. But it will come to me in time.

In a different programming language i have made an few snippets of minecraft / terraria to try different thing out. There range from polygon culling to basic 2d lighting and even 2d redstone.

There is a way to solve your lighting problem by using hashes to store the values of the light the best example i can think of is hashlife http://en.wikipedia.org/wiki/Hashlife . You should get a large speed up for the lighting calculations but drawing is still a problem i think. I never try it but you can do something on the same lines with the tiles if there are tiles that are the same next to each other draw 1 larger tile With the size of the smaller tiles. Octree http://en.wikipedia.org/wiki/Octree good example. Also good for world saving.














Alien

unread,
Dec 23, 2013, 7:55:42 PM12/23/13
to gummw...@googlegroups.com
One thing I forgot it's Quadtree http://en.wikipedia.org/wiki/Quadtree. Octree is for 3d and quadtree is for 2d.

















bw

unread,
Dec 26, 2013, 12:29:29 AM12/26/13
to gummw...@googlegroups.com
Hi. Thanks for the tips.

For the demo it sufficed to compute deltas for the X and Y panning and only evaluate tiles on those two edges and their neighbors for lighting. This approach turned out to be very low cost in terms of CPU cycles and additional code.

To do anything more elaborate I'm sure would require new tricks and optimizations. When processing a high number of objects in Python and pygame it becomes immediately clear that one can't get away with a brute force approach. I agree, big gains are to be had with hashing, caching, culling, dividing and scheduling workloads, memoization and and blit call reduction.

I tried a quadtree but my implementation was very slow so I ditched it. Gummworld2 now uses a spatialhash tailored for pygame rects, and optionally Gummworld2's geometry classes. I find it a pretty efficient solution for spatial culling and collision detection.
--
You received this message because you are subscribed to the Google Groups "Gummworld2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gummworld2+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alien

unread,
Dec 26, 2013, 10:50:03 PM12/26/13
to gummw...@googlegroups.com
I'm going to look at spatialhash never seen that type of hashing.

Started an snippet to test to see if i can get my old lighing demo working in python. Before I start
optimizations the code.
Reply all
Reply to author
Forward
0 new messages