Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Material doesn't have a texture property '_BaseColor'

Discussion in 'Universal Render Pipeline' started by viktorkadza, May 12, 2020.

  1. viktorkadza

    viktorkadza

    Joined:
    Sep 4, 2018
    Posts:
    46
    I got this error:
    Material doesn't have a texture property '_BaseColor'
    UnityEngine.Material:get_mainTexture()

    I am using out of the box URP shaders, nothing special. It seem that the shader has this property _BaseColor, but still the error occurs. Any ideas whats going wrong?

    Here an exaple of shader code:

    Code (CSharp):
    1. Shader "Universal Render Pipeline/Simple Lit"
    2. {
    3.     // Keep properties of StandardSpecular shader for upgrade reasons.
    4.     Properties
    5.     {
    6.         [MainTexture] _BaseColor("Base Color", Color) = (1, 1, 1, 1)
    7.         [MainColor] _BaseMap("Base Map (RGB) Smoothness / Alpha (A)", 2D) = "white" {}
    8.  
    9.         _Cutoff("Alpha Clipping", Range(0.0, 1.0)) = 0.5
    10.  
    11.         _SpecColor("Specular Color", Color) = (0.5, 0.5, 0.5, 0.5)
    12.         _SpecGlossMap("Specular Map", 2D) = "white" {}
    13.         [Enum(Specular Alpha,0,Albedo Alpha,1)] _SmoothnessSource("Smoothness Source", Float) = 0.0
    14.         [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
    15.  
    16.         [HideInInspector] _BumpScale("Scale", Float) = 1.0
    17.         [NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {}
    18.  
    19.         _EmissionColor("Emission Color", Color) = (0,0,0)
    20.         [NoScaleOffset]_EmissionMap("Emission Map", 2D) = "white" {}
    21.  
    22.         // Blending state
    23.         [HideInInspector] _Surface("__surface", Float) = 0.0
    24.         [HideInInspector] _Blend("__blend", Float) = 0.0
    25.         [HideInInspector] _AlphaClip("__clip", Float) = 0.0
    26.         [HideInInspector] _SrcBlend("__src", Float) = 1.0
    27.         [HideInInspector] _DstBlend("__dst", Float) = 0.0
    28.         [HideInInspector] _ZWrite("__zw", Float) = 1.0
    29.         [HideInInspector] _Cull("__cull", Float) = 2.0
    30.  
    31.         [ToogleOff] _ReceiveShadows("Receive Shadows", Float) = 1.0
    32.  
    33.         // Editmode props
    34.         [HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
    35.         [HideInInspector] _Smoothness("SMoothness", Float) = 0.5
    36.  
    37.         // ObsoleteProperties
    38.         [HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
    39.         [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
    40.         [HideInInspector] _Shininess("Smoothness", Float) = 0.0
    41.         [HideInInspector] _GlossinessSource("GlossinessSource", Float) = 0.0
    42.         [HideInInspector] _SpecSource("SpecularHighlights", Float) = 0.0
    43.     }


    Regards
    Viktor
     
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,133
    The attributes on the properties you listed are switched around. It should be:
    Code (Boo):
    1. [MainColor] _BaseColor("Base Color", Color) = (1,1,1,1)
    2. [MainTexture] _BaseMap("Base Map (RGB) Smoothness / Alpha (A)", 2D) = "white" {}
    3.  
    Alternatively, you can always be explicit by using Material.GetColor("_BaseColor") or Material.GetTexture("_BaseMap")
     
    phil_lira likes this.
  3. viktorkadza

    viktorkadza

    Joined:
    Sep 4, 2018
    Posts:
    46
    Thanks man! That was so obviously there, but not for Shadergraph noob like me :D
     
  4. Knbmedia

    Knbmedia

    Joined:
    Dec 8, 2014
    Posts:
    18
    It's the source code for the SimpleLit shader in the URP package.
    And it worked before I update to 2019.3.14f1 (and URP 7.3.1)
    Now I have the same error as @viktorkadza
    So I have to change this in source code ( ProjectName//Library/PackageCache/com.unity.render-pipelines.universal@7.3.1/Shaders/SimpleLit.shader).
    This error is still in the URP master branch on Github...
     
    khushalkhan and viktorkadza like this.
  5. khushalkhan

    khushalkhan

    Joined:
    Aug 6, 2016
    Posts:
    168
    The issue is in the source code of URP