3D rendering

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

3D rendering

Post by immibis »

As you may know (or will know, if you're a Factorio developer), Factorio uses a 2D engine that just draws pre-made images at specific positions on the screen.

When Factorio was using simple 2D hand-drawn sprites for most things, a 2D-based engine was fine. But now that most graphics are 3D models, it's a major waste of space to use them as pre-rendered 2D sprites - with no mods installed in 0.8.8, the texture atlases are over 370 MB uncompressed. That's insane.

Every computer with 370 MB of video memory (i.e. every computer that is not really old) should easily be able to handle the original 3D models, which would also take up much less space on disk and load faster.

Advantages of using 3D models:
  • Lower video memory requirements.
  • Faster loading.
  • Smaller file size.
  • Allows for more dynamic effects - for example, shadows could change as the sun moves across the sky.
  • Allows for more consistency - several parameters, like the light direction, must currently be "baked into" each image. If the game controls the light direction, there can't be accidental mismatches.
Advantages of using 2D images:
  • Simplicity.
  • Allows for more complicated graphics - what if someone wants to make an impossible triangle sprite, for example? Averted if both are allowed.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: 3D rendering

Post by ssilk »

A quite good suggestion!

Because this week - when I was thinking about how to make good pictures of factorio game engine running - I came nearly to the same conclusion. I'm just afraid, that this will be a sort of change, that takes month and some more people, which work for factorio. (Or better: be paid by factorio sales)

My very naive estimation is autumn, because some more things have to come before. But yes, I think this is a good option. My favorite music program Reason tooks the same way: the front plate of the devices where first hand painted. Then they made it a 3d model and rendered the front plates from that. And now with the rack extensions, the developers of the rack extensions (In Factorio the modders) send a 3d wireframe with their code and Propellerheads renders that into a front plate and so on. What I want to say: the way from 2d to 3d is not so difficult as some might think.

Um, another point is: the landscape could then be also 3d. How nice would that look? :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: 3D rendering

Post by kovarex »

I believe this is suggestion of Factorio 2 :)

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: 3D rendering

Post by immibis »

ssilk wrote: My very naive estimation is autumn, because some more things have to come before. But yes, I think this is a good option. My favorite music program Reason tooks the same way: the front plate of the devices where first hand painted. Then they made it a 3d model and rendered the front plates from that. And now with the rack extensions, the developers of the rack extensions (In Factorio the modders) send a 3d wireframe with their code and Propellerheads renders that into a front plate and so on. What I want to say: the way from 2d to 3d is not so difficult as some might think.
That's how Factorio already works, except we can render models ourself - we don't need to send them to the Factorio team.
ssilk wrote: Um, another point is: the landscape could then be also 3d. How nice would that look? :)
I'm not suggesting any changes to game mechanics here.

Olreich
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Dec 20, 2013 4:09 am
Contact:

Re: 3D rendering

Post by Olreich »

immibis wrote: Advantages of using 2D images:
  • Simplicity.
  • Allows for more complicated graphics - what if someone wants to make an impossible triangle sprite, for example? Averted if both are allowed.
  • Reduces loading times and reduces graphical power needed (no need to render 3d models down to 2d sprites on load or render 3d models)
You missed one.

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: 3D rendering

Post by immibis »

Olreich wrote:
immibis wrote: Advantages of using 2D images:
  • Simplicity.
  • Allows for more complicated graphics - what if someone wants to make an impossible triangle sprite, for example? Averted if both are allowed.
  • Reduces loading times and reduces graphical power needed (no need to render 3d models down to 2d sprites on load or render 3d models)
You missed one.
Graphical power yes, loading times no. Have you seen how much sprite data there is? (You should have, since I said it in the first post. 370MB in 0.8.8)

Edit: any computer that can run Factorio at all has plenty of spare graphical power, so that shouldn't even be a problem.

Olreich
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Dec 20, 2013 4:09 am
Contact:

Re: 3D rendering

Post by Olreich »

I don't know the exact numbers for how big the model library was, but assuming that it was even 60MB, the process of rendering those models down to 370MB of textures on the fly is pretty intensive. I've seen high quality models take several minutes to be rendered down to a 2d image after compositing and lighting. The oil rig that was shown in the blog was pretty high polygon count, but not nearly as high as those I mentioned. The thing to remember is that the 370MB of image data represents a bunch of renderings of the same object many times (most things that rotate).

It would not be good to rasterize those models at load for the sake of loading times (even a 5400rpm laptop drive would likely be faster than a high-end graphics card at that).

