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 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.

embarcadero-delphi-shader-programming-9870864

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 | B.Tech-CSE at AUT | Delphi/C++ Builder Enthusiast | Microsoft Learn Student Ambassador | Microsoft Azure Certified | Udacity Alumni
Related posts
DelphiInterview

Developer Stories: Oripov Murod Converses Regarding His DovtaLab2020 Application

DelphiRAD Studio

Websockets Harness Real-Time Power In Your Delphi Apps

DelphiShowcase

Plunge Into A Museum Adventure With This Delphi Integration

DelphiTech Partner

Creating Custom File Dialogs: ShellBrowser Delphi Components

Leave a Reply

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

IN THE ARTICLES