Old 02-24-2009, 10:31 PM   #1
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default realtime raytracer

realtime raytracing
very non-optimized version
burns cpu cycles!!



on my machine it's smooth at 150*150, but starts to get choppy around 200*200.
animated gif, lo-fi colors (realtime dithered to 256 colors):



the code is ugly at times, haven't prettified it, or structured it properly. lots of short-hands and hacks, single one-directional light (like the sun), diffuse lighting (no specular), one level of reflection only (no recursion in js), the eye/camera and fov (field of view) is a bit messed up. i might do some refactoring/cleanup, etc...

and, i would be grateful for any ideas about optimizations!

http://sites.google.com/site/jesucce.../gfx_raytracer

all of a sudden the triggers stopped working, they're supposed to start ('1') and stop ('0') the animation, or do single-frame rendering ('2'). but you can also change the anim time manually with the 'theta' slider

- ccernn
__________________
torhelgeskei.com

Last edited by cern.th.skei; 02-24-2009 at 10:51 PM. Reason: animated gif ddn't work ?
cern.th.skei is offline   Reply With Quote
Old 02-25-2009, 09:29 AM   #2
Youn
Human being with feelings
 
Youn's Avatar
 
Join Date: Jun 2006
Posts: 1,167
Default

this is awesome! i'm surprised it takes such little code to do this and renders as fast as it does
Youn is offline   Reply With Quote
Old 02-25-2009, 09:58 AM   #3
LOSER
Human being with feelings
 
Join Date: May 2006
Posts: 2,373
Default

Nice!

Now make a raytracing reverb .
LOSER is offline   Reply With Quote
Old 02-25-2009, 10:12 AM   #4
DerMetzgermeister
Human being with feelings
 
DerMetzgermeister's Avatar
 
Join Date: Feb 2008
Posts: 1,467
Default

Quote:
Originally Posted by LOSER View Post
Nice!

Now make a raytracing reverb .
Or better... A radiosity reverb!
DerMetzgermeister is offline   Reply With Quote
Old 02-25-2009, 10:42 AM   #5
liteon
Human being with feelings
 
liteon's Avatar
 
Join Date: Apr 2008
Posts: 510
Default

the gfx_setpixel() has no mercy on my cpu. :O
i would suggest more primitive spheres if you are planning to make the fx with real time animation.

take a look at senocular's planets demo:
http://www.senocular.com/flash/source.php?id=0.54

a sphere constructed from lots of rectangles (gfx_rectto())
may be lot faster and not bad looking either - stylized
it can still has primitive shadows and reflections.
liteon is offline   Reply With Quote
Old 02-25-2009, 02:36 PM   #6
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

cool, for speed you could try tweaking it to render random rays, and make them blobs rather than pixels (so you get motion blur and weird quality)

edit: I couldn't help myself, here's a faster, cartoony mod:

https://stash.reaper.fm/oldsb/122780/...racer_cartoony

Last edited by Justin; 02-25-2009 at 02:57 PM.
Justin is offline   Reply With Quote
Old 02-25-2009, 02:59 PM   #7
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by liteon View Post
the gfx_setpixel() has no mercy on my cpu. :O
i would suggest more primitive spheres if you are planning to make the fx with real time animation.

take a look at senocular's planets demo:
http://www.senocular.com/flash/source.php?id=0.54

a sphere constructed from lots of rectangles (gfx_rectto())
may be lot faster and not bad looking either - stylized
it can still has primitive shadows and reflections.
I dont think gfx_setpixel is responsible for the slownesss -- it's doing a lot of math per pixel (notice the reflections and shadows)..
Justin is offline   Reply With Quote
Old 02-25-2009, 03:58 PM   #8
Youn
Human being with feelings
 
Youn's Avatar
 
Join Date: Jun 2006
Posts: 1,167
Default

so, does this mean we'll soon see a JSDoom? Would be neat to somehow tie the music or midi to in-game graphics or control.
Youn is offline   Reply With Quote
Old 02-25-2009, 04:38 PM   #9
nerdfactormax
Human being with feelings
 
nerdfactormax's Avatar
 
Join Date: Oct 2007
Location: A-town, Australia
Posts: 633
Default

I think I may have to cancel my forum account so someone else can use my username. You've earnt it.
nerdfactormax is offline   Reply With Quote
Old 02-25-2009, 04:54 PM   #10
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default

Quote:
Originally Posted by LOSER View Post
Nice!

Now make a raytracing reverb .
Quote:
Originally Posted by DerMetzgermeister View Post
Or better... A radiosity reverb!



hm, there could be some ideas worth looking at there...
- ccernn
__________________
torhelgeskei.com
cern.th.skei is offline   Reply With Quote
Old 02-25-2009, 04:57 PM   #11
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default

Quote:
Originally Posted by Justin View Post
cool, for speed you could try tweaking it to render random rays, and make them blobs rather than pixels (so you get motion blur and weird quality)

edit: I couldn't help myself, here's a faster, cartoony mod:

https://stash.reaper.fm/oldsb/122780/...racer_cartoony
cool!
i might borrow some ideas from this..
- ccernn
__________________
torhelgeskei.com
cern.th.skei is offline   Reply With Quote
Old 02-25-2009, 05:50 PM   #12
audioguytodd
Human being with feelings
 
audioguytodd's Avatar
 
Join Date: Mar 2008
Location: Atlanta, GA
Posts: 1,057
Default

FYI, this is all insanely cool from a layman. I have done a bit of POV ray tracer, and to see what you have done with JS is nothing more than amazing.
__________________
Comp Specs: WIN XPSP3, Q6600, ASUSP5K, 3 GB PC6400 RAM, Focusrite Saffire, AlphaTrack, lots of plugins and hardware.
audioguytodd is offline   Reply With Quote
Old 02-25-2009, 07:01 PM   #13
dub3000
Human being with feelings
 
dub3000's Avatar
 
Join Date: Mar 2008
Location: Sydney, Australia
Posts: 3,955
Default

that's *obscene*

well done!
dub3000 is offline   Reply With Quote
Old 02-25-2009, 08:21 PM   #14
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

forgive my ignorance but what exactly does this do?
Jae.Thomas is offline   Reply With Quote
Old 02-25-2009, 09:29 PM   #15
liteon
Human being with feelings
 
liteon's Avatar
 
Join Date: Apr 2008
Posts: 510
Default

Quote:
Originally Posted by Justin View Post
I dont think gfx_setpixel is responsible for the slownesss -- it's doing a lot of math per pixel (notice the reflections and shadows)..
ah, yes thats what i ment in a way. lots of calculations per pixel.

reduced 'resolution' with gfx_rectto (4x4px, 8x8px rectangles) instead of per pixel action, would do great as a solution.

i can see ccern has a 'lowres' voxel landscape prototype posted in the other thread which uses rectangles in the same fashion.
liteon is offline   Reply With Quote
Old 02-26-2009, 04:24 AM   #16
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default

Quote:
Originally Posted by Jason Brian Merrill View Post
forgive my ignorance but what exactly does this do?
http://en.wikipedia.org/wiki/Ray_tracing_(graphics)

as it is now, it's quite useless. i mainly did it to see how JS handled lots of math, and also trying to stretch the boundaries of js coding, stepping a bit outside of what reaper/js is supposed to (be able to) do.

it could be used as a benchmark of some sort, except that there's no proper indication of cpu use or anything.

and, with something as cpu intensitive as this, i can experiment with js optimizations, trying out various tiny coding details and see their efficiency and performance.

last, when getting a better grip on the details (and hopefully a few small additions to the js language), we could start doing some more useful graphics plugins for VJ-ing and/or video things, realtime controllable via audio, midi, or whatnot.

- ccernn
__________________
torhelgeskei.com
cern.th.skei is offline   Reply With Quote
Old 02-26-2009, 04:40 AM   #17
ichijou
Human being with feelings
 
Join Date: Oct 2008
Posts: 157
Default

how much interactivity is possible, for instance, could you write a game where hitting a certain frequency pops the floating balls?
ichijou is offline   Reply With Quote
Old 02-26-2009, 04:40 AM   #18
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default

Quote:
Originally Posted by liteon View Post
ah, yes thats what i ment in a way. lots of calculations per pixel.

reduced 'resolution' with gfx_rectto (4x4px, 8x8px rectangles) instead of per pixel action, would do great as a solution.

i can see ccern has a 'lowres' voxel landscape prototype posted in the other thread which uses rectangles in the same fashion.
i have been testing a bit with some adaptive subdivisions.. initially rendering for example 16*16 blocks, and if any of the corners differ (normal, color, texture u/v, ..) more than some defined threshold, subdivide the square, and continue, until we reach another minimum-size threshold (or down to 1 pixel).

