Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Draco compression to mbgrd2gltf #1426

Open
MBARIMike opened this issue Jan 20, 2024 · 7 comments
Open

Add Draco compression to mbgrd2gltf #1426

MBARIMike opened this issue Jan 20, 2024 · 7 comments

Comments

@MBARIMike
Copy link
Contributor

Following up on #1257 it would be great to have the default output of mbgrd2gltf be a compressed mesh. The open source Draco library (https://github.com/google/draco) seems appropriate for providing this new feature.

An experiment with using draco_transcode showed a 60x decrease in file size for the Monterey25 terrain:

➜ draco_transcoder -i Monterey25_e10_lat_rev.glb -o Monterey25_e10_lat_rev_drc.glb
Transcode	Monterey25_e10_lat_rev.glb	7645
➜ ls -lh Monterey25_e10_lat_rev*
-rw-r--r--@ 1 mccann  513   237M Jan 20 12:50 Monterey25_e10_lat_rev.glb
-rw-r--r--@ 1 mccann  513   3.8M Jan 20 12:51 Monterey25_e10_lat_rev_drc.glb

We can convert to Draco compressed gltf following execution of mbgrd2gltf using draco_transcoder but it would be much nicer to have mbgrd2gltf write Draco compressed gltf to begin with as the file size reduction is significant.

@dwcaress
Copy link
Owner

dwcaress commented Jan 20, 2024 via email

@MBARIMike
Copy link
Contributor Author

Dave,

Thanks! I'm expecting to have a capstone team work on this Issue. The idea is to have more manageable smaller files so that we can use the output for 3D terrain displays in the Seafloor Mapping Database and STOQS web apps using x3dom.

-Mike

@dwcaress
Copy link
Owner

dwcaress commented Jan 20, 2024 via email

@varadpoddar
Copy link

Good Evening,
I am a CSUMB student and came across this issue through the capstone projects presentation. I was combing over the issue along with the related files. I was wondering if the goal is to simply transcode the resultant gltf using draco/tools/draco_transcoder.cc or to add draco encoding on the mesh data before generating the gltf file ?

@MBARIMike
Copy link
Contributor Author

Hello @varadpoddar,

It's the latter: add draco encoding on the mesh data before generating the gltf file. I look forward to meeting with your fellow team members to discuss the details of this Issue. We can come back here as needed with specific technical comments.

-Mike

@varadpoddar
Copy link

varadpoddar commented Apr 19, 2024

Good Evening @MBARIMike,

While testing the current dev build for draco compression functionality in mbgrd2gltf, I ran into the following error with 2 specific .grd files.

Screenshot 2024-04-18 at 4 33 59 PM

Have you encountered the issue on MacOS before? The Monterey25 and Globe_1M .grd files seem unaffected. Are there any prep steps that can be performed as I want to try to establish compression using samples from the MGDS Map View.
The datasets from MGDS seem to result in the same error.

Thank You.
varadpoddar / MB-System

@MBARIMike
Copy link
Contributor Author

Hi @varadpoddar,

See the gist referred to in #1456 for suggestions on dealing with different forms of metadata in .grd files.

With respect to using grids from the MGDS site (a nice thing to be able to do!) we need to first get the grids in geographic (longitude/latitude) coordinates.

From my reading of the GMT documentation this command should "unproject" the UTM grids from the MGDS Map View into geographic coordinates that mbgrd2gtlf can operate on:

gmt6 grdproject Topo1m_CCEShallow_20151104_UTM.grd -Ju10/1:1 -I -C -GTopo1m_CCEShallow_20151104.grd

However, the z array in the resulting file contains no valid data:

➜  MontereyCanyon_CCE ncdump -h Topo1m_CCEShallow_20151104.grd
netcdf Topo1m_CCEShallow_20151104 {
dimensions:
	lon = 8414 ;
	lat = 2703 ;
	grid_mapping = 12 ;
variables:
	double lon(lon) ;
		lon:long_name = "longitude" ;
		lon:units = "degrees_east" ;
		lon:standard_name = "longitude" ;
		lon:axis = "X" ;
		lon:actual_range = 238.08891789464, 238.183560559565 ;
	double lat(lat) ;
		lat:long_name = "latitude" ;
		lat:units = "degrees_north" ;
		lat:standard_name = "latitude" ;
		lat:axis = "Y" ;
		lat:actual_range = 36.78284265761, 36.808096455424 ;
	float z(lat, lon) ;
		z:grid_mapping = "grid_mapping" ;
		z:long_name = "Topography (m)" ;
		z:_FillValue = NaNf ;
		z:actual_range = NaN, NaN ;
	char grid_mapping(grid_mapping) ;
		grid_mapping:spatial_ref = "GEOGCS[\"unknown\",\n    DATUM[\"Unknown based on WGS 84 ellipsoid\",\n        SPHEROID[\"WGS 84\",6378137,298.257223563,\n            AUTHORITY[\"EPSG\",\"7030\"]]],\n    PRIMEM[\"Greenwich\",0,\n        AUTHORITY[\"EPSG\",\"8901\"]],\n    UNIT[\"degree\",0.0174532925199433,\n        AUTHORITY[\"EPSG\",\"9122\"]],\n    AXIS[\"Longitude\",EAST],\n    AXIS[\"Latitude\",NORTH]]" ;
		grid_mapping:crs_wkt = "GEOGCS[\"unknown\",\n    DATUM[\"Unknown based on WGS 84 ellipsoid\",\n        SPHEROID[\"WGS 84\",6378137,298.257223563,\n            AUTHORITY[\"EPSG\",\"7030\"]]],\n    PRIMEM[\"Greenwich\",0,\n        AUTHORITY[\"EPSG\",\"8901\"]],\n    UNIT[\"degree\",0.0174532925199433,\n        AUTHORITY[\"EPSG\",\"9122\"]],\n    AXIS[\"Longitude\",EAST],\n    AXIS[\"Latitude\",NORTH]]" ;

// global attributes:
		:Conventions = "CF-1.7" ;
		:title = "Produced by grdproject" ;
		:history = "gmt grdproject Topo1m_CCEShallow_20151104_UTM.grd -Ju10/1:1 -I -C -GTopo1m_CCEShallow_20151104.grd" ;
		:description = "\n\tProjection: UTM10N\n\tGrid created by mbgrid\n\tMB-system Version 5.5.2327\n\tRun by <eve> on <theo.wifi.mbari.org> at <Tue Mar 20 15:10:35 2018>" ;
		:GMT_version = "6.5.0" ;
}

Maybe I'm missing some option in the gmt6 grdproject command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants