当前位置:网站首页>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);
}
}
边栏推荐
- 超十万字_超详细SSM整合实践_手动实现权限管理
- flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
- What are the conditions for applying for NPDP?
- Pytest+request+allure+excel interface automatic construction from 0 to 1 [familiar with framework structure]
- C language pointer (Part 2)
- Regular matching starts with XXX and ends with XXX
- Redis common commands
- When inputting an expression in the input box, an error is reported: incorrect string value:'\xf0\x9f... ' for column 'XXX' at row 1
- shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
- Zen - batch import test cases
猜你喜欢
随机推荐
Unity shader (basic concept)
Unittest simple project
Regular matching starts with XXX and ends with XXX
Mysql database lock learning notes
STM32 and motor development (from stand-alone version to Networking)
Loxodonframework quick start
DRF authentication, permissions, and flow restrictions (only for views in DRF)
SAP MM STO单据的外向交货单创建后新加ITEM?
12、 Sort
How does the project manager write the weekly summary and weekly plan?
2020 year end summary
flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
Register address name mapping
Using JWT to realize login function
scrapy爬虫mysql,Django等
Regularly modify the system time of the computer
Locust performance test 3 (high concurrency, parameter correlation, assembly point)
Unity uses mesh to realize real-time point cloud (II)
Unity shader (to achieve a simple material effect with adjustable color attributes only)
超十万字_超详细SSM整合实践_手动实现权限管理