vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
470 stars 75 forks source link

Get color information from textures ? #39

Closed webgrid closed 4 years ago

webgrid commented 4 years ago

Is it possible to get color information from a texture by using "TexCoord" ? (SharpGLTF.Geometry.VertexTypes.VertexColor1Texture1.TexCoord)

Thank you.

vpenades commented 4 years ago

SharpGLTF.Geometry.VertexTypes.VertexColor1Texture1.TexCoord just gives you the UV coordinates within the texture associated to the material used by the mesh primitive.

so if you want to know the color of the pixel of the texture at that coordinate you would need to:

Notice that this is usually done by a vertex/pixel shader in a graphics engine.

webgrid commented 4 years ago

Thanks Vicente Penades!

I used MemoryImage to create a bitmap image, I get the color by GetPixel as you suggested, and I replaced the texture material by solid color material.

The result are generated files is reduced by around 80-90% in file size for my models.