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

Author Topic: shader scanline or interlace effect.  (Read 4990 times)

0 Members and 1 Guest are viewing this topic.

eventhorizon02

  • Newbie
  • *
  • Posts: 7
    • View Profile
shader scanline or interlace effect.
« on: April 12, 2016, 08:55:18 pm »
Hi,
I'm working on a SFML game and need a nice interlace or scan line effect. That sort of look old CRT monitors had.
It seems super easy to load shaders and apply them to sf::Drawable's.
My problem is that I just started learning the witchcraft of GLSL and have a hard time achieving anything near the desired effect.
If you have some GLSL code that I can use for that purpose I will greatly appreciate it.

cheers.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11027
    • View Profile
    • development blog
    • Email
AW: shader scanline or interlace effect.
« Reply #1 on: April 13, 2016, 08:11:16 am »
I'm pretty sure you could find one by googling a bit. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

eventhorizon02

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: shader scanline or interlace effect.
« Reply #2 on: April 13, 2016, 08:40:31 am »
Thanks for the awesome advice! I have never thought about  the option of using the ultimate all knowing search engine. Maybe I need to improve my googling skills but all I found was code that I never managed to integrate into SFML.  It seems like there is plenty out there, the sort of sudo GLSL code that works with LOVE, unity or whatever.
My understanding of GLSL is still minimal and I'm not able to migrate those code snippets to works with my C++ SFML project. That is the reason I came to this forum to ask if anybody has or knows about something I can use.

fallahn

  • Hero Member
  • *****
  • Posts: 505
  • Buns.
    • View Profile
    • Trederia
Re: shader scanline or interlace effect.
« Reply #3 on: April 13, 2016, 11:59:21 pm »
Few people are going to be willing to write code for you, although if you're lucky some might Google up a few resources ;) You could try this effect in at least two ways: use gl_FragCoord to skip every other row of your texture giving you black lines across the image, or more subtly using a combination of sin and cos to offset your texture lookup by some amount. Experimenting is half the fun!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: shader scanline or interlace effect.
« Reply #4 on: April 14, 2016, 12:09:09 am »
If you are more precise about your problem at integrating GLSL to SFML, you will get more helpful answers. Also, it's not true that one can't find examples -- a lot of SFML projects use shaders, and some developers even write a blog/article about it. This in addition to the plenty of official SFML learning resources.

Of course you don't have to look for somebody that has had exactly the same problem (implementing a scanline shader in SFML). But you can search for scanline GLSL implementations and read tutorial + doc + example code + 3rd party sources about SFML shaders, and if there are still questions regarding specific parts of this task, ask them here.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: shader scanline or interlace effect.
« Reply #5 on: April 14, 2016, 02:55:17 am »
This tutorial help me a lot with shaders and GLSL.
I would like a spanish/latin community...
Problems building for Android? Look here

eventhorizon02

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: shader scanline or interlace effect.
« Reply #6 on: April 14, 2016, 09:46:07 am »
Thanks for all the replies. I finally managed to get shaders from repositories implemented. My main issue was passing data such as time, mouse position and resolution over to the shader. After further investigation I figured out about the shader.setParameter way to communicate with it.
Again being completely new to GLSL I was not aware of uniform variable etc.
I guess now it's time to crank out the old linear algebra college books to some nice effects going on.
Cheers.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: shader scanline or interlace effect.
« Reply #7 on: April 14, 2016, 10:31:45 pm »
I don't know how realistic you want this scanline effect but for a simple one, that alternates light (unaltered texture) and dark (darkened texture) blocks of customisable size, you can use this one that I made. thickness and spacing determine the size (in pixels) of the light and dark blocks, and amount is how dark the dark blocks are. (don't forget to set the texture!)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything