Shader Chunk to access uv1?

I have a custom shader that uses a couple of extra maps, but I can’t find out how to use uv1 for some texture lookups (the main material is using uv0). Do I need to add a chunk? I tried switching some of the built in maps to use uv1 but although I have seen the $UV variable change what it gets converted to, I can’t make it work.

Also - is there a way to see the generated shader without triggering an error?



Hi @brucewheaton,

Take a look at this for adding the UV1 coords in the shader:

To see the shader compiled for a material, you can find it here:


Wow. My google kung fu was having a bad day apparently. I’ll try that, thanks.

1 Like

I’m having mixed results with that, but not enough to give up… Sometimes uv1 doesn’t get made, and it seems that touching the lightmap is switching lighting to the lightmapper, which I may not want.

But I do think I’m trying to use the wrong chunk…
I’m replacing diffuseTexPS and that is giving me control of UV sampling of the diffuse map, which is great, but I want to access the shaded (lit or shadowed) color and the names are tough. Any clue on which chunk @Leonidas?

My current goal is to use a diffusecolor and then apply shading as if by pencil on top, so I need to know what color the fragment is going to be after lighting etc. Maybe make a tonemapper?

So, studying your generated this.material._shader.definition.fshader;, you can find the order at which your specific material is being shaded. The shader main method will look something like this:

void main(void) {
	dDiffuseLight = vec3(0);
	dSpecularLight = vec3(0);
	dReflection = vec4(0);
	dSpecularity = vec3(0);

	ccSpecularLight = vec3(0);
	ccReflection = vec4(0);
	ccSpecularity = vec3(0);
   dVertexNormalW = vNormalW;
   dAlpha = 1.0;
   dLightDirNormW = light0_direction;
   dAtten = 1.0;
	   dAtten *= getLightDiffuse();
	   dAtten *= getShadowVSM16VS(light0_shadowMap, light0_shadowParams, 5.54);
	   dDiffuseLight += dAtten * light0_color;
	   dAtten *= getLightSpecular();
	   dSpecularLight += dAtten * light0_color;

	gl_FragColor.rgb = combineColorCC();
	gl_FragColor.rgb = combineColor();

	gl_FragColor.rgb += getEmission();
	gl_FragColor.rgb = addFog(gl_FragColor.rgb);

	#ifndef HDR
	gl_FragColor.rgb = toneMap(gl_FragColor.rgb);
	gl_FragColor.rgb = gammaCorrectOutput(gl_FragColor.rgb);
gl_FragColor.a = 1.0;


From there you can find the right shader chunk to override. Usually I search with the name of the method the Playcanvas engine repo to quickly find the right shader file, to get the name of the shader chunk.

1 Like