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

Author Topic: Polygon to shader  (Read 6739 times)

0 Members and 1 Guest are viewing this topic.

Ockonal

  • Jr. Member
  • **
  • Posts: 58
    • ICQ Messenger - 449909010
    • View Profile
    • WinCode
Re: Polygon to shader
« Reply #15 on: October 17, 2012, 03:45:18 pm »
Good news:

uniform sampler2D texture;

void main()
{
    /*vec4 color = texture2D(texture, gl_TexCoord[0].xy);
    color.r = 1.0;
    color.a = 0.0;
    gl_FragColor = color;*/


    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

Makes it fully red. So the texture is fine, something is wrong with processing it in shader.
Developing 2d engine&game using: sfml, box2d, librocket, spark2, zoom&zoost, thor

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Polygon to shader
« Reply #16 on: October 17, 2012, 03:46:37 pm »
But wait... what you draw (the texture of the polygon) is what's already drawn behind (the grey grid), right?

So the result is ok: you get a red version of what's behind the polygon. If you want full red, don't use the source texture, just output a constant red color like you do in your last post.
Laurent Gomila - SFML developer

Ockonal

  • Jr. Member
  • **
  • Posts: 58
    • ICQ Messenger - 449909010
    • View Profile
    • WinCode
Re: Polygon to shader
« Reply #17 on: October 17, 2012, 03:49:20 pm »
Making it red is just a test that everything is okay with the texture. As I understand, the texture shold become blue when I write: color.b = 0.9 isn't it? And the texture isn't rendered with more blue color.
---
Oh, it seems that I misunderstand something
« Last Edit: October 17, 2012, 03:51:54 pm by Ockonal »
Developing 2d engine&game using: sfml, box2d, librocket, spark2, zoom&zoost, thor

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Polygon to shader
« Reply #18 on: October 17, 2012, 04:09:43 pm »
color.b = 0.9 just changes the blue component of the pixel to 0.9, but the other components stay the same, i.e. you still get the inital pixel from the source texture; it's just more or less blue now.

So we can consider that you test was successful: it shows that the texture is correctly mapped on the polygon (there's no offset with the background) and that your simple shader works, and can now be improved.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Polygon to shader
« Reply #19 on: October 17, 2012, 04:11:53 pm »
However...
Quote
the texture isn't rendered with more blue color

Is the texture really drawn unchanged? You should see a difference, it should be either more blue or more yellow. Unless 0.9 is the exact value of the blue component of every pixel in the source texture.
Laurent Gomila - SFML developer

Ockonal

  • Jr. Member
  • **
  • Posts: 58
    • ICQ Messenger - 449909010
    • View Profile
    • WinCode
Re: Polygon to shader
« Reply #20 on: October 18, 2012, 09:28:38 am »
You were right, thanks! The theme is closed now.
Developing 2d engine&game using: sfml, box2d, librocket, spark2, zoom&zoost, thor