4
\$\begingroup\$

I see many example in shadertoy use texture, but in the cocos2d-x, only texture2d.

Does texture use normalized coordinate and texture2d doesn't?
Because when I use texture2d, it returns wrong result.

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

texture2D is the same as texture, but it's used in the older versions of glsl.

Between glsl 120 and 130 they changed the function to texture and made it accept every kind of samplers, not just a sampler2D.

There's no difference between them, so the problem is probably in your code.

\$\endgroup\$
2
  • \$\begingroup\$ It's weird, because the shader works well on shadertoy (shadertoy only works with texture), but when i apply it to the node, it renders wrong. And i realize that if i change the parameter for texture2d as pixel coordinate - normalized coordinate, it works. You can see the question here: gamedev.stackexchange.com/questions/138333/… \$\endgroup\$
    – TomSawyer
    Mar 9, 2017 at 7:28
  • \$\begingroup\$ @Tom As others pointed out below that question, there's no difference between normal shader code and shader code you use for cocos-2d. It doesn't know about nodes, and if something's wrong, it's a mistake from your side \$\endgroup\$
    – Bálint
    Mar 9, 2017 at 7:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .