Incari Studio
2023.2
2023.2
  • Incari HMI Development Platform
  • Getting Started
    • Overview
    • Requirements
    • What's New
    • Installation
    • First Steps
      • Incari Hub
      • Creating a Project
      • Incari Studio
  • Objects and Types
    • Overview
    • Project Objects
      • Scene
      • Scene2D
      • Screen
      • HMD
    • Scene Objects
      • Audio
      • Camera
      • Group
      • Image Sequence Sprite
      • Label
      • Light
      • List
      • Lottie Sprite
      • Mesh
      • On-Screen Keyboard
      • Overlay
      • Primitives
      • Sprite
      • Text
      • Vector
      • Video
      • Web Sprite
    • Scene2D Objects
      • Camera
      • Frame
      • GUI
        • Button
        • Dropdown
        • List
        • Slider
        • Text Area
        • Text Input
        • Toggle
      • Group
      • Image
      • Vector
        • Boolean Operation
        • Ellipse
        • Line
        • Rectangle
        • Text
      • Vector (old)
    • Prefabs
      • Creating and Using Prefabs
        • Prefabs in Scenes
        • Prefabs in Scene2Ds
      • Logic in Prefabs
      • Nested Prefabs
    • Attributes
      • Attribute Types
        • Asset/Object Attribute
        • Boolean Attribute
        • Color Attribute
        • Numerical Attribute
      • Common Attributes
        • Object
        • Sprite
        • Transformation
          • Global Transformations
          • Local Transformations
        • Tag
    • Data Types
      • Bool
      • Byte
      • Float
      • Int
      • String
      • Vector2
      • Vector3
      • Vector4
    • Terminology
  • Modules
    • Overview
    • Animation Editor
    • Asset Database
    • Asset Manager
    • Attribute Editor
    • Code Editor
    • Console
    • Exporter
    • Figma Importer
      • Current Limitations
    • Image Sequence Editor
    • Logic Editor
      • AI Logic Generation
    • Global Preferences
    • Material Editor
      • Car Paint Model
      • Custom Shading Model
      • Phong Model
      • Glass Model
      • Extended PBR Model
      • PBR Model
      • Shadeless Model
    • Model Editor
    • Plugins
      • Communication
        • Bluetooth
        • MAVLink
        • Serial
        • Socket.IO
        • TCP
        • UDP
        • WebSocket
    • Profiler View
    • Project Outliner
    • Project Settings
      • CAN
      • Fonts
      • HTTP
      • Keyboard
      • MAVLink
      • MQTT
      • Profiler
      • Scene Separation
      • Serial
      • Socket.IO
      • Styles
      • TCP
      • UDP
      • WebSocket
    • Scene Outliner
  • Toolbox
    • Overview
    • Actions
      • Delay Action
      • FadeFromTo Action
      • FadeTo Action
      • MoveBy Action
      • MoveTo Action
      • RotateBy Action
      • RotateTo Action
      • RotateFromTo Action
      • ScaleBy Action
      • ScaleTo Action
    • Array
      • Array Value
      • Clear Array
      • Concat Arrays
      • Get Array Element
      • Insert Array Element
      • Length of Array
      • Pop Array Element
      • Push Array Element
      • Remove Array Element
      • Set Array Element
    • Binary
      • Binary Value
      • Binary to Byte Array
      • Concat Binaries
      • Verify Checksum
    • Communication
      • Bluetooth
        • Events
          • On Bluetooth Device Paired
          • On Bluetooth Device Unpaired
        • Is Bluetooth Device Paired
        • Pair Bluetooth Device
        • Retrieve Call History
        • Retrieve Phonebook
        • Scan For Bluetooth Devices
        • Unpair Bluetooth Device
      • CAN
        • CAN Send Packet
        • CAN Start
        • CAN Stop
        • Events
          • On CAN Packet Received
          • On CAN Start
          • On CAN Stop
      • HTTP
        • Events
          • On HTTP Route
          • On HTTP Server Start
          • On HTTP Server Stop
        • HTTP Client
        • HTTP Response
        • HTTP Server Start
        • HTTP Server Stop
      • MAVLink
        • Events
          • On MAVLink Packet Received
          • On MAVLink Start
          • On MAVLink Stop
        • MAVLink Decode
        • MAVLink Start
        • MAVLink Stop
      • MQTT
        • Events
          • On MQTT Start
          • On MQTT Stop
          • On MQTT Topic
        • MQTT Publish
        • MQTT Start
        • MQTT Stop
        • MQTT Subscribe
      • Serial
        • Events
          • On Serial Error
          • On Serial Packet Receive
          • On Serial Start
          • On Serial Stop
        • Serial Send Packet
        • Serial Start
        • Serial Stop
      • Socket.IO
        • Events
          • On Socket.IO Error
          • On Socket.IO Receive
          • On Socket.IO Start
          • On Socket.IO Stop
        • Socket.IO Send
        • Socket.IO Start
        • Socket.IO Stop
        • Socket.IO Subscribe
        • Socket.IO Unsubscribe
      • TCP
        • Events
          • On TCP Error
          • On TCP Packet Receive
          • On TCP Start
          • On TCP Stop
        • TCP Send
        • TCP Start
        • TCP Stop
      • UDP
        • Events
          • On UDP Error
          • On UDP Packet Receive
          • On UDP Start
          • On UDP Stop
        • UDP Send
        • UDP Start
        • UDP Stop
      • WebSocket
        • Events
          • On WebSocket Error
          • On WebSocket Receive
          • On WebSocket Start
          • On Websocket Stop
        • WebSocket Client Send
        • WebSocket Client Start
        • WebSocket Client Stop
    • DateTime
      • Date Time Formatter
      • Now (UTC)
      • System Time
      • Timezone Value
    • Development
      • Assert
      • Benchmark Get
      • Benchmark Start
      • Benchmark Stop
      • Clear Console
      • Console
      • Profiler Start
      • Profiler Stop
    • Dictionary
      • Clear Dictionary
      • Dictionary Value
      • Erase Dictionary Element
      • Get Dictionary Element
      • Get Dictionary Keys
      • Get Dictionary Values
      • Merge Dictionaries
      • Set Dictionary Element
      • Size of Dictionary
    • Events
      • Custom
        • Event Listener
        • Event Trigger
      • Gestures
        • On Swipe
        • On Tap
      • ImageSequence
        • On ImageSequence Frame Changed
        • On ImageSequence Pause
        • On ImageSequence Play
        • On ImageSequence Stop
      • Input
        • On Text Change
      • Keyboard
        • On Key Press
        • On Key Release
      • Leap Motion
        • On Leap Motion Frame Update
        • On Leap Motion Grab End
        • On Leap Motion Grab Start
        • On Leap Motion Grab Update
        • On Leap Motion Pinch End
        • On Leap Motion Pinch Start
        • On Leap Motion Pinch Update
        • On Leap Motion Swipe Left
        • On Leap Motion Swipe Right
        • XR Position
      • List
        • On List Current Index Change
        • On List Entry Select
        • On List Load
      • List 2D
        • On List Active Index Change
      • Lottie
        • On Lottie Finish
        • On Lottie Pause
        • On Lottie Play
        • On Lottie Stop
      • Media
        • On Media Finish
        • On Media Play
      • Mouse
        • Get Mouse Position
        • Get Mouse Position Delta
        • On Hover Enter
        • On Hover Leave
        • On Mouse Button Down
        • On Mouse Button Up
        • On Mouse Click
        • On Mouse Double Click
        • On Mouse Enter
        • On Mouse Leave
        • On Mouse Move
        • On Mouse Scroll
      • Object
        • On Alpha Change
        • On CheckBox Value Change
        • On Dropdown Active Value Change
        • On Opacity Change
        • On Position Change
        • On Rotation Change
        • On Scale Change
        • On Slider Value Change
        • On Visibility Change
      • On-Screen Keyboard
        • On On-Screen Keyboard Arrow Down Pressed
        • On On-Screen Keyboard Arrow Up Pressed
        • On On-Screen Keyboard Enter Pressed
        • On On-Screen Keyboard Input Changed
        • On On-Screen Keyboard Key Pressed
      • Scene
        • On Scene Loaded
      • Unsubscribe
      • Screen
        • On Screen Scene Change
      • Variables
        • On Variable Change
        • On Variable Set
      • Web
        • On JavaScript Callback
      • WebSprite
        • On WebSprite Load
        • On WebSprite Remote URL Change
    • Flow Control
      • Branch
      • For Each Loop
      • For Loop
      • Index Switch
      • Is Equal
      • Is Greater Equal
      • Is Less Equal
      • Select Data
      • Sequential
      • Switch
      • Toggle
    • Functions
      • Function
        • Function Input
        • Function Output
    • IO
      • Create File
      • Get Current Directory
      • Get File Extension
      • List Directory Content
      • Load File
      • Remove
      • Save File
      • Set Current Directory
    • Incari
      • Animation
        • Pause Animation
        • Play Animation
        • Stop Animation
      • Asset
        • Add to Asset Database
        • Remove from Asset Database
      • Camera
        • Get Active Camera
        • Get All Cameras
        • Set Active Camera
      • ImageSequence
        • Get Current ImageSequence Frame
        • Get ImageSequence Duration
        • Get ImageSequence FPS
        • Get ImageSequence Total Frames
        • Go To Next ImageSequence Frame
        • Go To Previous ImageSequence Frame
        • Pause ImageSequence
        • Play ImageSequence
        • Resume ImageSequence
        • Show ImageSequence Frame
        • Stop ImageSequence
      • List
        • Generate List
        • Get Selected Item
        • Next List Entry
        • Previous List Entry
        • Select List Entry
        • Set Active
        • Set Current Index
      • List 2D
        • Add List Element
        • Get Active Index
        • Get List Data
        • Get List Element
        • Insert List Element
        • Remove List Element
        • Set Active Index
        • Set List Data
        • Set List Element
      • Lottie
        • Pause Lottie
        • Play Lottie
        • Stop Lottie
      • Material
        • Get Material Property
        • Set Material Property
      • Media
        • Get Media
        • Get Media Length
        • Get Media Loop
        • Get Media Progress
        • Get Volume
        • Is Media Playing
        • Pause Media
        • Play Media
        • Set Media
        • Set Media Loop
        • Set Media Progress
        • Set Volume
        • Stop Media
      • Object
        • Add Tag
        • Destroy Object
        • Get Active Dropdown Value
        • Get Alpha
        • Get CSS Property
        • Get CheckBox Value
        • Get Children
        • Get Dropdown Options
        • Get Material
        • Get Name
        • Get Objects By Tag
        • Get Opacity
        • Get Parent
        • Get Position
        • Get Root
        • Get Rotation
        • Get Scale
        • Get Size
        • Get Slider Value
        • Get Sort Index
        • Get Tag
        • Get Text
        • Get Text Color
        • Get Tint
        • Get Visibility
        • Has Children
        • Instantiate Object
        • On List Item Clicked
        • Remove Tag
        • Set Active Dropdown Index
        • Set Active Dropdown Value
        • Set Alpha
        • Set CSS Property
        • Set CheckBox Value
        • Set Dropdown Options
        • Set Mask
        • Set Material
        • Set Opacity
        • Set Position
        • Set Rotation
        • Set Scale
        • Set Size
        • Set Slider Value
        • Set Sort Index
        • Set Stylesheet
        • Set Text
        • Set Text Color
        • Set Texture
        • Set Tint
        • Set Visibility
        • Use Mask
      • Object 2D
        • Add CSS Class Name
        • Get CSS Class Names
        • Get Paint
        • Get Paint Opacity
        • Get Stroke Width
        • Remove CSS Class Name
        • Set Blend Mode
        • Set CSS Class Names
        • Set Paint
        • Set Paint Opacity
        • Set Stroke Width
      • On-Screen Keyboard
        • Get Screen Keyboard Layout
        • On-Screen Keyboard Clear Input
        • On-Screen Keyboard Get Input
        • On-Screen Keyboard Move Selection
        • On-Screen Keyboard Press Button
        • Set Screen Keyboard Layout
      • Scene 2D
        • Get Stylesheet
        • Merge To Stylesheet
        • Set Stylesheet
      • This Scene
      • Ultrahaptics
        • Ultrahaptics Play
        • Ultrahaptics Stop
      • Scenes
        • Scene
      • Screen
        • Get Scene
        • Load Scene
        • Set Background
        • Set Scene
        • Unload Scene
      • Screens
        • Screen
      • Vector
        • Arc
          • Get ArcEnd
          • Get ArcStart
          • Set ArcEnd
          • Set ArcStart
        • Get BackgroundColor
        • Get FillColor
        • Get StrokeWidth
        • Label
          • Get LabelText
        • Line
          • Get LineWidth
          • Set LineWidth
        • Pie
          • Get PieEnd
          • Get PieStart
          • Set PieEnd
          • Set PieStart
        • Rectangle
          • Get RectangleCorners
          • Set RectangleCorners
        • Set BackgroundColor
        • Set FillColor
        • Set StrokeWidth
      • WebSprite
        • Get Remote URL
        • Set Remote URL
        • Web Sprite Reload
    • Math
      • Absolute
      • Add
      • Average
      • Boolean
        • AND
        • Bool Value
        • Negate
        • OR
      • Ceil
      • Clamp
      • Decrement
      • Divide
      • Floor
      • Increment
      • Interpolate
      • Logarithm
      • Math Constant
      • Maximum
      • Minimum
      • Modulo
      • Multiply
      • Numerical Value
      • Power
      • Random
      • Range Mapper
      • Root
      • Rotation Matrix
      • Round
      • Subtract
      • Trigonometry
        • Arc Cosine
        • Arc Sine
        • Arc Tangent
        • Arc Tangent 2
        • Cosine
        • Radian-Degree Converter
        • Sine
        • Tangent
      • Vector Value
    • Plugins
      • (JSON) Scale Vector
    • Prefab
      • This Prefab
    • String
      • Capitalize
      • CharCodeAt
      • Compare
      • Concat Strings
      • Contains
      • CryptoHash
      • EndsWith
      • Format
      • FormatArray
      • IndexOf
      • IsLower
      • IsUpper
      • JSON Parse
      • JSON Stringify
      • Join
      • LastIndexOf
      • Length
      • Lower
      • MatchRegex
      • PaddingLeft
      • PaddingRight
      • RandomString
      • RemoveCharacters
      • Replace
      • ReplaceRegex
      • Reverse
      • Split
      • StartsWith
      • String Value
      • Substring
      • Trim
      • TrimLeft
      • TrimRight
      • Upper
    • Transition
      • CrossFade
      • Fade
      • MoveInFromBottom
      • MoveInFromLeft
      • MoveInFromRight
      • MoveInFromTop
      • SlideInFromBottom
      • SlideInFromLeft
      • SlideInFromRight
      • SlideInFromTop
    • Utilities
      • Color Value
      • Conversion
      • Create CustomID
      • Create Object
      • Get Command Line Option
      • Group
      • Interval
        • Reset Interval
        • Start Interval
      • Is Data Type
      • Is Object Type
      • System Call
      • Timeout
        • Cancel Timeout
        • Start Timeout
    • Variables
      • Variable Getter
      • Variable Setter
    • Web
      • Call JavaScript Function
  • Demo Projects
    • Overview
    • 4 Methods of Animation
    • Using APIs to Pull Dynamic Data
    • An Analog Clock
    • Image Sequence Button Animation
    • Prefabs
    • Project Initialization
    • On-Screen Keyboard
    • Skinnable Speedometer
Powered by GitBook
On this page
  • Attributes
  • Material
  • Shaders
  • Uniforms
  • Property Names
  • External Links

Was this helpful?

  1. Modules
  2. Material Editor

Custom Shading Model

PreviousCar Paint ModelNextPhong Model

Last updated 1 year ago

Was this helpful?

This model allows the user to create and customize their own Shading Model. The specifications are given via configuration files in the Attributes:

All these Attributes are described in greater detail below.

Attributes

Material

This Attribute provides the Name of the Custom Material as well as the Shading model type. It also sets the Alpha value if it is toggled on.

The Alpha channel is additional to the RGB channels and adds a kind of transparency to the object by mixing the background and foreground colors. For example, if the Alpha value is set to 0.5, then this would result in a 50% mix of the object and its background, providing a semi-translucent quality.

Shaders

Find below a detailed explanation of how to configure these shaders.

Shaders Configuration

Across the configuration of both, two uniform variables can be used:

  • incTime: Float that keeps the time from the start of the application.

  • incResolution: Vector2 containing the Screen resolution.

Vertex Shader

Vertex Shaders influence the rendering of the vertices of Objects.

My Vertex Shader.vert
void mainPosition(in mat4 projectionMatrix, in mat4 modelMatrix, in vec3 viewPosition, in vec4 worldPosition)
{
    gl_Position = projectionMatrix * vec4(viewPosition, 1.0);
}

