Hi,
I guess this goes in the beginner section rather than the advanced section.
I’m developing a 3D viewer of OpenStreetMap http://www.openstreetmap.org data which also shows terrain generated from NASA SRTM height data. The current version (very much pre-pre-alpha grade…) is available at http://www.free-map.org.uk/3d/.
I’d like to turn lighting on for the terrain, but off for the OpenStreetMap data (roads, footpaths, and other vector map data) because I don’t need lighting effects on the OSM data. I attempted to do this by declaring a boolean uniform variable and then using code in the vertex shader such as:
if (uDoCalculation==true)
{
// calculate lighting
}
else
{
vLightWeighting = vec3(1.0, 1.0, 1.0);
}
I render the SRTM data first, then the OpenStreetMap data. My plan was to set uDoCalculation to true when rendering the former, and to false when I render the latter. However this does not work (I get a blank screen), and even if I switch off the OpenStreetMap layer and just render the terrain (i.e uDoCalculation is always true) I just get a blank screen, with neither terrain nor OpenStreetMap data rendering.
However, if I change the if statement in the above code to if(true) it works, and if I change it to if(uDoCalculation==false) I get (as expected) a scene with no lighting effects.
I have checked that the vertex variable location for uDoCalculation is >=0 (rather than -1) and it is, so I’m really stumped as to why this is not working. It’s almost as if the shader variables are being corrupted in some way. Does anyone have any suggestions?
Thanks,
Nick