Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

A pure Graphics 2 '3D' demo in progress
Started by rakoonic2 Sep 11 2013 07:21 PM

13 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Not realtime (think Dungeon Master style) - in fact it is surprisingly slow, but then I'm drawing much further into the distance than needed (I am fairly certain the furthest layers are pure black from the fogging)

 

After an evening's coding I present the first screenshot of Dungeoneer! (Am sure that name has been taken but whatever...):

 

Attached File  dungeoneer.jpg   197.82KB   172 downloads



[TOPIC: post.html]
#2

DavidRangel

[GLOBAL: userInfoPane.html]
DavidRangel
  • Moderator

  • 888 posts
  • Corona Staff

Very nice!



[TOPIC: post.html]
#3

walter

[GLOBAL: userInfoPane.html]
walter
  • Moderator

  • 726 posts
  • Alumni

[TOPIC: post.html]
#4

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Hi Rakoonic

 

 

How did you go about solving the texture warping like I'm experiencing in this pic here?

 

Matt

 

Attached File  1.jpg   76.65KB   118 downloads



[TOPIC: post.html]
#5

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Each case tends to have its own solution, so it depends entirely on how you are drawing your road. Let me know the general concept and we can try to work something out to fix it.



[TOPIC: post.html]
#6

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Deleting this as it was incomprehensible.

 

Basically with large tiles, when one point went to a massive number off screen the textures warped and started to break up.

 
Attached File  2.jpg   46.52KB   60 downloads
 


[TOPIC: post.html]
#7

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

I think your 'focus' value is another way of specifying field of view. The bigger your focus value, the smaller the FOV. Therefore the larger the FOV the more distortion you are going to see. What is a reasonable value depends on your game, of course, but in general the smaller the field of view, the less distortion you will see.

 

What I find odd about your image above is how the stretching appears to affect things more vertically than horizontally when focus == 1.

 

 

 

One thing guaranteed to cause issues is having the Z values get close to or even pass the Z == 0 plane. What I tend to do, although it doesn't always give the right result when you rotate, is add a fixed value to distances from the viewplane - to push everything further away and minimize or remove these issues. Note this normally goes hand in hand with some form of culling to ignore completely anything that is deemed 'too close' (usually a trial and error situation determines what this value might be).

 

If you can't fix it and don't mind me taking a look, feel free to send me the source privately.



[TOPIC: post.html]
#8

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

I think I have it, it only really fails on large polygons so I'm going to sub diving the one closest to the camera and with a focus of 2, which yeah is a different way of doing field of view, it looks like it will work for all cases.

 

The stretching there an extreme case and it does warp horizontally as well, its just there the y value has shot to infinity so it gets pulled down a lot more than it should. Corona was saying it was going 1 million pixels down at that point so the perspective has failed.

 

It looks and works much smoother in real life, will post a vid when I get it put together. Corona actually does a much better job than I would have thought it could though it seems to automatically limit itself to 30fps when I have 100+ polygons on screen. Though final won't need anywhere near that many.

 

Attached File  1.jpg   24.35KB   64 downloads



[TOPIC: post.html]
#9

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Any time you get a massive value offscreen means the point was getting dangerously close to the Z == 0 plane.

In the past another 'solution' (which produces its own visual artifacts) was to do a test on points that were too close and if so, simply move the individual points to a safe Z value. It goes wrong if more than 2 points per quad have this happen (the quad collapses onto itself, but to be honest if more than 2 points need this, you might actually be able to cull it entirely), and if this happens at all, chances are the perspective distortion will not match up at the edges (a very Corona-only error, due to them adding perspective automatically).

Either way you are trading 1 set of mistakes for another, but ridiculously large polygons might not be a problem - it really depends on how they get drawn by the GPU, and I have no idea how good the culling is and in fact it might vary from device to device (or rather, GPU chipset to chipset) - my advice in general would be to try to avoid if possible, simply because the worst that can happen is you save nothing, but it *might* be beneficial :)

Good luck with this whatever it is - looks like a proper 3D racing game?



[TOPIC: post.html]
#10

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

I should point out if you are planning on having curves or twists (IE so the corners are not co-planar, or the opposite edges are not parallel) then the image perspective *will* go wrong due to how Corona calculates the perspective to use. Exactly how badly it goes wrong depends on the user case, but I just thought I'd mention it - forewarned is forearmed so to speak.



[TOPIC: post.html]
#11

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Yeah its going to be a racing game, or at least the demo I'm writing is, probably...

 

Im not sure what you mean about the perspective going wrong. Each tile is going to be 256 x 256 and any corners will be a part of the texture. So 4 square tiles would be used to produce a 90 degree turn.

 

Are you saying this won't work?



[TOPIC: post.html]
#12

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Nope, that'll work just fine.

From your screenshots I wasn't sure if you were using some sort of spline-based routine to generate the overall shape of the track, and I was referring to that. As you aren't doing it that way, you don't need to worry :)



[TOPIC: post.html]
#13

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Ah cool. I was worrying it was going to be for nothing!

 

The idea is to designs a set number of pieces of track, assign collision walls to the segments and run the game in 2D through the physics engine.

 

Then the camera is set to follow the car and just reads the positional information from the 2D track.

 

Im doing a lot of the ground work up front for the game so the engine is progressing slower than it should be. But now I have it so you can have unlimited cameras and screens. If it wasn't for the hit to the cpu I could do a rear view mirror.

 

How is yours coming it seemed quite far along a few weeks ago, its what got me back into Corona after a lengthy pause.



[TOPIC: post.html]
#14

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Ah nice - yeah you could make the game run purely in 2D top-down first (likely what you are doing). Then converting to 3D visually would be relatively simple.

 

My stuff I haven't touch in nearly 2 weeks. I was on holiday a week and came back to urgent deadlines so I've had no free time - which isn't great as the compo deadline is coming up fast and I need to finish off my entries.




[topic_controls]
[/topic_controls]