Questions tagged [shaderlab]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
50 views

Overlapping geometry (Z - Fighting) solution with shader in Unity

I have geometry that is overlapping with other geometry (the floor). So, I used a shader to bring my desired mesh to the top. However, a new problem arose: the shader was rendering not only on top of ...
Muhammad Faizan Khan's user avatar
0 votes
0 answers
50 views

Why is _GrabTexture(texture of current frame buffer) always empty in my code and how do I fix it?

*I am using Unity 2021.3.29 and the built-in render pipeline. Here is a fragment shader I wrote that uses a grab pass to replicate an "average color" blend mode ...
rasputin's user avatar
1 vote
1 answer
868 views

How to support Texture Tiling + Offset for custom shader

I've written a custom shader (with help) and I'm not sure why it does not have tiling & offset capabilities. What is the simplest way to add that feature to my shader? current shader code ...
Jacksonkr's user avatar
  • 229
0 votes
0 answers
46 views

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 ...
rasputin's user avatar
0 votes
0 answers
451 views

Render only part of mesh that is intersected into inother Mesh in Unity

How can i make ZTest only happen inside a object not behind it? my shader is simple unlit with two pass one is ZTest Greater as red one and one is ...
Cyclone's user avatar
  • 31
0 votes
0 answers
144 views

Why is the back layer sometimes rendering in front?

