Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

随书附赠的代码勘误-Chapter9 Unity阴影-Shadow.shader #322

Open
WaterAndFlower opened this issue Jul 28, 2022 · 2 comments
Open

Comments

@WaterAndFlower
Copy link

对于给出的Shadow,shader
(位于Stander->Chapter9->Shaders文件夹中)
发现在第二个Pass之中(Additional Pass),使用了一个UNITY_LIGHT_ATTENUATION(atten,i,i.worldPos);函数(在片元着色器内)。
但是实际上这个效果是只会有衰减效果而没有阴影效果的。

第一点是,在这个Pass之中,使用了#pragma multi_compile_fwdadd,而这个预编译指令并不会使得Shader对于不同光源类型产生对应的阴影变化变体。正确的使用方法是#pragma multi_compile_fwdadd_fullshadows,另外,在v2f结构体和顶点着色器中,都没有发现相对应的阴影映射Texture的宏定义。

这是刻意为之的嘛,还是另有考虑。

但是我当时学这章的时候,头都炸开了,然后看到了Page206页,我的想法是,如果能在之前告诉读者就好了,嗯。

@spicy-ice
Copy link

spicy-ice commented Jul 28, 2022 via email

@TheZoomFlash
Copy link

TheZoomFlash commented Jul 28, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants