Gltf import from Nomad Sculpt
5461 5 1- Benjamin Lemoine
- Member
- 143 posts
- Joined: Oct. 2015
- Offline
Hello ,
I'm testing this new app Called Nomad Sculpt from Stephane Ginier , the guy behind sculptGL
And it can export in Gltf (.glb) format
what is quite nice is that in the app you can paint color of course but also roughness and metallic
stored on the geometry
their is also an option to export those data in the gltf
and in houdini they are their as some integer from 0 to 255 , so just dividing those by 255 give some
value i can then use in Redshift or in Mantra
But what is weird is that the color import well in .obj
but come up in a weird form in .glb (stored as 3int and Value goes up to 16777215)
After some email with the develloper he suggested me to divide by 16777215
but this is what it gave (on the right the colos from .obj model)
the develloper suggested that maybe those are packed …
and wrote :
packed = 11387939
red = packed & 0x0000FF
green = (packed & 0x00FF00) / (1<<8)
blue = (packed & 0xFF0000) / (1<<16)
but i'm not sure i could do this in vex…
I wonder if someone can orient me ? and also if it's some gltf limitations…
And by the way the colors display well in Windows 3D viewer as in https://gltf-viewer.donmccurdy.com/ [gltf-viewer.donmccurdy.com]
Thanks
Benjamin
I'm testing this new app Called Nomad Sculpt from Stephane Ginier , the guy behind sculptGL
And it can export in Gltf (.glb) format
what is quite nice is that in the app you can paint color of course but also roughness and metallic
stored on the geometry
their is also an option to export those data in the gltf
and in houdini they are their as some integer from 0 to 255 , so just dividing those by 255 give some
value i can then use in Redshift or in Mantra
But what is weird is that the color import well in .obj
but come up in a weird form in .glb (stored as 3int and Value goes up to 16777215)
After some email with the develloper he suggested me to divide by 16777215
but this is what it gave (on the right the colos from .obj model)
the develloper suggested that maybe those are packed …
and wrote :
packed = 11387939
red = packed & 0x0000FF
green = (packed & 0x00FF00) / (1<<8)
blue = (packed & 0xFF0000) / (1<<16)
but i'm not sure i could do this in vex…
I wonder if someone can orient me ? and also if it's some gltf limitations…
And by the way the colors display well in Windows 3D viewer as in https://gltf-viewer.donmccurdy.com/ [gltf-viewer.donmccurdy.com]
Thanks
Benjamin
Edited by Benjamin Lemoine - Aug. 9, 2020 11:25:56
- jsmack
- Member
- 8041 posts
- Joined: Sept. 2011
- Offline
Benjamin Lemoine
the develloper suggested that maybe those are packed …
and wrote :
packed = 11387939
red = packed & 0x0000FF
green = (packed & 0x00FF00) / (1<<8)
blue = (packed & 0xFF0000) / (1<<16)
but i'm not sure i could do this in vex…
Is that supposed to create a teal color?
I translated it to vex as such:
int packed = 11387939; int red = packed & 255; int green = (packed & 65280)/shl(1, 8); int blue = (packed & 16711680)/shl(1,16); @Cd = set(red,green,blue)/255.0;
It's redundant to divide by the shifted bits, when you can just shift right I think.
This produces the same output:
int packed = 11387939; int red = packed & 255; int red = packed & 255; int green = shrz(packed & 65280, 8); int blue = shrz(packed & 16711680,16); @Cd = set(red,green,blue)/255.0;
As a bonus you can also decode alpha, but it's tricky since VEX doesn't have uint:
int packed = i@packedcolor; int red = packed & 255; int green = shrz(packed & 65280, 8); int blue = shrz(packed & 16711680,16); int alpha = shrz(packed & -16777216,24); alpha = select(alpha<0, alpha+256, alpha); @Cd = set(red,green,blue)/255.0; @mask = alpha/255.0;
and encode:
int @packedcolor; float r,g,b; int red,green,blue,alpha; assign(r,g,b,@Cd*255.0); red = (int)r; green = (int)g; blue = (int)b; alpha = (int)rint(@mask*255.0); green = shl(green, 8); blue = shl(blue, 16); alpha = shl(alpha, 24); @packedcolor = red | green | blue | alpha;
Edited by jsmack - Aug. 9, 2020 16:00:19
- Benjamin Lemoine
- Member
- 143 posts
- Joined: Oct. 2015
- Offline
Hello
Thank you very much for your nice reply and the code !
it was a guess from the developer that the colors came up as 24 bits packed int
but with your reply it make more sense that it would have been packed into a single int
but how it is imported it is a 3int vector …most of the time the 3 value are the same but not always..
i tried your code on Cd first comlumn it gave something but not the good colors !
i will join also the glb sample file i've used to compare or if you want to check
I will also submit an RFE because the Houdini importer should be able to read
the colors as other application does ; like windows viewer or https://gltf-viewer.donmccurdy.com/ [gltf-viewer.donmccurdy.com]
Thanks again for your code !
Benjamin
Thank you very much for your nice reply and the code !
it was a guess from the developer that the colors came up as 24 bits packed int
but with your reply it make more sense that it would have been packed into a single int
but how it is imported it is a 3int vector …most of the time the 3 value are the same but not always..
i tried your code on Cd first comlumn it gave something but not the good colors !
i will join also the glb sample file i've used to compare or if you want to check
I will also submit an RFE because the Houdini importer should be able to read
the colors as other application does ; like windows viewer or https://gltf-viewer.donmccurdy.com/ [gltf-viewer.donmccurdy.com]
Thanks again for your code !
Benjamin
Edited by Benjamin Lemoine - Aug. 10, 2020 07:15:07
- jsmack
- Member
- 8041 posts
- Joined: Sept. 2011
- Offline
- enoraVFX
- Member
- 1 posts
- Joined: July 2021
- Offline
- Benjamin Lemoine
- Member
- 143 posts
- Joined: Oct. 2015
- Offline
-
- Quick Links