Open jgoffeney opened 2 years ago
Something else to consider is the glViewport needs to have the resolution of the target raster. However the model bounds based on the input vertices will likely not have the same mapping.
For my test the source is 2000 x 2000. The model vertices need to be transformed to map to these bounds to generate the same output for the ground plane. However the elevation needs to remain the same.
Updated the argument parser to remove some internally set variables and added geospatial params. Created vertexRasterShaderSource to handle the vertex transformations.
tx = (vx - vertMinX) /(vertMaxX - vertMinX) * winX
The following orthographic projection sets up the correct rendering region.
glOrtho(0, argParams.targetWidth, 0, -argParams.targetHeight, -maxY, -minY);
What currently works:
To Do:
Current command
.\glb2raster.exe -mode framebuffer -targetdims 2000 2000 -geoOrigin -78.0085059999999970 34.0003519999999995 -pixelDims 4.000000000001892938e-06 -4.000000000001892938e-06 -rotate 90 1 0 0 ..\..\..\data\meshgrid_0_0.glb meshgrid.asc
The 3d tile JSON file has the LLA geospatial bounds so we can use that to create the initial ROI and then determine spacing. Think like WCS coverage call. Then ECEF to LLA
The root JSON bounds for the 0/0/0/0/json file. Note it is in the format minX, minY, maxX, maxY, minZ, maxZ with the X and Y in radians.
"boundingVolume":{
"region":[
-0.7853981633974483,
-0.5406359802559503,
0.7853981633974483,
0.785398163381105,
-10170.587093897164,
5874.600580642931
]
}
Degrees:
Current test for framebuffer output with shader files.
.\glb2raster.exe -mode framebuffer -vs ..\..\..\shaders\SimpleVertexShader.txt -fs ..\..\..\shaders\SimpleFramebufferFragmentShader.txt -targetdims 2000 2000 -geoOrigin -78.00850200000 34.00035600000 -pixelDims 4.000000000001892938e-06 -4.000000000001892938e-06 -rotate 90 1 0 0 -outputScale 1.0 0.01 1.0 ..\..\..\data\meshgrid_0_0.glb meshgrid_doub_scale_refactor_shadefile.asc
Windows test with shader files
.\glb2raster.exe -mode window -vs ..\..\..\shaders\SimpleVertexShader.txt -fs ..\..\..\shaders\SimpleWindowFragmentShader.txt -targetdims 2000 2000 -rotate 90 1 0 0 ..\..\..\data\meshgrid_0_0.glb
The JSON file is loaded during argument parsing and at the end updates the values. The mode and the presence JSON content indicates the code path.
The vertex program is the ECEF2LLA conversion while the fragment program just writes the altitude to the red channel.
Converted shaders for GL 3.3. Need to fix ECEF shaders as outputs are currently empty.
Current Save:
Look at cesium-native Cesium3DTilesSelection::GltfContent line 420.
The solution for the cartographic coordinates is to first apply the GLTF node transform and then apply the following:
1 0 0 0 0 0 -1 0 0 1 0 0 0 0 0 1
(https://github.com/CesiumGS/3d-tiles/blob/main/specification/README.md#transforms)[See implementation note).
Still issues with Z coord.
Currently Excel and shader results agree for transforming the GLTF ECEF to correct ECEF. Excel and web ECEF->LLA calculator agree for final result but I need to check why all points are clipped out when using transformed ECEF -> LLA in shader.
The shader appears to be producing the correct lat/lon values and altitude is at least looks relatively correct.
Removed the JSON requirement for tile 3d since parsing the files gets a complicated for some child nodes. Instead added a -cartoBounds parameter as (minX,maxX,minY,maxY,minZ,maxZ).
Working command
.\glb2raster.exe -mode framebuffer -vs ..\..\..\shaders\ECEF2LLAVertexShader.txt -fs ..\..\..\shaders\ECEF2LLAFramebufferFragmentShader.txt -targetdims 2000 2000 -cartoBounds 37.29720442 39.98123466 32.72223247 36.13867295 -402.63580276910218 1426.4234313657508 ..\..\..\data\latest_dsm_data_0_713.3tz_0_5_29_30.glb latest_dsm_index_0_713.3tz_0_5_29_30EUpdateAscTest.asc
Currently able to load the GLTF / GLB and render using a glOrtho based on the model bounds and essentially a passthrough for the shaders using the original POSITION vertex data.
Currently the test GLB file was generated as Geotiff->Unreal->mesh->FBX->Blender->GLB.
Issues:
To Dos: