Hi,
I would like to know why my custom shader is rendered in black color ?
// shader script used to display double segments
// the line with arrows is slightly translated from the center axis
// This is especially used in SegmentLoad Mode
#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
in float v_polylineAngle;
uniform vec4 color;
uniform vec4 dashGapColor;
uniform float dashPattern;
uniform float dashLength;
vec4 color1 = vec4( 1.,0.,0.5,0. );
vec4 color2 = vec4( 0.,1.,0.5,1. );
const float lineMaskLength = 16.0;
mat2 rotate(float rad) {
float c = cos(rad);
float s = sin(rad);
return mat2(
c, s,
-s, c
);
}
///////////////////////// GET MATERIAL /////////////////////////
// our goal is to return the material of the pixel
// We are indeed reasoning for one pixel of the trajectory here
czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;
// Get the relative position within the dash from 0 to 1
float dashPosition = fract(pos.x / (dashLength * czm_pixelRatio));
// Figure out the mask index.
float maskIndex = floor(dashPosition * lineMaskLength);
// Test the bit mask.
float maskTest = floor(dashPattern / pow(2.0, maskIndex));
vec4 fragColor = (mod(maskTest, 2.0) < 1.0) ? color1 : color2;
if (fragColor.a < 0.005) { // matches 0/255 and 1/255
discard;
}
fragColor = czm_gammaCorrect(fragColor);
material.emission = fragColor.rgb;
material.alpha = fragColor.a;
return material;
}