Vertex source: #version 110 #define MAX_LIGHTS 8 struct fw_MaterialParameters { vec4 emission; vec4 ambient; vec4 diffuse; vec4 specular; float shininess; }; uniform int lightcount; //uniform float lightRadius[MAX_LIGHTS]; uniform int lightType[MAX_LIGHTS];//ANGLE like this struct fw_LightSourceParameters { vec4 ambient; vec4 diffuse; vec4 specular; vec4 position; vec4 halfVector; vec4 spotDirection; float spotExponent; float spotCutoff; float spotCosCutoff; vec3 Attenuations; //float constantAttenuation; //float linearAttenuation; //float quadraticAttenuation; float lightRadius; //int lightType; ANGLE doesnt like int in struct array }; uniform fw_LightSourceParameters fw_LightSource[MAX_LIGHTS] /* gl_MaxLights */ ; uniform mat3 fw_NormalMatrix; attribute vec3 fw_Normal; attribute vec4 fw_Vertex; uniform mat4 fw_ModelViewMatrix; uniform mat4 fw_ProjectionMatrix; uniform fw_MaterialParameters fw_FrontMaterial; uniform fw_MaterialParameters fw_BackMaterial; varying vec4 v_front_colour; varying vec2 hatchPosition; vec3 vertexNorm; vec4 vertexPos; /* use ADSLightModel here the ADS colour is returned from the function. */ vec...void main(void) { gl_Position = fw_ProjectionMatrix * fw_ModelViewMatrix * fw_Vertex; vertexNorm = normalize(fw_NormalMatrix * fw_Normal); vertexPos = fw_ModelViewMatrix * fw_Vertex; v_front_colour = ADSLightModel(vertexNorm,vertexPos,true);hatchPosition = fw_Vertex.xy; } Fragment Source: #version 110 #define MAX_LIGHTS 8 uniform vec4 HatchColour; uniform bool hatched; uniform bool filled; uniform vec2 HatchScale; uniform vec2 HatchPct; uniform int algorithm; varying vec4 v_front_colour; varying vec2 hatchPosition; vec4 fillPropCalc(in vec4 prevColour, vec2 MCposition, int algorithm) { vec4 colour; vec2 position, useBrick; position = MCposition / HatchScale; if (algorithm == 0) { /* bricking */ if (fract(position.y * 0.5) > 0.5) position.x += 0.5; } /* algorithm 1, 2 = no futzing required here */ if (algorithm == 3) { /* positive diagonals */ vec2 curpos = position; position.x -= curpos.y; } if (algorithm == 4) { /* negative diagonals */ vec2 curpos = position; position.x += curpos.y; } if (algorithm == 6) { /* diagonal crosshatch */ vec2 curpos = position; if (fract(position.y) > 0.5) { if (fract(position.x) < 0.5) position.x += curpos.y; else position.x -= curpos.y; } else { if (fract(position.x) > 0.5) position.x += curpos.y; else position.x -= curpos.y; } } position = fract(position); useBrick = step(position, HatchPct); if (filled) { colour = prevColour; } else { colour=vec4(0.,0.,0.,0); } if (hatched) { colour = mix(HatchColour, colour, useBrick.x * useBrick.y); } return colour; } void main() { vec4 finalFrag = vec4(1.,1.,1.,1.); finalFrag = v_front_colour * finalFrag; finalFrag= fillPropCalc(finalFrag, hatchPosition, algorithm); gl_FragColor = finalFrag; } Vertex source: #version 110 #define MAX_LIGHTS 8 struct fw_MaterialParameters { vec4 emission; vec4 ambient; vec4 diffuse; vec4 specular; float shininess; }; uniform int lightcount; //uniform float lightRadius[MAX_LIGHTS]; uniform int lightType[MAX_LIGHTS];//ANGLE like this struct fw_LightSourceParameters { vec4 ambient; vec4 diffuse; vec4 specular; vec4 position; vec4 halfVector; vec4 spotDirection; float spotExponent; float spotCutoff; float spotCosCutoff; vec3 Attenuations; //float constantAttenuation; //float linearAttenuation; //float quadraticAttenuation; float lightRadius; //int lightType; ANGLE doesnt like int in struct array }; uniform fw_LightSourceParameters fw_LightSource[MAX_LIGHTS] /* gl_MaxLights */ ; uniform mat3 fw_NormalMatrix; attribute vec3 fw_Normal; attribute vec4 fw_Vertex; uniform mat4 fw_ModelViewMatrix; uniform mat4 fw_ProjectionMatrix; uniform fw_MaterialParameters fw_FrontMaterial; uniform fw_MaterialParameters fw_BackMaterial; varying vec4 v_front_colour; varying vec2 hatchPosition; vec3 vertexNorm; vec4 vertexPos; /* use ADSLightModel here the ADS colour is returned from the function. */ vec...void main(void) { gl_Position = fw_ProjectionMatrix * fw_ModelViewMatrix * fw_Vertex; vertexNorm = normalize(fw_NormalMatrix * fw_Normal); vertexPos = fw_ModelViewMatrix * fw_Vertex; v_front_colour = ADSLightModel(vertexNorm,vertexPos,true);hatchPosition = fw_Vertex.xy; } Fragment Source: #version 110 #define MAX_LIGHTS 8 uniform vec4 HatchColour; uniform bool hatched; uniform bool filled; uniform vec2 HatchScale; uniform vec2 HatchPct; uniform int algorithm; varying vec4 v_front_colour; varying vec2 hatchPosition; vec4 fillPropCalc(in vec4 prevColour, vec2 MCposition, int algorithm) { vec4 colour; vec2 position, useBrick; position = MCposition / HatchScale; if (algorithm == 0) { /* bricking */ if (fract(position.y * 0.5) > 0.5) position.x += 0.5; } /* algorithm 1, 2 = no futzing required here */ if (algorithm == 3) { /* positive diagonals */ vec2 curpos = position; position.x -= curpos.y; } if (algorithm == 4) { /* negative diagonals */ vec2 curpos = position; position.x += curpos.y; } if (algorithm == 6) { /* diagonal crosshatch */ vec2 curpos = position; if (fract(position.y) > 0.5) { if (fract(position.x) < 0.5) position.x += curpos.y; else position.x -= curpos.y; } else { if (fract(position.x) > 0.5) position.x += curpos.y; else position.x -= curpos.y; } } position = fract(position); useBrick = step(position, HatchPct); if (filled) { colour = prevColour; } else { colour=vec4(0.,0.,0.,0); }if (hatched) { colour = mix(HatchColour, colour, useBrick.x * useBrick.y); } return colour; } void main() { vec4 finalFrag = vec4(1.,1.,1.,1.); finalFrag = v_front_colour * finalFrag; finalFrag= fillPropCalc(finalFrag, hatchPosition, algorithm); gl_FragColor = finalFrag; }