当前位置:网站首页>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);
}
}
边栏推荐
- Implementation of corner badge of Youmeng message push
- 【SVN】SVN是什么?怎么使用?
- 十二、排序
- stm32和电机开发(从单机版到网络化)
- VSCode+mingw64
- Jenkins automated email
- Locust performance test 4 (custom load Policy)
- Run can start normally, and debug doesn't start or report an error, which seems to be stuck
- C language pointer (Part 2)
- 4、 Fundamentals of machine learning
猜你喜欢
Pycharm create a new file and add author information
Unity shader (to achieve a simple material effect with adjustable color attributes only)
E-commerce campaign Guide
What are the conditions for applying for NPDP?
Variable parameter of variable length function
Information Security Experiment 4: implementation of IP packet monitoring program
Mysql:select ... for update
Pytest+request+allure+excel interface automatic construction from 0 to 1 [familiar with framework structure]
Common short chain design methods
Difference between interface iterator and iteratable
随机推荐
Leetcode刷题记录(数组)组合总和、组合总和 II
PMP Exam details after the release of the new exam outline
flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
What is the use of PMP certificate?
[cloud native] Devops (I): introduction to Devops and use of code tool
Install pyqt5 and Matplotlib module
【云原生】DevOps(一):DevOps介绍及Code工具使用
Locust performance test 5 (analysis)
Unity shader (basic concept)
What are the conditions for applying for NPDP?
[SVN] what is SVN? How do you use it?
Mysql database transaction learning notes
Information Security Experiment 2: using x-scanner scanning tool
Serializer & modelserializer of DRF serialization and deserialization
When inputting an expression in the input box, an error is reported: incorrect string value:'\xf0\x9f... ' for column 'XXX' at row 1
章鱼未来之星获得25万美金奖励|章鱼加速器2022夏季创业营圆满落幕
Why is access to the external network prohibited for internal services of the company?
Jenkins+ant+jmeter use
Entity of cesium data visualization (Part 1)
Nested (multi-level) childrn routes, query parameters, named routes, replace attribute, props configuration of routes, params parameters of routes