#While I can just bake the tree s colors
1 messages ยท Page 1 of 1 (latest)
It will vary based on the object in question.
For the tree, since it has Green and Brown
I would need two ramps if I wanted it to have a single material
likewise, for something like a house
it might need more ramps to compensate for the multiple colors that go into that
Hence my questions about instanced materials, and whether or not they're worth considering as an option
I don't understand if ramp is the texture, a ramp is sampled for a (solid color) texture, or if a texture is sampled for a ramp
if Instanced Materials aren't as performantly heavy as regular materials, I might consider just using those, somehow.
The object's lighting is converted into greyscale, and then used as an alpha to blend between two colors, or so I assumed. Are we thinking of different definitions of a color ramp?
So I need to be able to define at least two colors, light and dark, and have the object lighting be used to create a gradient between those two on the object in question
I could try making you an example in blender if this isn't making sense to you.
That might help
One moment
I'll whip up a quick example.
@sharp wasp As you can see here, this tree has two materials, in blender. One for the leaves, and one for the wood. Each having a unique pair of two colors in its color ramp
I can't think of a way to replicate this in Unity without actually HAVING multiple materials
which isn't performant
Which is why I was asking about Instanced Materials, which I don't quite understand in terms of how they contribute to draw calls, and how efficient/inefficient they are
Will the lighting be baked or does it react to lighting changes on unity side?
Sorry for so many questions xD
It will need to react to lighting changes, yes
this methodology, if I can get it working at all
will be applied to everything in my scene, in some form or another
this is because my game using a color grading system which chooses "weird colors" from time to time
and a simple color ramp corrects for this autonomously.
Here's an example I showed to some other people
The default scale of lighting from dark to light on a white object results in "weird colors" being chosen by my palette forcing setup, as a consequence of distance comparisons in color space
But by using a color ramp to map light values to a color range and ignoring color data
I can correct for this
using a theoretical "red object being lit or darkened"
compared to one who has had its color value stripped, and its lighting data fed directly into a color ramp of my own choosing
While I could use a hackneyed solution involving blueshifting towards darker colors and apply it to all materials and colors universally to MAYBE get a similar result
it would still result in "weird color" issues with my grading method, which is easily solved in blender at least through the use of color ramps
This color grading, does it happen in the object's shaders or as a full screen post process?
It's a full screen post process. It's expensive, but it ensures that literally everything in the game, no matter what I do or what lighting it is in, will comply with my palette.
I have some examples if oyu want to see them
The challenge with that I suppose is that it won't know when to use a different shadow color per surface
Yes
which is why I'm asking about the best way to handle using multiple color ramps on a single object
And whether or not Instanced Materials are meaningfully useful in something like this
essencially
if this helps explain my goal at all
I want to be able to assign parts of a model specific colors (that have associated color ramps that are fed their lighting values)
Aren't material instances just at runtime duplicates of existing materials?
To my knowledge, yes.
Which is like, the exact opposite of optimized
Assuming there has to be a custom light ramp per object in addition to the grading PP, the crude approach would be to use separate materials for each part with a property for shadow color and light color
Which is what I want to avoid, since using seperate materials for each part, or so I've heard, is basically the worst possible thing to do.
Doable, but won't work with GPU instancing or SRP batching
So the question comes down to how can we store two different colors per surface with the exact same material for everything
It's strange to think I can't just use one material for everything and change its colors for each part.
Well you can if the colors are stored in a texture
"Palette mapping" it's sometimes called
I did consider the solution of just baking two textures, one for lights, and one for darks
Then the material could simply be fed both colors as texture maps
and plug them into the ramp
but that's a fairly excessive amount of work and allows for zero tweaking in unity
all editing I did would have to be in Blender itself,
https://i.stack.imgur.com/hVMcw.png talking about this technique
If every object samples the same palette, it'll be perfectly compatible with GPU instancing
Since we need a shadow color as well, my idea is to either use vertex colors for that, or sample the same palette texture plus/minus one grid cell's length
Interesting. I'd have to set up a special texture that has color ramps built in, exactly.
So the shadow color would always be grabbed from an adjacent tile on the palette
So the tree's UVs would all be on the "light green" cell
while the Light and Darks would be sampled from surrounding cells
That's intriguing.
Yes
Both ideas are kind of clumsy if you need to change stuff afterwards but I guess they'd work
definitely clumsy.
I MIGHT experiment with it, but at this point, it's looking more like I'll just be having to put up with "Weird Colors" in my fullscreen shader.
And the adjacent cell method only works if you can trust that the palette cells are at a defined distance
Yeah, I'd have to make the palette texture myself
But that distance could be defined as a global float
So you can change it easily if you need to change the cell grid size
Another possible problem is that this would be completely incompatible with certain other things
since the UVs would be turned into glorified color pickers
I couldn't effectively use the UVs for normalmaps or anything other than those palette setups
due to them being much smaller
Or the palette would need to be inordinately large
True, not ordinarily
There can be multiple UV channels though
For example unity uses the second channel for baked lightmapping
Yeah, but I also have to take into account the unspoken resource of personal time required
If every material and object I make requires TOO many hoops to jump through to set up a very simple visual effect
Time might be better spent elsewhere.
If you've got the color picker thing operational it shouldn't be much effort to make new assets
The palette texturing method is probably the quickest one out there anyway
Oh and triplanar mapping is also an option if you want to add detail or normal textures on top of everything
Usually something you end up using for environments anyway and doesn't take any extra effort to use once you've got it
I'll probably just ditch the idea of using color ramps and bake my asset textures. I don't really understand how Triplanar mapping works, from what little I've seen from a quick google search.
It projects a texture on all three axes and blends the edges, nothing more complex than that
Almost like a bit of a cheat since you don't even need UVs
I can see some uses for it, definitely. I'll look into it if setting it up doesn't turn out to be too much of a chore at this stage of development.
then again
Which render pipeline are you working in?
HDRP.
I don't know any better, so I just picked that one.
and at this point
I'm unsure if I could even change to URP without breaking my project irrecoverably
I hope you haven't been writing HDRP shaders by hand ๐
HDRP also uses SRP batching which usually performs better than GPU instancing, and they are mutually exclusive
Well, I did set up a sobel outliner using a several year old tutorial and wrote my own colorspace distance grading tool after getting frustrated with LUTs.
I don't suppose you know a way to convert a LUT into a true Point-interpolated 3D texture, instead of the gradiated ones that Unity generates against your will?
I tried using a LUT for my palette forcer, but it blended the colors together in a really nasty way because of how unity interpolated between the layers, and I couldn't figure out a way to make it not do that.
There are 3D texture / texture array formats which may interpolate better in that use, but I don't really know
I never worked with LUTs
Any good ways to force a strict palette other than brute forcing it with color space distance comparisons?
Besides sampling gradients I don't know any other ways
sampling gradients?
You know... color ramps?
This may be a good question to ask in #archived-shaders
Plenty people more advanced than me hang out there