Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Finding out scale factor for 3d label to be pixel perfect

Author
Message
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Apr 2013 01:01
I am using kind of name tags for certain 3D objects in a scene. These are simply plains textured with the result of a bitmap font, no problems there. However as they are 3D objects they get rendered smaller or larger than the texture's pixels making it look pretty bad at most camera positions / angles.

I figure there should be a way to determine the distance from the camera at which an object should be to correspond to pixel-perfect ratio (ie. a plane of 100x100 units facing the camera should take up 100x100 pixels on the screen) and that you could then divide this with the actual range from the camera to the label to acquire a scaling factor that can be used to preserve pixel size on a 3D object at various positions.

I'm sure there are tutorials on this around the net but I can't seem to figure out what you would call it so my searches have yielded no results.
Any link to a page on the subject, or by all means, if somebody knows it and cares to explain it himself, would be greatly appreciated.

Cheers,
Rudolpho


"Why do programmers get Halloween and Christmas mixed up?"
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 16th Apr 2013 01:11 Edited at: 16th Apr 2013 01:11
The range is 400 away from the camera, provided you're using the default FOV and a 640x480 resolution.

Note that you have to shift the object by half a pixel on both axes because 3D pixels are centered.

TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th Apr 2013 18:49
Can you not just use normal (or d3d) text at the objects position? Would solve this problem easier?

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Apr 2013 19:03
@Mobiius: I imagine it would be a slower calculation to figure out where (and if) the 3D objects are on the screen. I also want the labels to be hidden if they're behind another object.

@TheComet: Thanks. Sadly not the resolution (or even the same aspect ratio) that I am using but at least somewhere to start


"Why do programmers get Halloween and Christmas mixed up?"
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th Apr 2013 20:35
Quote: " I imagine it would be a slower calculation to figure out where"


Object Screen X
Object Screen Y
Object In Screen

Done. lol

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Apr 2013 21:16
Yes, but how slow (to execute) do you believe those functions are?
I haven't tried though, it's possible they are rather fast. The problem of getting other 3D objects to obscure the labels if they're in front of them still persist though so I don't think that is a desirable solution.


"Why do programmers get Halloween and Christmas mixed up?"
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th Apr 2013 21:28
They're very fast, but your right about the obscuring thing being more difficult to implement.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Jane Doe
19
Years of Service
User Offline
Joined: 29th Jun 2007
Location:
Posted: 17th Apr 2013 08:36
Hi, Rudolpho!

Cloggy posted this some time back:

(ScreenHeight * 0.5) / tan(FOV * 0.5)

This will yield the distance from the camera that a 3D plane needs to be to achieve pixel perfect representation of the plane's texture. ScreenHeight is the vertical screen resolution and FOV is the field of view.

Once the plane is positioned and oriented, it has to be moved 0.5 units of measurement to its right (assuming it's facing the camera) and 0.5 units of measurement up.

I use it all the time. It works great!

- Jane

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 17th Apr 2013 13:48 Edited at: 17th Apr 2013 13:48
@Jane Doe

Nice find!

«Just because you’re unique, doesn’t mean you’re useful»
«If you contributed to the reason for locking, you may now find yourself on moderation, or in extreme cases in the grave»
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 18th Apr 2013 02:35
I'm uploading an, errr, one of my experiments... which show how 2D hover tips work with 3D objects. Is this kinda what you're after?

Here's a link;

https://sites.google.com/site/bfmstudios/Home/Object%20Properties.zip?attredirects=0&d=1

Or a simple screengrab;



Although it burns your eyes, it's a functional example of how DBPro can read data out of a CSV file, then use that information to create objects and give them meta-data.

I've been building my game engine for a few years now, with my primary focus on that it has to be easily modifiable. And what easier way to modify a game, than to edit CSV data, which can control everything from the models & textures loaded, to the properties of everything.

Regarding 3D planes aligned with the camera, it's possible to do that, as per the techniques discussed in this thread. But, what are the advantages & disadvantages? I suggest you write these up and then go from there.

For the record, my favorite game interface is Dirt, which uses floating 3D planes, full of text & pictures. Love it.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th Apr 2013 19:02
Quote: "For the record, my favorite game interface is Dirt, which uses floating 3D planes, full of text & pictures. Love it."

I also like that kind of immersive UI. Dead space also has a very good immersive interface.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 24th Apr 2013 00:51
@Jane: ah yes, that's pretty much what I was looking for, thanks

Quote: "Regarding 3D planes aligned with the camera, it's possible to do that, as per the techniques discussed in this thread. But, what are the advantages & disadvantages? I suggest you write these up and then go from there. "

Well... the obvious advantage is that the text would look the same regardless of distance
It's ok if it becomes smaller further away I guess, but it looks horrid if you manage to move the camera in such a way that it is scaled up to several times it's pixel size; especially if it only happens along one axis.

Thanks for the share though, seems pretty interesting.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2026-07-06 18:37:23
Your offset time is: 2026-07-06 18:37:23