0 votes

enter image description here

asked Oct 17, 2019 in Engine by ATom 1 (209 points)
reshown Oct 18, 2019 by ATom 1

Do you talk about a 2D/CanvasItem shader or a 3D/Spatial shader? Your question would make less sense for a 3D Shader IMHO but who knows. In that case I'd try to get a 3D aabb of the meshinstance then transfer that via camera.unproject_position into screen coords and get the rect of the min/max of the 4 values (works for a cube, might be a bit too big for other shapes). Then pass the result via a uniform to the shader. But perhaps I'm thinking too complicated.

Thank you very much, it helped me a lot. I am trying to implement a fixed-view 3D game demo, and it is an orthogonal camera. According to your method, I only need to get aabb once when the camera is at the origin; then in the fragment shader, calculate the final aabb by camera position.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.