当前位置:网站首页>Unity shader (pass user data to shader)
Unity shader (pass user data to shader)
2022-07-07 09:25:00 【heater404】
Unity Shader( to Shader Passing user data )
Modify... By code Shader Properties in
I mentioned earlier that various types of attributes can be defined , Then you can make changes on the panel . But in fact, we can also modify it in the code .
Properties
{
_Color("I am Color", Color) = (1,1,1,1)// In turn RGBA(0-1)
_Int("I am Int", Int) = 1
}
public Material material;//Shader Where material
void Start()
{
material.SetInt("_Int", 200);
material.SetColor("_Color", new Color(0, 0, 0, 0));
}
stay Pass Define the data type in and then assign a value
Shader "Unlit/NewUnlitShader"
{
Properties
{
_Color("I am Color", Color) = (1,1,1,1)// In turn RGBA(0-1)
_Int("I am Int", Int) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float b2;
RWStructuredBuffer<float> b5;
ENDCG
}
}
}
public class NewBehaviourScript : MonoBehaviour
{
public Material material;//Shader Where material
ComputeBuffer b5Buffer;
// Use this for initialization
void Start()
{
material.SetInt("_Int", 200);
material.SetColor("_Color", new Color(0, 0, 0, 0));
material.SetFloat("float", 998);
b5Buffer = new ComputeBuffer(24, 4);
material.SetBuffer("b5", b5Buffer);
}
}
边栏推荐
猜你喜欢
The configuration and options of save actions are explained in detail, and you won't be confused after reading it
Information Security Experiment 3: the use of PGP email encryption software
網易雲微信小程序
答案在哪里?action config/Interceptor/class/servlet
Where is the answer? action config/Interceptor/class/servlet
Entity of cesium data visualization (Part 1)
MySQL common statements
4、 Fundamentals of machine learning
PMP examination experience sharing
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
随机推荐
flex弹性布局
正则匹配以XXX开头的,XXX结束的
What is the use of PMP certificate?
PMP certificate preparation experience sharing
MySQL common statements
Netease cloud wechat applet
Network request process
Why is access to the external network prohibited for internal services of the company?
How to pass the PMP Exam in a short time?
Using JWT to realize login function
12、 Sort
Postman setting environment variables
What are the conditions for applying for NPDP?
liunx命令
SiteMesh getting started example
Several stages of PMP preparation study
(3/8)枚举的不当用法 之 方法参数(二)
Port multiplexing and re imaging
Unity shader (to achieve a simple material effect with adjustable color attributes only)
JMeter JDBC batch references data as input parameters (the simplest method for the whole website)