Hi all,
I’m just optix/cuda beginner, I’m not sure this problem can be post here or not.
I’m working on a project which have to draw texture on 3D model with ray tracing.I modify SDK example “progressivePhotonMap”.
I read other draw texture examples like “swimmingShark” or “cook” and try to find out clue to use. However, those examples seem has different way to draw texture.
From now on, I know I have to load texture in cpp file
GeometryInstance instance = m_context->createGeometryInstance( mesh, &m_material, &m_material+1 );
instance["diffuse_map"]->setTextureSampler(loadTexture( m_context, ... );
and create TextureSampler in cuda file
rtTextureSampler<float4, 2> diffuse_map; // Corresponds to OBJ mtl params
,and give them texcoord to draw, like this,
float3 Kd = make_float3( tex2D( diffuse_map, texcoord.x*diffuse_map_scale, texcoord.y*diffuse_map_scale ) );
However, I cannot find where the texcoord get the texture coordinate data in cuda file. It seems there should be some code like below in .cpp file
GI["texcoord"]->setBuffer(texcoord);
But I can’t find any code just like this, where dose the cuda file get the texture coordinate data?
Also, if I want to draw texture with ray tracing, is it right that i modify “ppm_ppass.cu” file like below?
float3 Kdd = make_float3( tex2D( diffuse_map, texcoord_buffer.x, texcoord_buffer.y ) );
hit_record.energy = Kd * hit_record.energy * Kdd;
Could anyone give me advise about where texcoord get the texture coordinate data, and how to match coordinate data and texture to present 3D model with ray tracing? I can’t find tutorial in google or programming guide, I really need some help or direction to reach my goal.