admin管理员组文章数量:1026373
I want to make night vision camera like in outlast. And I need spot light only for this camera to light environment only through camera. In project that use built-in render pipeline I simply used this script
public class IgnoreNightVisionLight : MonoBehaviour
{
[SerializeField] private Light limelight;
private void OnPreCull()
{
limelight.enabled = false;
}
private void OnPreRender()
{
limelight.enabled = false;
}
private void OnPostRender()
{
limelight.enabled = true;
}
}
and MainCamera was ignoring light source from night vision camera successfully. But in URP project I think render is working other way so this script is not working anymore. I also tried just set special layer to light source and ignore it in culling mask of MainCamera but this also doesn't work. I also didn't find any solution in google so I don't know how can i fix this. If there are any other simple ways to create night vision camera that will light environment only for itself it'll be nice to get this
I want to make night vision camera like in outlast. And I need spot light only for this camera to light environment only through camera. In project that use built-in render pipeline I simply used this script
public class IgnoreNightVisionLight : MonoBehaviour
{
[SerializeField] private Light limelight;
private void OnPreCull()
{
limelight.enabled = false;
}
private void OnPreRender()
{
limelight.enabled = false;
}
private void OnPostRender()
{
limelight.enabled = true;
}
}
and MainCamera was ignoring light source from night vision camera successfully. But in URP project I think render is working other way so this script is not working anymore. I also tried just set special layer to light source and ignore it in culling mask of MainCamera but this also doesn't work. I also didn't find any solution in google so I don't know how can i fix this. If there are any other simple ways to create night vision camera that will light environment only for itself it'll be nice to get this
Share Improve this question edited Nov 18, 2024 at 14:19 derHugo 91.4k9 gold badges91 silver badges135 bronze badges asked Nov 16, 2024 at 23:52 WasTabonWasTabon 1431 gold badge1 silver badge7 bronze badges 7- can you ignore it by layer? – BugFinder Commented Nov 16, 2024 at 23:53
- It is not working. As i know, rendering light does not working as rendering 3d objects, so even if I trying to ignore this by layer it is not working. But if I do the same thing for 3d objects - camera will ignore that – WasTabon Commented Nov 16, 2024 at 23:59
- hmm, that seems dumb. Mind you, urp and lighting is a forbidden subject in this house so, i have other issues with it.. Id have expedcted the layer to work – BugFinder Commented Nov 17, 2024 at 1:34
- Do you mean just giving a separate layer to the light source and then removing that layer from the list in the camera component's culling mask? If yes, that doesn't work, neither in URP nor in Built-in; I've tried everything I could. I can send screenshots as proof. – WasTabon Commented Nov 17, 2024 at 1:44
- 1 TBH I wasnt planning on hunting through the bowels of youtube trying to find it, but I have seen something where they had like torches and those torches werent rendered on all cameras, but with that info, I would have as much chance of finding it as you do – BugFinder Commented Nov 17, 2024 at 13:36
1 Answer
Reset to default 1Not tested but I guess from this thread you can go through RenderPipelineManager
and do something like
public class CameraLight : MonoBehaviour
{
[SerializeField] private Camera _camera;
[SerializeField] private Light _light;
void OnEnable()
{
RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
}
void OnDisable()
{
RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
}
void OnBeginCameraRendering(ScriptableRenderContext context, Camera cam)
{
if (cam == _camera)
{
_light.enabled = false;
}
}
void OnEndCameraRendering(ScriptableRenderContext context, Camera cam)
{
if (cam == _camera)
{
_light.enabled = true;
}
}
}
I want to make night vision camera like in outlast. And I need spot light only for this camera to light environment only through camera. In project that use built-in render pipeline I simply used this script
public class IgnoreNightVisionLight : MonoBehaviour
{
[SerializeField] private Light limelight;
private void OnPreCull()
{
limelight.enabled = false;
}
private void OnPreRender()
{
limelight.enabled = false;
}
private void OnPostRender()
{
limelight.enabled = true;
}
}
and MainCamera was ignoring light source from night vision camera successfully. But in URP project I think render is working other way so this script is not working anymore. I also tried just set special layer to light source and ignore it in culling mask of MainCamera but this also doesn't work. I also didn't find any solution in google so I don't know how can i fix this. If there are any other simple ways to create night vision camera that will light environment only for itself it'll be nice to get this
I want to make night vision camera like in outlast. And I need spot light only for this camera to light environment only through camera. In project that use built-in render pipeline I simply used this script
public class IgnoreNightVisionLight : MonoBehaviour
{
[SerializeField] private Light limelight;
private void OnPreCull()
{
limelight.enabled = false;
}
private void OnPreRender()
{
limelight.enabled = false;
}
private void OnPostRender()
{
limelight.enabled = true;
}
}
and MainCamera was ignoring light source from night vision camera successfully. But in URP project I think render is working other way so this script is not working anymore. I also tried just set special layer to light source and ignore it in culling mask of MainCamera but this also doesn't work. I also didn't find any solution in google so I don't know how can i fix this. If there are any other simple ways to create night vision camera that will light environment only for itself it'll be nice to get this
Share Improve this question edited Nov 18, 2024 at 14:19 derHugo 91.4k9 gold badges91 silver badges135 bronze badges asked Nov 16, 2024 at 23:52 WasTabonWasTabon 1431 gold badge1 silver badge7 bronze badges 7- can you ignore it by layer? – BugFinder Commented Nov 16, 2024 at 23:53
- It is not working. As i know, rendering light does not working as rendering 3d objects, so even if I trying to ignore this by layer it is not working. But if I do the same thing for 3d objects - camera will ignore that – WasTabon Commented Nov 16, 2024 at 23:59
- hmm, that seems dumb. Mind you, urp and lighting is a forbidden subject in this house so, i have other issues with it.. Id have expedcted the layer to work – BugFinder Commented Nov 17, 2024 at 1:34
- Do you mean just giving a separate layer to the light source and then removing that layer from the list in the camera component's culling mask? If yes, that doesn't work, neither in URP nor in Built-in; I've tried everything I could. I can send screenshots as proof. – WasTabon Commented Nov 17, 2024 at 1:44
- 1 TBH I wasnt planning on hunting through the bowels of youtube trying to find it, but I have seen something where they had like torches and those torches werent rendered on all cameras, but with that info, I would have as much chance of finding it as you do – BugFinder Commented Nov 17, 2024 at 13:36
1 Answer
Reset to default 1Not tested but I guess from this thread you can go through RenderPipelineManager
and do something like
public class CameraLight : MonoBehaviour
{
[SerializeField] private Camera _camera;
[SerializeField] private Light _light;
void OnEnable()
{
RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
}
void OnDisable()
{
RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
}
void OnBeginCameraRendering(ScriptableRenderContext context, Camera cam)
{
if (cam == _camera)
{
_light.enabled = false;
}
}
void OnEndCameraRendering(ScriptableRenderContext context, Camera cam)
{
if (cam == _camera)
{
_light.enabled = true;
}
}
}
本文标签: cHow to ignore light source on main camera in urpStack Overflow
版权声明:本文标题:c# - How to ignore light source on main camera in urp? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745643314a2160876.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论