Subpixel Camera for a 3D Pixel Art Game Engine
Вставка
- Опубліковано 19 жов 2020
- Date of Recording: 2020-10-10
Following the example of many 2D pixel art games, we render our scene at a low pixel art resolution (640x360) and upscale the result to the screen resolution for presentation. At render-time, the camera is snapped to the nearest "pixel", and when blitting to screen, the snap offset is corrected so that the camera is permitted to smoothly glide over the pixels of the screen at the display's native resolution.
Some extra projections need to be computed in order to ensure that this operation works precisely even when the camera is rotated 45 degrees.
The pixel art shaders were also updated to add contrast in shadowed regions by shading the shadowed regions using a simple monochromatic Lambertian BRDF, resulting in a soft fake ambient lighting effect.
i love your channel and your work just looks so beautiful
i hope this will be finished and released someday^^
Love this! Just tried it myself and after a bit of tinkering I got the camera to work in both directions.. but only when using 45 degrees in the x axis.. when I set it to let's say 30 it's not pixel perfect anymore (I guess it's because the camera is moving in the z direction and the 30 degree angle means the camera needs to move slightly different compared to 45 degrees). Now I can't wrap my head around the maths. Do you have any suggestions / a formula how to calculate the amount of pixel I need to move when going up and down? Thanks in advance!
Hope you don't mind me asking, how do you deal with odd resolutions and aspect ratios that aren't 640x360? Love the work btw!
Does this function similarly to how the "pixel-perfect component" works in unity? or is your method slightly different?
How did you manage to do the sort of shading outlines of the boxes and such? I'm creating something sorta similar for a game and want to know how
OOH. Could be used for some really cool camera gimmicks in-game
yeah! like some camera based puzzles. I haven't thought it through though
Thank you t3ssel8r for the amazing inspiration. I recreated something like this without any shader code, just using a render texture and a script.
Moving the camera actually pans the whole viewport. Whenever the viewport moves one pixel or more from the center, I move it back a number of pixels and transform the camera with the same number of pixels, taking into account the units per pixel and some trigonometry for the angles. I was suprised, it works really well with almost no peformance hit, including rotations and zooming. I'll have to see how it works with moving entities though. Yours is probably the proper way of doing it and mine relies on C# code in the update function, it feels like it will lead to problems down the line.
this is essentially what I do as well
Would you mind sharing your camera script? I'm trying to get this to work but I still get the annoying jitters. I also have the slight suspicion, that cinemachine won't work for this.
@@Cheeztaco I haven't worked with cinemachine. But if it does any transformations like smoothing then it will cause jitter. To start out with I recommend making a regular camera pointing straight down. That way the number of units accross the height of the screen is 2 * orthographic size. So if you have a camera resolution of 360 and an orhographic size of 5. The units you have to move per pixel will be 1/36. Every translation of the camera should be dictated by the viewport panning across the screen.
I can't really show my code as I'm not home yet and it also depends on other objects and it's really messy right now.
@@starbi I'll grab me a coffee an try that. Thanks for pointing me in the right direction :)
@@starbi I can't seem to wrap my head around that. Relatively new to unity btw. Switched from gamemaker because plain 2d just wasn't enough for my idea. I'll ask a bit around and see if someone can help me, but thanks
are u ever gonna release this or make a tutorial ? ...... cos this looks soo goodd
do you use a shader found on the net to have this rendering?
What method did you use to render the scene? Is this an actual shader system? I have lots of questions.
How did you make the grasS?
One doubt came up when I read your description: what happens to the borders? If there is a snap offset of x, all the rendered scene should move x, opening a "letterbox" of size x in the borders. How do you guess what should be there?
x is always at most a single texel, so you can either pad the RT size by 1 texel in each dimension, or what I do is just set the texture extrapolation mode to clamp, and in practice it's pretty unobtrusive
Excelent work but i need to know how to do this
So am I right in assuming you render in a higher resolution to a texture and just reduce the size for displaying?
the opposite: render to low resolution and upscale for displaying
@@t3ssel8r If that's true then it's not sub-pixel, it's extra-pixel
@@t3ssel8r how do configure render to a low resolution other than the display resolution? 👀