A vertex shader requires a main function named mainPosition, which is called once per vertex each time the Scene is rendered. This function receives as inputs:

  • viewPosition: Vector3 that contains the relative position of the vertex.

  • worldPosition: Vector4 that contains the absolute position of the vertex.

It is always necessary to calculate:

  • gl_Position: Vector4 that contains the position of the vertex in clip space.

Fragment Shader

Fragment Shaders influence the rendering of each pixel of Objects.

My Fragment Shader.frag
‌void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
 vec2 uv = (fragCoord * incResolution) / incResolution.xy;
 vec3 col = 0.5 + 0.5 * cos(incTime + uv.xyx + vec3(0, 2, 4));
 fragColor = vec4(col, 1.0);
}

A fragment shader requires a main function named mainImage, which is called once per pixel each time the Scene is rendered. The argument for this function is:

  • fragCoord: Vector2 that contains the 2-dimensional coordinates of the pixel.

And the output is:

  • fragColor: Vector4 that stores the color that the pixel will be set to.

The uv coordinates can be obtained by using:

vec2 uv = (fragCoord * incResolution) / incResolution.xy;

Once there, copy the code on the right-hand side of the page.

Then paste that into a .frag file in Incari. It is imperative that one add #define USE_RESOLUTION_RANGE to the very beginning of the file (before all the code that has been pasted).

