81
questions
0
votes
0
answers
35
views
In writing a custom Camera shader in Unity (Shaderlab), how do I color each point in the captured image to be the color of the original 3D point?
I'm writing a Camera shader for Unity, which I'm rendering on a Camera using Camera.SetReplacementShader. I've currently defined a vertex and fragment shader, which serves to emulate a real-world ...
0
votes
0
answers
29
views
How to draw chart with high point density(>1 point per px) in Unity?
I have big array of values/samples, and i need to draw wave chart in uGUI for it. So i have points with same interval at the coordinate x and i should connect them. I tried to draw it by few methods, ...
0
votes
0
answers
168
views
(Unity shader). Problem with screen position
So I need to get the objects screen position, and here is the code I use for it:
v2f vert(appdata_full v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = ComputeScreenPos(o....
0
votes
1
answer
190
views
Unity shader,Zwrite On is not working. i cant see my object in scene
I set ZWrite to On for my object in Unity's shader and set it to the Geometry render queue. However, this object is not visible in the Scene, and I can see through Frame Debug that the Zwrite for this ...
0
votes
0
answers
34
views
Weird aliasing artifact on corners of a rectangle with SDF
I am trying to implement local anti-aliasing for rectangles with signed distance fields. However the pixels at the corners does not look quite right. Below is a screenshot of one of the corners.
Here'...
0
votes
0
answers
58
views
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)
}
...
0
votes
1
answer
197
views
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 ...
0
votes
1
answer
397
views
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 ...
0
votes
1
answer
1k
views
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 ...
0
votes
1
answer
132
views
Why does my Unity shading work strangely on a Mesh?
So for context, I create a mesh based on vertex and triangleindice data. Within the function I create a Polygon object, which basically holds an array of vertices who each have their individual colors ...
1
vote
0
answers
76
views
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 ...
0
votes
1
answer
619
views
How do I include shader functions from a package in a unity shader? (built-in pipeline)
I have installed the package NoiseShaders (https://github.com/keijiro/NoiseShader.git) via the package manager in Unity. It shows up as installed in my package manager.
My question is how do I use its ...
2
votes
1
answer
368
views
Sprite outline effect appears one frame later
So, I have the following problem in a Unity 2019.4.36f1 fresh project.
I would like to outline group of sprites with the Built-in render pipeline. For this, the developer needs to collect the ...
2
votes
0
answers
2k
views
How do I convert unity shader to URP?
So I found this shader on the internet, but apparently it doesn't work with URP, what do I add to it to make it work with URP? I don't know much about shaders. Kindly help me out.
Shader "Custom/...
1
vote
2
answers
915
views
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 (...
0
votes
1
answer
570
views
What does "2..xxx" mean in shaderlab?
float3 f = float3(1,2,3);
f *= 2..xxx;
I have no idea what ..xxx does. I got the code from here
-1
votes
1
answer
300
views
How to implement water clipping plane in Unity
https://youtu.be/0NH9k4zTAqk
I am using a camera for water reflection.
Is there a way to not render as height below the water level?
like the youtube video above.
Sorry for my bad english.
2
votes
1
answer
2k
views
Create an Unity transparent shader that hides itself
My shader code is:
Shader "Custom/Transparent" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB) Trans (A)", 2D) = "...
2
votes
0
answers
683
views
How to use Unity3d shader to mask another two-pass shader?
I am developing a game where I want to visualize user path - showing also where track overlaps (with some darker color than normal "not overlapped" track). Long time ago I have found this ...
0
votes
1
answer
735
views
"Stencil Operation" property setup?
I know when declaring the properties for a shader there are some types of "input": float, range, color, 2D.
but when I try to set up a Stencil Operation as a property. how to do this? I mean ...
1
vote
1
answer
460
views
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.
...
2
votes
0
answers
3k
views
How can I create Shader in runtime in Unity?
I want to create Shaders in Runtime in Unity.
Is there any way? I found that article Creating GLSL Shaders at Runtime in Unity3D
but this is no more working because Unity doesn't accept new Material({...
3
votes
2
answers
16k
views
Expose float2/vector2 property from shader to Unity material inspector
In a Unity shaderlab shader you can expose shader properties to the material inspector in the editor. This can be done by placing the properties you want to expose in the Properties section like so
...
1
vote
1
answer
700
views
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 ...
2
votes
1
answer
2k
views
Shader saturate() creating gradient when it shouldn't
Writing a shader for Unity and I don't understand what is happening here. I have a sphere with a material attached. Material has a shader attached. Shader is very simple, it generates some simplex ...
2
votes
1
answer
7k
views
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 ...
0
votes
1
answer
4k
views
Shader to warp or pinch specific areas of a texture in Unity3d
I've mocked up what I am trying to accomplish in the image below - trying to pinch the pixels in towards the center of an AR marker so when I overlay AR content the AR marker is less noticeable.
I am ...
0
votes
0
answers
278
views
Efficiently color pixels by given region as polygon in shader
In my application, I have partitioned the screen into different regions. These are given by the polygon boundaries. Once this partition has happened in the CPU, the shader should now give each pixel a ...
0
votes
1
answer
1k
views
Trying to modify Shader so that the colors are vertical and not horizontal
This shader (copied below) makes a material kind of like a radial gradient.
I am trying to modify it to have the shader effect resemble something like a vertical/linear gradient,like this. I don't ...
0
votes
1
answer
1k
views
Unity: Hide material in specific area
I am making a 3D application for ios and Android.
Each object in the below image has a different material than others.
I want to make the part of object 3 that intersects with object 2 appears and ...
2
votes
1
answer
1k
views
Unity mesh has black spots
Hello I have followed a video series on YouTube made by Sebastian league on procedural generation and I have followed his whole video series, however on my part there are black spots in the mesh, only ...
1
vote
0
answers
1k
views
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 ...
1
vote
1
answer
1k
views
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:
...
2
votes
1
answer
2k
views
How to create a shader that can display a texture made out of many small images in Unity
So what I'm trying to do is load satellite images from an SQL table and wrap them around a sphere to create a globe. I know I've got loading the images covered, I'm just not sure how to make my shader ...
3
votes
1
answer
1k
views
Why I can't use tex2D inside a loop in Unity ShaderLab?
I am trying to do something like
while (currentLayerDepth < currentDepth)
{
currentUV -= step;
currentDepth = tex2D(_HeightTex,currentUV).a;
currentLayerDepth += ...
2
votes
2
answers
3k
views
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 ...
3
votes
1
answer
777
views
What is IN.worldRefl in surface shader Input struct?
The question is pretty straight-forward. I have no idea what IN.worldRefl stands for, I've seen some tutorials using it with cubemaps but I still have no clue.
Unity's description for it is very poor:...
1
vote
1
answer
5k
views
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 ...
0
votes
1
answer
1k
views
How do I discard pixels based on vertex color and turn that on or off in a MonoBehaviour?
I've written a shader that uses a mesh's vertex colors and also has a function that clips all vertices that have an interpolated vertex color in the blue channel greater than 0.5 (discards all blue ...
0
votes
1
answer
887
views
ShaderLab offset not rendering one polygon above the other
I have two shaders, UnlitRGBA and TransparentNoOverlap. They are as follows:
UnlitRGBA.shaderlab
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
...
0
votes
1
answer
193
views
How to cache common (for all pixels) variables in ShaderLab?
Suppose I have the following shader:
Shader "Sprites/X"
{
Properties
{
[HideInInspector] _MainTex("Sprite Texture", 2D) = "black" {}
}
SubShader
{
Pass
{
...
1
vote
1
answer
2k
views
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 ...
1
vote
1
answer
6k
views
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.
...
1
vote
1
answer
1k
views
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 (...
0
votes
1
answer
175
views
Weird behaviour of shader when saving a scene
I wrote a custom Editor script for a class of mine to set colors to a material whenever any of the color values change, this gives me the option to preview the colors on the go.
The script works very ...
3
votes
1
answer
1k
views
Dump resources from Unity game to a file
I am trying to create a function that dumps every Resources data in a Unity game to a file and was able to dump the video, audio, script names and the image on the screen from the current loaded scene....
0
votes
0
answers
9k
views
How can I get texture size in shader?
I am trying to implement shader for a LineRenderer (Unity component). And i need to get value from 0 to 1 for x axis in frag shader, that means position in local texture coordinates (0 for pixel on ...
1
vote
2
answers
11k
views
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 ...
11
votes
1
answer
3k
views
Implementing Fur with Shells technique in Unity
I am trying to implement fur in Unity with the Shells technique. The Fins technique is purposely left out because I want this to run on low end mobiles (mostly Android devices) and that requires ...
1
vote
2
answers
838
views
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 ...