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

Author Topic: SFML normal map lights shader, attribute input  (Read 2261 times)

0 Members and 1 Guest are viewing this topic.

Kori

  • Newbie
  • *
  • Posts: 21
    • View Profile
SFML normal map lights shader, attribute input
« on: September 16, 2015, 11:23:25 pm »
Hi,
I am actually trying to implement a normal map lights into my project. Unfortunately, needful vert shader require some "attribute" variable. As far as i can see, SFML don't support it. Raw OpenGL can be good solution, but I stuck right after create "glCreateShader(GL_VERTEX_SHADER)" and fill it up with " shader.getNativeHandle()". My idea with drawing the dynamic lights on separate RendeTexture using OGL and these shaders, and next drawing this texture to my window is pretty difficult. Is it possible at all? If is, can anyone help me with this? Or maybe easier will be write my own shader using only uniform? 

this is the part of this shader:
//"in" attributes from our SpriteBatch
attribute vec2 Position;
attribute  vec2 TexCoord;
attribute vec4 Color;

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: SFML normal map lights shader, attribute input
« Reply #1 on: September 17, 2015, 12:19:50 am »
I made something like that before and this should get you started I think.

http://en.sfml-dev.org/forums/index.php?topic=16830.msg122202#msg122202
(Just scroll down to the end)

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: SFML normal map lights shader, attribute input
« Reply #2 on: September 17, 2015, 12:35:46 am »
If you are using normal maps as separate textures you can just use the SFML shader API to provide them to your fragment shader stage, no attributes required. All those attributes that you listed in your code block are those that SFML already takes care of on its own. You don't need to specify them yourself. If you really need to specify them yourself, then you are better off just skipping the SFML graphics module completely and using the window module with raw OpenGL.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Kori

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: SFML normal map lights shader, attribute input
« Reply #3 on: September 17, 2015, 10:49:22 pm »
I use @SpeCter version and works perfect. Now only implement it to drawing on my game Rendertexture and merge with something like ltbl. Anyway, thanks you very much!

 

anything