top of page
  • Writer: Asante Azevedo
    Asante Azevedo
  • Nov 13, 2022
  • 2 min read

Today I tackled more lighting in the shader. Yesterday I added support for directional lights. Today I added support for point and spot lights. Some of the things that I learned about were using multiple passes to because of the draw calls for multiple lights. The base pass is for the main directional lights. Then an additive pass is made for each additional light in the scene. These add to the color for the shader according to the light that the draw call is rendering from. I also learned how to use identifiers to control the code for the different kind of lights. I struggled with getting the attenuation for point and spot lights correct. I hadn't properly calculated the range of the light properly. This cause the attenuation to be square instead of spherical. There wasn't a gradual fall off. After double checking my code and comparing it the example that I was following, I found the equation that I was messing up. After that, the point lights looked much better. I also learned about vertex lighting. Vertex lighting is a lot cheaper than calculating the lighting in the fragment shader. There are a lot less verts to calculate lighting for than fragments. This is what allows the shader to support more than the standard 4 that are set in Unity's pixel light count. Extra lights are are furthest away and fairly weak are rendered with vertex lighting while the closer, stronger and more important lights are calculated in the fragment shader. Tomorrow I will finally get to shadows. Hopefully in the next few days, I'll be able to make a suitable shader for the leaves. I need to move on to other parts of the game.



 
 
 
  • Writer: Asante Azevedo
    Asante Azevedo
  • Nov 12, 2022
  • 1 min read

I didn't have a lot of time today to work on shaders. Today I learned about how to implement lighting. Catlike coding goes over the blin-phong lighting model as well as a physically based model. Some of the topics that were covered were specular, metallic, and smoothness. Making sure that the outputs for the albedo, specular, and more are less than 1 so they don't overpower other parts of the shader gives the shader a more realistic feel. There are more colors and directions that go into making the final color than I realized. Attached is an example of what I have so far.



 
 
 
  • Writer: Asante Azevedo
    Asante Azevedo
  • Nov 11, 2022
  • 1 min read

Updated: Nov 13, 2022

I was working on a small game where the player is raking leaves, when I was having issues with my leaf material. I had made a quad and a .png of a leaf with an alpha channel that would create a mask for the leaf. I wrote some basic shader code to turn the mask transparent. Each leaf was a mesh renderer with the lead material applied to a quad. This was working fine, but then I noticed that the shadows weren't right. I realized that the whole quad was casting a shadow instead of just the leaf.

After doing some research, I realized that I would have to learn to write my own shader that incorporates lighting and shadows. This lead me down the rabbit hole of shaders. I have some experience with shaders. I found this really awesome website for shaders called thebookofshaders.com. This website goes in-depth about the basics of shaders and how to use the basics to make some awesome stuff. Unfortunately this didn't cover anything about lighting or shadows. I found some other blogs and tutorials that had walkthroughs about shaders in unity. Catlikecoding is where I'm going to be learning how to make a leaf shader that has appropriate lighting and shadows.

Currently I'm working on the lighting part. Here's what I have so far.



 
 
 

© 2020 by ASANTE AZEVEDO. Proudly created with Wix.com

bottom of page