1
\$\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\$
3
\$\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.

|improve this answer|||||
\$\endgroup\$
  • \$\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 '17 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 '17 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.