#This is a Colour float 4
1 messages · Page 1 of 1 (latest)
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?
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?
Then add up all the colors and lastly check the alpha of it or something.
Assuming you sample all the sprites in one shader.
Yeh I'd love to do that and that is what I wanted to do but I can't then move them to create the outline
Why not?
Here is the end product alpha
I don't know how? If I create a UV offset, I don't know how to apply it to the alpha
I'm quite sure using many textures instead of several is compatible with the tutorials about the topic
They all end with telling you to put the UV offset into a sampled texture UV input
The outline calculations don't care if they're working on a single sampled texture or a sum of many sampled textures
Sample all of the textures with offset and then add up their value.
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?
The only other way I can think of is using several render passes.
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
Hmm. Hard to say. Texture sampling is kind of heavy
It will pretty much double the sampling needed
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
Yeh but it does seem all of them will require me to do the outline process per texture
There are also screen space outline techniques (as well as geometry outlines, but hardly relevant here)
I think you could do some stencil related magic with a renderer feature🤔
It's also possible to generate a texture of the "sum" image, but not purely with shader graph (and not with my abilities)
If I am going to do this approach maybe I should just have 2 images for each texture
- The RGB
- Outlined
And then just add all the outlines up at the end
If I want customization characters I think this might be the way to go though, does the shader run this process constantly or only on changes?
Saving what data you can into textures is usually for the best
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?
I'd just look up screenspace outline solutions.
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
For a 2d game I think that's the optimal solution.
Look into screenspace outlines as said, or into saving the outlines into textures
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?
Shaders are executed every frame. They're what bringing the picture to your screen.
Unless we're talking compute shaders, where you have full control over when they're executed.
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?
A shader runs (very generally speaking) for every pixel displayed of the material
But guesstimating performance cost is kind moot
If that's within your gpu time budget, why not. Got to test and profile.
But aren't your sprites animated?
If so, you'll have to recreate the texture every frame anyway.
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
Thing is I have a 3080 ti for graphical tests don't give me good data honestly... Can I handicap my gpu for testing?
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.
Yeh but it'll be a 1 off operation.
I can use a shader for realtime modifications so they can see the results and when they are done pass it to the CPU to generate the image, save it out and use it.
Oh wait you said I can just save the material output somewhere I think
Or you can draw the outlines on the sprites, and mask them out when needed
You can still make some educated guesses. If it takes 4 ms on your PC it would probably take 8 on one that's twice as slow(way more complicated than that, but still)
That's a point... the textures are RGB separated so why the hell don't I just draw the outlines on the image and then use the Alpha? derp..
I really over complicated this I think
It all depends on whether your characters are dynamic or static. If they animate, you'll need to "recreate" the outline every frame anyway.
This is an example of what a body looks like
A very simple way to do the outline would be to draw it on the RGB channels normally, and with grey on the alpha channel, so you can make it pop in/out just by changing the alpha threshold
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
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? 
Just reread this and that would be the solution, thank you