I made a tutorial for creating a pixel perfect vertex snapping in Blender to mimic that PS1 style!
Full written version of the tutorial under the cut!
I'd like to give a huge thanks to Chris Prenn for their Blender Geometry Nodes Fields Frustrum Culling Tutorial which really helped me figure out a starting point for this method, a lot of what I do here is based on his tutorial with added and modified steps.
To start we need 5 input values
The camera we're using
The output X resolution
The output Y resolution
Don't set these too high or your computer WILL hate you!
The Focal Length
The Camera Clip End OR distance to apply the effect
We need to make a grid for your pixels, let's get it to the right size first
Add a Mesh Privative -> Grid to your Geometry Nodes setup
To get the aspect ratio of your scene let's take 2 math nodes set to divide
For the Size X we want to divide our X Resolution input from earlier by our Y Resolution input
Clamp that! This makes sure that it'll work no matter if it's a landscape or portrait style render
This actually makes the size exactly fit the edges of the camera, but we want the vertices to line up with the pixels of the camera, so we need to scale them ever so slightly
To do this we need to subtract 1 from the X Resolution and then divide that BY the X Resolution, then multiply that value with the prior divide step
For the Size Y use the inverse, just swap the X Resolution and Y Resolution inputs
For the Vertices X and Vertices Y values we're going to directly plug in the X Resolution and Y Resolution inputs, and now our grid is the right size! But we have to get it in the right PLACE as well!
Add a Transform node and plug in our grid
For the Translation value plug in the Location from the Camera input
For the Rotation value plug in the Rotation from the Camera input
Now our grid is sitting right on top of the camera, but it needs to be moved to the lens!
Add a Set Position node
Divide the Focal Length input by negative 32, this is the distance from the camera focal point to the lens
I'd like to note that I did have an issue in one project where 32 was not the correct value for the camera, I'm not sure what caused that, but if when viewing your grid it's not in the right spot try adjusting this number a bit, just make sure it sits right on the lens
Plug that into the Z of a Combine XYZ node
Add a Vector Rotate node and plug our Combine XYZ node into the Vector slot
Plug the Rotation from the Camera input into the Rotation value
Plug the Vector Rotate node into the Offset of our Set Position node, the reason we rotate it first is so that it moves the grid in the right direction instead of just along an axis, it will now always follow the selected camera, glued directly to the lens.
I tried doing this with a raycast node first, having the vertices of our model snap to the nearest spot that would hit one of the vertices of the grid, but I couldn't figure it out, so instead I used lines coming from the camera!
Add a Mesh Primitive -> Mesh Line
Set the count to 2 for optimum performance, we just need a start and an end point for our purposes
Leave the Start Location at 0
For the offset we're going to take our Camera Clip End, multiply it by -1, and plug it into the Z value of a Combine XYZ node
Add an Instance On Points node
Temporarily set your X and/or Y value to something like 16 while working on this part so your computer doesn't start crying
Plug the Grid into the Points and the Mesh Line into the Instance
For the Rotation value we're first going to subtract the Position from the Camera input's Location using a Vector math node, this gives a new vector pointing from the camera towards each line's starting point
We then plug that into an Align Euler to Vector node and set the axis to Z
Plug this final value into the Rotation and you should see your lines pointing directly out from the camera, if you go into camera view you won't see them at all because they'll be perfectly lined up
Now we're ALMOST ready to see results! Add a Realize Instances node and plug your Instance On Points node into it to make those lines REAL!
Plug your now realized instances into a Geometry Proximity node and set the type to Edges since that's what we got!
Add a Set Position node and plug your Geometry Proximity Position right into the Position input
If we plug our input geometry into the geometry field and take a look at the results, assuming you lowered the resolution earlier, you'll see a blocky looking mess, it's WORKING! However, you'll notice that if anything goes outside of the camera view it really doesn't look right, we have a fix for that using the raycast method from Chris's tutorial I mentioned earlier!
Add a Raycast node and set the Target Geometry to the Set Position node from before you instanced on points. Remember, this is the grid itself!
The Ray Direction will be the position subtracted from the camera location from earlier, that way the rays will fire towards the camera
For the Ray Length we'll actually want to plug that same node into a Vector Math Length node, that way we won't affect objects behind the camera, Chris explains why this works in the tutorial, but the basics is that's the length to the camera so it won't go Past the camera to hit the grid
Now plug the Is Hit from our Raycast node into the selection of the Set Position node, and voila! Your model will no longer freak out when it's outside the camera, it just won't be affected at all!
The very last step we should do is add a Switch node to swap between the original geometry and the wiggle-fied geometry depending on if it's in viewport or not, that's easy
Add a Switch node and set the type to Geometry
Plug the final Set Position node into the False field
Plug the Original geometry into the True field
Add an Is Viewport node and plug that into the Switch
You now have a functioning PS1 wiggle effect that is active in render! Here's a couple tips for using it:
Add a Triangulate Modifier before the wiggle Geometry Nodes for maximum accuracy
Set your Render type to Eevee and then under Film set the Filter Size to 0 to get hard edges in your render
If trying to show off that you have THE PS1 wiggle it's best to do subtle movements, slow moving models will have a more noticeable Pop
Make sure the geometry nodes for the wiggle are at the very bottom of the modifier stack below anything that may distort the model such as an armature or displacement texture
If your geometry nodes disappear from your editor make sure you have the Geometry Nodes modifier selected in the modifier stack
Back in the Render Properties tab under Color Management set your View Transform to Standard and the Look to None for accurate colors in your final render
Be sure to check if you have any compositing nodes set up in your default Blender file that they aren’t going to mess up your non-photorealistic style!
Have fun!
23 notes
·
View notes