How to write light function/shader for point light like unreal engine4

I want to mix point light with a cubetexture

You mean like an image projection from a point? See this thread: Texture Projection

Hm, actually it can be solved much easier with a CubeTexture, if you don’t care about rotation… I am not sure I can resist this one…

3 Likes

https://jsfiddle.net/EliasHasle/s3mojxh1/83/ (Updated version with brightened texture artificially visible on light source too. Not really consistent with the light pattern on the environment, as that assumes light only from the nearest direction.)

Silly texture, though… I would really like to see this with a better texture. :smiley:

Update: The same, but with 1x1 textures on the sides, making very pronounced interpolation.

3 Likes

With diffuse shading and quadratic decay of light: https://jsfiddle.net/EliasHasle/s3mojxh1/88/ (Update: same with 1x1 textures)

With Pisa texture (used in three.js examples): https://jsfiddle.net/EliasHasle/s3mojxh1/104/

3 Likes

wow,thank you very much

No problem. I learned from it. :slight_smile:

I still wonder what you need this for. The demo isn’t exactly production-ready for all purposes. There are no shadows, and the shading of the receiving material basically depends only on the projector. Ideally, one would want to tap into existing code for lights.

Are you planning to combine it with cube cameras to use as light probes? (Light probes do pointwise measurements of light fields, and can be combined to approximate global illumination.) There are some existing projects with light probes. See related issues/PRs.