Items with no label
3335 Discussions

uv coordinate from get_texture_coordinates() is over 1

sshin9
Beginner
1,730 Views

I have testing pointcloud example in SDK 2.0 using D435.

// Wait for the next set of frames from the camera

rs2::frameset frames = pipe.wait_for_frames();

rs2::depth_frame depth_frame = frames.get_depth_frame();

 

// Generate the pointcloud and texture mappings

rs2::points points = this->pc.calculate(depth_frame);

rs2::video_frame color = frames.get_color_frame();

// Tell pointcloud object to map to this color frame

pc.map_to(color);

// save vertices and uvs

const rs2::vertex* rs_vertices = points.get_vertices();

const rs2::texture_coordinate* rs_tex_coords = points.get_texture_coordinates();

When I check the rs_tex_coords, u and v coordinate of some points is over 1.

I know uv coordinates have to be mapped to 0-1.

Why uv coordinate from rs2::points::get_texture_coordinate() is over 1 ?

0 Kudos
1 Solution
idata
Employee
806 Views

Hi heavyman,

Thank you for your patience.

As can be seen in example.hpp, the coordinates from get_texture_coordinates() are used in the glTextCoord2fv function. The glTextCoord2fv function uses the terminology "s, t" instead of "u, v." Before this call, you will see these calls:

glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, tex_border_color);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0x812F); // GL_CLAMP_TO_EDGE

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 0x812F); // GL_CLAMP_TO_EDGE

I found a good discussion of what these settings do here: https://gamedev.stackexchange.com/questions/62548/what-does-changing-gl-texture-wrap-s-t-do https://gamedev.stackexchange.com/questions/62548/what-does-changing-gl-texture-wrap-s-t-do

 

It seems that the s, t coordinates can be greater than 1 when the texture repeats and must be clamped in order to stop at the edge, or border.

Does this help?

Regards,

 

Alexandra

View solution in original post

0 Kudos
3 Replies
idata
Employee
806 Views

Hi heavyman,

 

 

Thank you for your interest in the RealSense D435 camera.

 

Let me look into it and I will get back to you later.

 

 

Regards,

 

Alexandra
0 Kudos
idata
Employee
807 Views

Hi heavyman,

Thank you for your patience.

As can be seen in example.hpp, the coordinates from get_texture_coordinates() are used in the glTextCoord2fv function. The glTextCoord2fv function uses the terminology "s, t" instead of "u, v." Before this call, you will see these calls:

glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, tex_border_color);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0x812F); // GL_CLAMP_TO_EDGE

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 0x812F); // GL_CLAMP_TO_EDGE

I found a good discussion of what these settings do here: https://gamedev.stackexchange.com/questions/62548/what-does-changing-gl-texture-wrap-s-t-do https://gamedev.stackexchange.com/questions/62548/what-does-changing-gl-texture-wrap-s-t-do

 

It seems that the s, t coordinates can be greater than 1 when the texture repeats and must be clamped in order to stop at the edge, or border.

Does this help?

Regards,

 

Alexandra
0 Kudos
idata
Employee
806 Views

Hi heavyman,

 

 

Was my answer helpful?

 

Do you have further questions?

 

 

Regards,

 

Alexandra
0 Kudos
Reply