- Home /
HDRP Lit Shader: How to disable Transparency "Blend preserve" through script?
Hello, i've been trying to disable through a script the "Blend preserve" property of the Transparency Blend Mode of the HDRP Lit Shader. The script does uncheck the "Blend preserve" box in the Inspector, but the material doesn't update unless i click the box manually. Am i missing something in the script?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ToggleFadeSettings : MonoBehaviour
{
Material m;
// Start is called before the first frame update
void Start()
{
m = GetComponent<Renderer>().material;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) {
m.EnableKeyword(" _BLENDMODE_PRESERVE_SPECULAR_LIGHTING");
m.SetFloat("_EnableBlendModePreserveSpecularLighting", 0f);
}
}
}
Bump and further details:
In order to see which keywords are enabled, i updated the Update function to this:
void Update()
{
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space)) {
m.Enable$$anonymous$$eyword("_BLEND$$anonymous$$ODE_PRESERVE_SPECULAR_LIGHTING");
m.SetFloat("_EnableBlend$$anonymous$$odePreserveSpecularLighting", 0f);
foreach(string k in m.shader$$anonymous$$eywords) {
Debug.Log(k);
}
}
}
This is what i get:
The expected result is a completely transparent object with no specular, however, i'm unable to achieve it through scripting.
Your answer
Follow this Question
Related Questions
Transparency cutting opaque mesh 0 Answers
Problem with transparent shader 0 Answers
Changing material color´s alpha in self iluminated shader 1 Answer
2 sides-transparent shader ProblemA 0 Answers