Wednesday, September 2, 2015

Cocos2d-x: Differences between applying shader to child node and entire scene?


I'm beginning with shader. I wonder what if i apply shader for single node, what'll happen?


The gl_FragCoord = (0.5,0.5) is the bottom left of the screen or the bottom left of the node?


I get some wrong caculations while wanting to draw something in the center of the node (not the screen).


Many shader tutorias with sample code to draw at center using gl_FragCoord.xy / resolution.xy, if it's 0.5, it's center. In this case, it might be wrong because i want to draw in center of the node.


Finally, how's about texture2D i use texture2D instead of texture, are they the same?


I've applied this code on the node and it prints out the whole screen with stretch version (resolution = device resolution)


vec2 xy = gl_FragCoord.xy / resolution.xy;
vec4 texColor = texture2D(CC_Texture0,xy);
gl_FragColor = texColor;



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...