{"id":13784531,"url":"https://github.com/ozlael/PlannarShadowForUnity","last_synced_at":"2025-05-11T20:30:51.694Z","repository":{"id":91976289,"uuid":"85260052","full_name":"ozlael/PlannarShadowForUnity","owner":"ozlael","description":"Planar Shadow is very cheap and useful for mobile games.","archived":false,"fork":false,"pushed_at":"2020-09-30T18:40:40.000Z","size":12357,"stargazers_count":124,"open_issues_count":1,"forks_count":29,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-03T19:08:49.991Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HLSL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ozlael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-17T02:01:01.000Z","updated_at":"2024-07-01T12:46:53.000Z","dependencies_parsed_at":"2024-01-17T04:51:47.733Z","dependency_job_id":null,"html_url":"https://github.com/ozlael/PlannarShadowForUnity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozlael%2FPlannarShadowForUnity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozlael%2FPlannarShadowForUnity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozlael%2FPlannarShadowForUnity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozlael%2FPlannarShadowForUnity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ozlael","download_url":"https://codeload.github.com/ozlael/PlannarShadowForUnity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225094286,"owners_count":17419970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T19:00:47.249Z","updated_at":"2024-11-17T21:30:18.920Z","avatar_url":"https://github.com/ozlael.png","language":"HLSL","readme":"# PlannarShadowForUnity\nPlanar Shadow is a kind of old school. But, it is very cheap and useful for mobile games.\nUnity’s default shadow system use Shadowmap. It needs more power of Pixel Shader and Render Targets. That means that Shadowmap system is expensive especially on mobile devices. Not only for Unity, other engins are the same. \n\nActually, the Planar Shadow is not real shadow. It is just a mesh. But, it looks like a shadow by pressing/projecting into plan using Vertex Shader. It doesn’t need much power of Pixel Shader.\nIt uses a little bit of math, but, simple trigonometric function. See image below : P is a point of the mesh and P' is a point of the shadow. \n\n![image](https://github.com/ozlael/PlannarShadowForUnity/blob/master/alittlebitmath.jpg)\n\n```\nfloat4 vPosWorld = mul( _Object2World, v.vertex);\nfloat4 lightDirection = -normalize(_WorldSpaceLightPos0); \nfloat opposite = vPosWorld.y - _PlaneHeight;\nfloat cosTheta = -lightDirection.y;\t// = lightDirection dot (0,-1,0)\nfloat hypotenuse = opposite / cosTheta;\nfloat3 vPos = vPosWorld.xyz + ( lightDirection * hypotenuse );\no.pos = mul (UNITY_MATRIX_VP, float4(vPos.x, _PlaneHeight, vPos.z ,1));  \n```\n\nDetailed explain(Korean) : http://ozlael.tistory.com/10\n\nPros is : cheap\n1. Core part is only for VS. PS handles only color and alpha (plus, Stencil)\n2. You can use LOD mesh for shadows. While, Shadowmap(Unity’s shadow) have to draw original mesh twice at least.\n3. Shadow doesn’t looks blocky. Mobile devices have to use blocky hard shadow because they doesn't have enough power to use soft shadows.\n\nCons\n1. Only for planar floor.\n2. Only sharp edge.\n3. Use Stencil. But, It is not a big deal nowadays because mobile devices are support it.\n\n![image](http://cfile22.uf.tistory.com/image/260EC04458CB87B32BAD70)\nSample asset : https://www.assetstore.unity3d.com/kr/#!/content/45319\n","funding_links":[],"categories":["Shadow"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozlael%2FPlannarShadowForUnity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fozlael%2FPlannarShadowForUnity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozlael%2FPlannarShadowForUnity/lists"}