#Terraria specifically is using a light

1 messages · Page 1 of 1 (latest)

cunning yacht
#

As you mention blurring the RT texture, if the texture only includes light from the empty space you could use that to allow light to "spill" over to solid tiles when the blurry texture is overlayed to them

#

But it wouldn't prevent your light from passing through "under" the blocks

#

I would rather look into a flood fill algorithm to do it properly

hallow cape
#

Starbound doesn't even fix it.

cunning yacht
#

It certainly does?

hallow cape
#

Light can fully travel through blocks it is just very rare which a situation like that looks bad since the cave walls are so many tiles thick.

hallow cape
cunning yacht
#

In your case the cone of your flashlight would illuminate areas up to its maximum range as long as there's empty space on the path

hallow cape
#

I never tested flashlights in game, but torch lighting can certainly illuminate "through" walls

cunning yacht
#

In Starbound light propagation intentionally allows light through solid objects, but intensity is lost

cunning yacht
#

this would not be possible in your case

hallow cape
#

I guess I never really accounted for intensity being lost

#

so you suggest they use raycasting?

cunning yacht
#

For flash lights and spot lights they do

#

This is an alpha screenshot back from when torches used raycasting also

#

But now they and other light emissive tiles use the same type of light propagation as Terraria

hallow cape
#

hmm, strange idea to get that same effect.

#

How plausible would it be to have an invisible 3d pillar, and cast light that way?

#

for example where the blocks are surrounding the torch, a 3d example could very easily get that result.

cunning yacht
#

I don't quite understand

#

Pillar?
We're still speaking of 2D, right

hallow cape
#

One sec, I'll try to draw an example.

hallow cape
#

if it'd be easier that is.

cunning yacht
#

There's various option I suppose

#

But none of them are precisely the flood fill light propagation you're looking for

#

3D is quite different in many ways

hallow cape
cunning yacht
#

Starbound and Terraria allow light to spill through thin walls because even if that's not what would happen in reality or even in 3D it looks better

#

In 3D we would not see any light on the solid walls because they're occluded from the light

hallow cape
#

I'm quite desperate for a working and good looking system.

#

I had the initial idea of using a different shader on the "Background" tilemap, so it allows more light through, and have my "wall" tilemap absorb a significantly larger amount of light, but that seems to not be possible in unity.

cunning yacht
#

No such thing as "absorption" in this context, unless you're talking about how the existing light is blended on the wall

cunning yacht
hallow cape
hallow cape
#

But I don't think there is full documentation to the "right" way, because I am fairly certain they don't use light values for each individual tile as Terraria does. (Which is VERY slow famously)

cunning yacht
#

As far as I know they both do

#

How they do it may be entirely different

hallow cape
#

To my knowledge.

#

So they could very possibly have a system in place to dissipate lights / fake light dissipation that I'd need to create myself, but that's just a theory I have.

cunning yacht
#

That's all irrelevant though

hallow cape
hallow cape
cunning yacht
#

There's a whole lot contributing to Terraria's hiccups besides the choice of engine, as tehree's a whole lot it does
And you can make something optimized or unoptimized regardless of engine

hallow cape
hallow cape
cunning yacht
#

That makes no sense
They're not using FNA either

#

Anyway, where and how you store the lighting information is something to plan for

hallow cape
#

Terraria uses XNA

#

it seems

cunning yacht
#

Which is not FNA

hallow cape
#

FNA is used for macos ports of the game

#

along with linux and their modding platform TModLoader

#

again we are getting pretty off topic which I apologize for

cunning yacht
#

You probably don't want to store the lighting in tile data directly, to avoid having to load information unnecessarily

cunning yacht
#

Since lights often need to be calculated after the tiles anyway

hallow cape
#

my current approach is using render textures for lighting and using that to gather "light" values, and in separate shaders for both the background and "wall" tilemaps deal with those values differently.

#

But I really don't know if that's even a possibility using Render Textures as I've never tried in the past.

cunning yacht
#

