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

Author Topic: Texel size when rendering a sprite with a shader  (Read 1621 times)

0 Members and 1 Guest are viewing this topic.

dydya-stepa

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Texel size when rendering a sprite with a shader
« on: November 30, 2011, 04:00:04 pm »
i'm rendering a sprite into window like this:

window.Draw(sprite, shader)

My window's size is 800*600 but my sprite's size is 1024*1024. I'm rendering it with some offset so only portion is shown. The shader (blur) needs texel size which is 1 / width for horizontal and 1 / height per vertical.

So the question is what the width and height should be equal to?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Texel size when rendering a sprite with a shader
« Reply #1 on: November 30, 2011, 04:10:05 pm »
It must be equal to the sprite's texture width/height.

Code: [Select]
shader.SetParameter("width", sprite.GetTexture()->GetWidth());
shader.SetParameter("height", sprite.GetTexture()->GetHeight());
Laurent Gomila - SFML developer

 

anything