Reputation: 11321
I created a pbr shader graph. The problem is when I change the material to use the new shader the character texture is changing too. Is there a way to keep the original texture with the new shader ?
This is a screenshot of the original material using with the character with the original shader :
This is the original textures :
This is the character mesh inspector settings with the script attached to it :
This is the new shader settings in the inspector :
This is the script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public Shader _shader;
// Start is called before the first frame update
void Start()
{
Store();
}
// Update is called once per frame
void Update()
{
}
private void Store()
{
Texture tex = gameObject.GetComponent<Renderer>().material.GetTexture("_MainTex");
gameObject.GetComponent<Renderer>().material.shader = _shader;
gameObject.GetComponent<Renderer>().material.SetTexture("_MainTex", tex);
}
}
When running the game now it's changing to the new shader but it's not keeping the original textures :
I tried to change the line in the script the last line in the Store function to this : but it didn't change much.
gameObject.GetComponent<Renderer>().material.SetTexture("vanguard_diffuse", tex);
This glowing lines is fine this is the effect the new shader should do but I want it to do it on the original textures like in the first screenshots.
The new shader using pbr and hdr and other stuff to make the character slowly disappear and show back again with the glowing color on the edges. I can't figure out how to use it on the character with the original textures.
I just did this tutorial and it's working fine but I want it to work now on the original textures of the character.
https://www.youtube.com/watch?v=taMp1g1pBeE
Upvotes: 0
Views: 717
Reputation: 26
You need to sample from the textures in your shader graph with the sample 2d node (I think it's called). Then you need to link the output from those nodes to the albedo and normal channels of the output node. If you need to sample more than one texture or want to add your other shader stuff to the albedo you can add the two together.
Upvotes: 1