Transformation about geometry in Opitx 6.0

I am trying to change the project from Optix 4.1.1 to Optix 6.0. There is a geometry transformation problem in Optix 6.0 but not in 4.1.

Transform trans_butterfly;//butterfly model
Transform trans_fly_left;//left wing
Transform trans_fly_right;//Right wing

There are three global variables in first of my code.

//butter fly obj
	OptiXMesh omesh_fly_left;
	omesh_fly_left.context = context;
	loadMesh(".\\obj\\fly_left.obj", omesh_fly_left);
	for (size_t i = 0; i < omesh_fly_left.geom_instance->getMaterialCount(); ++i) {
		omesh_fly_left.geom_instance->setMaterial(static_cast<int>(i), fly_matl[i]);
	}
	GeometryGroup fly_left = context->createGeometryGroup();
	fly_left->setAcceleration(context->createAcceleration("Bvh"));
	fly_left->addChild(omesh_fly_left.geom_instance);
	trans_fly_left = context->createTransform();
	trans_fly_left->setChild(fly_left);

	OptiXMesh omesh_fly_right;
	omesh_fly_right.context = context;
	loadMesh(".\\obj\\fly_right.obj", omesh_fly_right);
	for (size_t i = 0; i < omesh_fly_right.geom_instance->getMaterialCount(); ++i) {
		omesh_fly_right.geom_instance->setMaterial(static_cast<int>(i), fly_matl[i]);
	}
	GeometryGroup fly_right = context->createGeometryGroup();
	fly_right->setAcceleration(context->createAcceleration("Bvh"));
	fly_right->addChild(omesh_fly_right.geom_instance);
	trans_fly_right = context->createTransform();
	trans_fly_right->setChild(fly_right);

	//butterfly_body
	OptiXMesh omesh_fly_body;
	omesh_fly_body.context = context;
	loadMesh(".\\obj\\fly_body.obj", omesh_fly_body);
	for (size_t i = 0; i < omesh_fly_body.geom_instance->getMaterialCount(); ++i) {
		omesh_fly_body.geom_instance->setMaterial(static_cast<int>(i), fly_body_matl[i]);
	}
	GeometryGroup fly_body = context->createGeometryGroup();
	fly_body->setAcceleration(context->createAcceleration("Bvh"));
	fly_body->addChild(omesh_fly_body.geom_instance);

	//butterfly_zong
	Group g_fly = context->createGroup();
	g_fly->setChildCount(3);
	g_fly->setChild(0, fly_body);
	g_fly->setChild(1, trans_fly_left);
	g_fly->setChild(2, trans_fly_right);
	g_fly->setAcceleration(context->createAcceleration("NoAccel"));
	trans_butterfly = context->createTransform();
	trans_butterfly->setChild(g_fly);

Build the model and binding them with the transform.

void updateGeometry()
{
	//butterfly
	static int t_fly = 0;
	static int t_fly_zong = 0;
	static float t_fly_zong2 = 0;
	static bool state_wing = 0;
	if (t_fly < -30)
		state_wing = 0;
	if (t_fly > 50)
		state_wing = 1;
	float zong_fly2[16] = { 1.0, 0.0, 0.0, 0.0,
		0.0, 1.0, 0.0, t_fly_zong2,
			0.0, 0.0, 1.0, 0.0,
			0.0, 0.0, 0.0, 1.0 };
	Matrix4x4 mx_fly_zong2(zong_fly2);
	Matrix4x4 mx_fly = RotateMatrix(make_float3(-25.5, 25.0, 0.0),
		make_float3(-25.5, 25.0, 2.5), t_fly);
	Matrix4x4 mx_fly_zong = mx_fly_zong2 * RotateMatrix(make_float3(0.0, 0.0, 0.0),
		make_float3(0.0, 23.0, 0.0), t_fly_zong);
	trans_fly_left->setMatrix(0, mx_fly.getData(), 0);
	trans_fly_right->setMatrix(0, mx_fly.inverse().getData(), 0);
	trans_butterfly->setMatrix(0, mx_fly_zong.getData(), 0);
	++t_fly_zong;
	if (state_wing == 0) {
		t_fly += 1;
		t_fly_zong2 -= 0.1;
	}
	else {
		t_fly -= 3;
		t_fly_zong2 += 0.3;
	}

}

Defines the update function and I print transform’matrix which are change in real time.

void glutDisplay()
{
	updateCamera();
	updateGeometry();// transform geometry
	context->launch(0, width, height);
	context->launch(1, width, height);
	context->launch(2, width, height);

	Buffer buffer = getOutputBuffer();
	sutil::displayBufferGL(getOutputBuffer());

	{
		static unsigned frame_count = 0;
		sutil::displayFps(frame_count++);
	}

	glutSwapBuffers();
}

Add the function in display function.

I find that the values in the update function changes when run the code, but the model doesn’t change in real time. After the model is bound to transform, will the changes of transform not be updated to geometry in real time in the new version?

Or did I make any mistakes in Optix 6.0’s code?

I’m confused about this problem. I didn’t find a good solution after checking the document and debugging. I’m looking forward to your reply.

My graphics card is NVIDIA p4000, in win10 vs2017

Hi YuSHan,

I don’t see a call to rtAccelerationMarkDirty() in your code, are you doing that somewhere? That’s the most common cause of geometry updates not appearing in the output. If you change a mesh geometry, note you need to mark both the mesh AS and the top level instance AS dirty.

https://raytracing-docs.nvidia.com/optix6/guide_6_5/index.html#host#acceleration-structure-builds


David.

Thank you for your reply, I will modify the code according to your suggestion.