I have a layer rendering issue, where the top layer of content will sometimes not render to screen as it appears that the bottom layer is rendering on top (even though it's behind in world space). It ...
A__'s user avatar
  • 163
0 votes
1 answer
406 views

OUT.worldPosition effect on shader

I am trying to follow a shader tutorial from 2016 for unity. I reached the point where the author is distorting the text by changing OUT.wordPosition ...
Andrey's user avatar
  • 230
0 votes
0 answers
44 views

How to make it possible to change the width of the stripes?

I am making a shader to create stripes based on this tutorial, but I cannot set the width for each stripe and make a shader that accepts light. ...
Aimon Z.'s user avatar
  • 107
0 votes
1 answer
2k views

How to do "Screen Space Texture" mapping on a Unity UI Image?

So I'm fairly new to the shader and I've been trying to achieve this kind of effect from Ronja Tutorials, but instead of using it for normal mesh object, I'm trying to use it for Screen Space UI Image ...
deanrihpee's user avatar
0 votes
0 answers
187 views

Stencil test doesn't work at all in Unity when I am using a custom shader

I am using Unity 2019.3 and I have a custom shader A which contains the code Stencil{ Ref 5 Comp Equal Pass Keep } And the other custom shader B ...
OtakuFitness's user avatar
2 votes
1 answer
989 views

how are semantics used when declaring a struct?

I don't understand how semantics are used in shaders. While reading Unity's shader tutorials, I come across this ...
Mingheng Wang's user avatar
1 vote
1 answer
3k views

Morphing a 3D model into a sphere or cube using a vertex shader

I want to morph between 3d models.I found a simple OpenGL code to morphing In Graphics Shaders: Theory and Practice(page 456) but I couldn't Implement it correctly in unity. ...
Seyed Morteza Kamali's user avatar
0 votes
1 answer
5k views

How to add emission to texture in shader?

I want a texture to emit itself by 1, not more. In Standard Shader I enable Emission and set texture to Color and Color to 1. I don't need emission to go beyond the object, I only need the texture to ...
Ziya Jafarov's user avatar
0 votes
2 answers
302 views

GPU Gems Chapter 1, update normal

Had plans to follow GPU Gems to gain knowledge in Shaders - but my journey came to an abrupt end. ...
Sindri's user avatar
  • 21
0 votes
0 answers
296 views

Half-shaded pixel artifacts on 2d dynamic lighting shader

I'm working on a shader for dynamic lighting in a 2 unity game. I'm new to shaders but I've managed to get something close to the effect I was looking for, although not 100%. As you can see in the ...
PixelCake Games's user avatar
1 vote
2 answers
2k views

How can I make a shader that will make a cube or any object invisible?

I'm trying to create a shader that will make the object invisible and then with a script a fade in/out effect between invisible and visible. What I tried: ...
Daniel Lip's user avatar
  • 1,747
76 votes
1 answer
23k views

How can I make a "wet surface"/"shallow puddle" shader in Unity?

In my game I need to create dynamic water puddles but I cannot find a tutorial that shows how I can make such an effect (an example of which is shown below). How can I do it?
Seyed Morteza Kamali's user avatar
0 votes
1 answer
3k views

How can I fix my shadow caster problem?

I'm trying to make invisible object with shadow by using it's shadow castting pass it additionaly shades back side of object itself. I mean object shades his back side and draws shadow on the ...
Seyed Morteza Kamali's user avatar
9 votes
1 answer
3k views

Moving texture according to position in shader

Divinity Original Sin have beautiful particle effect , When I move around game I see galaxy through particle that move according to my position.how can I make like it? you can see this effect here: ...
Seyed Morteza Kamali's user avatar
13 votes
3 answers
9k views

How can I make natural rain drops on screen?

I'm trying to make rain effect drop with metaballs and trail on screen.I find a clue in shadertoy but I didn't understand how implemented: https://www.shadertoy.com/view/ltffzl unfortunately it have ...
Seyed Morteza Kamali's user avatar
0 votes
1 answer
3k views

how can I make delay in shader?

my effect is loop but I need have delay between each flash effect.i don't want use c# code because i believe there is easy way to implement delay in shader. ...
Seyed Morteza Kamali's user avatar
3 votes
1 answer
4k views

How can I roll up a plane with a vertex shader?

I have plane that I want to roll up using a vertex shader, like this: I found a math demo that shows the kind of curve I want my mesh to follow. I tried implementing this in my shader code, but the ...
Seyed Morteza Kamali's user avatar
1 vote
0 answers
934 views

How to create inline glow shader for 2d polygon in CG using Unity Shader Lab?

So here is what I am trying to do. Given irregular polygon (on the left) I would like to be able to create a shader that would resemble Photoshop inline glow effect with opaque fill (on the right). ...
IndieForger's user avatar
0 votes
0 answers
160 views

How can I Increase pixel In rendering my shader?

This is my flow map shader , it works correctly but I have problem In Rendering. how can I Increase pixels per unit In my shader? ...
Seyed Morteza Kamali's user avatar
0 votes
1 answer
2k views

Accessing vertex Input in surf directly without vert's out parameter In Tessellation Shader

I can get the vertex Input in vertex shader as follows: o.worldPos = v.vertex.xyz; But how do I get the worldPos directly without filling the out parameter in ...
Seyed Morteza Kamali's user avatar
1 vote
0 answers
109 views

how can I add animated shadow on my flag?

this is my flag: I need to adding shadow effect on my animated flag like below image but I don't know how can I do this: here is my shader: ...
Seyed Morteza Kamali's user avatar
2 votes
1 answer
215 views

How to draw texture with unlit effect on surface base texture

I am writing a shader to my Unity game and I want to have effect this type of effect: Base texture, for example, skin of character is a texture that will use shadows, lighting. Second texture, unlit, ...
Michael's user avatar
  • 119
6 votes
1 answer
1k views

How can I make custom character face editor In my game In an optimal way?

In many games there Is section as customize character that you can make your own character.I always love to know how can I make something like It. Even old game have this feature? but how ? For ...
Seyed Morteza Kamali's user avatar
9 votes
1 answer
893 views

Why does duplicating my object cause its vertex animation shader to distort it?

I used a vertex shader (based on this example) to animate a flag waving. When I have a single flag in my scene, it works correctly. When I duplicate the flag, all of the copies become wildly ...
Seyed Morteza Kamali's user avatar
0 votes
1 answer
3k views

Why my stencil mask doesn't work?

I've a very sipmle Unity scene. It has two objects in it, which is Sprites, and they both use sipmle black boxes as a textures. Here's two shaders, one should act as a mask, and second as a object, ...
PaulD's user avatar
  • 781
1 vote
0 answers
1k views

Adding an extra Pass to the Unity Standard Shader

I'm experimenting with adding some procedural textures to the unity standard shader. I'd like to add an extra pass (with vert and frag functions), but am unsure about where in the sequence this should ...
UpTheCreek's user avatar
4 votes
0 answers
3k views

Overlap transparent particles without blending? (Unity)

I'm trying to create a continuous output of light from an object (like the exhaust of a space ship), and I thought I'd use particles to achieve this. But I'm running into a problem with alpha blending....
eternal's user avatar
  • 341
2 votes
0 answers
458 views

Shaderlab and Cg API reference [closed]

I am looking for definitive information on Shaderlab's API and the Cg language. The documentation I have found so far has been by way of example programs rather than a definition of APIs. Also, ...
user3457326's user avatar
3 votes
1 answer
2k views

Selective Image Effects with Stencils

I am trying to create an image effect where only a part of the image has the effect applied to. One way I can think of to do this is to define the portion of the image using the stencil buffer. ...
eclmist's user avatar
  • 1,153
5 votes
1 answer
4k views

How are Stencil Buffer Operations Applied in ShaderLab

In Unity's Shader lab, I've read that the Stencil buffer is implemented with a mask, and an object reacting to the mask. The mask may be defined like the following: ...
eclmist's user avatar
  • 1,153
0 votes
0 answers
124 views

Unity equivalent of glDepthMask or alternative

I'm trying to achieve the following setup: 2 cubes. In the image attached they are the green and pink cube. They are both rendered culling their front faces, so that they are visible if a camera ...
SaldaVonSchwartz's user avatar
1 vote
1 answer
748 views

Problems with BlendOp Max

I'm trying to write a shader that doesn't blend additively etc etc. I'd like to take whichever of the source or destination colours is brighter and use that and ...
LeftRight92's user avatar
4 votes
2 answers
1k views

How do I get a Light's Range value in Shader?

I'm trying to write a simple frag/vert shader that, depending on whether it is in the range of a light, will paint the appropriate colour from either the 'lit' texture or from the 'unlit' texture. ...
LeftRight92's user avatar
2 votes
1 answer
2k views

How to apply a shader to only one side of an object in Unity3D

So I have this rather simple surface shader that essentially cuts a hole in the object based on another texture. ...
Uri Popov's user avatar
  • 3,027
1 vote
1 answer
6k views

Unity / How do I change the color of an object based on its depth?

The objective here is to change the color of the nearest object. (the nearer the object, the more "colorful" the object gets rendered; and the farther away, the more "grey" the ...
OC_Raiz's user avatar
  • 11
0 votes
1 answer
234 views

Unity Geometry Shader Compiles forever

I am writing a shader to achieve a laser show effect example. For now I am just focusing on the lines. One line ist represented as one triangle. When I save my shadercode, unity gets inactive and I ...
Freshchris's user avatar
6 votes
1 answer
22k views

Why can't I sample a texture in a vertex shader?

I'm old in Game Development but very new in shader writing. I just want a shader that transform from 1 texture to another. So I did start learning shader writing and wrote my desired shader. But ...
Hamza Hasan's user avatar
  • 3,377