Sometimes the shader I am creating will be given an image file to use as a texture sampler and sometimes it will not.
In the shader when the image file is given I need the line
uniform sampler2D refTexture;
and in the main function a line along the lines of
float x = 0.5 * texture2D(refSampler, uv).rgb.x;
and when no image file is given then
float x = 0.5 * position.x
From looking at the code in the samplers in the materialsLibrary I see there are some conditions on the uniforms such as
#if defined(SPOTLIGHT0) || defined(DIRLIGHT0) varying vec4 vPositionFromLight0; uniform sampler2D shadowSampler0; #else uniform samplerCube shadowSampler0; #endif
1. Is there a condition I can use for
#if .................. uniform sampler2D refTexture; #endif
2. Is there a conditional statement within the main function I can use for
IF texture loaded float x = 0.5 * texture2D(refSampler, uv).rgb.x; ELSE float x = 0.5 * position.x ENDIF