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
0
votes
0 answers

HLSL lighting based on texture pixels instead of screen

In HLSL, how can I calculate lighting based on pixels of a texture, instead of pixels that make up the object? In other words, if I have a 64x64px texture being rendered on a 1024x768px screen, I want to calculate the lighting as it affects the…
Felipe
  • 10,606
  • 5
  • 40
  • 57
0
votes
1 answer

Applying successive shaders to a texture while keeping float precesion

I have a render texture in Unity and am applying successive shaders to it as following: Graphics.Blit(Tex1, Tex2, myMaterialA); Graphics.Blit(Tex2, Tex3, myMaterialB); Graphics.Blit(Tex3, Tex4, myMaterialC); In my shaders, I only…
Mai Kar
  • 138
  • 1
  • 3
  • 18
0
votes
0 answers

Unity Z-Order. How can I put all sprite upon ground but not effects?

I have many soldiers(600+) on a battleground. So all soldier should be a 2d sprite for the performance issue. As you can see the foot of the horse is underground, so to solve this, I turn off the ZWrite in ground's shader. ZWrite Off But when I…
Tim
  • 2,121
  • 2
  • 20
  • 30
0
votes
3 answers

How to recalculate normals?

I'm trying to write a simple shader that moves all verts with a sin wave. v.vertex.y += sin(_Time.y * _Speed + v.vertex.x * _Amount * v.vertex.z) * _Distance; The problem is that after moving them, the normals are wrong, thus there are no real time…
Al3x
  • 125
  • 2
  • 9
0
votes
1 answer

Way to pass an Integer array/texture to unity shader

I'm trying to achieve rendering of cell-based terrain (one like in old games like Transport Tycoon) with strong cell borders. To optimize performance I pass a texture with an actual game map in which I try to encode a cell type for a custom shader,…
Pavel Vorobyov
  • 773
  • 6
  • 10
0
votes
0 answers

Merging 2 shaders in Unity using CG programming and Shaderlab

I want to merge the functionality of these two shaders for Unity. First shader is main shader that adds a glitch hologram effect. The Second shader is making a surface texture flimmer for added visual effect. I am trying to merge my versions of…
user4626838
0
votes
2 answers

Trying to Reproduce a light source Lara Croft Go in Unity

I want to have a light that projects onto multiple planes of my level geometry, to mimic the effect in this video: http://youtube.com/watch?v=vujrxOmh8Jc I attempted to recreate it with a point light, like this: But mine only projects on the the…
hassan sadeghein
  • 97
  • 1
  • 1
  • 5
0
votes
1 answer

Properly calculate circle maximum radius size based on screen size

I am trying to draw a circle, fill the inside with a red color and the outside with a black color. I want to set the size of the circle from code. With 0 being the smallest size and 100 being the maximum size of the circle and 100 means that the…
PassetCronUs
  • 447
  • 4
  • 11
0
votes
1 answer

Issue with initializing global variable in Shaderlab

I just realized that a global variable in Unity must be initialized in a function. Being new to shaders, I can't tell if I am doing this the wrong way. For example, when I define a const variable: const float PI = 3.14159265359; then try to write a…
Programmer
  • 121,791
  • 22
  • 236
  • 328
0
votes
1 answer

vertex distortion in shaderlab

I'm rather new to shaderlab with unity. I am trying to distort the vertices so that they are push backwards and towards the camera almost like looking at the camera from a 45 degree angle. I am replicating an effect from a game for fun. This is the…
0
votes
0 answers

Darken a gameobject which cross fog border

I created fog by raw image and material with custom shader. Now I want to darken some gameobjects(sprites) which cross fog border. But I'm noob in shaders. How I can do this? Write any links on manuals/tutorials or some ideas. Picture for clarity:…
Slimper
  • 23
  • 2
  • 6
0
votes
1 answer

ShaderLab use default unity skybox

All of the reflection examles set the Cubemaps with the property like: Properties { _Cube("Reflection Map", Cube) = "" {} } But i want to use the skybox from "Lighting" for all shaders. How to do that?
Tomas
  • 55
  • 2
  • 8
0
votes
1 answer

HLSL (Unity-specific ok, not necessary) combining Stencil and worldspace "reverse" clipping

I've built a working surface shader (call it "wonderland") that renders as invisible unless a companion "lookingGlass" shader intersects with it from the viewpoint of the camera. Simple stencil shader arrangement. Easy peasy. I can add shader…
EddieOffermann
  • 145
  • 1
  • 7
0
votes
1 answer

Unity shader how to store uv parameter?

In my shader, I calculate uv by multiplying vertex.position to some matrix. This looks fine if I dont move my object, but once I move my object or scale the object, the vertex position will change and uv will be wrong. If there is a way for shader…
ywj7931
  • 135
  • 1
  • 3
  • 9
0
votes
1 answer

Unity Pass multiple textures(array) into shader?

Right now in my shader, I have 5 textures, Properties { _MainTex ("Texture", 2D) = "white" {} _MainTex2("Texture2", 2D) = "white" {} _MainTex3 ("Texture3", 2D) = "white" {} _MainTex4 ("Texture4", 2D) =…
ywj7931
  • 135
  • 1
  • 3
  • 9