You'll want to read up on flood fill algorithms
Searching for "flood fill light propagation" may give you more relevant examples but note that there are many different ways to do that so some examples could turn to be totally irrelevant

hallow cape
cunning yacht
#

It's just an algorithm, it can do that if you give it the means to do that

hallow cape
#

Hmm, alright!

cunning yacht
#

Which would be to reduce the value to fill with when iterating solid tiles

#

You can do it simply in a simple C# script, especially when practicing, but I foresee you may need to optimize it heavily

#

Usually these kinds of operations will need to since you're reading and writing so many tiles / texture pixels

hallow cape
hallow cape
#

I really don't know how Unity renders 2D at all, so I am not sure if it is a separate action per pixel or if it somehow works as a whole.

#

Working with tiles is way faster if that's the case I would assume.

cunning yacht
hallow cape
cunning yacht
#

When I say that you don't want to store lighting in tile data, I just mean you have the data separately, like in a texture

hallow cape
#

The tilemap acts as a large "sprite" that works as a whole unit

cunning yacht
#

Whether you have an array of tiles (a tilemap) or an array of pixels (a texture) doesn't make a difference for this purpose

hallow cape
#

similarly to how you'd light something like a 2d character?

cunning yacht
hallow cape
cunning yacht
cunning yacht
#

It will not help you with light propagation though

hallow cape
hallow cape
#

I am not expecting to get a perfect lighting system with one operation, but if I can just get the effect starbound has with just the foreground, that would be perfect.

hallow cape
hallow cape
#

does this allow the referencing of the blended lighting?

cunning yacht
hallow cape
#

a "2D Light Texture" is only usable in built-in to my knowledge.

#

a customlit shader graph "does not sample the Light Textures but it does have a Normal pass and a fallback Forward pass for use in non 2D Renderer."

cunning yacht
hallow cape
cunning yacht
# hallow cape

This is when using URP 2D Renderer and with Custom Lit Sprite Graph?

hallow cape
#

Yes.

cunning yacht
#

I've used it before for custom 2D emissive blending

hallow cape
cunning yacht
#

Without the 2D Renderer there is no 2D Light Texture to sample

hallow cape
#

I believe I am using the 2D render pipeline

#

Let me double check haha.

cunning yacht
hallow cape
cunning yacht
#

That looks correct, assuming it's in use

hallow cape
hallow cape
# hallow cape

should it state it is a "2D" Universal Render Pipeline Asset?

#

It is connected to one, so I'm guessing not. But it's good to be safe.

cunning yacht
#

The Quality tab of project settings can have multiple quality levels with different URP Assets

#

an URP Asset can have an "URP Renderer" or an "URP 2D Renderer"

hallow cape
#

I think we may have found an issue.

#

should I propagate that?

cunning yacht
hallow cape
#

I'm trying it now, I'll see if that fixes it.

#

yeah, I think I might be dumb.

cunning yacht
#

Shaders alone even with the light texture will still not let you do propagation though

hallow cape
#

I am glad that is the issue all along.

hallow cape
cunning yacht
#

"look like"?

hallow cape
#

I don't think I can display it in the shader as it's not in runtime.

hallow cape
cunning yacht
#

Basically yes

hallow cape
#

I'm still confused on how this Light texture actually works.

hallow cape
cunning yacht
#

If you have a 2D light illuminating a pure white Lit Sprite, the lighting you see is the same as on the Light Texture

hallow cape
#

Ah, alright.

#

So I assume this also stores color data for each pixel of light?

cunning yacht
#

Yea

hallow cape
#

Okay, this is definitely the best news I've gotten the past 12 hours or so of working on this haha.

#

I really appreciate it, I wrote this off as being a documentation issue.

#

I don't know what the "Quality" render asset wasn't propagated but I'm glad I can use this now.

#

I'll try to get a couple ideas working with this and I'll send screenshots here if I get anything I was looking to get ahah.

#

Also, thank you very much for the insight. It will definitely help a ton!

cunning yacht
hallow cape