I want OpenGL to synchronize the position of the light source with the point of view and texture.

Asked 2 years ago, Updated 2 years ago, 97 views

As the title says, I would like to do texture mapping on 3D objects by projecting two-dimensional images.Also, I want to make sure that the position of the projected light source is always the same.
In other words, if you move your perspective, you want to move the light source position accordingly. (It's always like your eyes are a projector.)

http://marina.sys.wakayama-u.ac.jp/~tokoi/?date=20150607
Using this source code as a reference, I was able to project the image right away.
I was able to move my point of view.
However, I don't know how to change the position of the light source according to the point of view.

Could someone please tell me?
I'd like a hint, even if it's general.

opengl

2022-09-30 21:19

1 Answers

If you multiply the transformation matrix that rotates the object by the transformation matrix in the shadow map, you will expect it to work.

Specifically,

// Translation matrix for shadow mapping
const GgMatrix ms(ggPerspective(window.getZoom()*0.01f+0.3f, aspect, 3.2f, 6.8f)*mv);

in the section
// Translation matrix for shadow mapping
const GgMatrix ms(ggPerspective(window.getZoom()*0.01f+0.3f, aspect, 3.2f, 6.8f)*mv*window.getLtb());

Change as shown in

However, if you are constantly projecting from the viewpoint side like this, you may not need to use shadow mapping (view mapping).

It's been a while since your question, so please forgive me if I lost it late.


2022-09-30 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.