Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiRAD Studio

Windows Shader Programming In Delphi FireMonkey – Apply Color To The GPU Shader

shader programming in delphi firemonkey apply color to the gpu shader

In the first blog post, we quickly explored shader programming in Delphi FireMonkey. And we learned how to create a material source using TCustomMaterial. Then we applied that material to a 3D control. This post is based on a blog post by Embarcadero MVP Erik van Bilsen.

Now, we will add a color property to our 3D control to customize color. This can be achieved by adding a uniform input to the pixel shader for the color. So, on the Delphi side, the Color property should be added to the new material.

  • From this code we can observe that to pass the color to the GPU shader, we must override the DoApply function. In the DoApply function, you call SetShaderVariable method to pass the color to the shader.

Finally, you must update the material source by adding a new Color property. Here is the implementation

And here is our result:

Head over and be sure to check out the full blog post and demo applications here. And stay tuned for the next part which we will add a texture to our 3D control.

embarcadero delphi shader programming 9870864

You can program easily window shader and apply color to the GPU shader using Delphi’s IDE Software. Try your Free Trial here and begin developing in C++ or Delphi environments right away.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Software Developer | CS(CyberSec) Undergrad at APU Malaysia | Delphi/C++ Builder Enthusiast | Microsoft Learn Student Ambassador | Microsoft Azure Certified

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES