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

Author Topic: Shaders, vertex shaders?  (Read 8481 times)

0 Members and 1 Guest are viewing this topic.

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Shaders, vertex shaders?
« on: April 04, 2011, 08:46:40 pm »
Hi!

Any possibility to expand the shader class some more? Why doesn't SFML support vertex shaders? Is there ever going to be support for vertex shader?

Seems like all new games(even 2d indie games) uses some advanced "shading"..

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Shaders, vertex shaders?
« Reply #1 on: April 04, 2011, 09:08:57 pm »
You can still use vertex shaders the old-fashioned way if it's a show-stopper for you. :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shaders, vertex shaders?
« Reply #2 on: April 04, 2011, 09:49:03 pm »
Vertex shaders are not very interesting for 2D rendering. The only thing that you can do is to tesselate your geometry and apply some distorsion to it.

What do you want to do with vertex shaders in SFML?
Laurent Gomila - SFML developer

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Shaders, vertex shaders?
« Reply #3 on: April 05, 2011, 02:35:05 am »
Well, there is a bunch of functions that the fragment shader don't have, and vice versa.

And sometimes when building more complicated shaders the vertex shader needs to pass some info over to the fragment shader..

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shaders, vertex shaders?
« Reply #4 on: April 05, 2011, 07:59:26 am »
Nothing more precise? Is this a "just because it sounds cool" feature request? ;)

More seriously, I'm not against vertex shaders. I just need to know whether or not they are relevant in the context of SFML, which is still not clear to me.
Laurent Gomila - SFML developer

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Shaders, vertex shaders?
« Reply #5 on: April 05, 2011, 11:32:49 am »
You could use Vertex Shaders in 2D-games to "wobble" sprites or tilt them, for instance. Implement something similar to Mode-7 (SNES) etc.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shaders, vertex shaders?
« Reply #6 on: April 05, 2011, 11:43:19 am »
For anything that can be defined as a linear transformation (in 4D space), using a matrix will be much more efficient than a vertex shader.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Shaders, vertex shaders?
« Reply #7 on: April 06, 2011, 12:18:09 am »
There are also other choices than just Matrixes to do similar stuff. I think Quaternions could be used for interpolations ( never used it myself, just pieces I've picked up )
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shaders, vertex shaders?
« Reply #8 on: April 06, 2011, 07:56:17 am »
Quote
There are also other choices than just Matrixes to do similar stuff. I think Quaternions could be used for interpolations ( never used it myself, just pieces I've picked up )

This is a different topic; here we are talking about transformations that can be applied in real time to the 2D geometry. On the CPU side we can of course do everything that we want ;)
Since OpenGL doesn't know anything about quaternions, if you want to use them to transform your points on the GPU you'll have to convert them to matrices anyway.
Laurent Gomila - SFML developer

Frizi

  • Newbie
  • *
  • Posts: 4
    • View Profile
Shaders, vertex shaders?
« Reply #9 on: May 19, 2011, 10:36:39 pm »
I'm just trying to code a skeletal animations for 2d sprites. First thought: vertex shaders. Second: how to do that in sfml?
This library really lacks of this functionality. If can create pixel-based effect, then why i cannot do the same with my geometry? Now i must do it by myself dirty way coding my own shader wrapper (or do it on CPU). I can do that, but wait, SFML should be Simple ;)

Cheers

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shaders, vertex shaders?
« Reply #10 on: May 19, 2011, 10:38:53 pm »
Don't worry, vertex shaders will be implemented in SFML 2 in a few weeks -- as soon as the new graphics API (more specifically the "custom geometry" thing) is available.
Laurent Gomila - SFML developer

heishe

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Shaders, vertex shaders?
« Reply #11 on: May 31, 2011, 07:05:17 pm »
Quote from: "Laurent"
For anything that can be defined as a linear transformation (in 4D space), using a matrix will be much more efficient than a vertex shader.


Are you sure about that? I'm sure there's a reason that basically any graphics engine using OpenGL 3.0 and DirectX10 and above does all of their transformations using vertex shaders.

As far as I know, even a very very good CPU doesn't even scratch the surface of what a GPU can do, due to the high amount of shading units on a good graphics card and therefor very good parallelization.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shaders, vertex shaders?
« Reply #12 on: May 31, 2011, 07:12:09 pm »
I'm sure about that because vertices are always transformed, whether it is by your specific matrix or by the identity (if you don't use one). And it's done on the GPU, not on the CPU.

What you're referring to is a different thing, new 3D APIs tend to drop the fixed-pipeline support and focus on shaders to do everything.
Laurent Gomila - SFML developer

Tronic

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://performous.org/
Shaders, vertex shaders?
« Reply #13 on: July 07, 2011, 12:07:32 am »
Vertex shaders are seldom needed for moving the vertices (besides the matrix multiplication) but rather they are used for preparing input data for fragment shaders to use. Not so sure how useful this would be for 2d sprites.

You cannot use vertex shaders to create any new geometry (for tesselation). Geometry shaders (OpenGL 3.3) can create new objects (paint your sprite multiple times on one pass, perform stereo3d/multiangle rendering from one render pass to multiple buffers, etc). Tesselation shaders (OpenGL 4.0) are designed for subdividing triangles (i.e. they can be used to wave/morph a sprite) but a bleeding edge GPU is required. Open-source graphics drivers only support OpenGL 2.1 (3.x is in development).

 

anything