Phaser灯光问题

huangapple go评论52阅读模式
英文:

Phaser Lighting issues

问题

这是使用Phaser的WebGL光照的代码示例:

this.lights.enable();
this.lights.setAmbientColor(0x808080);
this.spotlight = this.lights.addLight(2040, -200, 20000).setIntensity(20);

我试图覆盖非常大的距离,如20000像素的半径,基本上是游戏内的太阳,我面临的问题是如何让大区域明亮,但又不会使顶部过于明亮,以至于你只能看到白色。

英文:

So I'm using the phaser webgl lighting

this.lights.enable();
this.lights.setAmbientColor(0x808080);
this.spotlight = this.lights.addLight(2040, -200, 20000).setIntensity(20);

I'm trying to cover really large distance, seen in that 20000px radius, basically an in-game sun, and I face the issue of actually making the large area bright, but not have the issue of the intensity making it so bright at the top that you can only see white over there

Phaser灯光问题
Phaser灯光问题

答案1

得分: 0

以下是翻译好的部分:

"如果你想要光照效果,像所有2D游戏一样的简单方法是伪造它。这里有一篇精彩的文章介绍了如何在Phaser中创建一个昼夜循环,尽管有点陈旧,但它详细解释了如何实现这一目标。

而在文章中描述的大致方法是一个简单而不错的解决方案。基本上:

  • 太阳只是一个图像
  • 通过叠加和alpha值可以实现明暗效果(如果想要淡化效果,请在叠加层中使用渐变)"
英文:

Well if you want a lighting effect, the easy way like by all 2D games is to fake it. There is a brilliant article on how to make a day/night cycle in phaser, it is abit dated, but it explains exactly how you can achieve this.

And more or less something like, discribed in the article is a easy and good solution. Basiclly:

  • the sun is just an image

  • the darkness and brightness can be achieved with overlays and alpha values (use gradients in the overlays if you want a fading effect)

huangapple
  • 本文由 发表于 2023年2月10日 04:07:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75403909.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定