It would also not be good to have the game switch to full-3d when the aesthetics are based on 2d graphics and the hardware requirements would increase drastically. Perhaps for those of us with a dedicated gaming desktop or laptop, it would be better to have 3d graphics, as we'd not even notice the performance hit. But those who are playing on a $300-$400 laptop? They would probably see degraded performance.

For those with slow hard drives and weaker devices, on-the-fly, delayed, background loading, or some combination there-of would be far better for loading times. Maybe even have a low LOD set of textures that is always loaded or something. Assuming using better-compressed PNGs doesn't degrade performance much, using better PNG compression (lossless) would be optimal, as when I run the base/graphics folder through a compressor, I go from 90MB to 64MB, so there is some reduction in file size that needs to be loaded.

Doing tests on this optimized graphics set, I found that by optimizing the graphics folder with PNGGAuntlet I could get from a median 7.80 seconds to load to a median 7.15 seconds to load. That's an 8% reduction in loading time right there without using any lossy compression techniques (which could reduce the file sizes even further).

Another thing that might help loading times would be adding in threading support the loading. Right now, it maxes out one core and only one core when loading, if that can be parallelized into 2 or more threads, it might really improve loading times on slower devices.

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: 3D rendering

Post by immibis »

Olreich wrote:I don't know the exact numbers for how big the model library was, but assuming that it was even 60MB, the process of rendering those models down to 370MB of textures on the fly is pretty intensive.
It wouldn't do that, it would render them every frame like (almost) every other 3D game.
Olreich wrote: I've seen high quality models take several minutes to be rendered down to a 2d image after compositing and lighting. The oil rig that was shown in the blog was pretty high polygon count, but not nearly as high as those I mentioned.
The oil rig could be optimized quite a lot. It doesn't need that many polygons.
Olreich wrote: It would also not be good to have the game switch to full-3d when the aesthetics are based on 2d graphics and the hardware requirements would increase drastically. Perhaps for those of us with a dedicated gaming desktop or laptop, it would be better to have 3d graphics, as we'd not even notice the performance hit. But those who are playing on a $300-$400 laptop? They would probably see degraded performance.
The idea is to leave most things as 2D. It would still be a 2D game, based around 2D graphics, except that some of those 2D graphics would "secretly" be 3D models. No user-visible difference, except that they don't get pixelated when you zoom in, and that the game doesn't need 370MB of graphics memory (387MB in 0.9).
[/quote]

Olreich
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Dec 20, 2013 4:09 am
Contact:

Re: 3D rendering

Post by Olreich »

So, make it appear 2D while being 3D and degrade performance drastically for some possible video memory reduction (after texturing, the load on video memory is unlike to be significantly reduced). That doesn't make very much sense.

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: 3D rendering

Post by SilverWarior »

The main reason why current 2D graphics require so much memory is that you still use quite a lot of that memory for storing those transparent pixels.
Now most 3D engines apply textures to the 3D model meshes by defining which texture pixel would be at which vertex node (vertex nodes are points which define the shape of a 3D model). This alows you to contain several nonrectangular texture shapes in one rectangular pixture.
So this is what reduces the memory requirement for storing textures in 3D graphical engine with comparison of storing Sprites in 2D engine.

Now as far as performance goes 3D graphical engine wouldn't necessary be so much slower as 2D graphical engine. It all depends on what you do with it.
The main reason why many 3D games require so much GPU power is becouse they do several postprocessing phases applying lighting, shaders, Anti-Aliasing etc.
So if Factorio would implement 3D rendering with litle of this postprocessin it would run even on basic laptops like many old 3D based games do.

But in the end moving Factorio to 3D (even if it is for 2D like perspective) would require quite a lot of work and time.
I think it is better that developer use all that time for implementing new stuff into Factorio and then sometime in the future make factorio 2 which would be in full 3D.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: 3D rendering

Post by kovarex »

The models would have to be simplified, some of the animations took hours to render on farm of 3 computers with high-end cards.

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: 3D rendering

Post by AlexPhoenix »

Every computer with 370 MB of video memory (i.e. every computer that is not really old) should easily be able to handle the original 3D models, which would also take up much less space on disk and load faster.
PC is able, but render 3D models is harder task for PC, so lower FPS will be here.
Allows for more dynamic effects - for example, shadows could change as the sun moves across the sky.
Allows for more consistency - several parameters, like the light direction, must currently be "baked into" each image. If the game controls the light direction, there can't be accidental mismatches.
this can be handled by the game itself.
if game will have different shadow map and sprite, than we can be able to draw more complex shadows.
Smaller file size.
not so much, you forget textures.
Faster loading.
50/50, cuz preparing and optimizing data for 3D also not so simple.

