Closed Zylann closed 7 years ago
not going to happen, but as mentioned a while ago, you can use vertexID and vertex texture fetch to get as much data as you want
But isn't a texture fetch a lot more expensive than vertex attributes? Especially when it's about rendering pretty large patches of pixels
No, there is no reason for it to be more expensive, it's just bandwidth
On Aug 6, 2017 11:25 PM, "Marc" notifications@github.com wrote:
But isn't a texture fetch a lot more expensive than vertex attributes? Especially when it's about rendering very big patches of pixels
— You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/9134#issuecomment-320553515, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z2xoZxl44d1JQzm7bHQrcx9KFD7aZks5sVnWSgaJpZM4N3dQh .
Is there a way to use the vertexID in a shader?
I need additional attributes in a CanvasItem shader for a MeshInstance2D. The idea now would be to use the vertexId inside the vertex() shader function to calculate the UV texcoord for the vertex texture fetch. The trick with a MultiMesh to use INSTANCE_CUSTOM (see https://github.com/godotengine/godot/issues/31299 ) should not be possible because MeshInstance2D uses a Mesh and not a MultiMesh.
Okay, I've now found a solution. Instead of using vertexID, I now use UV as vertexID. It even has the advantage that I can already precalculate the correct fetch coordinates between 0.0 and 1.0. For the real UV coordinates I need now an additional vertex texture (because the original UV is now used for vertexID). It would be great if something like CUSTOM_ATTR (e.g. as vec4) would be available.
@jwurzer just use UV2 and or Color.
UV2 doesn't exist for CanvasItem shaders. Only for Spatial shaders. COLOR is used at my example for colors.
In my MeshInstance2D example I want to realize Multitexturing with two textures via CanvasItem shader. Where different UV coordinates are to be used for the textures. The two textures doesn't share the same uv coordinates. Therefore the UV attribute is not enough. Since a CanvasItem shader does not provide UV2, I solved it as described above.
you can use vertexID
How can we use it it's not exposed ?
Even then, for dynamic geometry, how is updating a texture on cpu then fetching it in shader faster then passing another array ?
Will vertex id and custom vertex attributes come to Godot4.0 with Vulcan ?
how about geometry / tesselation / mesh shaders ?
Currently i don't see ANY way to implement anything that needs more than Color and UV attributes in a canvas_item shader. There is no UV2 or anything else that could be used. There is no vertexID that could be used to circumvent it.. At least give us some additional 4 floats or something to use please. Adding proper support for custom attributes would be way nicer but hey, anything would be better than nothing.
Shading a heightmap terrain as a module using texture arrays requires at least the following vertex attributes:
By usage + type:
In order to be able to do this in the shader (assuming texarrays are supported):
However the amount of attributes currently in engine are limited for this. In theory I could use COLOR, UV and UV2 to have those 8 missing floats, but if COLOR needs to be used for something else then there is not enough attributes left (TANGENTS, BONES and WEIGHTS give only 2 floats and an int).
Given that GLES3 allows for any number of attributes (no longer hardcoded), is there a chance we can have more, or at best custom vertex attributes in 3.0?