CC_Texture0 fix (backward incompatible fix).

161 views
Skip to first unread message

Ricardo Quesada

unread,
May 15, 2014, 7:57:23 PM5/15/14
to cocos2d-...@googlegroups.com, cocos3d...@googlegroups.com
Hi,

Since all the built-in uniforms (the ones that start with CC_) were predefined by cocos2d-x (all, expect CC_Texture0), what I did was to predefine CC_Texture0 as well.

If the shader uses it, it will be set automatically.

So, if you are using custom shaders, what you have to do is remove this line from your shader:


uniform sampler CC_Texture0; // <--- REMOVE THIS LINE from your shaders



If you don't remove this line, cocos2d-x will crash since it won't be able to compile the shader.

Xiaoming Zhang

unread,
May 16, 2014, 2:48:42 AM5/16/14
to Ricardo Quesada, cocos2d-...@googlegroups.com, cocos3d...@googlegroups.com
Oh.
It will break compatibility.
Many developers use their own shaders. 
And their is not a good way to say that “you have to remove uniform sampler CC_Texture0;"

Best Regards
Minggo




--
You received this message because you are subscribed to the Google Groups "cocos3d-x-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos3d-x-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ricardo Quesada

unread,
May 16, 2014, 10:33:59 AM5/16/14
to Xiaoming Zhang, cocos2d-...@googlegroups.com, cocos3d...@googlegroups.com
I think saying exactly what you said is the correct way to say it.
But what's your proposal?
Thanks.


--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.

Xiaoming Zhang

unread,
May 16, 2014, 11:31:13 AM5/16/14
to Ricardo Quesada, cocos2d-...@googlegroups.com, cocos3d...@googlegroups.com
So, if you are using custom shaders, what you have to do is remove this line from your shader:


uniform sampler CC_Texture0; // <--- REMOVE THIS LINE from your shaders

I mean if custom shaders include this one, and failed to be compiled. 
Is the error message clear enough that they know they have to delete this line?

Best Regards
Minggo



Ricardo Quesada

unread,
May 16, 2014, 11:48:23 AM5/16/14
to Xiaoming Zhang, cocos2d-...@googlegroups.com, cocos3d...@googlegroups.com
Yes, the error message is something like this:

"
Error compiling shader:
you cannot redefine uniform CC_Texture0
"

The error is generated by the shader compiler, and it will abort the execution of the game.

What we need is to post in the forums/blog (and twitter) how to fix that.

We can also add an script that searches for "uniform sampler2D CC_Texture0;" in shader files, and if the finds it tell the user that they need to remove that file in order to make it work on v3.1


Xiaoming Zhang

unread,
May 26, 2014, 6:15:59 AM5/26/14
to Ricardo Quesada, cocos2d-...@googlegroups.com, cocos3d...@googlegroups.com
I found “CC_Texture0”, “CCTexture1”, “CCTexture2” and “CCTexture3” are all defined.
Not only “CC_Texture0”.

Best Regards
Minggo



Ricardo Quesada

unread,
May 26, 2014, 10:40:20 AM5/26/14
to Xiaoming Zhang, cocos2d-...@googlegroups.com, cocos3d...@googlegroups.com
yes, I added those values. They are not used for the moment. But they will be used in the future.
Reply all
Reply to author
Forward
0 new messages