main advantage of Factorio is game idea, not graphic(but graphic not bad at all)

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: 3D rendering

Post by kovarex »

The biggest advantage of 3d models would be the freedom of movement of different machines, more space for lots of different enemies types. No limitation in rotation precision etc etc.
The disadvantage is, that it will be hardly faster to render 3d model, even simplified than just draw one 2d sprite, in other words, when you zoom out and see tens of thousands of sprites, this would mean tens of thousands of 3d models.

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: 3D rendering

Post by AlexPhoenix »

kovarex wrote:The biggest advantage of 3d models would be the freedom of movement of different machines, more space for lots of different enemies types. No limitation in rotation precision etc etc.
The disadvantage is, that it will be hardly faster to render 3d model, even simplified than just draw one 2d sprite, in other words, when you zoom out and see tens of thousands of sprites, this would mean tens of thousands of 3d models.
it may be good idea to use hybrid style, like 3d for rotating objects(player, car, bitters, trains, etc) for other(buildings, tiles, etc) still use 2d.
it's rather cheap for perfomance.

User avatar
rlerner
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Tue Mar 05, 2013 1:26 am
Contact:

Re: 3D rendering

Post by rlerner »

Think of using PNGs as a bytecode cache or compiler. You can build a program in an interpreted language, when then has to be JIT compiled before it starts using processing power to do its job. This in turn becomes a tremendous waste of time, as each time a program is used, this needless compute cycle has to occur again. If you just store the code compiled or even in a bytecode cache, that much less work must be done each time the program is ran.

The same is true here. Each time a 3D model is used, needless compute power is being used. There are advantages to this, but for the scope of the game, I think PNGs are a better approach.

Hours on a 3-node computer setup? Was it the biter nest? How did you distribute the load? Just curious, seems pretty interesting.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: 3D rendering

Post by sparr »

immibis wrote:But now that most graphics are 3D models, it's a major waste of space to use them as pre-rendered 2D sprites - with no mods installed in 0.8.8, the texture atlases are over 370 MB uncompressed. That's insane.

Every computer with 370 MB of video memory (i.e. every computer that is not really old) should easily be able to handle the original 3D models, which would also take up much less space on disk and load faster.

Advantages of using 3D models:
  • Lower video memory requirements.
  • Faster loading.
  • Smaller file size.
I don't know why you think the 3D models would use less file size or video memory. To produce the same view as the 2d sprites, the 3d models would need *at least* as much texture information as the 2d sprite already has (more likely at least 3x as much, and more realistically 5-10x as much).

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: 3D rendering

Post by immibis »

sparr wrote:I don't know why you think the 3D models would use less file size or video memory. To produce the same view as the 2d sprites, the 3d models would need *at least* as much texture information as the 2d sprite already has (more likely at least 3x as much, and more realistically 5-10x as much).
Animations. They don't need a full copy of the texture information per frame.

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: 3D rendering

Post by AlexPhoenix »

immibis wrote:
sparr wrote:I don't know why you think the 3D models would use less file size or video memory. To produce the same view as the 2d sprites, the 3d models would need *at least* as much texture information as the 2d sprite already has (more likely at least 3x as much, and more realistically 5-10x as much).
Animations. They don't need a full copy of the texture information per frame.
but they need more calculations, also models with the same vertex animation as 2d prerendered pics need very much vertices for this.
with 3d texture animation we have the same thing as with 2d.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: 3D rendering

Post by sparr »

immibis wrote:
sparr wrote:To produce the same view as the 2d sprites, the 3d models would need *at least* as much texture information as the 2d sprite already has (more likely at least 3x as much, and more realistically 5-10x as much).
Animations. They don't need a full copy of the texture information per frame.
I overlooked that. But still, at 8-16 frames per sprite, it sounds like you might break even.

dee-
Filter Inserter
Filter Inserter
Posts: 414
Joined: Mon Jan 19, 2015 9:21 am
Contact:

Re: 3D rendering

Post by dee- »

It would be nice if Factorio could run inside a VirtualBox machine, which it currently can not because the 128 MiB video RAM are not enough. Which, I admit, struck me unexpected when I tried for the first time, error messages and not helping fallbacks following.

Post Reply

Return to “Ideas and Suggestions”