polygons, or interpolated squares would help a lot here, so that we don't have to do this 'manually' with loops/setpixel.. perhaps some tricks with gfx_blitext and creative use of parts of gradient bitmaps.

but, i would like to look into algorithmic optimizations first, before doing code-based tweaking. easier to test new features, check if this or that algo is better/worse than another, and for not losing overview of the spaghetti code in there

- ccernn

and, i have (partially working) a better version of the voxel land too, with interpolation, both when reading from the height/color maps, and when rendering those vertical bars, in addition to some caching and min/max-y-drawn-so-far. update coming soon here too.
__________________
torhelgeskei.com
cern.th.skei is offline   Reply With Quote
Old 02-26-2009, 04:48 AM   #19
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default

Quote:
Originally Posted by ichijou View Post
how much interactivity is possible, for instance, could you write a game where hitting a certain frequency pops the floating balls?
everything is possible, if you have enough cpu cycles available. time (and motivation) will tell how far we can take this...

since it's all calculated, every parameter and value in there can be changed on the fly. we could do lots of weird things.. modify objects (size, color, etc) based on audio, distort the camera direction/rays, adding/removing objects, ... imagination is the main limit.

one thing i hoped for when making/posting this, was to inspire others to continue in their own directions, or take what they wanted and making somethng else, or come up with exciting new ideas. there's lots of possibilities!
__________________
torhelgeskei.com
cern.th.skei is offline   Reply With Quote
Old 02-26-2009, 09:58 AM   #20
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

You're all barking mad! Love it!
IXix is offline   Reply With Quote
Old 02-26-2009, 09:50 PM   #21
liteon
Human being with feelings
 
liteon's Avatar
 
Join Date: Apr 2008
Posts: 510
Default

Quote:
Originally Posted by cern.th.skei
but, i would like to look into algorithmic optimizations first, before doing code-based tweaking. easier to test new features, check if this or that algo is better/worse than another, and for not losing overview of the spaghetti code in there
i like the subdivisions idea.
the algorithm in its current state is quite heavy for realtime. 'compression' in one way or another will be required

btw that 'code extraction' or 'loop unroll' or whatever, will not reduce the cycles much for the gfx thread. i did some test the other day

Quote:
Originally Posted by IXix
You're all barking mad! Love it!
wolfenstein 3d & tetris are on the way for js (shocker) -

well its fun - some games in the daw.
blah...all that mixing and recording. xD
liteon is offline   Reply With Quote
Old 02-28-2009, 07:52 PM   #22
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default

recoded the raytracer. it's not really realtime anymore. (yet?). but, now it handles recursive rays, has multiple light sources, a material system, and specular highlights. next out is the refractions, more object types (planes, cubes,..), and then i can start cleaning up, and optimizing.



- ccernn
__________________
torhelgeskei.com
cern.th.skei is offline   Reply With Quote
Old 02-28-2009, 08:36 PM   #23
LOSER
Human being with feelings
 
Join Date: May 2006
Posts: 2,373
Default

Quote:
Originally Posted by cern.th.skei View Post
recoded the raytracer. it's not really realtime anymore. (yet?). but, now it handles recursive rays, has multiple light sources, a material system, and specular highlights. next out is the refractions, more object types (planes, cubes,..), and then i can start cleaning up, and optimizing.



- ccernn
Holy! That looks sweet.
LOSER is offline   Reply With Quote
Old 03-02-2009, 01:14 PM   #24
cern.th.skei
Human being with feelings
 
cern.th.skei's Avatar
 
Join Date: Sep 2007
Location: trondheim, norway
Posts: 362
Default new

new screenshot, things looking a bit more 'correct' now.

__________________
torhelgeskei.com
cern.th.skei is offline   Reply With Quote
Old 03-02-2009, 01:31 PM   #25
Liquidclear
Human being with feelings
 
Join Date: Mar 2008
Location: Newcastle, WA
Posts: 70
Default

This is amazing!
Liquidclear is offline   Reply With Quote
Old 03-04-2009, 01:49 AM   #26
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Cool!!
Tale is offline   Reply With Quote
Old 03-04-2009, 10:08 AM   #27
audioguytodd
Human being with feelings
 
audioguytodd's Avatar
 
Join Date: Mar 2008
Location: Atlanta, GA
Posts: 1,057
Default

Sweet!!! Maybe someday I can stop using POVRay and just use JS!
__________________
Comp Specs: WIN XPSP3, Q6600, ASUSP5K, 3 GB PC6400 RAM, Focusrite Saffire, AlphaTrack, lots of plugins and hardware.
audioguytodd is offline   Reply With Quote
Old 03-05-2009, 03:22 PM   #28
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Unbelievable what you mad scientists come up with...

