Saturday, December 11, 2010

Unicorn Nightmare - More LBP2 Ray Caster Fun

 So yesterday I worked on this wonder for the most of the day.

This is NOT using the layer glitch. Although I've had plenty of ideas for using the layer glitch with the ray casting method. Raphael has published a level that uses my ray casting idea combined with his knowledge of emitting into glitched layers (Sackenstein 3D) and I will detail the key to both methods. Please see my other blog post as well:

First off, my ray casters, all of them, are entirely pseudo-3D. That means the perspective effect is just an illusion and is provided by a series of rays hitting walls at incrementing angles. It looks something like this:

Figure 1: Diagram of "shish kebab" or "Spider Web" Perspective Projection of rays.  

The calculations recursively travel down each line in the web, stopping when one piece intersects a wall. Due to the arc-like shape, we achieve a perspective effect in the same manner as Wolfenstein 3D or Ken's Labyrinth. This translates well to my methods of treating the rendering side of the equation as plotting 2D pixels. Thus, this method is best combined with either thin hologram or solid material in layers combined with a fully flat camera view. Note a fully flat camera view can still be mixed with depth of field or depth attenuation via hologram brightness or light by layer. If using holographic material or not using the layer glitch, microchip based early cancellation is necessary. This can be both a blessing or a curse. On one hand, it's good to be able to cut off all extraneous calculations in the chain. On another, recursion is slow. You must use a workaround to make sure the microchip recursion does not lag - such as wiring a "dummy" chain of inputs and outputs aside from the "NOT -> Activate" chain.  The full implementation of this style of recursive microchip logic is detailed here:

 Does not require knowledge/use of the 3D layer glitch.
 Full control over FOV angle

Naturally suited to 2D pixel mapping which is easier on the eyes.

Can be used with holographic OR solid material

Can be mixed with the glitched layers to provide higher res depth testing for game sprites.

Microchip based recursion has exponential latency - there will be bigger delays the further away on the chain you are. Unless you use workarounds.

Takes time and effort to get accurate angle increments in the rays.

Fixed camera height and orientation.

Works best with flat camera view. Texture mapping per distance must be simulated.

Sackenstein 3D is performed slightly differently. Perspective effect is slightly more 3D, it uses the glitched layers to provide a sense of depth and perspective. Therefore mixing it with an artificial perspective as in my arc based ray routine is unnecessary and may lead to strange results. Rather, an orthogonal projection is probably better.

Figure 2: Diagram of orthogonal "net" type setup. Recursion is not necessary.

Rather than simulate perspective with differently scaled slices of material, it uses the game's 3D graphics to do it with the glitched layers. In Sackenstein 3D and similar approaches, all the material is solid and emitted within a grid like figure 2 - imagine the Y axis of this grid to be further away in layers, and the X axis to be left and right.

Recursion is unnecessary - We are not trying to render a true orthogonal view, we don't want the rays to function in columns or that is the effect we will have. Rather, all cells in this grid have an impact sensor - just like the shish kebob method. Let's say it's set to read tag "WALL". Then all that happens is each cell is paired up with an emitter in the world, and when a cell impacts with wall the emitter is turned on. (Emit with 0.1 lifespan constantly to turn "on" solid material).  The slices of material each take up a thick layer.


Since it is 3D you can perform effects like the camera rolling or moving up and down.

Texture mapping for distance is handled by game engine.

Naturally clips against sprites well - put sprites in thin layer

The ray casting portion is extremely simple to setup.

Requires knowledge/use of 3D layer glitch.  

Wall Slices are solid blocks with fixed orientation relative to the camera. This makes for a visual phenomena that is very annoying to look at and confuses and give headaches easily.
Lack of early cancellation means all impact sensors are being calculated constantly.

Both have their strong points and weak points. Also, with character sprites, in Unicorn Nightmare I use holographic images for them - this leads to translucency and duplicate ray hits. Using layer glitch in either method will allow you to use a solid material for sprites - meaning that one cannot emit into the same space as the other, minimizing the ghosting effect.

Both however share one fatal flaw: too many impact sensors in one place will cause them all to stop working.

This ray caster concept I've started last month has really gone to town. I'm very glad I brought this idea to the community but it is beginning to reach its technical limits - for all simulated 3D, from now on I will use the 90 degree dungeon crawler style variant of my ray caster - stay tuned for full feature on it this weekend.

No comments: