OpenGL 3D viewport renderer

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

milek7
Engineer
Engineer
Posts: 9
Joined: 18 Jul 2016 08:04

Re: OpenGL 3D viewport renderer

Post by milek7 »

Assert wrote:
03 Dec 2019 23:56
No, this is just because the land generator do not invalidate all of the tiles, just save and load. I will fix this soon.
That fixes missing tiles, but I meant that UI graphics are pixelated: https://i.imgur.com/4yPs6wE.png I tracked it to be caused by sampling atlases at wrong mipmap level, removing that from code fixed it for me:

Code: Select all

glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_LOD_BIAS, 0.5);

Assert
Engineer
Engineer
Posts: 14
Joined: 24 Nov 2019 22:19

Re: OpenGL 3D viewport renderer

Post by Assert »

milek7 wrote:
04 Dec 2019 17:03
Assert wrote:
03 Dec 2019 23:56
No, this is just because the land generator do not invalidate all of the tiles, just save and load. I will fix this soon.
That fixes missing tiles, but I meant that UI graphics are pixelated: https://i.imgur.com/4yPs6wE.png I tracked it to be caused by sampling atlases at wrong mipmap level, removing that from code fixed it for me:

Code: Select all

glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_LOD_BIAS, 0.5);
Ah, i see. Thisng not so simple. Without this bias too hi level is selected on my hardware. Probably this is something dependent to the drivers or hints. I will make an explicit mip level selection in the shader.

Assert
Engineer
Engineer
Posts: 14
Joined: 24 Nov 2019 22:19

Re: OpenGL 3D viewport renderer

Post by Assert »

milek7 wrote:
04 Dec 2019 17:03
That fixes missing tiles, but I meant that UI graphics are pixelated: https://i.imgur.com/4yPs6wE.png I tracked it to be caused by sampling atlases at wrong mipmap level, removing that from code fixed it for me:

Code: Select all

glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_LOD_BIAS, 0.5);
Fixed, with a lot of other things https://github.com/Assert1/OpenTTD

modreoci
Engineer
Engineer
Posts: 1
Joined: 14 Dec 2019 21:04
Contact:

Re: OpenGL 3D viewport renderer

Post by modreoci »

I compiled and ran game but 3D viewports does note appear... I also made appropriate settings like in the video... What I have to do? (Manjaro Linux)

Assert
Engineer
Engineer
Posts: 14
Joined: 24 Nov 2019 22:19

Re: OpenGL 3D viewport renderer

Post by Assert »

modreoci wrote:
14 Dec 2019 21:08
I compiled and ran game but 3D viewports does note appear... I also made appropriate settings like in the video... What I have to do? (Manjaro Linux)
It's better to contact milek7 about nix, i can't test it in my env:(

milek7
Engineer
Engineer
Posts: 9
Joined: 18 Jul 2016 08:04

Re: OpenGL 3D viewport renderer

Post by milek7 »

https://github.com/Assert1/OpenTTD/blob ... v.cpp#L172
Replace that line with #if 1
The other if branch was for OpenGL ES (mobile devices etc., but some other changes necessary for GLES weren't merged from my branch)

Assert
Engineer
Engineer
Posts: 14
Joined: 24 Nov 2019 22:19

Re: OpenGL 3D viewport renderer

Post by Assert »

milek7 wrote:
15 Dec 2019 10:36
https://github.com/Assert1/OpenTTD/blob ... v.cpp#L172
Replace that line with #if 1
The other if branch was for OpenGL ES (mobile devices etc., but some other changes necessary for GLES weren't merged from my branch)
Latest changes shoud work with ES profile... at least, i am tested it in windows, and everything is ok...

User avatar
stefino_cz
Traffic Manager
Traffic Manager
Posts: 249
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: OpenGL 3D viewport renderer

Post by stefino_cz »

I had a chat with Assert yesterday about this 3D mode. It looks really good but I found a problem with vehicle length. 3D models have constant length and it seems like a big problem because 3D environment still uses 2D engine which changes the length of the vehicle at the direction. This fact produces big spaces between wagons in _ and I directions. The question is if this problem has any solution :|
Image

Assert
Engineer
Engineer
Posts: 14
Joined: 24 Nov 2019 22:19

Re: OpenGL 3D viewport renderer

Post by Assert »

stefino_cz wrote:
16 Dec 2019 06:38
I had a chat with Assert yesterday about this 3D mode. It looks really good but I found a problem with vehicle length. 3D models have constant length and it seems like a big problem because 3D environment still uses 2D engine which changes the length of the vehicle at the direction. This fact produces big spaces between wagons in _ and I directions. The question is if this problem has any solution :|
This is not a problem, and this is a fundamental thing in OTTD, because it uses integer space coordinates.

User avatar
jimbob
Engineer
Engineer
Posts: 87
Joined: 24 Nov 2014 21:13
Location: At a desk
Contact:

Re: OpenGL 3D viewport renderer

Post by jimbob »

This looks amazing. I've got some low poly 3d models I was making for my own game, I'd be happy to share them to help with this project.
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter

pelya
Transport Coordinator
Transport Coordinator
Posts: 283
Joined: 18 Nov 2010 19:48
Contact:

Re: OpenGL 3D viewport renderer

Post by pelya »

After 15 years of development, OpenTTD is getting a revolutionary new feature - rotate the map in any direction!

I'm tempted to release this as Android version on April 1st for one week, of course rename it to 'OpenTTD 3D' in gaudy 3D font. All NewGRFs will be rendered as billboard-style flat sprites, like monsters from Doom (1993), aesthetics be damned.

User avatar
Zephyris
Tycoon
Tycoon
Posts: 2831
Joined: 16 May 2007 16:59

Re: OpenGL 3D viewport renderer

Post by Zephyris »

Very cool! How does it link sprites to 3D models to know what to use? If you fixed the vertical elevation of the camera you could probably get away with billboarding trees.

I wouldn't try to grab anything from zBase though, those models are wildly unoptimised for real time 3D!

User avatar
NekoMaster
Tycoon
Tycoon
Posts: 3963
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: OpenGL 3D viewport renderer

Post by NekoMaster »

Would it be possible for someone to post a binary? I can never seem to get compiling on windows to work.
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!

mando
Engineer
Engineer
Posts: 2
Joined: 11 Jan 2020 13:11

Re: OpenGL 3D viewport renderer

Post by mando »

I had literally just tried doing this myself, seeing as you've gotten this far, I will save myself some effort. It looks very cool, just needs some 3DGRFs.

User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1264
Joined: 15 Feb 2003 17:32
Location: Villefranche-sur-Saône, France

Re: OpenGL 3D viewport renderer

Post by MagicBuzz »

All what I can say about newgrf is...

Ok, newgrf (as their name say) are... graphics. And graphics are eyecandy.
3D is eyecandy too.

As a result, I don't think the lack of 3D newgrf is a real matter : you choose right now to play with newgrf eyecandy or 3D eyecandy.
Next newgrf versions could implement 3D graphics.
It's the same problem with 32 bits + max zoom newgrfs : most of newgrf doesn't support max zoom, that's not a reason do not support it.

Next, most newgrfs are not simply eyecandy : there are vehicle properties, industries properties, new cargos, etc. so existing newgrf are still usefull.

IMO 3D port is a very good thing.

User avatar
jimbob
Engineer
Engineer
Posts: 87
Joined: 24 Nov 2014 21:13
Location: At a desk
Contact:

Re: OpenGL 3D viewport renderer

Post by jimbob »

MagicBuzz wrote:
14 Jan 2020 13:32
All what I can say about newgrf is...

Ok, newgrf (as their name say) are... graphics. And graphics are eyecandy.
3D is eyecandy too.

As a result, I don't think the lack of 3D newgrf is a real matter : you choose right now to play with newgrf eyecandy or 3D eyecandy.
Next newgrf versions could implement 3D graphics.
It's the same problem with 32 bits + max zoom newgrfs : most of newgrf doesn't support max zoom, that's not a reason do not support it.

Next, most newgrfs are not simply eyecandy : there are vehicle properties, industries properties, new cargos, etc. so existing newgrf are still usefull.

IMO 3D port is a very good thing.
Quite, first thing first is a set of base models. Then newgrfs can default to a base graphic until some creates the proper graphic for the new vehicle/building etc...

I've some 3d models I want to load into this, the day I get some free time to try it out.
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: OpenGL 3D viewport renderer

Post by SirkoZ »

How about a 2D approach - to increase color depth of any existing sprite be it newgrf or old via some sort of upscaling via OpenGL. Just to get smoother transitions between the pixels of each sprite.
That is the most important thing to reduce the strain on eyes of any TTD or TTO because if its 256-bit graphics.
3D terrain can come later. A friend and I made a 3D OpenGL terrain similar to TTD's ages ago (year 1998) on linux before OpenTTD was created and it worked well and one could change tile textures on the fly, but it wasn't developed into a real game.

mrgiords
Engineer
Engineer
Posts: 3
Joined: 17 Mar 2020 14:59

Re: OpenGL 3D viewport renderer

Post by mrgiords »

Personally I find this prototype fantastic and I hope that it gets developed more! :bow:

One thing I always found a bit difficult and frustrating with OpenTTD is terrain reshaping and map exploration: I think 3D would help a lot in this sense.

My only concern would be about performance, it would be a pity if it was not possible to create the same amount of vehicles that one can create now. But I'm ignorant about the technology side, so it might not really be a problem.

Awesome idea! :)

User avatar
kamnet
Moderator
Moderator
Posts: 7253
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: OpenGL 3D viewport renderer

Post by kamnet »

I've tried running this a couple of times now, and unfortunately it starts off really laggy, then my mouse starts very slowly moving all over the place, outside of my control, before it stops responding and Windows wants to shut it down.

zbx1425
Engineer
Engineer
Posts: 1
Joined: 16 May 2020 13:54

Re: OpenGL 3D viewport renderer

Post by zbx1425 »

I would like to say this is an awesome project, and I rushed to try it out.
However, it does not seem to be working on my device...
I downloaded the binary, reset the configuration, and the program crashed instantly at startup.

The OS was Windows 10 1709, and the graphics adapter was Intel UHD Graphics 630.

I have little knowledge of C++ so I cannot help :cry:

Crash Log: https://pastebin.com/HqVqwHuq
Crash Dump: https://drive.google.com/file/d/1T-qmnw ... sp=sharing

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests