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
1
vote
2 answers

How can i convert uv coordinates to world space?

I am trying to implement a shader. It will use with Unity LineRenderer. Shader will have noise that scrolling overtime raltive to texture coordinates. For example in parallel to x axis of uv space of texture. I have an implementation, but i…
Sergiy Klimkov
  • 530
  • 7
  • 15
1
vote
2 answers

Do I need triangle information in my surface shader?

Update The main question is: How can I pass the world space vertex positions of the triangle to the surface shader in a Unity shader. As mentioned in a comment it might be possible to pass them from a geometry shader. But I read somewhere that…
Luca Hofmann
  • 1,442
  • 2
  • 14
  • 26
1
vote
1 answer

Packing int16 into fixed2 (Red + Green)

In Unity, a heightmap is internally shorted as an Int16 (note that only 0-32767 is used). I want send the heightmap to the GPU, and ideally only use 16-bits. It seems like the best way to do that would be to encode the heightmap value to a RG16…
AquaGeneral
  • 155
  • 1
  • 19
1
vote
1 answer

How does the Unity terrain engine add an arbitrary amount of shader passes?

Right now I'm working on a project that involves applying splatmaps to a generated mesh. I'm trying to use the built in Terrain shaders to achieve this but I'm running into one problem that involves the "FirstPass" and "AddPass" shaders. It's pretty…
Walker Christie
  • 531
  • 1
  • 3
  • 18
1
vote
2 answers

Unity3d - remove white background from an image at runtime

I am working on a unity application for children. The idea is that the kids draw an image (like a fish) on a white surface, which is then stored as an image file on a folder. The application has to import these at runtime and then move them around…
1
vote
0 answers

Gaussian blurring wrong objects using Grabpass (on Unity ShaderLab)

I'm attempting to apply a Gaussian blur to a plane, such that any object behind the plane gets blurred, and any object in front of the plane does not get blurred. The code for my shader is as follows: Shader "Custom/Blur" { Properties { …
1
vote
1 answer

Unity Shader: Overlapping two Layers with the same stencil value

I'm trying to write a shader for unity that will remove all overlapping fragments of the underlying objects. I found different solutions for this problem, which were really helpful. For me this Link (Unity shader highlighting overlaps) was the most…
Manuel
  • 21
  • 6
1
vote
2 answers

Unity Shaderlab- transform from screen space to world space

I'm making a post-processing shader (in unity) that requires world-space coordinates. I have access to the depth information of a certain pixel, as well as the onscreen location of that pixel. How can I find the world position that that pixel…
HalpPlz
  • 691
  • 4
  • 11
1
vote
0 answers

How can I render two transparent objects as one continuous object?

I'm struggling with transparency right now to get two objects to overlap and work as one layer. Ideally I'd just have one big red field over the skybox but instead I have moments where the transparency adds up. Is there an effective way around…
thnewlands
  • 33
  • 6
0
votes
0 answers

How to get multiple values from a texture in parallel in HLSL (ShaderLab)?

I am new to HLSL (ShaderLab) and this site. I need some help. Shader "TEST/UnlitMultiStarTest" { Properties { _BaseColor("BaseColor", Color) = (0, 0, 0, 1) _StarColor("StarColor", Color) = (1, 1, 1, 1) …
Bekosan
  • 1
  • 2
0
votes
0 answers

Same Shader Do Not Perform Same Effect In Different Project

I am learning a basic lambert lighting model shader, the shader scripts: Shader "Unlit/NewUnlitShader" { Properties{ _MainColor("MainColor",Color)=(1,1,1,1) } SubShader { Pass { CGPROGRAM …
0
votes
0 answers

Discarding pixels of a 2D game object based on its properties in camera render texture?

I have a c# script and a shader script that is supposed to create two game objects and discard pixels of the second game object based on whether or not the b value of the pixel as shown in a camera's render texture is equal to a b value previously…
rasputin
  • 31
  • 5
0
votes
1 answer

Unity Built-In Renderer Volumetric Rendering Shader Problem

So I tried to create an unlit shader in unity using the built-in render pipeline and blit it to the screen using the function: OnRenderImage(RenderTexture src, RenderTexture dest) in my C# code. I have been kind of loosely following this…
0
votes
1 answer

Problems and Inaccuracies Converting + Interpreting Unity Shadergraph to C#

Context I've been trying to create a buoyancy script that samples the position of a point, tests if it's under a certain level (the "water level"), and adds a force on that position based on depth. Separately, I worked on creating a nice looking…
0
votes
1 answer

How to make things "scale independent" in shader?

I tried to make border using rectangular sdf but with different scale it gets distorted. I was thinking about object scale but can't figure how to do this myself Object scales: (1, 1), (1, 0.125) How it looks Desired result (Made in photoshop,…
lafxyz
  • 3
  • 2