Swift 3D Game Tutorial
24: Phong Diffuse Shading | Swift Game Engine
Hide/Show description
It is about time we jumped into some diffuse lighting. Diffuse lighting is the concept of making objects in 3d have brighter surfaces that point toward the light, and darker surfaces that point away from the light.
Swift Game Engine Tutorial With Metal Playlist
https://www.youtube.com/watch?v=PcA-VAybgIQ&list=PLEXt1-oJUa4BVgjZt9tK2MhV_DW7PVDsg
Edit:
In the basicShaders.metal file you should be using this snippet of code for rd.surfaceNormal instead.
rd.surfaceNormal = (modelConstants.modelMatrix * float4(vIn.normal, 0.0)).xyz;
When calculating the diffuse use this calculation to get the absolute value of the dot product.
float nDotL = max(dot(abs(unitNormal), unitToLightVector), 0.0);
Become A Patron:
https://www.patreon.com/2etime
I really do appreciate everyone in this community! Thank you all!
Source Code
https://github.com/twohyjr/Metal-Game-Engine-Tutorial/tree/master/Episode%20Project%20Files/Episode24.0_DiffuseLighting
Keynote Presentation:
https://github.com/twohyjr/Metal-Game-Engine-Tutorial/blob/master/Helpful%20Files/KeyNote/AboutDiffuse.key
Awesome Lighting Explanations:
http://buildnewgames.com/lighting/
https://learnopengl.com/Lighting/Ligh...
Metal Specification Documentation:
https://developer.apple.com/metal/Met...
Discord:
Join me on Discord for discussions about Metal. I am always open to talk code :)
https://discord.gg/hKPBTbC
Sweet Standing Desks: http://bit.ly/2XxH13m





























