Closed nekotogd closed 1 year ago
Fixes #1
That was fast, thanks @nekotogd !
Unfortunately with your solution when rotating the object, the dissolve is not being preserved like it is with the Godot 3 shader. You can see it's incorrectly acting like a clipping plane:
https://user-images.githubusercontent.com/248383/197826575-b0aa5836-60e0-48fe-a4e4-db76031b62c6.mp4
But when moving the object the shader is working as expected.
As a comparison, rotate in Godot 3 - you can see half of the head always stays dissolved, the offset is always respected:
https://user-images.githubusercontent.com/248383/197827616-3ccfff82-3673-41e8-8988-40ea625e81ce.mp4
Rookie mistake! My bad!
I realized you're just looking for the object-space position of the VERTEX
in the fragment shader. Luckily, the vertex()
function uses VERTEX
in object-space anyways.
So, I just dragged that from the vertex()
function to the fragment()
function using a varying vec3 vertexOS
smooth
is just to ensure its interpolated across fragments. I believe this is default behavior but I wasn't sure so I added the smooth
just in case.
Oh I can't believe it doesn't even need all the MATRIX transformations. Thanks a lot! Works beautifully!
Also thanks for this @nekotogd:
smooth is just to ensure its interpolated across fragments. I believe this is default behavior but I wasn't sure so I added the smooth just in case.
I didn't know this.
Leave it to Nekoto to solve issues like this in a matter of minutes xD
Also did the matrix multiplication in
vertex
function so that the result is calculated per-vertex and then interpolated across the fragments.Final result:
https://user-images.githubusercontent.com/81257780/197825079-1acbcf8f-ce59-40dd-9adf-8d7a7424f4de.mp4