This makes a shader from shadertoy.com useable in Incari. Now one just needs to add the file to a Custom Shading Model in the Fragment Shader section.

Uniforms

There are five types of variables:

Please note that for the Uniforms to have any effect, the names in the files must match the Attribute names seen here in the Custom Shading Model.

Channels

These Attributes can take any file that is an image or texture map. With these, it is possible to add other textures and/or visual components to the already existing Custom Material. It is possible to set up to four of these currently in Incari.

For example, the user could switch between two texture maps. After setting textures for iChannel1 and iChannel2, the code for the Fragment Shader could use these in an if/else statement:

if( iBool0 ) {
fragColor = texture( iChannel1 , uv );
}
else
{
fragColor = texture( iChannel2 , uv );
}

Integers

These Attributes set the values for Ints. This can be used to set the x, y, z , and/or w values for a Vector4 in the code for the Fragment Shader, for example. It is possible to set up to four of these currently in Incari.

Floats

These Attributes set the values for Floats. This can be used to multiply the time variable present in the code for the Fragment Shader by some Float during runtime, for example. It is possible to set up to four of these currently in Incari.

Vectors

These Attributes set the values for Vector4s. This can be used to set certain RGB values, for example. The first value corresponds to the red value, the second for green, the third for blue, and the fourth for the alpha overchannel. It is possible to set up to four of these currently in Incari.

