Ray Tracing
Pages: 1 2
Colin Ferris (399) 1814 posts |
Rick has been busy writing about “Ray Tracing” in BASIC on his site. The code with small mods has been run on a Beeb! |
nemo (145) 2546 posts |
Like this? 1600×900 png A few lines of Basic and 4 whole colours. |
Rick Murray (539) 13840 posts |
It’s actually ray casting. Slightly different beast, I did explain the difference.
Pretty nifty. Thank you for demonstrating my point about people who create ray tracers liking reflective spheres. ;) |
Steve Pampling (1551) 8170 posts |
Is it my eyes, the screen I’m viewing on, the browser, or is the chequerboard representation of a planar surface slightly distorted? |
nemo (145) 2546 posts |
Please feel free to improve it:
[You won’t be able to change mode so easily unless you have my VDUMode module though.] |
Rick Murray (539) 13840 posts |
The actual f…….. I know you said
but that’s taking the……. |
Clive Semmens (2335) 3276 posts |
I once won an Acorn User (I think – might have been a different mag) competition with a 3 line (iirc – could have been 4 or 5, I don’t have a copy to check, memory might be playing tricks but I don’t think so) BASIC program that converted a string representing an integer in any base*, to another string representing the same number in any other base*. 3 (or however many it was) LINES, but a LOT of instructions. You can even cheat on the 255 character limit on the length of a line, by putting the tokens in instead of the human-readable versions. * Up to some limit, possibly 256, I forget. |
nemo (145) 2546 posts |
Length byte maximum is 255 of course but it, the CR and the line number take up 4 bytes, so 251 is the maximum number of actual Basic chrs/tokens. |
Paul Sprangers (346) 524 posts |
Shouldn’t that be: Please feel free to get it run? |
Stuart Swales (8827) 1357 posts |
Not in a TaskWindow will help, for sure. Save it out and run it. |
Rick Murray (539) 13840 posts |
Of course. Just providing the code makes it too easy. ;)
Note also nemo’s reference to a custom mode. You’ll want to tweak that to be something else. |
nemo (145) 2546 posts |
It’s not a custom mode but a custom API. It has irked me that the introduction of deep modes, mode specifiers and WimpMode strings in RO3.5 was not extended to the actual VDU, so whereas
And then because this is an emulator, there’s another module called AnyMode that enables any screen geometry to be selected (subject to RO granularity restrictions). Fun fact: This monitor is 900 lines high and RISC OS 4.39 doesn’t totally get scrolling right when it isn’t a multiple of eight, so leaves some lines of junk at the bottom of the screen, uncleared, when hardware scrolling. Anyway, enough of my agonies. |
nemo (145) 2546 posts |
Paul typed in a listing and then tried to debug it like it’s 1982 muttering
I am very sorry. I didn’t think anyone actually would. Here’s the code as it is:
However, the bytes in the REM statement at the start (I’m sorry, this was a BBC Micro program I adapted slightly) will probably get mangled by the internet pixies. In hex they are:
w,h are the size of your screen in pixels, S is effectively the focal scaling parameter, x,y are the pixel coordinates of the centre of a pixel in the middle of the screen (so |
nemo (145) 2546 posts |
And here’s a version that uses 16 colours, a nice palette, a standard MODE, and no BBC Micro tricks like REM-peeking or GOTO:
|
Rick Murray (539) 13840 posts |
Acorn probably figured we should be using the shiny new SWI and not spitting bytes at the VDU driver.
Whoops! I have one that’s… 1440×900? Something like that. I use it on the PC.
Oi! That’s bleeding edge around these parts. Lots of SWI 298, and you’ll know how far it got by counting the asterisks on the screen. |
nemo (145) 2546 posts |
The advantage of the VDU interface is that it can be captured by
VDU is a bit olde worlde because of its one-byte-at-a-time API, though UKVDU23V filters that for implementors somewhat. But the Printer Driver issue is a real one. Especially in an OS that traditionally has been phobicly resistant to coining new vectors. |
David J. Ruck (33) 1635 posts |
Also works a treat in a Graphic TaskWindow |
Colin Ferris (399) 1814 posts |
Years ago the Arc plus Colour Card gave a mode of “MODE 120” 1024 × 768 16col. Long time ago I tried to make a module to recreate MODE 120 on newer machines without success. Has anyone got some ideas – Tks |
Chris Hall (132) 3554 posts |
The answer is simple. The 1024×768 is not relevant. You just want a 16 colour MODE number in place of 120 in the sprite. |
nemo (145) 2546 posts |
Do you mean “How can I get 1024 × 768” or “how can I make ‘MODE120’ select that”? |
Colin Ferris (399) 1814 posts |
To select Mode 120 in a graphics taskwindow !Smalltsk – which has number modes as a input. |
nemo (145) 2546 posts |
Try this and see if it works. If not I’ll have to put more numbers in it. |
Colin Ferris (399) 1814 posts |
Just found where I downloaded Nemo’s Mode 120 module 1024 × 768 16col – many thanks Nemo – seems to work ok with !SmallTsk on VRPc DL RO 5.x the Iyonix is playing up at the mo – USB being temperamental :-( Any explanation of how the 120 Module works :-) |
David Jackson (3317) 22 posts |
FYI my Iyonix USB (front panel) went high-resistance due to frequent keyboard swap-out. A quick resolder on the earth lug cleared the problem :) |
Colin Ferris (399) 1814 posts |
My Iyonix double boots and then sits there looking at me no keyboard no mouse – auto booting no keyboard :-( Is there a prog that gives the USB a kick if it is not working? |
Pages: 1 2