自定义阴影颜色

编程入门 行业动态 更新时间:2024-10-11 09:25:27
本文介绍了自定义阴影颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以为阴影渲染指定黑色以外的其他颜色?我想允许用户同时试验光和阴影的颜色,例如.在光/影中使用互补色.

Is it possible to specify other colors than black for shadow rendering? I would like to allow users to experiment both with light and shadow colors, eg. using complementary colors in light/shadow.

这是我设置其他阴影设置的方法,效果很好.但我发现除了黑色/不同深浅的灰色之外,没有办法制作阴影.

Here's how I setup other shadow settings, and it works perfect. But I found no way to make shadows other than black / different shades of gray.

this._sun_light = new THREE.DirectionalLight(0xffffff, 1); ... this._sun_light.intensity = this.getParameter("sun_intensity"); this._sun_light.color.setHex(this.getParameterColorHex("sun_color")); ... this._sun_light.shadowDarkness = this.getParameter("sun_shadow_intensity"); ...

我在three.js\src\renderers\WebGLShaders.js 中发现了一些对shadowColor 变量的引用,但是理解该文件超出了我的心理能力,无法找到配置它的方法.考虑到阴影映射技术,这甚至可能吗?

I found some references to shadowColor variable in three.js\src\renderers\WebGLShaders.js , but understanding that file is way out of my mental capabilities, and couldn't find a way to configure it. Is this even possible considering the shadow mapping technique?

我能想到的唯一解决方法是让来自相反方向的其他光线照亮阴影区域,并被阴影区域外的主光抵消.但是当我开始添加更多灯光时,这可能很快就会变得混乱,如果它真的有效的话..

Only workaround I could think of is having other light from the opposite direction illuminating the shadowed areas, and getting kind of canceled by the mainlight outside shadow area. But that could soon get messy when I start adding more lights, if it worked at all..

推荐答案

shadowColor 变量在开始时只是设置为 1,如果启用了阴影,它会根据位置变得越来越暗.这个值最后乘以最终的颜色值,所以如果它仍然是 1 没有任何变化,但如果它小于 1 它会使最终颜色变暗.所以没有办法设置阴影的颜色.

The shadowColor variable is just set to 1 in the beginning and if shadows are enabled it gets darker and darker depending on the position. This value gets multiplied by the final color value in the end, so if it is still 1 nothing changes, but if it is less than 1 it makes the final color darker. So there is no way to set the color of the shadow.

更多推荐

自定义阴影颜色

本文发布于:2023-07-19 13:49:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1157126.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   阴影   颜色

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!