threejs(13)-shader set point material

Shader material built-in variables The built-in variables of the three.js shader are gl_PointSize: In point rendering mode, controls the rendering pixel size of the square point area (note that this is the pixel size, not the three.js unit, so when the camera is moved, the size of the point seen on the screen remains unchanged) […]

threejs(12)-shader to create smoke and water cloud effect

1. Encapsulate the water ripple effect yourself src/main/main01.js import * as THREE from “three”; import {<!– –> OrbitControls } from “three/examples/jsm/controls/OrbitControls”; import gsap from “gsap”; import * as dat from “dat.gui”; import vertexShader from “../shaders/water/vertex.glsl”; import fragmentShader from “../shaders/water/fragment.glsl”; // Goal: Set the cloud smoke effect //Create gui object const gui = new dat.GUI(); // […]

threejs(11)-Proficient in shader programming (difficulty) 2

1. Writing advanced patterns with shader Small Japanese flag precision lowp float; varying vec2 vUv; float strength = step(0.5,distance(vUv,vec2(0.5)) + 0.25); gl_FragColor =vec4(strength,strength,strength,strength); Draw a circle precision lowp float; varying vec2 vUv; float strength = 1.0 – step(0.5,distance(vUv,vec2(0.5)) + 0.25); gl_FragColor =vec4(strength,strength,strength,strength); Ring precision lowp float; varying vec2 vUv; float strength = step(0.5,distance(vUv,vec2(0.5)) + 0.35); […]

Unity shader syntax

Previous article: TA Shader basics shader syntax ShaderLab+CG Unity defines commonly used vertex-based data boxes The default data of the following boxes is as follows, which can be flexibly changed by yourself and loaded with any data type (float, float2, float3, float4): POSITION: location NORMAL: normal TANGENT: tangent TEXCOORD0: texture coordinates TEXCOORD(n): Define the content […]

Meta Pass generation of Shader’s indirect light in Unity

Article directory Preface The indirect light of Shader in Unity generates Meta Pass, which is also the content of global illumination GI. It is mainly implemented like in real life, when light shines on a colored object, the object has the effect of reflecting light of that color. 1. Let’s first use Unity’s own Shader […]

Shader light probe support in Unity

Article directory Preface 1. Where and how to use light probes 1. Application scenarios of light probes 2. We build an identical environment in Unity according to the above conditions. 3. Create light probes 2. Implement support for light probes in our own Shader 1. Use the commonly used cginc 2. In v2f, prepare the […]

URP built-in Lit.Shader file ForwardLit Pass parsing

Article directory Lit main file Properties SubShader code block FormardLit Label Compilation command Declare keywords Material Keywords Rendering pipeline keywords Universal Pipeline keywords Unity defined keywords Unity defined keywords Contains directives 1. LitInput.hlsl (1) Attribute variables (2) Texture sampling function (3) AO sampling function (4) Surface data initialization function SurfaceData: fragment data, in `SurfaceData.hlsl` SurfaceInput: […]

Judgment of Shader’s baking branch in Unity

Article directory Preface 1. The lightmapUV required in the previous article will only be used during baking. 1. After checking the help document, Unity uses LIGHTMAP_ON to determine whether baking is enabled. 2. We define the second set of UVs in appdata and v2f Foreword Judgment of the baking branch of Shader in Unity, based […]

UnityShader(5)

This time I’m going to use a surface shader to create a water effect. Scroll to the bottom first to read the code. If you don’t understand, then read the explanation below. The first step is to judge the depth of water and distinguish between deep water areas and shallow water areas. The concept of […]