A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in '2D Experimental Preview' started by rustum, May 24, 2019.
Any updates on the light shafts?
Does Normal Maps work with sprite atlases now?
Any timeframe on full release?
Writing to normal buffer does not respect depth buffer! Please fix this!
We should be able to choose the light buffer and shadow buffer (if this also exist) sampling type. For pixel art style, we would very much like to have pixel perfect 1:1 pixel ratio to what is set on the main camera.
We also want to have the shadows's intensity to be controlled not only by the light but also by the shadow caster as well. This is because we want to control the intensity of the shadow, but at the same time we need ability to block light completely so we can control the leaking to the other side of the wall for example.
Also when you are drawing shadow, it seems like the objects that are outside of range of particular shadow casting light is also drawn into consideration.. I am looking at the frame buffer, and draw call increased whooping number of multiples when I started using shadow. I can understand some more draw call is needed , but most of the objects that are well outside the range of the light is still casting shadow for some reason. This has to be a bug? Maybe this is kind of thing that Unity is talking about to fix and currently working on?
I've been trying out your lighting-features and they are AMAZING.Thank you for making such wonderful tools.
I saw the Unity tutorial on how to make "light shine through leafs". In it you take theses sprites:
and make Sprite-Lights of them and make beautiful light-patches on grass:
Trying to make an 'inverse' cloud-shadow effect:
I thought perhaps I could do reverse effect, where I make a reverse sprite to make "shadow patches on grass" that resemble clouds passing overhead. I have done this and the sprite looks like this:
(it's like an inverse version of your light-patches sprite). The effect that I get with this on a Sprite Light 2D is beautiful, see here in this video:
However, with this solution, as you can see in the video, one always has to consider how to handle the edges of the where the "Sprite Light 2D"-sprite ends. You can see this edge of sudden light/dark appearing around the sprite when the "cloud" moves downward in the video above. Due to this the Light Sprite 2D becomes difficult to use here and probably for other similar purposes.
Because of this I am wondering if you are planning on adding something like a "Shadow Sprite 2D" (much like your "Shadow Caster 2D" script)? What I mean is a feature where a sprite becomes a 2D-shadow (unlike your wonderful Shadow Caster 2D that casts a shadow). And if not, would you consider it?
If it existed for example I, and others in a similar position, could simply use sprite like this:
And use it to become/"cast" a shadow in the world.
I think it would be a very powerful tool for developers and enable even more flexibility (especially when you've created such a powerful system for manipulating light.)
Thank you so much in advance!
Some people accomplish an effect like this by putting a screen-sized sprite in front of the camera with a shader that animates the clouds so they swirl in and out. The shader takes into account the worldspace position so that as the camera moves about the position changes so the swirling clouds appear to have a real worldspace position independent of being of the sprite, which stays locked in front of the camera. Other weather effects, like rain, can be done in a similar way. As someone who didn't gravitate to shaders as a solution because of their unfamiliarity, Shader Graph makes stuff like this way easier than it used to be. Might be worth investing some time in.
Is there an update on the state of the _CameraOpaqueTexture? If I'm not mistaken it's still broken in then 2D renderer :/
Unfortunately, you are not mistaken. It's still making its way to the top of the list of things we need to do.
Make your own shader based on the Sprite-Lit-Default and in every pass, multiply the value by the _Color property before returning.
Maybe change the title of this thread since there's no more LWRP...
@SlimeProphet Good point! Done!
Hey! Been using the lights for a while and really enjoying them and the wider 2D features.
Something recently prompted me to go back and look at my tilemaps which have secondary normal textures applied. When I rotate them in the tilemap editor the normal maps don't rotate alongside the tile's sprites, which I gather is because the normals are calculated from UVs, so they don't (and shouldn't) line up if rotated. Lazy past me just generated all 4 sides of the tilemap which is a fairly inefficient way of doing it but worked.
I wondered if anyone could point me in the right direction for how to go about doing this for future projects (this has been most useful). Seems like it might be a job for a custom shader?
I think this is a bug and should be reported.
Any timeframe on Normal Maps working with sprite atlases?
+ Target sorting layers available on script?
This is already working but you need to be using Unity 2020.2 alpha. I am not sure if it works with 2020.1
It will be cool to have some official stand on this, which version of Unity and URP it is supported.
Do you mean normal maps or target sorting layers or both?
I'll check it out, because if it's not working its a bug. If it is working, I'll try and track down what version of unity/urp its working in.
Hey there! I was wondering if there is anyway to achieve filtering and layer masking within the 2DRenderer? If not, are there plans to include render features in the future?
Hi, A project I'm working on is using Universal RP 7.3.1 and Unity version 2019.4.1f1.
I've been having trouble trying to get a custom image effect shader working in the 2D rendering pipeline. I'm trying to do a cut-out lighting effect similar to this.
My plan of attack was to render all light sprites to a render texture, then on another camera render all sprites as unlit. There would then be an image effect shader that combines these two results using some blend. Unfortunately, I can't seem to even get a basic custom image effect shader working at any capacity, even something like making everything grayscale. Does the 2D rendering pipeline not currently support custom image effects, or is there some resource out there that I can try to get this to work? I've tried the following:
https://github.com/Unity-Technologies/PostProcessing/wiki/Writing-Custom-Effects (The 2D rendering pipeline doesn't seem to allow custom Renderer features when I look on a 2D Renderer Data asset)
https://www.alanzucconi.com/2015/07/08/screen-shaders-and-postprocessing-effects-in-unity3d/ (Universal RP doesn't seem to support Graphics.Blit() like the built-in renderer does)
For legacy renderer, we were able to choose between different HDR buffer format to save some performance on lower capable hardware such as mobile or Switch. What is the default HDR buffer format used right now and is there way to change it if it is using F16 format?
Right now these formats are specified by the Universal RP Asst. The default HDR format appears to be GraphicsFormat.B10G11R11_UFloatPack32 if alpha is not needed, and GraphicsFormat.R16G16B16A16_SFloat if it is. If these formats are not supported then it falls back to the platform's default HDR format.
To answer the second part of your question, it doesn't look like there is a way to change this.
Thanks for the info. At least I know it now. Hopefully we are able to set the format as we need. How can we tell renderer that we need to be able to write to the alpha?
It is controlled by Graphics.preserveFramebufferAlpha which reads the value from the player settings.
Ok, so Graphics.preserveFramebufferAlpha = true means do not write to alpha right? Making format GraphicsFormat.B10G11R11_UFloatPack32 and if false making GraphicsFormat.R16G16B16A16_SFloat
Forgive me if I am asking stupid question, but I cant find this option about Graphics.preserveFramebufferAlpha anywhere in the player settings.
Graphics settings has :
And there is nothing that I can tell on URP Pipeline Asset or Renderer Asset...
Can you tell us exactly how / where to find this option please?
Thanks, much appreciated!
Hey there! I just added the 2D lighting to my game, and I'm trying to write a cel/toon shader to light my sprites. However I can't seem to access lighting information in shader graph. Is this currently possible?
Is there any update on this?
I'm sorry, I still don't have an update. Since there seem to be a number of people interested in this I'll try and post an update when I have one.
Ok the above thread tells me that it is mobile only option. Desktop and Console platform does not even show this option in the player setting. Since I am actually interested with Desktop and Console platforms, I am curious to know and can assume that Graphics.preserveFramebufferAlpha is always set to false for console and desktop build? forcing HDR format of GraphicsFormat.B10G11R11_UFloatPack32 at all times without any choice?
Hey there, would just like some confirmation on whether you can interact with 2D lighting information in shader graph or the ability to do so is in the works.
You can interact with the lighting information in shader graph.
There are 4 light buffers that correspond to the light buffers of the blending styles. They are global textures and named:
If you create a texture2d on the blackboard and use those names in the ref field, they will reference the light buffers.
There may be changes to these names or the way lights work as the 2D Renderer is still experimental.
Yes. If you need a different format, you might want to try and bring it up in https://forum.unity.com/forums/universal-render-pipeline.383/
This is functionality built-in to Universal RP and not specific to the 2D renderer.
Thanks Chris! Is there currently any documentation on how this works? I cant seem to find anything in the Unity Documentation.
SpriteAtlas support for Secondary Textures is added in 2020.2. Thanks.
Wonderful to hear! Any chance you can support runtime Sprite Atlas generation for mods / content from web? Even if there's a reduced feature set, it would be very helpful in all kinds of scenarios.
I've looked into the shader code, and it appears that normal map interaction happens on the light2D shader using some sort of normal map shared between sprites rather than light direction data being used on the object (unless I've misread what is happening, fairly new to shader code).
If I'm correct, this means that I could not, for instance, have an object use its normal map for toon shading and another use regular normal shading, nor control color for shaded areas separately without also changing it for every other object.
I just made a post about an issue I'm having with 2D lighting. After I posted I noticed this thread. Maybe I should have posted the issue here instead.
Here is a link to my post: https://forum.unity.com/threads/strange-outline-when-using-2d-lighting-normal-maps.955980/
We don't have any docs or shadergraph samples for this at the moment. We are sorting some things out with the way light buffers work, I think when the changes are online, we can add a shadergraph sample or docs.
Were you able to get what you wanted working?
I dont think what I would like to do is possible yet without some heavy modification that is likely beyond my skill. When I looked into the shader code it looked like normal maps (and maybe light maps too) are processed on the light rather than the sprite. So if I wanted to change the way a mapped sprite is affected by the light, it would affect all sprites. Meaning, for example, I couldn't have one sprite cel shaded and another sprite normal shaded, or have light masks affect different sprites differently.
I could just be misinterpreting how the shader code works though, since I am fairly new to it.
Perhaps a solution could be an option to have the light directions render to something like a _ShapeLightNormals[index] texture similar to how the light buffer is rendered, and maybe stick attenuation in the alpha channel of the light buffer (if that's possible since it seems like the alpha channel is unused) so that we can perform shading calculations on the sprite?
Can you at least let us know "guesstimate" on when this will happen? We would like more information on schedules about 2DRenderer development.
I'm having issues with the lighting on 2D sprites with normal maps flickering as the camera moves.
Here are two zoomed in images. Both same gameobject/sprite/normal but camera in different places.
As you can see the lighting on the 'lip' changes as the camera moves. This causes a flickering effect when the camera is in motion.
I also get some flickering on the outside edges of the sprite.
I guess this is caused by the normal map lining up with the pixels in different ways depending on the camera position and so sometimes the normal colour gets blended with neighbouring colours.
This is probably only a real issue when you have hard edges in your normal map. Not having hard edges is a pretty big limitation though.
Has anyone had any experience with this issue? Maybe there is something I can do to fix it?
I would first vheck two things.
1. Pixel perfect placement of sprite.
2. Pixel perfect placement of camea.
And maybe also check the light buffer size to be 1 so it matches your screen size.
Where do I find the light buffer size?
Not sure which thread to ask for this, but each of our scenes has a global light in it and there are multiple situations where we are loading up multiple scenes and we're receiving the error from Light2D.cs:427
Debug.LogError("More than one global light on layer " + SortingLayer.IDToName(sortingLayer) + " for light blend style index " + m_BlendStyleIndex);
I get why it's there, but whenever, we're doing processing that requires multiple scenes to be loaded up that error shows up in the log. Is there anyways I could ask for a static bool added to the codebase to disable this check? Or maybe have a checkbox on the 2D renderer settings that we can turn off for our project? I can add it myself, but I don't particularly want to have to update everytime we update the URP.
Does _CameraOpaqueTexture work with 2DRenderer?
I get why you need this. Let me look into this and I'll get back to you.
Not at the moment.
Let me ask about what I can talk about.