mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Add stb_image.
Suppress clang warnings.
This commit is contained in:
17
README.md
17
README.md
@@ -38,6 +38,8 @@ $ make
|
||||
* `TINYUSDZ_BUILD_EXAMPLES` : Build examples(note that not all examples in `examples` folder are built)
|
||||
* `TINYUSDZ_WITH_OPENSUBDIV` : Use OpenSubviv to tessellate subdivision surface.
|
||||
* `osd_DIR` to specify the path to OpenSubdiv repo(I recommend to use https://github.com/syoyo/OpenSubdiv-aarch64 )
|
||||
* `TINYUSDZ_WITH_AUDIO` : Support loading audio(mp3 and wav).
|
||||
* `TINYUSDZ_WITH_EXR` : Support loading EXR format HDR texture.
|
||||
|
||||
#### Build with OpenSubdiv
|
||||
|
||||
@@ -57,8 +59,20 @@ $ ninja
|
||||
|
||||
See `examples` directory.
|
||||
|
||||
### Data format
|
||||
|
||||
#### Primitive
|
||||
|
||||
* [x] `visibility`
|
||||
* [x] `position`(FLOAT3 only)
|
||||
|
||||
## TODO
|
||||
|
||||
* [ ] Audio play support
|
||||
* [ ] Play audio using SoLoud or miniaudio(or Oboe for Android)
|
||||
* [ ] wav(dr_wav)
|
||||
* [ ] mp3(dr_mp3)
|
||||
* [ ] m4a?
|
||||
* [ ] Android example
|
||||
* [ ] iOS example?
|
||||
* [ ] CPU raytracer viewer
|
||||
@@ -83,4 +97,7 @@ TinyUSDZ is licensed under MIT license.
|
||||
* USD : Apache 2.0 license. https://github.com/PixarAnimationStudios/USD
|
||||
* lz4 : BSD-2 license. http://www.lz4.org
|
||||
* cnpy(uncompressed ZIP decode/encode) : MIT license https://github.com/rogersce/cnpy
|
||||
* tinyexr: BSD license.
|
||||
* stb_image: public domain.
|
||||
* dr_libs: public domain. https://github.com/mackron/dr_libs
|
||||
|
||||
|
||||
67
doc/preview_surface.md
Normal file
67
doc/preview_surface.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# PreviewSurface
|
||||
|
||||
https://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html
|
||||
|
||||
## Inputs
|
||||
|
||||
* diffuseColor - color3f - (0.18, 0.18, 0.18)
|
||||
* emissiveColor - color3f - (0.0, 0.0, 0.0)
|
||||
* useSpeclarWorkflow - int - 0
|
||||
* 1
|
||||
* specularColor - color3f - (0.0, 0.0, 0.0)
|
||||
* 0
|
||||
* metallic - float - 0.0
|
||||
* roughness - float - 0.5
|
||||
* clearcoat - float - 0.0
|
||||
* clearcoatRoughness - float 0.01
|
||||
* opacity - float - 1.0
|
||||
* opacityThreshold - float - 0.0
|
||||
* ior - float - 1.5
|
||||
* normal - normal3f - (0.0, 0.0, 1.0)
|
||||
* displacement - float - 0.0
|
||||
* occlusion - float - 1.0
|
||||
|
||||
## Outputs
|
||||
|
||||
* surface - token
|
||||
* displacement - token
|
||||
|
||||
## UsdUVTexture
|
||||
|
||||
### Inputs
|
||||
|
||||
* file - asset - string
|
||||
* st - float2 - (0.0, 0.0)
|
||||
* wrapS - token - useMetadata
|
||||
* black, clamp, repeat, mirror,
|
||||
* wrapT - token = useMetadata
|
||||
* fallback - float4 - (0.0, 0.0, 0.0, 1.0)
|
||||
* scale - float4 - (1.0, 1.0, 1.0, 1.0)
|
||||
* bias - float4 - (0.0, 0.0, 0.0, 0.0)
|
||||
|
||||
### Outputs
|
||||
|
||||
* r, g, b, a
|
||||
|
||||
|
||||
## UsdTransform2d
|
||||
|
||||
### Inputs
|
||||
|
||||
* in - float2 - (0.0, 0.0)
|
||||
* rotation - float - (0.0)
|
||||
* counter-clockwise rotation in degrees around the origin
|
||||
* scale - float2 - (1.0, 1.0)
|
||||
* translation - float2 (0.0, 0.0)
|
||||
|
||||
### Outpuits
|
||||
|
||||
* result - float2
|
||||
|
||||
|
||||
## TODO
|
||||
|
||||
* [ ] Primvar Reader(arbitrary vertex attributes)
|
||||
* [ ] displacement
|
||||
* [ ] Texture transform
|
||||
|
||||
@@ -59,6 +59,12 @@ velocities : usually vec3f[]
|
||||
* inputs:file : @filename@
|
||||
|
||||
|
||||
## TODO
|
||||
|
||||
* [ ] non-vec3f `position`
|
||||
* [ ] vertex color
|
||||
* [ ] xformOpOrder
|
||||
* [ ] Multi texcoord UVs
|
||||
|
||||
|
||||
|
||||
|
||||
7656
src/stb_image.h
Normal file
7656
src/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -85,8 +85,8 @@ void subdivide(int subd_level, const ControlQuadMesh &in_mesh, SubdividedMesh *o
|
||||
|
||||
// Populate a topology descriptor with our raw data
|
||||
Descriptor desc;
|
||||
desc.numVertices = in_mesh.vertices.size() / 3;
|
||||
desc.numFaces = in_mesh.verts_per_faces.size();
|
||||
desc.numVertices = int(in_mesh.vertices.size() / 3);
|
||||
desc.numFaces = int(in_mesh.verts_per_faces.size());
|
||||
desc.numVertsPerFace = in_mesh.verts_per_faces.data();
|
||||
desc.vertIndicesPerFace = in_mesh.indices.data();
|
||||
|
||||
@@ -126,10 +126,10 @@ void subdivide(int subd_level, const ControlQuadMesh &in_mesh, SubdividedMesh *o
|
||||
|
||||
// Allocate and initialize the 'vertex' primvar data (see tutorial 2 for
|
||||
// more details).
|
||||
std::vector<Vertex> vbuffer(refiner->GetNumVerticesTotal());
|
||||
std::vector<Vertex> vbuffer(size_t(refiner->GetNumVerticesTotal()));
|
||||
Vertex *verts = &vbuffer[0];
|
||||
|
||||
for (int i = 0; i < in_mesh.vertices.size() / 3; ++i) {
|
||||
for (size_t i = 0; i < in_mesh.vertices.size() / 3; ++i) {
|
||||
verts[i].SetPosition(in_mesh.vertices[3 * i + 0],
|
||||
in_mesh.vertices[3 * i + 1],
|
||||
in_mesh.vertices[3 * i + 2]);
|
||||
@@ -198,10 +198,10 @@ void subdivide(int subd_level, const ControlQuadMesh &in_mesh, SubdividedMesh *o
|
||||
// Print vertex positions
|
||||
int firstOfLastVerts = refiner->GetNumVerticesTotal() - nverts;
|
||||
|
||||
out_mesh->vertices.resize(nverts * 3);
|
||||
out_mesh->vertices.resize(size_t(nverts) * 3);
|
||||
|
||||
for (int vert = 0; vert < nverts; ++vert) {
|
||||
float const *pos = verts[firstOfLastVerts + vert].GetPosition();
|
||||
for (size_t vert = 0; vert < size_t(nverts); ++vert) {
|
||||
float const *pos = verts[size_t(firstOfLastVerts) + vert].GetPosition();
|
||||
ofs << "v " << pos[0] << " " << pos[1] << " " << pos[2] << "\n";
|
||||
out_mesh->vertices[3 * vert + 0] = pos[0];
|
||||
out_mesh->vertices[3 * vert + 1] = pos[1];
|
||||
@@ -242,15 +242,15 @@ void subdivide(int subd_level, const ControlQuadMesh &in_mesh, SubdividedMesh *o
|
||||
// assert(fverts.size()==4 && fuvs.size()==4);
|
||||
assert(fverts.size() == 4);
|
||||
|
||||
out_mesh->face_index_offsets.push_back(out_mesh->face_num_verts.size());
|
||||
out_mesh->face_index_offsets.push_back(uint32_t(out_mesh->face_num_verts.size()));
|
||||
|
||||
out_mesh->face_num_verts.push_back(fverts.size());
|
||||
out_mesh->face_num_verts.push_back(uint8_t(fverts.size()));
|
||||
|
||||
if (dump) {
|
||||
ofs << "f";
|
||||
}
|
||||
for (int vert = 0; vert < fverts.size(); ++vert) {
|
||||
out_mesh->face_indices.push_back(fverts[vert]);
|
||||
out_mesh->face_indices.push_back(uint8_t(fverts[vert]));
|
||||
|
||||
if (dump) {
|
||||
// OBJ uses 1-based arrays...
|
||||
@@ -263,17 +263,17 @@ void subdivide(int subd_level, const ControlQuadMesh &in_mesh, SubdividedMesh *o
|
||||
}
|
||||
|
||||
// triangulated face
|
||||
out_mesh->triangulated_indices.push_back(fverts[0]);
|
||||
out_mesh->triangulated_indices.push_back(fverts[1]);
|
||||
out_mesh->triangulated_indices.push_back(fverts[2]);
|
||||
out_mesh->triangulated_indices.push_back(uint8_t(fverts[0]));
|
||||
out_mesh->triangulated_indices.push_back(uint8_t(fverts[1]));
|
||||
out_mesh->triangulated_indices.push_back(uint8_t(fverts[2]));
|
||||
|
||||
out_mesh->triangulated_indices.push_back(fverts[2]);
|
||||
out_mesh->triangulated_indices.push_back(fverts[3]);
|
||||
out_mesh->triangulated_indices.push_back(fverts[0]);
|
||||
out_mesh->triangulated_indices.push_back(uint8_t(fverts[2]));
|
||||
out_mesh->triangulated_indices.push_back(uint8_t(fverts[3]));
|
||||
out_mesh->triangulated_indices.push_back(uint8_t(fverts[0]));
|
||||
|
||||
// some face attribs.
|
||||
out_mesh->face_ids.push_back(face);
|
||||
out_mesh->face_ids.push_back(face);
|
||||
out_mesh->face_ids.push_back(uint32_t(face));
|
||||
out_mesh->face_ids.push_back(uint32_t(face));
|
||||
|
||||
out_mesh->face_triangle_ids.push_back(0);
|
||||
out_mesh->face_triangle_ids.push_back(1);
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef struct {
|
||||
std::vector<float>
|
||||
facevarying_uvs; /// [xy] * 3(triangle) * num_triangle_faces
|
||||
|
||||
std::vector<uint32_t> material_ids; /// index x num_triangle_faces
|
||||
std::vector<int32_t> material_ids; /// per face materials. -1 = no material. index x num_triangle_faces
|
||||
|
||||
// List of triangle vertex indices. For NanoRT BVH
|
||||
std::vector<uint32_t>
|
||||
@@ -72,7 +72,7 @@ struct Vertex {
|
||||
_position[2] = src._position[2];
|
||||
}
|
||||
|
||||
void Clear(void * = 0) { _position[0] = _position[1] = _position[2] = 0.0f; }
|
||||
void Clear(void * = nullptr) { _position[0] = _position[1] = _position[2] = 0.0f; }
|
||||
|
||||
void AddWithWeight(Vertex const &src, float weight) {
|
||||
_position[0] += weight * src._position[0];
|
||||
|
||||
Reference in New Issue
Block a user