- Home /
Question by
Benjamen247 · Feb 03, 2018 at 10:57 AM ·
shaderslightlightmapshadowmap
Get the light texture from a spotlight
I am trying to get the light texture from a spotlight, the area which is illuminated from the spotlight.
I have tried using command buffers on the shadowmap for the light, but the resulting texture is always black. Here is the code I have tried:
public RenderTexture lightMap;
public Renderer demoPlane;
Light _light;
CommandBuffer buffer;
void OnEnable()
{
if (!lightMap)
lightMap = new RenderTexture(256, 256, 0, RenderTextureFormat.ARGB32);
_light = GetComponent<Light>();
buffer = new CommandBuffer();
buffer.name = "Get Light Buffer";
buffer.Blit(BuiltinRenderTextureType.GBuffer3, lightMap);
_light.AddCommandBuffer(LightEvent.AfterScreenspaceMask, buffer);
demoPlane.material.mainTexture = lightMap;
}
private void OnDisable()
{
_light.RemoveAllCommandBuffers();
}
Any information to point me in a direction as to how to get the texture of a light would be greatly appreciated.
light-texture.png
(45.9 kB)
Comment
Your answer
Follow this Question
Related Questions
How to access shadow map depth values? 0 Answers
Baked light problem 0 Answers
Lightmap - Blotchy & Square 1 Answer
Baking from cubemap to LightProbes 0 Answers
Beast Lightmapping - No shadows when doing "Bake Selected" 2 Answers