OMG I have been trying for 3 days to figure out why changing parameters on individual instances wasnt working. I had to use the PerInstanceCustomData stuff in the material! Thank you!
Thanks for the explanation. I have only one question. You mark the render state dirty after setting parameters for each instance. From the performance side, if we have a lot of instances for one ISM, it may be much more efficient to mark render dirty once. Or do you think we should do it strictly for each instance?
Sometimes the Set Custom Data Value fails. Then that specific instance is just black. I checked this with the return boolean. I wonder why it fails at times?
You mean moving the vertices around? I don't think it's possible. But, you probably can add a WorldPositionOffset (with a mask) in the material to offset the vertices you want.
That's pretty awesome. But do you think there's a way to do it with actual textures, so that a single object can have more than one color (or just... a texture)?
@@AlexQuevillonEn you can only set them up once then though, and switch between existing ones that way (if it's inside the Material). You can't actively set a variable amount of them in your blueprint that way I guess?
@@dieblauebedrohung Exact, but you can change the textures with blueprints. But keep in mind that changing material parameters (not CustomData) will affect all the Instances.
@@AlexQuevillonEn yeah excactly. That's the problem I face rn. Trying to assign a variable amount of textures randomly to thousands of [different] objects without getting additional draw calls for each texture re-use. Thank you for your quick response thougj! :)
@@dieblauebedrohung Did you ever figure this out? I'm using a Texture Atlas and *attempting* to use the Custom Data to change the U and V coordinates of the texture, which should work in theory, but I can't actually get Custom Data to update in real-time in UE5 for some reason.
@@IamTheWordofGod I don't think it's possible (at least, not easily). The only suggestion I have would be to add all the textures you need directly in the material and then switch between them based on a Scalar Parameter. (With something like a Lerp or an If)
@@AlexQuevillonEn surprisingly I got it to work using a switch node with the textures plugged into it then a custom data value running into the switch value with the custom data value being changed per height level took me hours to figure out but it's actually quite simple One major downside tho the textures don't blend together they tile weirdly due to it being applied to sperate meshes I gotta figure out a way to have it set to nanite and still use custom data maybe primitives?
@@AlexQuevillonEn just figured out a fix for it while using custom data values you csnt have nanite and instances static mesh both on so instead use a scalar paramater called texture connect that into the switchvalue with the textures connected to the switch create a dynamic material instance in your construction script of your actor your trying to change the texture of dynamically then add a sequence with the height conditions setting a float value using the values of the switch textures you want per height then connect each of the branches exec pins into a set scalar paramater node connected to the create dyanmic material node with a set material node right after setting your mesh to that dyanmic material or texture based on height conditions no need for custom data values and no tiling issues 🙏
I don't think so :/ But you could always either - have both textures in your material and switch between them using the float parameters. - or have an atlas of textures and choose which one you want.
Maybe if we could somehow store different rgb values of materials with just a base texture like grabbing the texture rgb values then inputing them into the custom data value with a condition set up for choosing while using a texture sample instead of color coords for the rgb input in the material blueprint
I can't figure out how to grab rgb values from a texture or material variable in blueprint tho I've seen it done before but don't know how that's the only thing stopping me
OMG I have been trying for 3 days to figure out why changing parameters on individual instances wasnt working. I had to use the PerInstanceCustomData stuff in the material! Thank you!
oh... my... god! The amount of insanity I can do with this! Thank you!
Thanks. Was looking for way to set up different texture per instance :)
Glad it helped! :D
Thank you so much for this tutorial. I'm using this method to dynamically modify meshes spawned with the PCG tool, it works great!
Awesome!
ooo this'll blend well with the other series, thanks!!
Thanks for the explanation.
I have only one question. You mark the render state dirty after setting parameters for each instance. From the performance side, if we have a lot of instances for one ISM, it may be much more efficient to mark render dirty once. Or do you think we should do it strictly for each instance?
I think you can just do it once at the end. I just used the lazy route :P
This superb! Thanks a lot for sharing this method. new sub.
:D
Sometimes the Set Custom Data Value fails. Then that specific instance is just black. I checked this with the return boolean. I wonder why it fails at times?
That's actually something I never looked into, but yeah, it's a bit unstable. Even in newer versions of Unreal
Thank you so much!
Hello Alex, do you think it’s possible to edit vertexes of specific instances meshes with geometry script or otherwise?
You mean moving the vertices around? I don't think it's possible.
But, you probably can add a WorldPositionOffset (with a mask) in the material to offset the vertices you want.
Ah okay well that’s unfortunate, will have to look into world position thanks for the response.
That's pretty awesome. But do you think there's a way to do it with actual textures, so that a single object can have more than one color (or just... a texture)?
You can always have multiple textures in your material and switch between them with a LinearInterpolate.
Which you can control with the CustomData :)
@@AlexQuevillonEn you can only set them up once then though, and switch between existing ones that way (if it's inside the Material). You can't actively set a variable amount of them in your blueprint that way I guess?
@@dieblauebedrohung Exact, but you can change the textures with blueprints.
But keep in mind that changing material parameters (not CustomData) will affect all the Instances.
@@AlexQuevillonEn yeah excactly. That's the problem I face rn. Trying to assign a variable amount of textures randomly to thousands of [different] objects without getting additional draw calls for each texture re-use.
Thank you for your quick response thougj! :)
@@dieblauebedrohung Did you ever figure this out? I'm using a Texture Atlas and *attempting* to use the Custom Data to change the U and V coordinates of the texture, which should work in theory, but I can't actually get Custom Data to update in real-time in UE5 for some reason.
awesome thx
Is there a way to break a texture down to float value to do this ?
Tryna get custom data to work with the RGBA of. A texture so it can choose a texture based on height
@@IamTheWordofGod I don't think it's possible (at least, not easily).
The only suggestion I have would be to add all the textures you need directly in the material and then switch between them based on a Scalar Parameter. (With something like a Lerp or an If)
@@AlexQuevillonEn surprisingly I got it to work using a switch node with the textures plugged into it then a custom data value running into the switch value with the custom data value being changed per height level took me hours to figure out but it's actually quite simple
One major downside tho the textures don't blend together they tile weirdly due to it being applied to sperate meshes I gotta figure out a way to have it set to nanite and still use custom data maybe primitives?
@@AlexQuevillonEn just figured out a fix for it while using custom data values you csnt have nanite and instances static mesh both on so instead use a scalar paramater called texture connect that into the switchvalue with the textures connected to the switch create a dynamic material instance in your construction script of your actor your trying to change the texture of dynamically then add a sequence with the height conditions setting a float value using the values of the switch textures you want per height then connect each of the branches exec pins into a set scalar paramater node connected to the create dyanmic material node with a set material node right after setting your mesh to that dyanmic material or texture based on height conditions no need for custom data values and no tiling issues 🙏
Is it possible to do this with a texture aswell ?
I don't think so :/
But you could always either
- have both textures in your material and switch between them using the float parameters.
- or have an atlas of textures and choose which one you want.
Maybe if we could somehow store different rgb values of materials with just a base texture like grabbing the texture rgb values then inputing them into the custom data value with a condition set up for choosing while using a texture sample instead of color coords for the rgb input in the material blueprint
I can't figure out how to grab rgb values from a texture or material variable in blueprint tho I've seen it done before but don't know how that's the only thing stopping me
not find out the "num cuntom data floats" in ue5.3😭
Clean..