2

I'm trying to add a "sticker" on an equirectangular image.

The parameters I have are the angle of the sticker (yaw, pitch, roll), and its size in pixels, and the equirectangular image size (always a 2:1 ratio).

Example with this sticker (don't mind the background) :

enter image description here

If we put the sticker at the bottom of the sphere, the shader should be able to get something like this :

enter image description here

Xys
  • 8,486
  • 2
  • 38
  • 56
  • 2
    I suggest using raytracing. If I understand the wikipedia page on equirectangular projection correctly, you can easily get ray directions from image coordinates (`ray_yaw = x / image_w * 2 * pi` and `ray_pitch = (y + image_h/2) / image_h * pi` or something similar). Then for each ray you just need to find a point where (and if) it intersects your quad (the math should be relatively easy to google). – HolyBlackCat Mar 27 '19 at 13:47
  • Shadertoy reference: https://www.shadertoy.com/view/MlfSz7 – Ramil Kudashev Mar 28 '19 at 09:33
  • @HolyBlackCat Thanks a lot I will have a look at ray tracing – Xys Mar 28 '19 at 13:20
  • @mlkn Thanks this link is very interesting. In the shader you linked, the image "covers" all the sphere, do you know how I could place the image at a certain place on the sphere, not on the whole object ? – Xys Mar 28 '19 at 13:23
  • when you know your sticker size and you want something simple you can experiment with texture projection on a sphere; created a little playground for experiment (hope it is useful) https://www.shadertoy.com/view/3dBSzy – nabr Apr 01 '19 at 18:55
  • @nabr Thanks a lot but I don't really understand what your shader is doing ^^' . I'm really bad at maths.. – Xys Apr 03 '19 at 09:52
  • @mlkn Any idea why the image gets red ? – Xys Apr 03 '19 at 11:52
  • @Xys OK. man! For better understanding, collected few links --> [demofox](https://blog.demofox.org/2013/10/12/converting-to-and-from-polar-spherical-coordinates-made-easy) **|** [mathinsight](https://mathinsight.org/spherical_coordinates) **|** [wiki](https://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#3-dimensional) **|** [scratchapixel](https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/geometry/spherical-coordinates-and-trigonometric-functions) – nabr Apr 04 '19 at 16:00

0 Answers0