Comments (7)
What geometry is the mesh supposed to be? It is likely just the one grass object, which is also seen in the instancing case. I cannot spot any obvious error in your code.
from embree.
You can also take a look at the instance array geometry tutorial
https://github.com/embree/embree/blob/master/tutorials/forest/forest_device.cpp
that we added in Embree 4.3.0. This tutorial does almost the same as you want to do but with trees instead of grass/herbs.
from embree.
@svenwoop @freibold Thanks for helping.
I updated the question because it could be confusing. So now the scene has only one mesh: the plane.
To recall I have 2 implementations. I don't get why the second is not working.
1) No instancing(WORKS)
Steps:
-->Create the scene(rtcNewScene)
-->Create a RTCGeometry(RTC_GEOMETRY_TYPE_TRIANGLE) for the plane
-->Set the geometry vertex and index buffers(using rtcSetSharedGeometryBuffer).
-->Commit the geometry(rtcCommitGeometry)
-->Attach the geometry to the scene(rtcAttachGeometryByID)
-->Commit the scene.
2) Instancing(DOESN'T WORK)
Steps based on the instanced geometry tutorial :
-->Create the root scene
g_scene = rtcNewScene(g_device)
-->Create the instanced scene
g_scene1 = rtcNewScene(g_device)
-->Create a RTCGeometry for the plane
g_geometry = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_TRIANGLE);
-->Set the geometry vertex and index buffers.
-->Commit the geometry
rtcCommitGeometry(g_geometry)
-->Attach the geometry to the instanced scene
rtcAttachGeometryByID(g_scene1, g_geometry, mesh->getFlatId())
--> Commit the instanced scene
rtcCommitScene(g_scene1)
-->Create a geometry instance.
g_instance0 = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE)
-->Link the geometry instance to the instanced scene
rtcSetGeometryInstancedScene(g_instance0, g_scene1)
-->Set the instance transform
`
const float transform[] = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
rtcSetGeometryTransform(g_instance0, 0, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, &transform[0]))`
-->Attach the instance to the root scene
rtcAttachGeometry(g_scene, g_instance0)
-->Commit the root scene
rtcCommitScene(g_scene))
from embree.
Could you please provide a reproducer by modifying the instance geometry tutorial? It is not obvious what is wrong there and we would need a small reproducer to debug this.
from embree.
I managed to have it working by doing the same steps as what it is in the instanced geometry tutorial. So it works but I don't understand why. It look like this:
-->Create the root scene
g_scene = rtcNewScene(g_device)
-->Create the instanced scene
g_scene1 = rtcNewScene(g_device)
-->Create a RTCGeometry for the plane
g_geometry = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_TRIANGLE);
-->Set the geometry vertex and index buffers.
-->Commit the geometry
rtcCommitGeometry(g_geometry)
-->Attach the geometry to the instanced scene
rtcAttachGeometryByID(g_scene1, g_geometry, mesh->getFlatId())
-->Release the geometry
rtcReleaseGeometry(g_geometry);
--> Commit the instanced scene
rtcCommitScene(g_scene1)
-->Create a geometry instance.
g_instance0 = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE)
-->Attach the geometry instance to the root scene
rtcAttachGeometry(g_scene, g_instance0)
-->Release the geometry instance
rtcReleaseGeometry(g_instance0);
-->Set the instance transform
`
const float transform[] = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
rtcSetGeometryTransform(g_instance0, 0, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, &transform[0]))`
--> Commit the instance geometry
rtcCommitScene(g_instance0)
-->Commit the root scene
rtcCommitScene(g_scene))
from embree.
@svenwoop How does rtcReleaseGeometry works?
Here we create the instance geometry then we free it inside the same function(device_init ):
https://github.com/embree/embree/blob/master/tutorials/instanced_geometry/instanced_geometry_device.cpp#L123
Then we later use the same geometry(we released) and we commit it:
https://github.com/embree/embree/blob/master/tutorials/instanced_geometry/instanced_geometry_device.cpp#L339
from embree.
The rtcReleaseGeometry decreases the reference counter on the geometry handle, thus you should not use that handle anymore. However, if you previously attach the handle to some scene, then the object itself will still be alive, as the scene itself increases the reference count on that geometry.
from embree.
Related Issues (20)
- GeomID, PrimID in Pathtracer Tutorial HOT 5
- rewrite embree using sycl with CPU version HOT 3
- Embree ASAN issues with Emscripten HOT 4
- Attach UserData to rtcScene and retrieve rtcScene from rtcGeometry
- What am I supposed to do with Intersections with outside barycentric coordinates? HOT 3
- Does Embree support geometry instancing? HOT 3
- Rays do not hit triangle HOT 5
- installation on Arch Inux HOT 2
- Unable to compile Embree on Windows 10 HOT 2
- ThreadSanitizer issue in parallel_any_of HOT 2
- access violation on rtcGetBufferData()
- Build failure on x32 ABI
- Why does RTC_RAY_QUERY_FLAG_INVOKE_ARGUMENT_FILTER not apply to user-defined geometries? HOT 2
- Using buffers with user geometry
- Simple point query with curve example, RTCPointQueryFunction is never called
- Build fails with LTO
- python APi
- What is the correct return value for valid in the geometry callback?
- Output operators access non-existent members HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embree.