TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Unity Materials and Shaders

Unity Materials and Shaders with Introduction, Installing, GameObject, First Unity Project, Unity 2D, Sprite Unity, Loops, If Statement, Data Types, Swith Statements, Unity UI, Unity Asset Store etc.

<< Back to UNITY

Unity - Materials and Shaders

Every beautiful looking game contains a different variety of surfaces. Like metal, plastics, holograms, alien artifacts, and so on. Specifically, physical based Rendering.

Rendering in Unity uses Shaders, Materials, and Textures. And three of them have a close relationship.

Materials

In Unity 3D, a Material is a file that contains information about the lighting of an object with that material.

A material has nothing to do with collisions, mass, or even physics in general. It is simply used to define how lighting affects an object with that material.

In unity, Materials are not much more than a container for shaders and textures that can be applied to models. Most of the customization of Materials depends on which shader is selected for it, although all shaders have some common functionality.

Let's create our new material, for that, first of all, create a new 3D project in Unity.

Then right-click on the Assets, and go to Create -> Materials and give a name like 'My Material.'

Unity Materials and Shaders

See the properties of Material.

Unity Materials and Shaders

These properties are not that we have studied so far. That is because these are the properties that are programmed in the shader, not in the material.

Materials are what make our objects visible in the first place. In fact, even in 2D, we use a unique material that does not require lighting as well.

Shaders

A shader is a program that defines how every single pixel is drawn on the screen. Shaders are not programmed in a C# or even in an object oriented programming language at all. Shaders are programmed in a C-like language called GLSL. This language can give direct instructions to the GPU for fast processing.

Shader's scripts have mathematical calculations and algorithms for calculating the color of each pixel rendered, based on the lighting input and the material configuration.

If the texture of a model specifies what is drawn on its surface, the shader is what determines how it is drawn. In other words, we can say that a material contains properties and textures, and shaders dictate what properties and textures a material can have.

Textures

Textures are flat images that can be applied to 3D objects. Textures are responsible for models being colorful and interesting instead of blank and boring.

It looks strange to think that a 2D image can be applied to a 3D model, but it is a very simple and straight forward process once you are familiar with it. Let's see one simple example: think about a water bottle, if you have taken off the label of a water bottle, you would see that it is a flat piece of paper. That label is like a texture. After the label is printed, it is then wrapped around the 3D bottle to provide a more pleasing look.

Just all other assets, adding texture to a Unity is very easy. To create texture in Unity, simply create a folder for your textures; a good name would be Textures. Then download and drag any texture you want in your project into the Textures folder you just created. That's it.

To create a folder, right click on the Assets and go to Create -> Folder. Rename it to 'Textures.' Now download any texture and drag it to that folder.


Next TopicUnity Coroutines




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf