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

Author Topic: A quick question about shaders...  (Read 2186 times)

0 Members and 1 Guest are viewing this topic.

Solluxx

  • Newbie
  • *
  • Posts: 19
    • View Profile
A quick question about shaders...
« on: January 27, 2013, 06:48:45 am »
Hola, was just a little confused about shaders and was hoping that maybe I could get some things cleared up. So right now I have a simple 2d game where I draw everything to a RenderTexture, display it and then display the RenderWindow with a shader parameter. (Example sorta below)

Not for compiling just for visualization

window.create(sf::VideoMode(320, 240, 32), "Example");   //RenderWindow
screen.create(window.getSize().x,window.getSize().y);      //RenderTexture
effects.setParameter("color", .1f,.9f,.5f);                             //change the effect of the shader?
shaderstate.shader = &effects;                                           //Applying shader to a RenderState

//Loop//
    window.clear(gray);
    screen.clear(gray);
    //draw some stuff to screen rendertexture
    screen.display();
    window.draw(sf::Sprite(screen.getTexture()),shaderstate);
    window.display();
//End Loop//

 

So everything runs fine but it seem the game isn't changed at all. In the many examples I have seen people load a .frag shader and set parameters to that. I'm wondering if there is a simple way to create a "clean slate" shader and just use the params you set to change the window? perhaps I'm missing the point of shaders or something but all I want to do is be able to apply things like a tint, some exposure, etc. Any help you can give is much appreciated.
-Sam

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: A quick question about shaders...
« Reply #1 on: January 27, 2013, 06:21:42 pm »
You probably should take a look at the official documentation and example for shaders.

Then if you still have problems, you need to provide a complete and minimal example and explain to us, what you're expecting from it to happen and what actually happens.
With the current information we can't really do much. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Solluxx

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: A quick question about shaders...
« Reply #2 on: January 27, 2013, 11:05:47 pm »
My inability to scroll down in documentation is shameful lol. O.k. I think I can give a little better explanation of what I'm looking for. I need a postfx shader to apply to a Rendertexture that I have drawn everything to. I want it to be able to do color tinting, exposure, and glow kinds of effects. Would I have to write my own shader for this or is there an all-in-one shader floating around somewhere that I can just edit the params of?

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: A quick question about shaders...
« Reply #3 on: January 27, 2013, 11:35:40 pm »
SFML doesn't provide any shader (but the ones in the shader example), just ways to use them.
You'll have to write your own or find one on the internet. (since 2.0 shaders are in GLSL, so you can probably find what you want)

Solluxx

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: A quick question about shaders...
« Reply #4 on: January 28, 2013, 05:29:02 am »
Hm... alright to the googlez I go. hopefully I can find what im looking for somewhere, or learn glsl from scratch lol. ty