-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble using with materials instead of images #7
Comments
UPD: materials support is implemented: Hi there! Thanks a lot for checking out the Custom Shape Button. Your interest means a lot! You're right about the issue. Currently, it supports only textures, not materials. I'm excited about your idea to use materials for making button icons on the fly, it could make the Custom Shape Button even better. When I start updating the Custom Shape Button to UE5.4, I'll check if adding material support is possible. I can't promise it will be implemented, but I'll definitely look into it. |
I don't know how you can get at the pixels, but the GetResource() call can be casted to a UMaterialInstance, and aside from the deprecated looking property name, the brush has the image size available on it.
I imagine there's gotta be some way to sample the material, seeing as slate does it (and capturing to render target must too?), but I don't have any clue what magical craziness that would be. I tried a work-around of dumping the material to a render target, it's pretty awful. I suspect in a perfect world where performance at run time is the most important thing ever this might be what you'd want to do, but from a material instance aspect it kinda crushes the value as you make more instances. Here's what I had to do:
|
As a workaround, maybe have an OverrideAlphaMask in case you want to use a material, and provide the alpha mask separately? |
Simply connect your mask to the 'Opacity' input: This allows you to select your material in the usual way in the 'Button Style' instead of a texture, without any extra steps. See documentation here. Download the Sample Project from the Release page, where the UE Logo is used as an example of material usage: I have tested materials support both in PIE and the shipping build. However, I would appreciate it if someone could confirm that it's working as expected. |
Thank you for confirming this feature. I really appreciate your interest and for raising the issues. I confirm that overlapping multiple custom shape buttons with their alpha causes the issue. Creating custom hit-test geometries is needed. I will definitely take a look during UE5.5 integration. Feel free to share your ideas or links to possible solutions; it will greatly assist me in resolving this issue more quickly. |
I can't seem to find anything good on where to even begin. I was hoping I could tinker with hover events but that didn't appear to work. Is a hit geometry a slate widget thing? |
I'm trying several things here to use this with some materials instead of an image so that I can stitch together button icons at run time instead of modifying every single icon.
So. The button works if I use the hex image.
![image](https://private-user-images.githubusercontent.com/812920/285601394-b6278331-eb11-47a1-b1e2-7552cba5151e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNTczNTQsIm5iZiI6MTcxOTI1NzA1NCwicGF0aCI6Ii84MTI5MjAvMjg1NjAxMzk0LWI2Mjc4MzMxLWViMTEtNDdhMS1iMWUyLTc1NTJjYmE1MTUxZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNFQxOTI0MTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kMjkzZjFiZjQ1ZWZiODUxOGUwODhmYmQ2ZWRkOGU1MzZjOGJmNDUwMzc3MGRmODE0NmY4YjExMTM2MThhZDQyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.VSWqQEY4iy6ztkSXpuwwH6LjXrG7o-qF0EgpsEMJUFY)
I then use this same image to try and mask a material:
![image](https://private-user-images.githubusercontent.com/812920/285601427-492c1c7f-debf-452a-b0e6-4f3f6aaaf6da.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNTczNTQsIm5iZiI6MTcxOTI1NzA1NCwicGF0aCI6Ii84MTI5MjAvMjg1NjAxNDI3LTQ5MmMxYzdmLWRlYmYtNDUyYS1iMGU2LTRmM2Y2YWFhZjZkYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNFQxOTI0MTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lZjI2MTY5MzhmZjJhMTExZDYyN2MyNzIwZDgyMmZjMTZjZjhmNzQ2ZWU3MWY5NjUyNDFiZjI0ZDNlODhhYTgzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.2axStFkPj1tJ3IbumZSXnEWx0XlSsFOU3kAJ5eBa8mY)
And then set this as the brush image:
![image](https://private-user-images.githubusercontent.com/812920/285601455-503b78f9-6aa7-4f1f-8485-2a1236235a52.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNTczNTQsIm5iZiI6MTcxOTI1NzA1NCwicGF0aCI6Ii84MTI5MjAvMjg1NjAxNDU1LTUwM2I3OGY5LTZhYTctNGYxZi04NDg1LTJhMTIzNjIzNWE1Mi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNFQxOTI0MTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kMzc2Yjg5MmM2ODg0MDY2NjAxODQ1NjFhNzUyYTdiMjNkNjFlZTQyOTY3ZTZlNjUwMTI3ZGM1NWUxNDdjODQ5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.kKUVojzZWnhzGbiiUQLVoVSn1sHwacwF8OfKCa5gcjQ)
And it doesn't detect any hit testing 😢
I can see that it's this chunk right here relying on a Texture2D but not being able to use a material. https://github.com/JanSeliv/CustomShapeButton/blob/main/Source/CustomShapeButton/Private/SCustomShapeButton.cpp#L157
Any guidance?
The text was updated successfully, but these errors were encountered: