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


In the first blog post, we have quickly explored shader programming in Delphi FireMonkey. And we learned how to create a material source using TCustomMaterial. Then we have applied that material to a 3D control. This post is based around 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 simply be achieved by adding a uniform input to the pixel shader for the color. So, on the Delphi side, Color property should be added to 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.


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
Related posts
C++DelphiIDENewsRAD StudioWindows

Windows 11 Win32 Debugging Patch for RAD Studio 11.1

C++DelphiIDENewsRAD StudioShowcase

Bookmarks and Navigator are available for RAD Studio 11!

C++RAD Studio

5 Reasons We Are Addicted To App Builder Software

C++IDERAD Studio

Which Is The Best C++ IDE For A Newbie?

Leave a Reply

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