as far as i am aware this effect has never been done before in any game

how it works 

deferred renderers write a world-space position to every pixel. when we calculate lighting colors for each pixel we do that by finding the angle of the ray going from light source to the position relative to the angle of the camera to the position. the color of the light, amount of angle and the distance from the light to the position affects the color of the shading.

the problem is that if you are using pixel art textures, those shading values aren't going to respect the size of the pixels in the pixel art - the light will appear to cross pixel boundaries, which looks unnatural because your eye expects the light to shade at the "resolution" of the pixel art


how it works part 2 

to solve this, we find the distance from the pixel's current texture coordinate to the center of the texel. we get the rate of change of the texture coordinate across pixels and put it in a 2x2 matrix. we invert that matrix, and then we can use that matrix to transform world positions, which effectively "quantizes" the position data we write to the geometry buffer with respect the texel size. that way we "trick" the light calculations into treating each pixel that exists within a texel as having the same position value.

@dankwraith woah, that’s really clever! I’m guessing this means you need an actual buffer for position instead of just faking it from the depth map?

@cinebox yeah with deferred rendering you typically have at least a buffer for positions, a buffer for normals, and a buffer for albedo color

@dankwraith Unity does it the way I described, world position is calculated from depth and the camera transform

@cinebox huh, makes sense, that implies you could use this technique with forward rendering too

how it works part 2 

@dankwraith ...texture coordinate jacobian
very spicy

re: how it works part 2 

@dankwraith That looks really good. Do you happen to have another video showing what it looks like with per-pixel lighting? When I look at your clip, I can imagine what it'll look like, but it would be nice to actually see it on the screen.

Also, are you making a game with this?

re: how it works part 2 

@dankwraith Thanks. I noted immediately that the trailer didn't have this feature. 🙂

Sign in to participate in the conversation is a community for goth nerds, aka people who are interested in the intersections of math, art, programming, philosophy, and related topics. this does not include your techbro ass. we also enjoy a healthy amount of shitposting. if you are a techno-materialist, technocrat, or some flavor of capitalist, don't even bother applying. if you are interested in an account please fill out an application, detailing why you are interested in joining, what you have to bring to the community, and your prior, if any, accounts on the fediverse.