How to make a false floor in 3D?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
retrotails
Party member
Posts: 212
Joined: Wed Apr 18, 2012 12:37 am

Re: How to make a false floor in 3D?

Post by retrotails »

OP, would this not work? It's incredibly difficult to add hills, not only for the shader code but also for the game code.
Arrow keys to move, + and - to rotate (call it '= and -' if you prefer...) 0.9.0, requires shader support but not canvas support.
This code is mine and you're free to use it, I am however too busy dabbling in true 3D games to help much.
Attachments
mode7.love
(458.05 KiB) Downloaded 275 times
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: How to make a false floor in 3D?

Post by Ref »

Jasoco wrote:
1. You ran setMode after loading the library? Because if you only setMode before loading the library (require 'Perspective') then it works fine until you try to change the window mode again. Are you on 0.8.0 or 0.9.0? Because it has failed for me on both.

2. Not sure what you mean by this because the way I use it is for my 3D project where everything is going to be changing every frame. So caching imagery for later isn't going to help when the whole screen changes. Don't really see how a canvas would apply here.

I'd like to see someone figure out proper perspective warping using Mesh's though.
I would also like to see warping with Meshes.

1. I'm on Windows 7 Love 0.9 and haven't experienced any problems with setMode though that is not something I usually reset. (Re-ran a simple test with setMode in different of positions and encountered no problems but test may not be valid.)

2. As I said, I didn't think this approach would meet your requirements but to create a 'false floor in 3D' it should do just fine since I wouldn't expect a floor would be changed too often.

3. The use of a canvas would limit the area over which the effect of the shader would be active to the canvas. Texturing a single small object every frame shouldn't be too much of a problem. Multiple objects - big problem as you point out.

Here's hoping someone gets the Mesh approach going.
User avatar
ncarlson
Prole
Posts: 35
Joined: Wed Jul 20, 2011 4:00 pm

Re: How to make a false floor in 3D?

Post by ncarlson »

Here's a few tech demos I whipped up. All source is MIT. But you must respect the Ol' Barry, his Whiteness.


1. 3D Box
3d-cube-and-xyY-colorspace.love
Real 3D using Model View Projection
(18.26 KiB) Downloaded 443 times

2. Steam Effect (very sexy)
extra-steamy.love
Faux clouds by fiddling with perspective matricies
(604.85 KiB) Downloaded 430 times
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: How to make a false floor in 3D?

Post by Jasoco »

The 3D Box intrigues me. I'll have to take a closer look at the code.

And the steam one is pretty realistic looking. Makes me want to figure out some place to use that effect. (Almost looks like you're flying over some clouds)
User avatar
ncarlson
Prole
Posts: 35
Joined: Wed Jul 20, 2011 4:00 pm

Re: How to make a false floor in 3D?

Post by ncarlson »

The Steam demo was just eyeballed on my part. Basically,

1. Place a quarter-scale cloud sprite in back
2. Chose random movement vector (left or right, mostly)
3. Move sprite along vector while also
3.a Increasing sprite scale
3.b decreasing alpha

The whole thing was a failed attempt to port this WebGL demo: http://www.mrdoob.com/#/131/clouds


As for the cube demo, the interesting part was trying to cram 3d-Position, 4d-Color, and 2d-Texture coords into the mesh. If you stick to just flat color, or just UV texture cords, the current Mesh api opens a world possibilities.
User avatar
slime
Solid Snayke
Posts: 3134
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How to make a false floor in 3D?

Post by slime »

If you only care about texture coordinates in the range of [0, 1] with a <= 256 texel resolution and don't need alpha for colors (but still want the RGB colorspace), you could use the 'u' texture coordinate component for the Z component of the position, and the 'a' color component to replace the 'u' texture coordinate component.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: How to make a false floor in 3D?

Post by Ref »

This is my 'best effort' with mesh.
Not too sure I got it right but will try to refine later.
Triangulation apparent on surfaces and am recreating meshes every frame (bound to be slow.)
Arrow keys to rotate
WSAD to change FOV and scale
Esc to exit
Edit: ncarson ,took a peek at your code! Wow! Seems a bit of an overkill. My little cube took only 80 lines of code - total.
Attachments
meshcube.love
Monkey free meshed cube
(610.82 KiB) Downloaded 151 times
User avatar
slime
Solid Snayke
Posts: 3134
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How to make a false floor in 3D?

Post by slime »

Ref wrote:Edit: ncarson ,took a peek at your code! Wow! Seems a bit of an overkill. My little cube took only 80 lines of code - total.
His shader-based method is closest to how the 'real' 3D pipeline works, and is likely the most efficient out of anything here as well.

Also, using [wiki]Mesh:setVertices[/wiki] will usually be more efficient than re-creating the entire mesh.

The shader-based approach allows the GPU to do the work it's designed to do (transforming vertices in parallel, using a perspective projection matrix, the perspective divide / perspective-correct interpolation, etc.) and it also provides a built-in way to know if a face is front- or back-facing so you can act accordingly.

My recommendation if you want to experiment with 3D: learn vertex and pixel shaders. :)
User avatar
alberto_lara
Party member
Posts: 372
Joined: Wed Oct 30, 2013 8:59 pm

Re: How to make a false floor in 3D?

Post by alberto_lara »

Thanks everybody.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 62 guests