Questions tagged [shaderlab]

ShaderLab is a declarative language for writing shaders used in the Unity3D game engine.

ShaderLab is a declarative language used in all shaders for Unity3D. By itself, ShaderLab can only be used to write simplistic fixed function shaders that are compatible with older devices. However, it is often used in conjunction with and inside of CGPROGRAM snippets to write more complex surface shaders or vertex and fragment shaders.

References

79 questions
2
votes
2 answers

Unity particle outline shader

I wish to create an unlit shader for a particle system that emits cube meshes, such that each emitted mesh has a hard black outline around it. Here is the pass for the outline (in Cg): struct appdata { float4 vertex : POSITION; float3 normal…
rbjacob
  • 193
  • 3
  • 14
2
votes
2 answers

In Unity Shaderlab, how can you animate towards a value using lerp and deltaTime

How can a Custom Standard Surface Shader be used to animate a value towards a target value? For Example: ... float targetAlpha; //Set by the property block, or a C# script float currrentAlpha; //Used internally only. void surf (Input IN, inout…
Jethro
  • 3,029
  • 3
  • 27
  • 56
2
votes
3 answers

color ramp shader (cg / shaderlab)

I have a shader function which functions like the "color ramp" node in Blender3D. It takes as input a float between zero and one and outputs a color that is a blend of any number of colors in a specified order: blender3D color ramp Here is my…
dixiepig
  • 123
  • 1
  • 4
2
votes
1 answer

Getting "incorrect number of arguments to numeric-type constructor" error in a shader

I've been learning Unity shader for couple of days and decided to port this oil shader from Shadertoy. I get the following error: incorrect number of arguments to numeric-type constructor at line 69 (on glcore) Here is the relevant part of the…
Programmer
  • 121,791
  • 22
  • 236
  • 328
1
vote
0 answers

Unity Shader with SCript to WebGL?

Does anyone know how to recode a Shaderlab Shader from Unity with an Script to WebGL Website? The original code is from Shadertoy. It was then recoded so it works with Unity. (Original Source I don't know much about shaders so, yeah maybe there is…
Rafael
  • 13
  • 2
1
vote
2 answers

Efficient way to draw circles

I'm drawing circles in the following way: for each pixel px { if (isInside(px)) px.color = white else px.color = black } bool isInside(pixel p) { for each circle cir { if (PixelInsideCircle(p, cir)) return true } …
Hello Humans
  • 25
  • 1
  • 6
1
vote
1 answer

HLSL: What happens when I "squish" a 3x3 matrix into 3x2 matrix?

Initially I thought it just means that the last column is simply discarded, but apparently I am getting differing results when I do such conversion as contrasted with just declaring a 3x2 matrix. float3x3 TBN = float3x3(IN.tangent, IN.binormal,…
1
vote
1 answer

Clip the region in Ellipse shape using ShaderLab in Unity

I am trying to draw an Ellipsoid using shaders in Unity Following the steps 1. I have written a custom shader with the help of some internet tutorial 2. Added the shader on the material 3. Applied that material on the object Shader…
muttahir
  • 115
  • 10
1
vote
1 answer

How can I add a ZWrite pass to a transparent shader graph?

I have been trying to achieve this effect from Tim-C (which all seems to be outdated, even the fixes posted in the comments) with ShaderGraph (Unity 2019.3.0f3), but as far as I know you can't do that within ShaderGraph, so after looking at this…
Grant Shotwell
  • 330
  • 3
  • 14
1
vote
0 answers

How can I rotate Cubemap?

I am currently working on some reflection shaders in Unity. And I am totally newbie about shaders. I found an article about cubemap rotation. I' ve done some implementation but it seems doesn't work properly. I rotated cubemap in vertex shader with…
1
vote
1 answer

How to map letters on mesh with shader?

I'm trying to create a shader that allows mapping text on a mesh. How do I align each character horizontally? Currently, all of them overlap each other. Currently looks like this: Texture used: Shader "Unlit/MapText" { Properties { …
1
vote
1 answer

How do I set a shader setting/property at runtime using MonoBehaviour?

I have a shader that displays a mesh's vertex colors and has the ability to clip vertices that are blue. I'd like the user to be able to turn this setting on/off while using the application. I've tried the suggestions offered here Find and change…
espeon
  • 57
  • 1
  • 8
1
vote
1 answer

Is there a way to ensure that an object is always displayed on top of another with no overlaps?

I'm having some issues with items of clothing on an avatar as you can see in the image below Most would suggest that i simply pull the trousers away from the body within the modelling software which is fine until it is combined with other items of…
Zaine Abaddin
  • 51
  • 1
  • 7
1
vote
1 answer

How to get original texture from SpriteAtlas to use in a shader as alpha mask?

I have an issue, and i need help to resolve it. I am try to colorize some parts of sprite dynamically by custom shader and additional textures as masks. It is not a problem and i solve it easy. Screen for better understanding: This is real…
Sergiy Klimkov
  • 530
  • 7
  • 15
1
vote
1 answer

multiplying vertex data causes uneven outline (shaderlab unity3d)

I have created a simple outline shader in Unity3D's shader lab with two passes: pass one scales the object up by multiplying vertex information along a vertex normal and pass two draws the regular (base pass) version of the object. The problem is in…
rbjacob
  • 193
  • 3
  • 14