Jump to content

Pixel art lighting - Is this even possible?


JustinLeduc

Recommended Posts

Hey guys!

 

I’m dealing with an interesting challenge. Basically, I’d like to light my scene in a pixel art fashion (except in 3D, so I guess that would be in a "voxel" fashion).

 

I initially wrote a wall of text, but I've decided instead to make a few renders to better illustrate what I'd like to achieve.

 

First, this is my setup (viewport screenshot):

 

https://i.imgur.com/nzJK5iP.png

 

Now, a traditional way to light this scene would be to use a Spotlight, as such:

 

VIDEO 001 https://i.imgur.com/XYmDKFk.mp4

 

But this is not the result I want.

 

I would like to find a way to light my scene/meshes in a way that resembles this:

 

VIDEO 002 https://i.imgur.com/Xza6tnQ.mp4

 

Problem: The method I used to create the render above is utterly inefficient and CPU-intensive. In short, I'm duplicating each voxel of the bicycle, extruding those duplicates on the Z-axis and detecting any intersection between those extrusions and the "wall". See here (in red):

 

VIDEO 003 https://i.imgur.com/gH8ZwSG.mp4

 

Objective: I would like to find an efficient way of having the boundaries of the lights/shadows projected onto my meshes (like the voxel walls) be restricted to the voxels/cubes they (those same meshes) are made of, i.e. in a pixel art fashion.

 

I've attached the demo scene to this post. Please note that Octane was used in this project file, but I'm also opened to using default materials if needed.

 

At this point in time, I’m wondering if this is even possible to do with Octane, or Cinema 4D for that matter (unless I decide to dive into Python or something). That said, given my novice status, there could be a ridiculously obvious solution that I haven't thought of. I feel like this could be more likely...

 

Any advice/tip/insight would be hugely appreciated. Seriously. Even just keywords to Google and what not, because I'm running out of keywords to Google over here...

 

Thanks a ton!

BIKE_DEMO_001.c4d

Link to comment

Wow...that is really ingenious how you did it.  Sometimes, creating a low tech look can only be accomplished with a high tech approach.

 

So you want just the shadows  to be heavily pixelated?  The first thing that came to mind was to use shadow maps with an extremely low resolution but the lowest custom setting in C4D was 40 x 40.  That created this result (settings to the side)

 

image.png.481343ef1eb3f633926425e352d199dd.png

 

 

So while the pixelation is there, it is not as pronounced as you desire.  Another approach would be if you had Redshift and set the initial ray cast levels extremely low as well but that could have other unintended consequences.

 

Interesting challenge to make something look 8 bit with 64 bit tools.

 

Dave

 

Sorry...but I simply do not have enough faith to be an atheist.

Link to comment

Just an idea:

- Start with approach 1 

- Lower the output resolution to something like 160x100

- Carefully position the Camera, so that a voxel roughly equals an output-pixel (you could make an overlay for the camera with a grid of output-pixels)

- Everything including shadows should now be pixelated

- Upres in post as needed (without filtering for "clean" pixel look)

 

 

Link to comment

Hey guys,

 

A huge thanks for helping me out on this. I really, really appreciate it.

 

@3D-Pangel @keppn

 

The idea of having a low-res shadow map crossed my mind, but here's the thing: my voxel scenes will not just be made of flat walls, meaning that the Z-Depth of said "voxel walls" will vary. So with that in mind, wouldn't the idea of having a low-res shadow map (that still somehow matched the location of my voxels) simply not work, even if up-scaled without sampling in post? It's hard for me to put into words as to why, but I feel like you guys might know what I mean. Plus, I would need a certain amount of flexibility regarding the position/rotation of my camera, and I feel like this method would limit my options greatly.

 

@HappyPolygon

 

