Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Verifying Claims Made in an Article : SFML Cannot Do 3D?  (Read 2856 times)

0 Members and 1 Guest are viewing this topic.

Kain Nobel

  • Newbie
  • *
  • Posts: 22
    • View Profile
Verifying Claims Made in an Article : SFML Cannot Do 3D?
« on: January 23, 2022, 11:50:14 pm »
Hello and good day!

I've browsed/studied the SFML library for quite some time before jumping in and using it. On one hand, I feel intimately familiar with it and it all makes sense to me and all I have to do is learn the nuances of C++, on the other hand I haven't actually used it enough to know what I'm talking about. I'm a n00b, okay. We all were at one point.

So I'm reading an article from geeksforgeeks.org (link) and in the Pros and Cons, under Cons, they state SFML "cannot do 3D" and states something about OpenGL. This library *can* do 3D, and is ran on OpenGL, am I correct? I'm sure it's not *designed* for (or against) 3D, but there shouldn't be any issues making a 3D project with this library, right?

It's not a big concern of mine (my project is 2D) but I would like to hear about the experiences of designing a 3D game with this library. Tell me about your projects using 3D, tell me about the pros and cons, your challenges, your failures, your triumphs. Do you find that SFML suits your needs well or do you have to go through great lengths to design a project in the 3rd dimension? Does your project use full 3D or just some 3D elements to enhance an otherwise 2D experience? What kind of libraries would you need to further support the rendering of 3D assets?

Also, how is the iOS/Android support? I'm sure there is room for improvement but is it pretty robust thus far? The article was written in 2019 so maybe things have improved dramatically.
« Last Edit: January 23, 2022, 11:59:50 pm by Kain Nobel »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10327
    • View Profile
    • development blog
    • Email
Re: Verifying Claims Made in an Article : SFML Cannot Do 3D?
« Reply #1 on: January 24, 2022, 08:32:13 am »
So I'm reading an article from geeksforgeeks.org (link) and in the Pros and Cons, under Cons, they state SFML "cannot do 3D" and states something about OpenGL. This library *can* do 3D, and is ran on OpenGL, am I correct? I'm sure it's not *designed* for (or against) 3D, but there shouldn't be any issues making a 3D project with this library, right?
SFML doesn't provide any facilities to do anything 3D, but it provides you with a window and an OpenGL context, so if you know your OpenGL, there's nothing stopping you from doing your own 3D magic.

There's only one released game I know to use SFML and has some 3D things. I haven't seen the author on the forum and only found out about this game the other day :D

3D is an order of magnitude more complex and there are lots of ways to achieve the same thing. Writing a 2D game from scratch is often not that bad of an idea, as you can customize the code base in ways that really fit your needs. Doing that for a 3D game/engine it can be a lot more work and then you're only just starting out. You need a mash loader, a texture mapper, some materials shaders, lighting in various forms (point, global, etc.), which in turns requires shadow maps and maybe some more modern lighting techniques, etc. etc.
When you get all of that in high quality for free with e.g. Unreal Engine or Unity, it becomes rather questionable why you'd want to rewrite all of it on your own.

Also, how is the iOS/Android support? I'm sure there is room for improvement but is it pretty robust thus far?
They are pretty solid, but there are still some issues. Due to the OpenGL ES 1 limitation that SFML currently has, we can't use shaders. And there are currently only setup guides on the GitHub wiki, no official tutorials.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://dev.my-gate.net/

fallahn

  • Sr. Member
  • ****
  • Posts: 472
  • Buns.
    • View Profile
    • Trederia
Re: Verifying Claims Made in an Article : SFML Cannot Do 3D?
« Reply #2 on: January 24, 2022, 10:45:01 am »
I've managed to render 3D models using the SFML graphics module with some shader trickery, and by forcing normal/depth data into the colour property of sf::VertexArray - and made a couple of games with that technique:

https://fallahn.itch.io/did
and
https://fallahn.itch.io/purcitop-garden

The gist of it is to replace the model/view/projection matrices with your own in a custom vertex shader, and to store the normal vector in the vertex RGB channel, and vertex z-depth as a normalised value in the vertex alpha channel. It kinda works, although to be honest the amount of OpenGL you need to learn to understand how SFML works under the hood means it's probably not worth the effort (other than the learning exercise) and I should probably just use OpenGL directly for the performance gain  ;D

If you're curious source is available here: https://github.com/fallahn/osgc/tree/master/did and here https://github.com/fallahn/osgc/tree/master/lightmapper for a model format converter I made to go with it (yes, I even went as far as to create a specific model format...)

Kain Nobel

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Verifying Claims Made in an Article : SFML Cannot Do 3D?
« Reply #3 on: February 01, 2022, 01:41:55 pm »
Wow that's pretty cool! Very sleek and professional :D

How long did it take you to develop Sequence Storm? I'm gonna have to go check that out :D

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10327
    • View Profile
    • development blog
    • Email
Re: Verifying Claims Made in an Article : SFML Cannot Do 3D?
« Reply #4 on: February 01, 2022, 01:46:57 pm »
How long did it take you to develop Sequence Storm? I'm gonna have to go check that out :D
I didn't develop it :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://dev.my-gate.net/