We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
之所以有这个疑惑是因为 7.1 单张纹理 中 ambient 的计算方式与 7.3 渐变纹理 中的不同。
这是 7.1 单张纹理 中片元着色器的部分代码
// Use the texture to sample the diffuse color fixed3 albedo = tex2D(_MainTex, i.uv).rgb * _Color.rgb; fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz * albedo; fixed3 diffuse = _LightColor0.rgb * albedo * saturate(dot(worldNormal, worldLightDir));
这是 7.3 渐变纹理 种片元着色器的相关代码,我的问题也在最后两行代码上。
// Use the texture to sample the diffuse color fixed halfLambert = dot(worldNormal, lightDir) * 0.5 + 0.5; fixed3 diffuseColor = tex2D(_RampTex, fixed2(halfLambert, halfLambert)).rgb * _Color.rgb; fixed3 diffuse = _LightColor0.rgb * diffuseColor; fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz; // 为何不是这种方式来计算 ambient //fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz * diffuseColor;
上面是这两种不同方式计算 ambient 所带来的不同效果,个人觉得后面的效果要好些。还是说这个问题的答案并不绝对?两种方式都没有问题?如果是那样的话,那么 7.1 单张纹理 中 albedo 的计算方式是否也可以变为 fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz; ?可能有点钻牛角尖了,但确实比较困惑。望解答。
fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz;
这是 Chapter7-SingleTexture.shader 中用不同方式计算 ambient 后的效果对比。
The text was updated successfully, but these errors were encountered:
你好,这个问题你可以参考之前的issue。
Sorry, something went wrong.
@candycat1992 明白了,这两种ambient的计算方式都是经验模型而已,效果会有不同,但没有说一定谁就是更好的。谢谢。
No branches or pull requests
之所以有这个疑惑是因为 7.1 单张纹理 中 ambient 的计算方式与 7.3 渐变纹理 中的不同。
这是 7.1 单张纹理 中片元着色器的部分代码
这是 7.3 渐变纹理 种片元着色器的相关代码,我的问题也在最后两行代码上。
上面是这两种不同方式计算 ambient 所带来的不同效果,个人觉得后面的效果要好些。还是说这个问题的答案并不绝对?两种方式都没有问题?如果是那样的话,那么 7.1 单张纹理 中 albedo 的计算方式是否也可以变为
fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz;
?可能有点钻牛角尖了,但确实比较困惑。望解答。这是 Chapter7-SingleTexture.shader 中用不同方式计算 ambient 后的效果对比。
![](https://github.com/HongfeiXu/UnityShader_FLL/blob/master/Images/RampTextureIssue_2.png?raw=true)
The text was updated successfully, but these errors were encountered: