#This is a Colour float 4

1 messages · Page 1 of 1 (latest)

willow jay
#

SampleTexture is just a way to get color/float4 information from an asset into the graph
Graph logic is in almost all cases exactly the same regardless of whether the color information is sampled or procedurally generated

#

Your sprite is a sampled texture, isn't it though?

turbid epoch
#

It's a combination of several sampled textures

#

So for instance you pick a head type, you can what kind of ears you want... leg variations, a body... etc and it combines them all + changed colours to get an end product

#

I then need to add the outline to the final product.

The only other way is for to generate an outline for every single texture, add them all together and then add the colour to the outline

#

But it seems really taxing?

heady bay
#

Assuming you sample all the sprites in one shader.

turbid epoch
turbid epoch
#

Here is the end product alpha

turbid epoch
# heady bay Why not?

I don't know how? If I create a UV offset, I don't know how to apply it to the alpha

willow jay
#

I'm quite sure using many textures instead of several is compatible with the tutorials about the topic

turbid epoch
#

They all end with telling you to put the UV offset into a sampled texture UV input

willow jay
#

The outline calculations don't care if they're working on a single sampled texture or a sum of many sampled textures

heady bay
turbid epoch
#

I'd have to run the outline for every single texture then and so far it seems the only option even if it doesn't sound optimal

#

Sample head, offset 4 times
sample face, offset 4 times
sample ears, offset 4 times
sample legs, offset 4 times

if they have a hat? offset 4 times
if they have glasses? offset 4 times

Is that really the only way?

#

If I could just get the final produced colour4 and create a texture from that and sample that, it'd be far better

Is that not possible?

heady bay
turbid epoch
#

I guess I'm worrying too much about optimizing it, I suppose the GPU would hardly care about the additional tasks

#

I'll just offset every single image that's part of the final product then

heady bay
#

Hmm. Hard to say. Texture sampling is kind of heavy

turbid epoch
#

It will pretty much double the sampling needed

willow jay
#

If something looks or feels expensive it doesn't mean that it is, only testing would prove that

#

There are many techniques for outlines besides though

turbid epoch
#

Yeh but it does seem all of them will require me to do the outline process per texture

willow jay
#

There are also screen space outline techniques (as well as geometry outlines, but hardly relevant here)

heady bay
#

I think you could do some stencil related magic with a renderer feature🤔

willow jay
#

It's also possible to generate a texture of the "sum" image, but not purely with shader graph (and not with my abilities)

turbid epoch
#

If I am going to do this approach maybe I should just have 2 images for each texture

  1. The RGB
  2. Outlined

And then just add all the outlines up at the end

turbid epoch
willow jay
#

Saving what data you can into textures is usually for the best

turbid epoch
#

Just wondering if there would be a better way where the character creates an image at the start, exports it as a texture and then uses that texture

#

Does the shader run it's code constantly like an update? If so my shader is recoloring several images, adding several images together and adding several outlines together which sounds terrible

#

Might be a bit more work getting it running but probably the best solution?

heady bay
#

I'd just look up screenspace outline solutions.

willow jay
#

All I know is that shaders can save data into render textures for later use, and compute shaders have even more options for doing so
But I don't recommend going down that route unless this already sounds familiar

heady bay
#

For a 2d game I think that's the optimal solution.

willow jay
#

Look into screenspace outlines as said, or into saving the outlines into textures

turbid epoch
#

no... I'm new to Shaders and graphical stuff

#

Yeh but to my question though with how shaders work, do they constantly run through their code or only when a value is updated?

#

I just simply ask this because I wonder if it's really inefficient me adding all these together in a shader?

heady bay
#

Unless we're talking compute shaders, where you have full control over when they're executed.

turbid epoch
#

Yeh so isn't it really bad for me to add 6+ textures together each frame for each character?

Wouldn't it be far better for me to create a script to generate the texture once and then keep it?

willow jay
#

A shader runs (very generally speaking) for every pixel displayed of the material
But guesstimating performance cost is kind moot

heady bay
heady bay
#

If so, you'll have to recreate the texture every frame anyway.

willow jay
#

Doing texture operations with a script on the CPU is much, much slower generally than on the GPU with a shader
But it depends on testing

turbid epoch
#

Thing is I have a 3080 ti for graphical tests don't give me good data honestly... Can I handicap my gpu for testing?

heady bay
#

Sure, you could render it once into a stencil buffer or something and then use it in the actual shader, but that would basically be 2 passes as I suggested previously.

turbid epoch
#

Oh wait you said I can just save the material output somewhere I think

willow jay
#

Or you can draw the outlines on the sprites, and mask them out when needed

heady bay
turbid epoch
#

I really over complicated this I think

heady bay
#

It all depends on whether your characters are dynamic or static. If they animate, you'll need to "recreate" the outline every frame anyway.

turbid epoch
#

This is an example of what a body looks like

willow jay
#

If it's drawn with a specific color, you can lerp/mask out that color to separate it so you can recolor it or add it to emission or whatever

turbid epoch
#

Hang on I have an old version somewhere that shows it

#

I realize I actually use the alpha and subtract it from the old image to then add the new colours

#

Which would break this idea... Unless there is something I can do to override colours when I add instead of being additive? PikaThink

turbid epoch