Get an 20% OFF using the RELEASE code on your book purchase. For a limited time.

Introduction to the shader programming language

3.1.1. MPD PowerSlider and IntRange

This post is also available in…

These drawers are quite useful when working with numerical ranges and precision. On the one hand, we have the PowerSlider, which allows us to generate a non-linear slider with curve control. 

Its syntax is as follows:

[PowerSlider(3.0)] _PropertyName ("Display name", Range (0.01, 1)) = 0.08

On the other hand, we have the IntRange which, as its name says, adds a numerical range of integer values. 

Its syntax is as follows:

[IntRange] _PropertyName ("Display name", Range (0, 255)) = 100

Note that, if we want to use these properties within our shader, they have to be declared within the CGPROGRAM in the same way as a conventional property. To understand how to use it, we will do the following operation:

Shader “InspectorPath / shaderName”
        // declare drawer 
            _Brightness (“Brightness", Range (0.01, 1)) = 0.08

            _Samples ("Samples", Range (0, 255)) = 100
            // generate connection variables 
            float _Brightness;
            int _Samples;

In the example above, we declare a PowerSlider called _Brightness and an IntRange called _Samples. Finally, using the same names, we generate our connection variables within the CGPROGRAM.

Follow us to stay informed about all the latest news, updates, and more.

Join the group to share your experiences with other developers.

Subscribe to our channel and keep learning game dev!


Jettelly Team

We are a team of indie developers with more than 9 years of experience in video games. As an independent studio, we have developed Nom Noms in which we published with Hyperbeard in 2019. We are currently developing The Unity Shader Bible.

Follow us on our social networks.