mailto: blog -at- heyrick -dot- eu

Navi: Previous entry Display calendar Next entry
Switch to desktop version

FYI! Last read at 03:28 on 2024/12/18.

Slightly speeding up the raycaster

The main problem with the raycaster is that once you introduce wall textures, the number of calculations that are necessary jumps from "where does this wall piece begin and end?" to "step through every pixel of this texture in step with drawing every pixel of the wall piece".
It's like going from building a lego house to building a real one.

Therefore, there are two ways to make things go faster. The complicated way is to change the maths to use fixed point, or something (anything) that doesn't require a lot of floating point operations. This is hard and means a deeper understanding of maths, possibly lookup tables, and... yeah, just no.
The simpler way is to cheat and simply perform fewer calculations.

For this to happen, pop this up at the top somewhere.

dofast% = TRUE

Now change this:

REM Now, cast rays for each scrcol across the screen, starting from the left

FOR scrcol% = 0 TO (width% - 1)

to be this:

REM Now, cast rays for each scrcol across the screen, starting from the left

IF dofast% THEN stepping% = 8 ELSE stepping% = 1
FOR scrcol% = 0 TO (width% - 1) STEP stepping%

Now change these lines:

REM ...and write it to the screen
screen%?( (yloop% * width%) + scrcol% ) = col%

to be this:

REM ...and write it to the screen
IF (dofast% = FALSE) THEN
  screen%?( (yloop% * width%) + scrcol%) = col%
ELSE
  col% = col% + (col% << 8)
  col% = col% + (col% << 16)
  screen%!( (yloop% * width%) +  scrcol%      ) = col%
  screen%!( (yloop% * width%) + (scrcol% + 4) ) = col%
ENDIF

Obviously, this will lead to a fairly dramatic decrease in resolution.

It'll look like this, more or less...

Low resolution raycasting
Low resolution raycasting.

This changes the plain BASIC version from 1-3fps (on a Pi 3B+) to 9-12fps, which isn't good, but it isn't quite as awful. This can go up to 15-20fps if the code is crunched.

The compiled version runs at a straight 75fps. It won't go any faster as that's the video refresh rate. If you take out the WAIT command in the switchbank procedure, it will flicker like crzy, but prepare to have your mind blown.

Pay attention to the FPS value
Pay attention to the FPS value.

 

What I did this morning

It was quite a pleasant morning, so I went out and slaughtered some brambles. I didn't think to take a before picture, and I don't have any in my photos because it was a part of the property that was mostly "that pile of brambles over there". The only notable thing there was the burst of purple due to the big Buddleia that had been growing there for many years (about 30, I think). I left well alone because the mixture of Buddleia and later the bramble flowers were appreciated by various bugs.

But I think last summer's heatwave may have killed the Buddleia. I'm going to cut it back a lot in a couple of weeks. Fingers crossed.

Anyway, one of the springtime jobs is to attack the brambles before they turn into a mess. The overall idea is to maximise the amount of land that can be handled by the big mower.
I have left a barrier of brambles between my land and the neighbouring field. Partly to make an obvious barrier, but also to leave something to catch whatever might be sprayed on the field - though thanks to various EU directives, farmers aren't chucking random poisons down quite like they used to.

Here's a short little video.

 

First signs of Spring

Just as a brief blast of cold is predicted for the mornings in the coming week...

Japonica
Japonica, the first to flower?

Daffodils, and other bulbs, are coming up but no flowers yet. One, a crocus I think, is near flowering. Maybe tomorrow or Monday?

 

There's a fungus among us

This winter, a mass of fungi has sprung up on the dead willow log that's sitting in the potager (because it's too big to move). I'm not sure if it was the hot summer, or the milder winter with the short cold blast... Either way, it looks like one of the Trametes mushroom/fungi has come along to colonise the dead wood. It is helping it to decompose, though I do hope to move the log at some stage this year...currently no idea how, two years I tried tying it to the back of the big mower but that was a non-starter.

Anyway, I found it rather fascinating. A sort of icky beauty.

Fungi on a dead log
Fungi on a dead log - overview.

Fungi on a dead log
Fungi on a dead log - macro of one part.

Fungi on a dead log
Fungi on a dead log - flash to highlight both sides.

Now for some mind blowing things. First up, mushrooms have DNA. This isn't a big surprise, as DNA is basically the code of life, and mushrooms are alive in their own squishy way.

But consider. In a human, people are doing things like looking for "the gay gene" and trying to map out the human genome. I'd be more concerned with working out how the body is created. I mean, you have a kidney, right? Two actually. Well, what is it that arranges some of your cells to be a pee filter, to make it that shape and that behaviour, and in that position, and connected to that plumbing in that way? Now repeat this for the thousands of other bits that make you, well, you. You have 206 bones (actually about 300 as a baby to make it easier to push you out of a very small hole), around 600 muscles, a ridiculous amount of internal wiring that is the central nervous system. Ancilliary systems such as the lymphatic, digestive, and of course the one that pumps the vital blood all around the body. Your heart, the one muscle that never rests (when it stops, you die). It's a little larger than a clenched fist, and it continually squishes to pump your blood around, in a rather complicated manner. And, just think, a normal person's heart beat is 60-110 beats per minute (and this changes depending upon activity). Let's assume 100bpm to keep the maths simple. It's 6,000 times an hour. 144,000 times a day. Actually, you slow down as you sleep, so let's round that down to 100,000 beats a day. Thirty six and a half million beats in a single year.
Given that children tend to be more active than adults (and thus a higher heartbeat), it's probably not a surprise to imagine that you've probably racked up a billion beats by the time you're in the range of 18-24 years old (depending on your physical activity).

