Custom Shaders - Game Progress
For the purposes of the game, as the view is 2.5D with a static camera, this means that any and all big objects will cover the camera view and therefore the player. This makes it difficult to navigate, so the easy logical resolution is to make the objects transparent while the player is behind them. On paper it's simple - create a raycast from the camera, if something covers the player then the object alpha becomes transparent.
The problem arises with the shader system in Unity. Yes, objects like trees will become transparent as planned, but with a caveat. Any in-build Unity render system does not account for the position of each plain if it can become transparent. It's not an issue with 2D objects, but this idea breaks down with 3D objects. This is how the object ends up looking after an alpha shader is used in Unity:There are clear markings of the remaining tree branches that are behind the object. It almost appears like random planes are stuck on top of the trees. Sadly, this is an intended purpose of the shaders and it cannot be changed. This is why I created custom shaders to solve this problem and make it a nice and easy fade into transparency. This was an entirely new endeavour, especially due to the archaic code structure that Unity uses for shaders. (There is another custom shader applied too on another object in this image, but more about it later)
For the custom shader we want to have few significant functions:
- Can render a 3D object.
- Will first render the planes closest to the camera, and will refrain from rendering hidden planes.
- The alpha value of the 3D texture can change.
- All of this can be modified in code for raycast.
Surprisingly, a lot of this is already achieved by some premade shaders, but the biggest issue is the rendering of planes. I had to modify the way that the planes are first rendered on the camera. The rendering depends on what is written first. While yes, of course, that's how coding works like, the thing that took a longer time to understand is what needs to be prioritized in code, and what changes are necessary to fulfil the vision. And in the end, it looks great!
Another custom shader made for this game was for the path, or more specifically, 3D lighting for a 2D surface. For this I followed a simple tutorial on youtube. It only required tiny tweaks, but the results are stunningly good
No 3D Lighting vs 3D Lighting
Forgotten Stories DevBlog
More posts
- Future Plans - DevDiscussionsApr 19, 2024
- Main Story - DevDiscussionsApr 19, 2024
- Characters - DevDiscussionsApr 16, 2024
- Core gameplay - DevDiscussionsApr 08, 2024
- Introductions! (un-forgetting Forgotten Stories)Mar 31, 2024
Leave a comment
Log in with itch.io to leave a comment.