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

Author Topic: Passing multiple textures to the shader  (Read 1966 times)

0 Members and 1 Guest are viewing this topic.

Mercurialol

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Passing multiple textures to the shader
« on: January 01, 2014, 01:01:50 pm »
As I was going to ask my question, I saw http://en.sfml-dev.org/forums/index.php?topic=13934.0 on the very top of the forum board, but it didn't actually answer my question.

Enemy get hits by a bullet. I need to apply a debuff. It's basically a color which is masked by a noise texture which then gets masked by the sprite texture. Something like:
 
gl_FragColor= spriteTexture * noiseTexture * color;

To achieve the animation of the debuff, I'd like to animate the noiseTexture rect myself, by moving the rect from... let's say (0.0 , 0.0) , (0.2 , 0.2) to (0.0, 0.8) (0.2, 1.0) - basically just moving the rect slowly down.

Question: I'd need to pass a different rect for the noise texture, and I've done this in the past by simply passing texture coordinates for each vertex separately, in plain OpenGL.

1. Is this achievable in SFML?
2. If not, is there an alternative ?

I was thinking about playing with SFML source a bit (which actually super excites me  ;D ), but I figured I ask you guys before doing any acrobatics.

Btw. I really like SFML and I'm a big supporter. Still waiting for the day it comes on iOS.

Thanks in advance

Mercurial

Mercurialol

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Passing multiple textures to the shader
« Reply #1 on: January 05, 2014, 12:53:10 am »
Alright, I decided to play with the source a bit. Can anyone give me a bit of help on the technical stuff about altering the source and making it work? I've read the resources on cmake, static libs, linking, but I must admit my head is becoming a big mess. I just need guidelines, i.e.:
1. Download source
2. Include... whatever
2. Compile... whatever
3. Link... whatever

Thanks in advance

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Passing multiple textures to the shader
« Reply #2 on: January 05, 2014, 08:01:50 am »
There's a tutorial on how to build SFML. If you just modify the files, the build script should work out of the box.

Personally, I'd rather implement a solution with OpenGL than editing the source...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mercurialol

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Passing multiple textures to the shader
« Reply #3 on: January 06, 2014, 10:49:09 pm »
Well, I'd like to pass different coordinates for different textures. As I can't access m_vertices inside the sf::Sprite, the only alternative I know about is to draw a polygon over my sprite, use the sprite's texture as a mask and finally play with some blend modes.