Is it possible to make it pixel perfect?
I have 2d sprites in a 3D world and I see pixel stretching, especially noticeable in the character's single pixel wide eyes.
Is it possible to make it pixel perfect?
I have 2d sprites in a 3D world and I see pixel stretching, especially noticeable in the character's single pixel wide eyes.
make sure the shape you map the sprite onto is of the correct size, or alternatively correct via manipulating the UV coordinates in case you are using a material/shader.
There might also be some pixel stretching depending on the perspective of the camera, as it tries to map 2D pixels from a 3D plane (or quad, etc) to a flat screen. If you have the sprites always face the camera, then this will not be as much of an issue, though depth could still cause some pixel size changes depending on the texture, mip-maps, and the resolution of the game.
Camera is at -45 degree angle. FOV is integer number 20, translation integer values 8y and 8z. Camera is a child of player. There are some non-integer values in the resulting matrix though 0.707.
Each frame in the sprite is 38x48 pixels
As you can see in the image, the pixels in the eyes are squashed.
Is there a reason you aren't using the orthogonal camera projection?
Orthogonal doesn't look as good. But, someone on reddit told me that perspective camera is the source of the problem. Even in orthogonal I'm having problems. camera size is 4, translation is integer value, angle 45 degrees. Billboarding sprite. Stretch viewport in display settings.
What is the size of the game window? And the aspect ratio, for that matter. Both of these values can change the FOV (I think vertical, but I don't remember) as Godot tries to fill the display. I'm not sure if it is causing the issue, but it might be something to look at.
in width/height in window settings i put 1920x1080. same for test width/test height (putting these at 0 doesn't make a difference. I also have keep_height in both the window setting and camera setting.
Here is a link to the project folder: https://www.dropbox.com/sh/5no0o31c61catlo/AADZmsTCtBp1zIUpmQsB1iN0a?dl=0
I'm using Zylann's heightmap addon, so that might need to be activated.
the .gdignore file in zylann's addon folder was not uploading correctly. I uploaded a version without the addon installed. It has a basic scene without heightmap.
https://www.dropbox.com/sh/e66udqft2up6rdh/AABW-nLk7sdZtRRzLksOlAuWa?dl=0
I'll try to take a look at the project later today and see if I can figure out what is going on :+1:
I think I found a potential pathway to a solution, but not sure how to implement it.
I think this shader is the solution: https://github.com/CptPotato/GodotThings/blob/master/SmoothPixelFiltering/SmoothPixel3D.shader
It's described in this video:
On sprite3d I can apply the shader material in the geometry instance section. But the code shader code appears to not be working for me. It makes the sprite disappear.
Huzzah! I did it!
CptPotato's shader worked! It was disappearing earlier because UV scale was set to 0 for some reason.
Uniforms lacking a default value in the shader.
Awesome! I'm glad you were able to figure it out! I accidentally forgot about this yesterday (busy day), otherwise I would have tried to help. I'm glad you were able to find a solution :smile: