自定义阴影颜色 [英] Customizing shadow color

查看:51
本文介绍了自定义阴影颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于自定义阴影颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