Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material doesn't have a texture property '_MainTex' #7

Closed
boxseto opened this issue Jan 31, 2021 · 4 comments
Closed

Material doesn't have a texture property '_MainTex' #7

boxseto opened this issue Jan 31, 2021 · 4 comments

Comments

@boxseto
Copy link

boxseto commented Jan 31, 2021

Hi,

I am very new to both unity and shader, and I come across your brilliant project.
I just tried to pull your code and import to a new project I loaded together with Unity-chan. I tried to change her body material to this project, but everything goes purple and the following error was thrown

Material 'body' with Shader 'SimpleURPToonLitExample(With Outline)' doesn't have a texture property '_MainTex' UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

image

I have tried to

  1. add the original picture to _BaseMap (Albedo)
  2. change the variable _BaseMap to _MainTex in SimpleURPToonLitOutlineExample.shader
    but both does not work...

If it helps, I am using Unity version 2020.1.f11.

I am very new to these tools and concepts, I am sorry if I asked a stupid question.

@Kadae
Copy link

Kadae commented Jan 31, 2021

Hi, you can try to add this to the shader...

_MainTex("Main Texture", 2D) = "SimpleURPToonLitExample(With Outline)" {}

I have similar issues on another shaders, but this is a hotfix, lol.

@boxseto
Copy link
Author

boxseto commented Jan 31, 2021

I tried but it seems not working...
Do you mean adding the line in properties section of SimpleURPToonLitOutlineExample.shader file?
I tried to add there, plus adding/removing the code for _BaseMap, but still the texture does not render.

Can I ask if your fix is trying to "add a new texture to the shader" or "replace the texture of the _BaseMap texture"?

@Kadae
Copy link

Kadae commented Jan 31, 2021

I just added this to Properties, but this helps in another shader, not in this.
Important: the name must be the same as the Shader's name (first line of code).

_MainTex("Main Texture", 2D) = "** SHADER NAME **" {}

If this not works, so... I don't know, sorry.

@boxseto
Copy link
Author

boxseto commented Jan 31, 2021

OK, so after some testing and poking around, I found that the problem is I used the wrong pipeline...

Make sure you choose "Universal Render Pipeline" when creating a project:
image

I have chosen "3d", but it does not render correctly even after I imported URP in packet manager (not sure why, so you may need to search on swapping pipeline if you are upgrading it).

For those tries to use this with Unity Chan (For Absolute Beginners like me):

  1. Open new project with URP selected
  2. Install Unity chan and this project
  3. go to /Assets/unity-chan!/Unity-chan! Model/Art/Models and put the model to scene
  4. go to /Assets/unity-chan!/Unity-chan! Model/Art/Materials, the preview should be all wrong; this indicate that the pipeline of original Unity-Chan is using a different rendering pipeline
  5. for each of the material, change its shader to the one in this project

In the end something like this should be seen:
image

It does not look good but at least it renders. From here I can try to poke around with the project code. Thanks!

TL;DR: Purple is wrong pipeline, Are you sure you are using URP?

@boxseto boxseto closed this as completed Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants