Search Unity

Assets Realtime Indirect Lighting Using a Cubemap

Discussion in 'Works In Progress - Archive' started by Atomike, Nov 15, 2017.

  1. Atomike

    Atomike

    Joined:
    Mar 25, 2014
    Posts:
    15


    At this point in time, actual Realtime Indirect Lighting is extremely hardware taxing to pull off with today's technology, however I may have found somewhat of a solution. This solution allows non-static meshes to receive indirect light in realtime, meaning it can be used for day-and-night cycles. The idea stems from a lighting technique known as IBL, or Image Based Lighting, in which an object's lighting is calculated completely from a cubemap. To emulate this I have a 32x32 cubemapped RenderTexture which I have set as the ambient light source of the scene, and both refresh on Void Update (). The RenderTexture receives it's input from a camera positioned inside the player character. This seems to get the job done for small, moving objects such as the player, however the downside is that the lighting effect is applied to ALL meshes on-screen. Obviously I only want this to apply to a single object so there is much work needed to be done.

    I'm wondering if it would at all be possible to create a shader which uses the cubemap as an ambient light source rather than the Scene's ambient light in order to allow the indirect lighting to only be applied to the material with the cubemap set as it's ambient light source, however I have no experience writing shaders in Unity so I wouldn't know the feasibility of such a shader.