Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera Artifacs #67

Open
RodrigoMedeirosRS opened this issue Dec 28, 2016 · 7 comments
Open

Camera Artifacs #67

RodrigoMedeirosRS opened this issue Dec 28, 2016 · 7 comments

Comments

@RodrigoMedeirosRS
Copy link

RodrigoMedeirosRS commented Dec 28, 2016

Right, i found a little glitch when i try to resposition my camera.

Here is a screenshot before i active the function:
erro01
... and here is a screenshot after i active the function:
erro02

And here is the function:

def CameraReposition(self):
base.camera.reparentTo(self.point)
base.camera.lookAt(self.orb)

The problem is directly related with the "reparentTo" command.

@tobspr
Copy link
Owner

tobspr commented Dec 28, 2016

Hi, yeah, the render pipeline does not expect the camera to be parented to another nodepath.

I will see if I get to implement this for the next Release, in the meantime you can use a task which synchronises the camera position to the desired nodepath.

@RodrigoMedeirosRS
Copy link
Author

RodrigoMedeirosRS commented Dec 28, 2016

Right! I will wait for you!

Please try to fix soon, because into my controller system, when i update the camera position into task, the results very, very poor.

Thanks for the attetion.

@tobspr
Copy link
Owner

tobspr commented Dec 29, 2016

Make sure the task has the right sort, so that your logic happens first, then the camera position is synchronized, and the render pipeline updates.

The rp updates all have a sort greater zero, so try running your game logic with a sort of -10 and your camera synchronization with a sort of -5 or so.

I am currently in vacation, so I can't do much until next week :)

@RodrigoMedeirosRS
Copy link
Author

RodrigoMedeirosRS commented Dec 29, 2016

I found the origin of problem!

Analyzing the glitchs, i see they follow a pattern, and they occour's only into skybox, and how many times i test, less glichs occour's. So when i try you manual solution suggestion, i find the origin of error, and a perfect workaround.

The error occour's because the RP cannot get the starter position of camera when his is a child of another thing, and he is getting some memory info trash, and receiving invalid coordinates.

But, if i can set manualy only the original position, the RP can apply any other transformations correctly, and here is the workaround:

base.camera.setPos(self.orb.getPos() + self.playerNP.getPos() + Vec3(0, 2.5, 0))
base.camera.lookAt(self.orb)
base.camera.reparentTo(self.orb)
base.camera.setPos(0,2.5,0)
base.camera.lookAt(self.orb)

Basically, i am manualy setting the camera position into his future child position, then i make it a child, after this, the RP can correctly calculate the camera position and all glich's are solved.

Now i belive is much more easy to you to found a definitive solution ;)

Att. R.M.Lehnemann

@RodrigoMedeirosRS
Copy link
Author

Only a minor update, i found another error, the cascade shadow map, he can't update correctly the camera position, so when i go so far, the shadow quality become very very poor.

But for this problem the solution is more simple, put a if into the cascade shadow map, if the camera is a child, use the father coordinates.

Note: please consider multiple child levels, bacause into my System the camera is a child of child. :P

@RodrigoMedeirosRS
Copy link
Author

No more fix is needed, problem as definitely solved.

If you need reparent a camera, instead create a empty node, them use the following command:

base.camera.setTransform(self.EmptyNode.getNetTransform())

Solved. The camera now will recive all transforms of child component.

@tobspr
Copy link
Owner

tobspr commented Dec 30, 2016

Cool, glad to hear you found a solution!

I will leave this PR open though, since I think the render pipeline should automatically be able to detect this (by always using the correct transform)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants