Hello @billhollings ;
Thanks for the information, I have been reading about GLSL shaders and ".pfx" files and I'm still a little confused about the implementation.
".pfx" files are simple to understand, they are formed by a few basic blocks of code:
HEADER: File information
TEXTURES: Specify if requires textures
EFFECT: Effect name and what use
VERTEXSHADER: Its post-processing using: "ClipSpace_vsh" & "CC3ClipSpaceTexturable.vsh"
FRAGMENTSHADER: Here it’s where you apply your GLSL code.
I made a simple Cocos3d demo to apply and test GLSL shaders with post-processing. I'm using the grayScale effect from the CC3DemoMashUp and its working (See image below).
My confusion is when I try to implement finished GLSL codes from other sites into my ".pfx" file.
For example, this code for pixelation from "here" its not working on my ".pfx" file...
I´m ignoring this part, I suppose that "Vertex Shader" set-up on the "PostProc.pfx" file its the indicated for the post-processing effect using the "ClipSpace_vsh"...
gl_Position = ftransform();
gl_TexCoord = gl_MultiTexCoord0;
Then we have a second block of code named "Pixel Shader", I assume that its the equivalent to the "FRAGMENTSHADER" in our ".pfx" file.
uniform sampler2D sceneTex; // 0
uniform float vx_offset;
uniform float rt_w; // GeeXLab built-in
uniform float rt_h; // GeeXLab built-in
uniform float pixel_w; // 15.0
uniform float pixel_h; // 10.0
vec2 uv = gl_TexCoord.xy;
vec3 tc = vec3(1.0, 0.0, 0.0);
if (uv.x < (vx_offset-0.005))
float dx = pixel_w*(1./rt_w);
float dy = pixel_h*(1./rt_h);
vec2 coord = vec2(dx*floor(uv.x/dx), dy*floor(uv.y/dy));
tc = texture2D(sceneTex, coord).rgb;
else if (uv.x>=(vx_offset+0.005))
tc = texture2D(sceneTex, uv).rgb;
gl_FragColor = vec4(tc, 1.0);
I copied the code above into my [FRAGMENTSHADER] section (Without the "[Pixel_Shader]"), inside the [GLSL_CODE] on my “.pfx” file. But I get errors related to syntax. Here is the complete code used for reference.
I chose this post-processing effect because it looks easy...
What do I need to do to implement the examples from the provided web into my “.pfx” file? (I thought that copy paste was enough because it’s the same language…).
Is there an API section for Cocos3D & "PFX"/GLSL effects implementation? I ask this because on "PostProc.pfx" file I see Cocos3d items "v_texCoord0", "u_cc3CameraFrustumDepth" & "s_cc3Texture".
What do I need to learn to master this implementation?...
Thanks again for your time Bill!