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

Author Topic: Vertex Shader  (Read 8498 times)

0 Members and 1 Guest are viewing this topic.

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Vertex Shader
« on: August 30, 2010, 06:56:49 pm »
Hi Laurent
Why don't you allow to set the VertexShaderSrc? This is quite useful even for normal sprites in a deferred rendering approach. And as far as i can see the changes are minimal (adding a second parameter to LoadFromFile).
Am i missing something?
I did add a member char* vertexShaderSrc to the sf::Shader that is used instead of vertexSrc if it is non-null...
greetz TGM

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vertex Shader
« Reply #1 on: August 30, 2010, 07:04:54 pm »
Hi

I already answered to this feature request, you'll find my answer(s) on this forum ;)
Laurent Gomila - SFML developer

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Vertex Shader
« Reply #2 on: August 30, 2010, 09:29:36 pm »
shit sry  :oops:
*edit*
I think my point is still valid:
Vertexshader can (and are) used to transform texture coordinates.





over 500 lights fluidly with full normal mapping -> only possible with vertex shader. (screenshot didn't vsync.. but hey i think you get the idea)
*edit2*
sry for that oversize images

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vertex Shader
« Reply #3 on: August 30, 2010, 10:53:04 pm »
Last time I implemented lighting with a vertex shader was a long time ago, can you explain how exactly you implement with SFML and a vertex shader?
Laurent Gomila - SFML developer

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Vertex Shader
« Reply #4 on: August 30, 2010, 11:08:38 pm »
Actually the lighting is done in a pixelshader...
The vertexshader is only needed to calculate texcoords.
I render 1 pass colors only into a target,
I render 1 pass normals only (world coords) into a target.
Then I use small sprites for every light, using 3 textures:
the 2 rendertargets and a mask.
And this is where the Vertexshader is needed: this sprite has a second set of texcoords containing its world coordinates. This coordinates are used to make a lookup in the color&normal buffer. Then we I can calculate the light influence. Of this light in the world as texture of my sprite. The sprite is finally blended additively. and dadada.. very little overhead for pixel not being reached by the light. Its called "Deferred Lighting"
(sry its late..)
greetz

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vertex Shader
« Reply #5 on: August 30, 2010, 11:27:40 pm »
Ok I see. So it would be useful to people who want to implement deferred lighting with SFML... which seems too specific to me.

From the point of view of a regular user, this class would be useless, nobody would be able to get something interesting from it.

SFML doesn't aim at providing a complete OpenGL wrapper, but rather a simple and consistent API for 2D graphics. For this kind of advanced/fancy stuff, you'd better use OpenGL directly.

I hope that you understand my point of view ;)
Laurent Gomila - SFML developer

mooflu

  • Newbie
  • *
  • Posts: 1
    • View Profile
Vertex Shader
« Reply #6 on: February 21, 2011, 02:45:17 am »
Sorry to resurrect an old thread. I've also found setting a custom vertex shader useful.

I realize you want to keep your 2D api simple, but as a compromise, maybe you could add a member variable for the default vertex shader (which you have to setup anyway) and make the shader strings and CompileProgram protected. That way, those of us needing it can derive from sf::Shader.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Vertex Shader
« Reply #7 on: February 21, 2011, 07:37:45 am »
I'll think about it, yes.
Laurent Gomila - SFML developer

 

anything