Quote:
Originally Posted by ichijou View Post
how much interactivity is possible, for instance, could you write a game where hitting a certain frequency pops the floating balls?
Love the edutainment idea of this.

I could also imagine to play a good game of Pong with a mate and two guitars... and raytraced rackets
gofer is offline   Reply With Quote
Old 03-06-2009, 08:33 PM   #29
zildjohn01
Human being with feelings
 
Join Date: Dec 2008
Posts: 189
Default

How can I hook this up with ReaMote and Blender? I've been having trouble getting a reliable render farm set up, but ReaMote works fine on my system
zildjohn01 is offline   Reply With Quote
Old 03-07-2009, 03:21 AM   #30
liteon
Human being with feelings
 
liteon's Avatar
 
Join Date: Apr 2008
Posts: 510
Default

Quote:
Originally Posted by zildjohn01 View Post
How can I hook this up with ReaMote and Blender? I've been having trouble getting a reliable render farm set up, but ReaMote works fine on my system
Have you tried http://www.drqueue.org/cwebsite/?

What you are asking for here is a bit complicated since this JS fx should be made into a complete renderer with full geometry, texturing, complex lighting support and particle systems etc. While - image exporting, .blender file format support, python scripting..etc etc are added to the JS engine. ReaMote should be then optimized for rendering tasks and Blender. And Blender must add support for JS (as a renderer) and ReaMote (as a farm). :-) something like that...

Last edited by liteon; 03-07-2009 at 08:18 AM.
liteon is offline   Reply With Quote
Old 11-30-2011, 12:57 PM   #31
Youn
Human being with feelings
 
Youn's Avatar
 
Join Date: Jun 2006
Posts: 1,167
Default

With the Doom 3 source now released, it would be cool to see a port in JS... you up for the challenge?
Youn is offline   Reply With Quote
Old 11-30-2011, 01:33 PM   #32
Evan
Human being with feelings
 
Join Date: Oct 2006
Location: Greece
Posts: 3,553
Default

Where's the teapot? I want a teapot...
Evan is offline   Reply With Quote
Old 10-24-2020, 03:44 AM   #33
rekkandevar
Human being with feelings
 
Join Date: Jan 2020
Posts: 58
Default

I decided to take the blob version of this and turn it into a visualizer. You have to hook the new sliders up to things from the audio statistics JS effect, but at least it is now capable of responding to audio input. It would be cool if this could be made into a video processor preset but I am not qualified to do that much.
Attached Files
File Type: txt gfx_raytracer_toony.txt (7.7 KB, 98 views)
rekkandevar is offline   Reply With Quote
Old 10-24-2020, 10:33 AM   #34
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Video Processor works under completely different paradigms and is missing functions like setpixel.
So porting it would be challening.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 11-07-2020, 12:48 AM   #35
Loulou92
Human being with feelings
 
Loulou92's Avatar
 
Join Date: Sep 2015
Location: Paris
Posts: 544
Default

Can I import my 80 million poly models in it already ? looooooooool No but seriously, awesome awesome fascinating initiative.
Loulou92 is offline   Reply With Quote
Old 10-08-2023, 06:23 AM   #36
zookthespook
Human being with feelings
 
Join Date: Mar 2015
Location: India Mumbai
Posts: 816
Default

Quote:
Originally Posted by cern.th.skei View Post
realtime raytracing
very non-optimized version
burns cpu cycles!!



on my machine it's smooth at 150*150, but starts to get choppy around 200*200.
animated gif, lo-fi colors (realtime dithered to 256 colors):



the code is ugly at times, haven't prettified it, or structured it properly. lots of short-hands and hacks, single one-directional light (like the sun), diffuse lighting (no specular), one level of reflection only (no recursion in js), the eye/camera and fov (field of view) is a bit messed up. i might do some refactoring/cleanup, etc...

and, i would be grateful for any ideas about optimizations!

http://sites.google.com/site/jesucce.../gfx_raytracer

all of a sudden the triggers stopped working, they're supposed to start ('1') and stop ('0') the animation, or do single-frame rendering ('2'). but you can also change the anim time manually with the 'theta' slider

- ccernn
This post was so ahead of its times ! i guess now that reaper is also working as a Video NLE , this should be implored !
zookthespook is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.