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

Author Topic: Help with Shader and Texture  (Read 1381 times)

0 Members and 1 Guest are viewing this topic.

M3rs

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Help with Shader and Texture
« on: October 30, 2015, 02:33:15 pm »
Hello SFML!
I'm having trouble getting my sf::Shader to work on a sf::RectangleShape that has a texture attached to it via setTexture( &texture).
Is there something I am missing in order to get that to work?

I'm using a simple fragment shader that I got from the forums somewhere here. Here is the shader:
(click to show/hide)
And what happens is this:
(click to show/hide)

The rectangle shape on the left, with no texture, is properly lighted. On the right, with my wall.png as a texture, it still shown bright as day.

I'm pretty new to GLSL and wanted to use SFML because: 1. I really like it and have used it before, 2. OpenGL is a lot more code / scary to me.

Here is how I load the shader, create the rectangles and apply the texture:
(click to show/hide)

Here is a snippet for the drawing:
(click to show/hide)

NB:
- The shadow method is what's creating those faux-hard shadows, again courtesy of the sfml forums (thanks, it's awesome, I have the link on my other computer).
- The "light" parameter for the shader is set earlier based on the mouse position.

Any help / advice would be much appreciated.

Thanks!


 

anything