And somewhere in the mass of genetic coding lie the instructions for how to make all of those parts, and how to arrange them to make a functioning human.
This includes some massively complicated parts, namely the eyes, ears, and brain. Of course, the system isn't perfect and flaws are quite common in all three parts. Though oddly having crappy eyes seems to be the most accepted (glasses can be a fashion statement), hearing troubles and/or deafness next... and people don't tend to like to talk about mental issues as far too many people equate "mental problems" with "psychopath", however there are many many types of non-neurotypical issues that can affect the brain. For instance, I believe that I have a mild form of autism, possibly Aspergers, but I was never tested. I have dyscalculia and dyspraxia, and when I was younger I had hyperactivity and attention deficit disorder (it's lumped together as ADHD these days). I can put much of this down to being born dead, but I don't think every autistic and/or dyslexic person in the world was likewise born dead. It might have been that something got a little messed up in the creation of the brain. After all, signal noise can distrupt digital signals, why not some form of interference affecting DNA?

Which brings us back to the mushroom. Take a look at the middle picture, and note the bands of... whatever those white things are. They look like velcro, but they're in very obvious bands. The mushroom was specifically designed that way. I don't know enough anything about mushrooms to hope to offer a reason why they have evolved to look like that. But they did. And something in their DNA will contain the information on how to grow like that. Just like our DNA describes what fingers look like.

Oh, and the DNA of a mushroom is much closer to the DNA of a human than it is to the DNA of a plant. They produce vitamin D when exposed to sunlight, just like we do.

Oh, and while the Trametes family are not edible, various members of this family are well known in Chinese herbal medicine. Many years ago, a very friendly and touchy-feely Chinese woman made up a concoction for mom to help... let's just say it was to calm and to forget. Anyway, the instructions were pretty simple. Boil a litre of water, empty the contents of the bag into the water, boil for a period of time (twenty minutes? I forget), then draw off a cupful through a cloth strainer. Let it cool a little, then drink while it was still warm.
Mom did. And survived. ☺

As the pan washer, I tried picking out the gunk in the pan onto a plate to try to figure out what it was. I didn't identify most of it, but the things I did (mostly) figure out, it was a very eclectic collection of "random stuff found while walking through a forest in the rain", along with pieces of lotus root, because, come on, what Chinese herbal remedy doesn't have slices of that distinctive bulb in it?
But once I identified "that mushroom that grows on rotting wood", I decided the best approach would be "don't look, don't ask". Mom took that approach in the beginning, told me not to say anything beyond the lotus root (it's a really obvious thing - Google it).

 

Oh, and just to mess with you one last time, there may actually be no genetic encoding for "how to make a kidney" (etc). This may be a standardised process resulting from the mother providing the instructions during the embryo stage, with the DNA acting as a way to modify the process (such as eye colour). What parts of the creation of a human are contained within our DNA, and which parts are inherted during the creation process?

 

 

Your comments:

Gavin Wraith, 4th February 2023, 22:18
You might be interested in this: 
 
https://www.theguardian.com/science/2021/oct/10/epigenetics -the-misunderstood-science-that-could-shed-new-light-on-ageing 
David Pilling, 5th February 2023, 04:20
Buddleia pretty tough, weed tree that grows on railways. I'd be looking for buds and cut back to just above them. Of course if no buds then you've not much to lose by cutting it down to the ground. 
Dust like seed, rapid grower, easy to replace. Besides the standard butterfly bush, there is also the one with golden balls - globularis.
Anon, 5th February 2023, 15:02
Careful with those fungi. If the spores get into your brain they'll turn you into a zombie under the control of the hive mind, hell-bent on destroying humanity. And eventually when the fungus is done with you it'll send a stem out of the back of your neck from which more spores will come, thereby infecting even more unfortunate humans. 
 
(That sounds like a good horror movie plot. I wonder why nobody's made a Hollywood movie out of it? Oh... wait.)
J.G.Harston, 6th February 2023, 05:08
Trametes are one of those odd mushrooms where you distingush between inedible and not edible. Most of them are not poisonous - so they are not inedible - but they are so tough and indigestible that they are not edible. 
 
Some of them are traditionally used as field dressings, as you can peel the skin off in moderately thick sheets. 
 
Checking Roger's Mushrooms (*the* definitive reference) confirms it's the Multizoned (or Striped) Polydore. 
 
I used to get good Chanterelles when I lived in Scotland, I think I now live too near the coast and with the wrong woodland to find them now.

Add a comment (v0.11) [help?]
Your name:

 
Your email (optional):

 
Validation:
Please type 30386 backwards.

 
Your comment:

 

Navi: Previous entry Display calendar Next entry
Switch to desktop version

Search:

See the rest of HeyRick :-)