I’m trying to reduce the size of one of my PFX files that’s getting a little too large to manage, so I thought I’d put the shader code in separate text files and include them.
I’ve checked the PFX specification and it seems you include them like this:
Here’s the full listing of the PFX if it helps
DESCRIPTION Moon shaders
// GLOBALS UNIFORMS
UNIFORM WorldViewIT WORLDVIEWIT
UNIFORM WVPMatrix WORLDVIEWPROJECTION
UNIFORM LightDirection LIGHTDIREYE
UNIFORM sMoon TEXTURE0
ATTRIBUTE inVertex POSITION
ATTRIBUTE inNormal NORMAL
ATTRIBUTE inTexCoord UV
TEXTURE 0 moon
Then in the plain text files I have this for the Vertex Shader:
attribute highp vec4 inVertex;
attribute mediump vec3 inNormal;
attribute mediump vec2 inTexCoord;
uniform highp mat4 WVPMatrix;
uniform mediump mat3 WorldViewIT;
uniform mediump vec3 LightDirection;
varying mediump vec2 TexCoord;
gl_Position = WVPMatrix * inVertex;
mediump vec3 transNormal = normalize(WorldViewIT * inNormal);
TexCoord = inTexCoord;
And for the Fragment Shader:
uniform sampler2D sMoon;
varying mediump vec2 TexCoord;
gl_FragColor.rgb = texture2D(sMoon, TexCoord).rgb;
gl_FragColor.a = 1.0;
Unfortunately I get an error in PVRShaderEditor saying:
Error while parsing PFX: Error loading file ‘moon.vsh’ in [VERTEXSHADER] on line 18
The PFX and the shader files are in the same directory, so I can’t see what the problem is.
Am I missing something?
You’ve found a legitimate bug in PVRShaderEditor. The current working directory is not been correctly set up before the PFX is parsed, hence the problem. A nasty work-around would be to place the shader files with the PVRShaderEditor executable, but obviously this is an awful solution.
I’ve filed bug report BRN45433, and as this is a feature-breaking bug it should be fixed fairly quickly.
Thanks for the fast response. I’ll hold off on refactoring my PFX files in this way until the fix.
You’ll be pleased to know that the fix made it into our 3.2 release, which went public yesterday.
Hopefully this should fix your problem.
That’s great. I’ll check it out on monday
I’ve installed the latest SDK and Tools and the PVRShaderEditor is now happy with external shader files, and compiles the PFX without any issues
However, having the shader code in external files causes a material using this PFX to fail in PVRShaman
Has anyone been able to replicate my problem with PVRShaman I mentioned above?
Apologies - I completely missed this thread! I’ve reproduced the problem you’ve described and I’m investigating it now.
Hi again Andre.
This was a simple bug and has now been fixed. It will be released publicly in the next SDK or subsequent updates of PVRShaman however if this is a blocking issue for you, please send an email to firstname.lastname@example.org and we can provide you with a fixed version.
Thanks for your response. I’m working on a different part of the system at present so it is not blocking my work at present. When is the next PVRShaman/PVRSDK release scheduled?
SDK 3.3 is due around late February 2014 but we can update individual utilities before this date if we find a major issue.
I’m back working within PVRShaman now, and having the issue I mentioned in this thread above.
Do you have a fixed version of PVRShaman you could give me so I can edit PFX’s which reference external shader sources?