Booleans

These Attributes set the true or false values for Bools. This can be used to execute a certain condition in the code for the Fragment Shader, for example. It is possible to set up to four of these currently in Incari.

Property Names

It is possible to hover over each Attribute and access their property names to be used in code or Nodes. A complete list of these names is as follows:

  • iChannel0

  • iChannel1

  • iChannel2

  • iChannel3

  • iInt0

  • iInt1

  • iInt2

  • iInt3

  • iFloat0

  • iFloat1

  • iFloat2

  • iFloat3

  • iVec40

  • iVec41

  • iVec42

  • iVec43

  • iBool0

  • iBool1

  • iBool2

  • iBool3

External Links

There are two types of shaders that can be used for this model: and .

The Vertex Shader is configured via an Asset with .vert extension. This Asset consists of code and can be edited in Incari with the .

This is the code that is generated by default when creating a .vert Asset in the :

projectionMatrix: 4x44x44x4 matrix that represents the perspective of the Camera.

modelMatrix: 4x44x44x4 matrix that represents where the vertex is.

The Fragment Shader is configured via an Asset with .frag extension. This Asset consists of code and can be edited in Incari with the .

This is the code that is generated by default when creating a .frag Asset in the :

It is also possible to use shaders from . To do so, simply locate a shader which uses the standards.

Incari makes it possible for the user to set values in Fragment and Vertex Shader files. This can also be done on runtime by using the .

Here, the user can set the values for several variables. These variables correspond to those present in the files given in the shaders. Please note that shaders should be conform to the standards.

on OpenGL Wiki.

on GPU Shader Tutorial.

on OpenGL Wiki.

on GPU Shader Tutorial.

in Learn OpenGL.

Code Editor
Asset Manager
Code Editor
Asset Manager
ShaderToy
GLSL_ES
Set Material Property Node
GLSL_ES
Vertex Shader
Vertex Shader
Fragment Shader
Fragment Shader
Shaders
Vertex Shader
Fragment Shader
Channels
Integers
Floats
Vectors
Booleans
Vertex Shader
Fragment Shader
Uniforms
Material
Example Shader from shadertoy.com.
Fragment Shader Example.
Custom Shading Model Example.