gpt4 book ai didi

c - 阴影和底纹

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:26:02 27 4
gpt4 key购买 nike

我在网上看了很多光线追踪算法。但是,我对阴影和阴影没有清楚的了解。根据我的理解,下面的伪代码是否正确?

for each primitive 
check for intersection
if there is one
do color be half of the background color
Ishadow = true
break

for each ambient light in environment
calculate light contribution to the color

if ( Ishadow == false )
for each point light
calculate diffuse shading
calculate reflection direction
calculate specular light


trace for reflection ray // (i)
add color returned from i after multiplied by some coefficient

trace for refraction ray // (ii)
add color returned from ii after multiplied by some coefficient

return color value calculated until this point

最佳答案

您应该将阴影与正常的光线追踪路径相结合:对于每个屏幕像素,您通过场景发送一条光线,并最终确定最近的对象交点:在最近的对象交点处,您首先会读出像素颜色(该点处对象的纹理),除了计算反射 vector 等(使用法线 vector )之外,您现在可以另外从该交点向场景中的每个光源转换一条光线:如果这些光线与其他物体相交在击中光源之前,交叉点处于阴影中,您可以相应地调整该点的最终颜色。

关于c - 阴影和底纹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13126252/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com