Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Light Function material and Cubemaps


I'm trying to get fake shadows from a lamp using a material light function. I'm already using simple light functions with spotlights and 2D textures, but I would like to push that more, using point lights and cubemaps.

I baked a cubemap in Max around a lamp prop, and I'm trying to make it work with a light function material, but I'm stuck at that point. Here is what I have:

alt text

I've only found one thread about this topic here, but it didn't really helped me. I've tried 2 types of cubemaps, DDS generated with ATI Cubemapgen and HDR spherical. So far the light function seems to be totally ignored by my light actor. Other light material function we have in bank are working fine, but they all use 2D textures.

Product Version: UE 4.20
lfmat.jpg (290.8 kB)
more ▼

asked Feb 06 '19 at 09:17 PM in Rendering

avatar image

6 1

avatar image AlexeyLM Mar 27 '19 at 03:39 PM

It seems the best way is to use several Spots with LightFunctions. In this discussion, you will surely find the answer to your question https://polycount.com/discussion/190402/ue4-learning-lighting-art/p2 .

avatar image ThomasDidier Mar 27 '19 at 05:51 PM

Hey! I have found a workaround in the end, thanks :) Turns out the LightFunction projection is already using a spherical map out of the box, so nothing was required shader-wise, I just had to find the correct coordinate when baking a shadow and that was it!

avatar image BarrettMeeker 2 days ago

Can you show an example? I'm trying to get a similar effect. In UE3 I used the Light Vector for coordinates but it doesn't seem to work correctly in UE4. Thanks!

avatar image ThomasDidier 2 days ago


I don't have an example that I can show because of NDAs. But it's quite simple, I have found this documentation for Unity : https://docs.unity3d.com/uploads/ExpertGuides/Create_High-Quality_Light_Fixtures_in_Unity.pdf

I took a lot of inspiration from it, and it's actually easier to do in Unreal, since you don't need to render on 6 textures to create a cubemap. You only need to render your shadows on a sphere from a 360 camera.

Here is how I would do it:

• In your 3D software, place your lamp mesh and whatever lights you need inside it.

• Create a sphere around your lamp.

• Set your lamp mesh to be invisible to cameras (still needs to cast shadows, easily done with VRay or Arnold properties).

• Create a 360 camera at the center of your lamp mesh.

• Hit render, use a square resolution.

• Use that render as a texture in a light function material. Might require some tweaks in Photoshop to look the way you expect.

• Done! You may need to adjust the axis of your texture, since UE will not necessarily project it in the way you expect. To edit that quickly I simply created flip X & flip Y parameters in my master material, so I can tweak shadow projection easily in material instances.

avatar image BarrettMeeker 2 days ago

Thanks so much for your fast & detailed reply! Great documentation on it as well. I feel inspired by the caustics part.

If I'm understanding correctly then you aren't using a cubemap in UE4? Even for point lights you use a normal texture?

I had a cube map already, and it kinda works if I hook a light vector into the coordinates but tends to flicker off weirdly and apparently "Light Vector" coordinates are depreciated. I was hoping to find out what coordinates I should plugin to use a cube map. I might change to a spherical map though if that seems to work for you?

alt text

avatar image ThomasDidier 2 days ago

I'm not using a cubemap indeed, just the raw texture in a point light. I think the point light already has a built-in spherical projection for light functions. Just like you I started with cubemaps & complicated maths for UVs, but the solution was really that simple. I have not tried with spots though, IES are doing a good enough job for me, but I think they would totally work with light functions too, the projection is probably a simple plane at that point. And I tried caustics in one of my tests, it works beautifully :) The only thing that refrains me from using that everywhere is that UE's documentation specifies that light functions are heavy rendering-wise. I have not been able to profile them in a stress test yet, it's something I look forward to do.

Little tip, you might need to do your mipmaps by hand. You don't need a big resolution for your light function textures, but they tend to look wonky or even totally disappear in the distance when higher mip levels kick in. I would recommend to disable mipmaps to begin with.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question