Yes! While the end result will resemble a pixelated emission/shadow map, as mentioned in my original post, I'm very committed to having the boundaries of those lights/shadows (that are projected onto my voxel meshes, like the walls) be strictly restricted to the walls' voxels/cubes, which is why I've resorted to Mograph and Fields so far as opposed to dabbling into any texture trickery  (which I'm still opened to, but doesn't feel like it would yield the result I'm expecting, the variable Z-Depth of my voxel matrix being one of the reasons).

 

A big thanks once again for the help, truly.

Link to comment

Ah... so, if I understand correctly, a voxel in the background should have only 2 states:

1. Completely in the light OR

2. Complety in the dark (shadowed)

 

...Like a pixel with two luminance states.

 

Then how about this:

- Build the wall from voxels

- Assign individual color materials

- The base color (for example, diffuse) should be the shadow color - quite dark

- Now give the material a strong Subsurface Scattering color.

 

Now, when a voxel is in the shadow (not hit by light source), it should stay dark (the shadow color defined in diffuse)

 

When a voxel is hit by light source, it should light up complety, due to SSS. 

 

With a medium SSS setting, you could even produce some kind of "pixel flickering" like dithering in pixel art.

 

... it's just a theory, though 🙂

 

 

 

 

 

Link to comment
  • Customer
1 hour ago, JustinLeduc said:

Yes! While the end result will resemble a pixelated emission/shadow map, as mentioned in my original post, I'm very committed to having the boundaries of those lights/shadows (that are projected onto my voxel meshes, like the walls) be strictly restricted to the walls' voxels/cubes,

 

I have a simple solution.

The key concept is "discrete".

If your model moves in discrete distances your shadows will also move in discrete distances.
If you have a moving light source then that light source should move in discrete distances.

We essentially convert the animation to a stop-motion format without dealing with frame rate.

This leads to other problems though...
I know there is a way to make a voxelated object that moves discretely in space using the Cloner. (If you don't know how to do this let me know)
What I don't know, is how to make the light source move discretely in space. If you do want that and don't know how to do it we can summon someone expert on this.
One more problem you should solve is positioning your light source in a certain way to have the shadow fall exactly parallel to your wall without spreading (I think the parallel spot is what you are looking for) - you may want to switch to Hard Shadows. Maybe make the shadows more transparent. You can duplicate the light and position it bit next to the first one  (it is up to you to find the exact distance so it coincides with the voxel size) with a different shadow opacity to make a penumbra shadow effect.

Link to comment

Hey @keppn,

 

Huge thanks for the possible solution.

 

I've just spent a chunk of time experimenting with SSS, both in Octane and with C4D's default materials, and I was unsuccessful in both cases.

 

As far as Octane goes, I simply couldn't get the desired result (I will be experimenting a lot more on that front), and as for the default materials, SSS was taking so long to render (even with "Fast evaluation" checked off) that I might as well as be using the inefficient method showcased in VIDEO 003 of my original post. Additionally, I couldn't get a result that came close to what you suggested.

 

That said, as I am very inexperienced with C4D's SSS, I'll have to dig deeper into ways of speeding it up, but I'm not holding my breath. I still think that Octane's SSS is the way to go if I'm ever able to put your theory into practice.

 

Either way, I'll be experimenting with the SSS. Thanks again for the help!

Link to comment

Hey @HappyPolygon,

 

Big thanks for suggesting another path to explore!

 

I've been staring at your message for the last 10 minutes and it feels like, at this point in time at least, I need to ponder a lot more on this potential solution, i.e. letting it simmer for a while. It definitely has its caveats, but your idea of converting the animation into a stop-motion "format" is definitely worth reflecting on.

 

I think the biggest caveat to this proposed solution (and please correct me if I'm wrong) is the fact that I plan on having many lights emitting from different angles in my final scene. Said lights could also be blocked/intersected by other voxel meshes from all angles. I'm sorry if the videos found in my original post were a bit misleading in that regard, as they only showcase 1 front-facing light.

 

Still, I'll experiment with a few things and get back to you on that.

 

Thank you very much once again!

Link to comment
  • 1 month later...
×
×
  • Create New...

Copyright Core 4D © 2023 Powered by Invision Community