5 votes
Accepted

Unwanted highlight on far side of objects near the edges of the screen when using orthographic camera

The default shaders in Unity 5+ use something called physically-based rendering. This means they try to model a number of quirks we observe in real materials, which aren't included by the Lambertian/...
DMGregory's user avatar
  • 134k
5 votes
Accepted

How to create a material with variable color

MaterialPropertyBlock probably what you are looking for. Just make sure to create the block once and cache it, to save on garbage collection. I'd create one ...
Draco18s no longer trusts SE's user avatar
5 votes
Accepted

Unity: How do I only show parts of objects that overlap [2D]

First, create a simple mesh (such as a quad or a cube). Place it over top the actual game area, and stretch it so that it covers the entire camera view. Next, create a new shader named "...
Coffee Boat's user avatar
5 votes
Accepted

Material changes to "material (instance)" on Start

When you access a renderer's material with the .material getter, Unity instantiates a new copy of the material unique to this object — that's why you see an "(...
DMGregory's user avatar
  • 134k
5 votes

Why are all materials pink in my Unity URP project?

To upgrade built-in Shaders (ref): Open your Project in Unity, and go to Edit > Render Pipeline > Universal Render Pipeline. According to your needs, select either Upgrade Project Materials to ...
Muhammad Faizan Khan's user avatar
4 votes

Change color, or material of specific line segments on Line Renderer

Here's an example of what you can do with a single material and a shader that changes behaviour based on world position: This shader looks something like this: ...
DMGregory's user avatar
  • 134k
4 votes
Accepted

Creating paralax background in Unity3D

When importing a texture, you can set two different 'wrap modes'. These tell the renderer what to do when the UV map goes past the edges of the texture. Yours is set to 'clamp', which will just ...
Robin van Ee's user avatar
4 votes
Accepted

What game objects can have a "material"?

There are actually two completely unrelated kinds of materials in Unity: Renderer materials (which define how things are rendered) and physics materials (which define how rigidbodies behave when they ...
Philipp's user avatar
  • 119k
4 votes
Accepted

How do materials and shaders work in graphics programming?

A shader is simply a program that runs on the GPU. Shaders are most often used to determine how a mesh is rendered, but can be used for many other things as well. Rendering meshes The most common use ...
Kevin's user avatar
  • 5,734
3 votes
Accepted

Emission on part of the mesh

When you set the UVs for your model, make sure the faces which are supposed to have a different material get assigned to different images. When you then import the model into Unity, you will have a ...
Philipp's user avatar
  • 119k
3 votes
Accepted

Unity3D - Resources load to materials, how to?

Renderer.materials is a getter that returns a copy of the materials array. The code you've written modifies that copy, but does not change the material used by the ...
DMGregory's user avatar
  • 134k
3 votes

Can't change materials of model from FBX

Inside the import settings inspector for your model, change from "Use Embedded Materials" to "Use External Materials (Legacy)". You will then have a Materials Folder to modify.
Fred Ip's user avatar
  • 31
3 votes
Accepted

How can I update my materials to work with LWRP?

To upgrade all the materials that can be supported by LWRP, go to: Edit Menu -> Render Pipeline -> Lightweight Render Pipeline -> Update Project Materials to LightweightRP Materials Note - only ...
Dr Rob Lang's user avatar
3 votes
Accepted

How to Convert Sprite into Texture

...
virtouso's user avatar
  • 2,608
3 votes

How can I make the hue of a material change over time?

Here's how to write a shader that applies this effect. I'm assuming you want lighting, so I started this shader by right-clicking in the Project view and selecting Create -> Shader -> Standard ...
DMGregory's user avatar
  • 134k
2 votes
Accepted

Gameobjects disappearing when changing renderer.material.color

Place this on an empty GameObject in the scene: ...
Engineer's user avatar
  • 29.5k
2 votes

Why do I get a blank material in Unreal Engine 4?

If you want to add the material to an Actor, just select it in the editor, select the StaticMeshComponent of any other Mesh and then you can select a material in the Properties Panel, just type it ...
Maxim DC's user avatar
  • 139
2 votes

Difference between Material and Shader

Although late, there is a "cheat" which can help you understand better. A material is everything that is attached to a certain shader for that draw call. For example, in the above answer, you have ...
Adrian Voinea's user avatar
2 votes

How to create a material with variable color

In a simple case you can change the main albedo color of the material of an object by assigning a different Color to gameobject.renderer.material.color Note that ...
Philipp's user avatar
  • 119k
2 votes
Accepted

How to get color or value from material with shader?

The cheapest (but not necessarily very flexible) solution would be to duplicate the shader code in your C# script. When the player clicks, fire a ray through the mouse position. Capture the ...
DMGregory's user avatar
  • 134k
2 votes

How to have random and different colors on multiple objects with one material?

You can change the color of the same material, on different objects, from script. Do the following: Create a materialand assign it to the target game object. Create a new C# script, and copy in the ...
Shuvro Sarkar's user avatar
2 votes

UE4 How to Avoid Boundary Seams with Multiple Refractive Meshes

You don't say if your boxmodel uses separate materials per face - if not, I suggest that you do this. Then pre-pass each face before drawing the block, checking for a water block against each face; if ...
JonS's user avatar
  • 299
2 votes
Accepted

How to make player stay on a moving object

You don't have to apply any Force or Velocity to your player. Just set your player child of the current Obstacle, and it will stick to that Obstacle. ...
Aditya Yadav's user avatar
2 votes
Accepted

How to make a static Material reference?

Quite often I'll use a ScriptableObject to hold this kind of shared data. It's similar to OC_RaizW's suggestion of a ...
DMGregory's user avatar
  • 134k
2 votes
Accepted

Using 10 materials for one Model?

It's most likely that for every material the pipeline needs to change state and validate a lot of stuff. Which means you'd end up with a shaderpass for each material. Depending on the scope of your ...
Sidar's user avatar
  • 3,577
2 votes

Using different shaders based on desktop or mobile?

You can also use shader compile directives in custom shaders to skip over expensive sections, resulting in a simpler look, which only triggers when on a mobile device. https://docs.unity3d.com/...
Draco18s no longer trusts SE's user avatar
2 votes

Using different shaders based on desktop or mobile?

It may lead to longer load times, but you could switch shaders in Awake based on the platform: ...
noone's user avatar
  • 96
2 votes

Why does my line disappear against a white image?

It should be because the alpha channel of the line is set to 0, so the Unlit/Transparent shader effectively makes it invisible when there're other objects rendered ...
Galandil's user avatar
  • 1,284
2 votes
Accepted

How to stop and start sprite sheet flipbook materials in a widget blueprint?

Add a Time node and Multiply node. Take the Time node and pass it as an input to the Multiply, add a float parameter as the other input on the multiply node then plug the output of the multiply into ...
dave's user avatar
  • 36
2 votes
Accepted

How can I make Iridescence material In unity?

I found same question here and I could make Iridecence In unity . you can download this shader from my github. My tutorial About Iridescence Shader Iridescence (also known as goniochromism) is ...
Seyed Morteza Kamali's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible