+1 vote

How would I access the albedo color of a given MeshInstance's mesh's surfaces inside a spatial shader?
As you can see I have 18 unique surfaces on this mesh, each with its own material (I generated this mesh procedurally and saved it, if I can host it somewhere and share the link here please suggest where I should host it).
enter image description here
I would like to apply a shader to the mesh, eventually taking the albedo of each surface and mapping the color value to one out of a collection of textures, and blending the differences between each tile (digression: this lets me use square tiling textures for irregularly/non-square shaped tiles, which is my purpose for writing this shader). I'm just not sure how to first get the surface's original albedo to the shader.
EDIT: also I've been using the material_override to apply the shader, how much does that override? The MeshInstance itself also has 18 empty material slots -- the current albedos are strictly from the mesh resource's surfaces.
EDIT2: The material engine actually has a built-in ability to add shaders on top of each other in succession called "Next Pass;" I didn't realize this. That answers the organizational aspect of the shaders, but I'm still confused about how to get the previous color into the new shader (without using discard, of course, since that just makes the shader transparent).
EDIT3: Doing some debugging on the mesh revealed I'm setting the UV coordinates incorrectly, it seems that the same UV value is being applied to the entire mesh. I've tried fiddling with the generator (which I discussed in my previous question) and I cannot figure out the proper use of the Mesh.ARRAY_TEX_UV array. I wouldn't expect that to cause problems just passing a color to the next pass of the shader, though.

in Engine by (682 points)
edited by

Is this... Zelda related?

No, strategy/history sim. I want higher terrain diversity and more control over where political boundaries are placed, so I chopped up the hex tiles of the gameboard into 18 congruent pieces.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.