#extra color attachment for custom material?

6 messages · Page 1 of 1 (latest)

boreal anvil
#

Is it possible to add a color attachement for usage in the shaders of a custom material? I saw that I could add ColorTargetState in the specialize method of MaterialExtension, but I couldn't find a way to specify which texture to use as the color attachment.

I need the extra color attachment in order to write the normals generated in the prepass shader to it. The precision of the current bevy normal texture isn't enough for my use case. Maybe there is some better way to do this?

boreal anvil
#

I'm using a patched version of bevy now that replaces the TextureFormat of the normal texture with the format I need, this works great, but I'd still love to get answers for the questions above.

soft zenith
#

Not really possible. A custom deferred setup might let you, but not very familiar with it.

#

Just a question, how is it not enough precision?

#

I'm surpised Rgb10a2Unorm is not enough for most users

boreal anvil
# soft zenith Just a question, how is it not enough precision?

I came up with a very good method for outline/edge detection.
The usual method: To determine whether a fragment is part of an edge just check for normal and depth differences of surrounding fragments.
My method: Take the view position and view normal of the fragment to construct a plane, then calculate the view positions of the plane on surrounding fragments and compare those to the actual view positions of the fragments.
The usual method has a bunch of issues most of which can be worked around, but not all of them, at least I didn't find a solution for some things. As far as I can tell my method doesn't have any of the issues, but it needs precise normals because there is more math involved and errors compound quickly. I'm assuming it's also less performant, but I didn't measure.