#archived-shaders
1 messages · Page 66 of 1
Bump.
Still not sure if this goes here or in #💥┃post-processing too. It fits both..
what kinda noise would you use for a procedural texture used to color the grass shader above it? not too familiar with all the kinds of noises
(URP) I have a pretty basic shader setup with some normal information, and for some reason the normals only show up when the shader is applied to a primitive object like cube or sphere, and I'm trying to put it on imported fbxs from blender. ANy idea why this happens?
As in a normal map (texture)? Is the model UV mapped?
yeah normal map texture (driven by noise in this case). I'm 99% sure they're uv mapped but let me double check
yeah they weren't uv mapped lol
thanks
does anyone know how to design a shader that affects tilemaps depending on a texture?
like the alpha of the tilemap changed depending on the black in the texture
How do I make everything that is hit by a light or some sort of raycast be shaded and the rest black / dark
I have a question about color gamut and which screen I should choose. I want to buy a new laptop and I'm wondering about what color gamut I should select. I know that 100% sRGB is the standard, and anything below that will not display colors 'accurately'. For example, a 45% NTSC panel may not accurately represent colors. However, I found a laptop within my budget that offers a 100% DCI-P3 color gamut. Upon researching it on Google, I discovered that it covers much more than 100% sRGB.
From what I understand, converting from a lower to a higher color gamut or vice versa can result in color flaws, such as higher saturation than the original image. I'm unsure if I should buy a laptop with 95-100% sRGB or if I can choose one with a slightly higher or lower color gamut. (I'm aware of hardware color calibrators, but i don't really want to buy one)
Hey hey guys, im wondering if i could grab some help making a blue light shader in URP. I have a bluelight torch item, and i want to make it so that when i shine the torch over a specific blood splatter that is invisible, it glows blue and appears for the player. I am struggling as i have never used the Unity URP Shader graph and wouldnt even know where to start. Its an important part of the game that i am making.
Could be unsaved transparent color
how can i do that one ?
I have a tutorial like this - https://www.cyanilux.com/tutorials/ultraviolet-lights-invisible-ink/
@regal stagyou are amazing!! thankyou so much!
Hey! I would love some help. I am trying to make PSX style game and I have all the pieces to the puzzle except for glass. I can't get the Glass material to work and pixelate like other materials
@regal stag is it okay if i DM you please? Im like brand new to shader graphs! aha
I'm practicing with the Fullscreen shadergraphs and was wondering if it makes a difference if I make each effect in seperate graphs or if I should make all the effects in 1 graph and blend them over eachother?
Bump.. again.
render some effect (a texture) at a specific location on the map
Combining into one fullscreen shader will likely be better for performance. But I don't know by how much. Could try both and profile (e.g. with RenderDoc)

What's the problem with this shader?
quick solved it by adding a font material to the worldspace text
dunno what's wrong with the shader tho
does materialless renderers gets confused when another thing with shader overlaps with them?
@regal stag Hello, im having an issue, the decal projector isnt projecting the material however if i drag the material onto a normal object and shine it with a torch it glows, im not sure why the decal projector isnt projecting the material
Do you mean the built-in projector?
If so, it has its own material:
The material must use the Projector/Light or Projector/Multiply shaders, available in Unity’s Standard Assets.
@vocal narwhal i did get it working, just had to restart my unity, it was bugging out aha
Hello everyone 🤗.I had a question, I wanted to know how to use the old mask method in Unity? The same way of saving a photo to a black background and then with a photo that is like the first photo completely white, I don't know how to do that.
What context
Texture authoring, UI images and sprites, or materials and shaders?
@river vine Please don't crosspost across multiple channels. This is where your question belongs.
Yes, I want to mask images this way, it's an old method, it uses jpg compression and instead reduces the file size by 2x. This method in engines like solar 2d It works but not in Unity, I was wondering if there is a way to run it in Unity?
I thought you wanted masking, not file compression
I'm way too confused
If you actually want some type of masking, you'd have to clarify if you want to do it on textures, with sprites/images or with shaders
I think he might mean using the mask as transparency or as an alpha mask
That itself implies different things in different contexts
It does but he mentions compression, so maybe he means having separate textures to keep file size down (although honestly it wouldn’t really matter since the texture gets converted to a different format with unity anyway)
Yes, that's exactly what I mean, I want to use the alpha masking method in Unity because in this method you can use the JPG format and because this JPG is more compressed than PNG, it takes up less space, I mean compression of the same image format.
Afaik it doesn't matter what format an image is (i.e. png/jpg). When imported Unity converts to specific formats that the target platforms expect. See https://docs.unity3d.com/2023.3/Documentation/Manual/texture-compression-formats.html
https://docs.unity3d.com/2023.3/Documentation/Manual/class-TextureImporterOverride.html
Do you mean that the images become like this after being built?
I'd assume as soon as an image is imported, but maybe when building too. You can see what type (and size in memory) it has at the bottom of the preview in the inspector when on a texture asset.
e.g.
Would change when adjusting format/compression with these settings
"Jpg" and "png" and all the normal image formats cease to be when building
Any artifacts from lossy compression until that point will be cemented into the data of the new format
hi, has anyone had an issue with unity removing preprocessor directives from shaders after clicking on play/reloading the editor? I'm updating a shader from a package I own to support HDRP and after doing some changes and adding preprocessor directives unity just removes them, I'm using unity 2021.3.21f1
Hello!
I am having some shader problems
an cant seem to know whats wrong
I was wondering if someone could help me
✔️ Works in 2020.1 ➕ 2020.2 ➕ 2020.3
Oftentimes, it's useful to set shader properties from a C# script. In this video, I show how to set property values on a shader created in the URP shader graph. In the process, I create a system that draws colored ripples wherever you click on a mesh.
👋 Subscribe for weekly game development videos!
https://...
trying to make this
but nothing happens when I click
and I did everything in the video
is something outdated?
How do you make a shader fade to black depending on the distance from empty space(for a tilemap)?
I want to create a flash effect which is triggered on enemies when damage is dealt to them. These will be 3d models. I don't want lighting to affect the models when applying this flash. What's a good way to build this effect?
This flash would have their model becoming bright, nearly solid color, for just a moment.
How do you blend between a lit shader and an unlit shader?
Shaders cannot do this because they have no information about which tile they are or where other tiles are
I think usually the method to do that is to run a flood fill type of algorithm on the negative space tiles and store the results in a texture or a new tilemap, which is then overlayed onto the first tilemap
It's a pretty heavy operation to do in realtime so games use compute shaders or multi-threading for it if possible
Uhh
Okaaay
Thank you
basically i've made a wave (for water) shader that uses the sine node to move the vertices and make it look like ocean waves, but instead of moving like in video 1, i want it to move like in video 2
The direction this preview window draws in is irrelevant
This value is just a single number
Between -1 and 1
Plug it into a "y" node somewhere to make it apply to the y axis
thanks! i did it
Hi. Is it possible to modify Unity Toon Shader.(v3)
I want to change the Zalways parameter.
Is there a way to do that?
What's the maximum number of bones a skinned mesh can have in total?
I know its limited to 4 bones per vertex however I cant find any documentation at all that mentions the maximum total number of bones.
I did some testing and there seems to be a limit of ~500 bones but it varies from mesh to mesh and I would like to have a actual number.
How can we create hifi rush style shader and material in unity3d ?
Hi, i hope someone can help me here: I have a smoke shader (from the asset store, from Knife) which compiled on various machines. Now I have moved the complete dev environment to a new machine with another graphic card and now I get "Shader error in '': Parse error: syntax error, unexpected $end, expecting TOK_SHADER at line 1". I have no clue what is going on here: thanks!
Inspired by the release of Hi-Fi Rush by Bethesda, I wanted to see if I could get a similar vibrant and stylized aesthetic in Unity. Little did I know, it would swiftly lead me down a rabbit hole of custom rendering in Unity and, in turn, completely overhaul my entire perception of Unity's Scriptable Render Pipelines. This video is a showcase of...
it's going to be hard since the documentation and the example is hard to find
is there a way to convert my vector4 into a texture? Sorry if my wording is terrible, first time doing any work with shaders, but i was looking to try and combine a procedural circle with a pixelation effect, and i've seen people do the pixelation by just applying it on a texture using sampletexture2d, but in my case i don't have a texture
or maybe is there a node that does the same thing that sample texture 2d would do here
https://iquilezles.org/articles/distfunctions2d/
A circle's SDF is just distance to the center minus the radius
Then you can just use a step, or sample a gradient to get the above
well i already have the circle above, i was just curious if I could sort of pixelate it using the node below. For example, if i save the above node's result as a png and use it with a sampletexture, i get this result, but i'm wondering if it's possible to achieve this without first saving it as an asset or whatever
If you made the circle procedurally then you used UVs at the start, just pass in your pixelated uvs instead?
that makes a lot more sense, seems to be working fine for the most part
just gonna try to remove those artifacts now
thanks for the help!
hi everyone, I have an issue with effects. I have main camera with effect that makes old/pixelated effect on camera which works perfect and I have another camera that shows only flashlight so it wont clip trough walls. Issue is, effects on main camera works on everything except flashlight and I want it to work on a flashlight too...Here are some screenshots of my two cameras.
I want it to look like this, this is when main camera also render my flashlight but now it will clip with walls...
Hey everyone. I'm currently facing a problem I cannot solve at the moment. I'm trying to create an intersection mask for my water caustics. so basically everything that intersects with the water should turn white. This works for all convex meshes (cubes, sphere, ect.), because you cant see the outer wall from the inside or though the object itself. I use a 2 pass shader for that with ztest greater which is a basic approach for that.
As you can see in the image I have a "bend" river mesh (2), that runs along the terrain curve (1). You can clearly see the outer wall through the inner wall from inside the mesh and outside, which ruins the mask I use in post processing.
I tried almost all stencil, ztest and zwrite settings and I am getting kinda frustrated.
Does anyone have an idea or faced the same problem and got it solved? Or is it simply put unsolvable?
Thank you!
Don't crosspost please
Is there a way to replicate Unlit surfaces in a Lit shader? I have my UVs for color, smoothness and the third one would be for "light". Emission won't do here, what else is there?
i wonder how stupid it is to do shadows (for 2 objects only) like this, because i want good shadows for them specifically, but URP is lacking
- have orthographic camera follow object, same angle as sun
- do some layer/shader stuff so it renders completely white, and black where the object is
- use that texture as a decal on the ground

is there a way to have a texture tile alongside the UV of a mesh at the duration of the particle's lifetime?
that idea worked out even better than i imagined it https://cdn.discordapp.com/attachments/85338836384628736/1189318463601246268/desertracer_-_SampleScene_-_Windows_Mac_Linux_-_Unity_2022.3.13f1___DX11__2023-12-26_22-25-03.mp4
so i'm extracting the three channels to get three different textures. However I want to treat each of those textures extracted as completely white so I can change the color of each part of the slash to whatever color I want. In the vid I want the big blue part of the slash to be red but it's still blue.
Is there a way I can take each of the channel's textures and treat them as their own grayscale texture so they can take any color?
nevermind found my solution
it was addition
not turning it all into a vec4
Is this even possible to begin with, without using actual emission?
maybe you could just add custom lighting function and just simply pass the albedo to the output?
Why don't you have an Emission output? 🤔 Is this built-in render pipeline or what?
I am dealing with a compatibility issue when building for webgl. I have narrowed it down to these two lines in my shader script on my camera:
Graphics.Blit(src, renderTexture, passthroughMaterial);
Graphics.Blit(renderTexture, dest);
passthroughMaterial is a debug shader that just samples the main texture and returns it unchanged. So this snippet should just blit the main camera texture into a render texture, and then blit it from that render texture to the screen.
On one machine, this snippet results in a successful passthrough. On another machine, this snippet results in a black screen. Meaning it must be a compatibility issue.
The following snippet results in a successful passthrough on both machines:
Graphics.Blit(src, renderTexture);
Graphics.Blit(renderTexture, dest);
So it must have something to do with the material.
Any pointers on what the compatibility issue might be, or how to investigate it further? Thanks.
Are there any glaring issues with my passthrough shader? I am a bit of a newbie when it comes to shaders. The purpose of this passthrough shader is to do nothing to the texture:
Shader "Custom/Passthrough"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag (v2f fragment) : SV_Target
{
return tex2D(_MainTex, fragment.uv);
}
ENDCG
}
}
}
The solution seems to have been to enable ZTest Always in my shader. I still need to do more testing on other machines, but it works for now.
I'm new to shader programming, how could I do this?
I removed the emission output, it's URP.
I tried just using that, but the performance was terrible.
Removed how and why?
I just clicked the emission node thingy, and deleted it? Because it's not in use?
So add it back and use it
Iirc you can add block nodes by right clicking between them or selecting the block and pressing space
Maybe you missed this 😄
I assumed you meant in reference to built-in render pipeline
Emission output should have less than negligible impact on performance since it's no more than an add operation
Yea that thought hit me as well, is the SRP way better with emission for mobile?
Unlikely to be any difference
Pipelines all do emission the same way
Oh ok!
If you have a performance problem it's not related to shader emission I'm fully certain
Well I honestly don't know what to tell you, it went from stable 60fps to <30fps with the emission node used.
Same shader, same everything, but the emission output was used.
is global illumination set to realtime in the shader/material? try setting it to none
I am not sure actually, could be!
This is actually good to know, is emission actually this simple?
it's not shader graph but maybe it's there on shadergraph too
even on builtin, emission should be almost free, except when it has to affect global illumination in realtime (maybe)
Yes
I would think it only could affect performance if enabling it breaks some type of batching in your scene, but 50% loss is worse than the worst case scenario I've seen, and that shouldn't be unique to Emission
Or it's some editor bug related to shaders that might vanish on restart, or we're barking up the wrong tree entirely
The global illumination option should only have an impact when your emissive objects are static, you've precomputed Enlighten's realtime GI and on top of that changing the emissive color during runtime
But that shouldn't be too expensive either as Enlighten is designed to handle that
Well definately my objects are not static. It's a car runner game, with many cars and a infinite road tile system. But all of them use that same single material/shader.
The draw calls are in high 30s at it's worst
I plugged the UV2 in to the emission node, and boom, performance tanked.
Seems like it shouldn't be relevant but why so many different UV channels?
Did you try emission with UV0 texture or just color?
The goal was to have one shader and one texture atlas for the whole game. UV0 for color, UV1 for smoothness and UV2 for "light source" so emission. I previously just used an unlit shader for those surfaces.
At this point I wouldn't trust anything and test everything, including a fresh project with the same version and render pipeline for performance profiling and frame debugging
Oh wow, you feel like that's necessary?
That type of performance drop makes no sense, so I'd try to isolate it and rule out any editor and project related issues
Having an empty test project in parallel isn't a big deal, and it's really useful for problem solving
Remember to make test builds too
Hi! I'm struggling a bit with my shader. Before, I had a circular plane mesh that grew and shrank depending on the units Attack Range. Easy enough. But now I want a ring on the edges of the circle. Anyone know how to go about this?
I've tried just doing a 'ring' shader with radius/width variables, but I realized that I can't have independant range indicators then, as adjusting the 'radius' of the ring would apply the change to all indicators that have the shader.
Hello, I have a problem with the reference from a graph class
I do get a print out
but the ripple never gets called out
Either make different materials for each ring size, or could pass the size of the range indicator into the shader and use it to calculate the width.
If it's a graph, can also get size from the Object node, which extracts it from the model matrix.
Thanks for the reply! By "pass the size of the range indicator into the shader" I'm assuming you mean the size of the game object? Is this possible without affecting all objects with the same material? And yeah, it's a graph.
I'd probably do something like this then
can i cancel pasting nodes into the shadergraph ?
Wow thank you! I'll try this 🙂
Probably not, unless you force close unity but might lose work then.
its pasting for 36 minutes now TT
Check the property names in the code match the "reference" fields of the properties in the graph node settings (while property is selected)
Otherwise, is probably something in the calculations. If you're following a tutorial, compare your graph to check for errors.
It almost works! The border/edge is shrinking as the object size increases, but im sure i can figure this one out. Thanks again! Very kind
Ah maybe I got the calculations slightly wrong then 😅 , but yeah shows the general idea
It was matching but thanks anyways, I found the solution
Hey,
Do you know how the Depth-Texture is generated? is it generated using ray-marching?
No
https://en.wikipedia.org/wiki/Z-buffering
It's generated from mesh data during rasterization
A pixel's depth can be figured by knowing where the polygon's vertices are relative to view frustum
thanks
Sorry for not thanking you man, you helped me quite a lot! 😄
Thanks!
Hi all!
I'm attempting to use shadergraph to modify transparency (i.e. the alpha value) of a model based on a color in a UV. I'm in URP.
My shader samples a UV texture, and if the sample matches a 'TransparencyColor', it should return an alpha value for transparency (e.g. 0.25). If it doesn't match, it'll return 1.
Attached is a screenshot of my shadergraph.
Here's the code I've connected to my Custom Function.
#ifndef COLORCOMPARE_HLSL
#define COLORCOMPARE_HLSL
void ColorCompare_float(float4 InputColor, float4 ComparisonColor, out float3 Out)
{
float result = (InputColor.rgb == ComparisonColor.rgb) ? 0.25 : 1;
Out = float3(result, result, result);
}
#endif
I've just started learning about shaders, so I may well be tackling this problem in the wrong way. Any help would be much appreciated!


Comparing floats with == might not work that well. Probably better to give it some range, maybe (abs(Input - Color) < 0.01)?
Or Shader Graph has a Color Mask node that would work. That returns 0 or 1, so will need some additional math to return 1 and 0.25, e.g. a Lerp or Comparison&Branch
Thanks so much, I'll give it a go!
Color Mask node worked perfectly, thanks again @regal stag !
Hello. I am trying to make a shader that creates a tile, depending on local coordinates, and can create a tile per pixel per unit. I want it to work as a UI Image tile mod. Right now, it creates a tile using a simple uv multiplication, and the frac function, and when I resize the image, the tile is stretched. How can I make it so that the tiling is independent of the rectangle?
i.uv *=4;
i.uv = float2( frac(i.uv.x),frac(i.uv.y));
Hi!
I've made a fog shader for my game. It's been working fine but now I need to use it so that it "offsets" differently. How can I achieve the desired functionality as seen on the video?
Both of the objects are UI images, and the one on the left has the bool "OffsetWithCamera" (may not be the best name ik) set to true, while the one on the right has it set to false. I've tried to use a default UV0 and multiply it with some values, but as you can see it gives a stretched result, and stretches even more when the aspect ratio gets bigger.
Hello, I am trying to use the _CameraDepthTexture buffer for my scene, however, it seems to be either completely black or white, not grayscale. I am not sure why.
hello
can someone help me figure this out
I have a visual effect on the screen that works but I cant see the scene
What's the underlying implementation of the effect?
what do you mean
Like, if you have a shader graph or something for it
Okay, we (i) need to see it in order to help
trying to clean it up so you can see it
I have a shader that sets a material's emission if a purple light is touching it as a blacklight reveal, in URP Forward this works perfectly fine. however in Forward+ it seems there's some depth issue(?) because now it only works if the camera gets very close to the objects or if the camera is turned at just the right angle and i'm not entirely sure how to correct this.
for the cube object in the video i just pass its world position using the position node
Alr
Now it's better but still quite noisy
Can't really see what the values are set to and stuff
its hard to zoom in beccause you wont be able to see the whole set
also for the decal position, i did whatever the hell this math(in the attached image) is using the view direction, camera direction, and scene depth. i don't understand how exactly it works, i just happened to find it in some random unity thread a few months ago
and if it matters, the actual shader code is this: https://hatebin.com/liwyfjsgmz
where the inputs are the position, the color and possible intensities of the blacklight, and the output color
What is the Sample Texture 2D node in the top right sampling? You may want a Texture2D property called _MainTex in the texture input.
Though if this is a Fullscreen Graph in URP, I'd replace it with the URP Sample Buffer node with mode set to "Blit Source"
how would I do that
Might be that the code needs some extra bits to properly support Forward+. I usually set inputData.normalizedScreenSpaceUV and inputData.positionWS as iirc they are used in lighting calculations.
If it helps, I have a similar effect here (afaik it works in both) - https://www.cyanilux.com/tutorials/ultraviolet-lights-invisible-ink/
alright
Edited my answer above, hopefully that is clearer
I dont think I have the URP sample buffer
Would depend what render pipeline and unity version you're using. How are you applying the shader to the screen?
How are you applying the shader to the screen?
Pretty sure this version should have the URP Sample Buffer node
I got a Sample Buffer Script
thank you so much! assigning those fields on inputData fixed it 🙏
but not node
Not sure what you're referring to.
The shader is dark because it's outputting black for those pixels. You need to use the output of this node (highlighted in red), into the T input on a Lerp node, with B set to the color property and A set to the camera view before the effect was applied. That depends on how you're applying it to the screen, could be sampling a _MainTex texture or the URP Sample Buffer node.
Or maybe use that highlighted node as the alpha and color property in base color, assuming the method you're using to apply it to the screen supports transparency.
The depth texture usually ranges from 0-1 between the near and far camera planes. If the far plane is very far away it would make sense most values are close to white. If you can, change it on the camera component.
Also if it's a perspective camera, depth would be stored non linearly, there's functions like Linear01Depth and LinearEyeDepth for converting it.
For ortho, it's already linear but might need remapping (also may want to take into account #if UNITY_REVERSED_Z to properly support all platforms)
Might be able to use View space on the Postion node, or keep using world but subtract the camera's position from Camera node.
Could also keep using UV or Screen Position, but account for aspect ratio changes by multiplying by a Vector2 of 1, Width/Height (outputs from Screen node).
Thanks for your reply! The far plane was at 1000 for some reason, setting it to a reasonable number fixed it
Out of curiousity what do you mean by #if UNITY_REVERSED_Z ? I tried googling it but I am not sure what to do with that.
Something like
#if UNITY_REVERSED_Z
depth = 1 - depth;
#endif
to flip the depth value. Some platforms will have a depth of 0 meaning near plane, and 1 meaning far plane, while others are reversed (far plane at 0, near plane at 1), which is better as floating point values closer to 0 are more precise afaik.
Hello!
In Blender I have this brick wall object set up with 2 UVs:
One with the brick wall texture
The other with the graffiti message written over a transparent field (black field with alpha set to 0)
How do I recreate this in unity now?
The reason I have them in two separate UVs is because the brick texture is tiled seamlessly, so the message could not be included on the same UV.
Can anybody provide any insight please? Any help is appreciated
it would be easiest just to use decals. URP and HDRP have decals. Don't try to combine them into one material
so there's a tool for this. thank you! im a noob
is there a reason ive got no settings folder? dumb question maybe. Ill say this is a VRchat world
I have no idea what render pipeline VR Chat uses, it could use default for all I know. Though, a settings folder is not required in any project.
I imagine it doesn't use URP, and even if it does I doubt it's on a version that has decals
in that case you would need to manually create one with a transparent cutout material on a quad that floats a little in front of the wall
cute
ok
thanks
going to experiment with this, will return with update on if it's a solution
or, maybe the projector?
Hello devs , combined 2 shaders by myself but got this Warning :
" Use of UNITY_MATRIX_MV is detected. To transform a vertex into view space, consider using UnityObjectToViewPos for better performance. "
I've tried all fixes from forums but nothing helps, can someone help
Here is Shader
https://codefile.io/f/lk6G4syBPv
Does anyone have a couple of minutes to talk with me about how to get a linerenderer working with glow? I am having lot's of issues, and I have never worked with a lit environment before
I want to make a side view mirror for my car, im using a camera view as a texture and assigning that texture to a plane, however this plane i have is rectangular, my car's side view mirror is a circle, i try putting this same texture on the right mirror component of the car but i think its too zoomed in or something. Any solutions?
using texture as mirror view is not reliable, try using planar reflection instead
Ok will do thanks. I read from a website that this method was more resource intensive which is why i chose the camera approach.
it's the same in my opinion, i mean if your mirror camera will render everything then there's no much different with planar reflection
ofc you can do some optimization such as rendering impostor for the mirror camera instead of the real 3d
Will look into it. Thanks for the quick reply!
np, you can try using this : https://github.com/Kink3d/kMirrors.git
since it's like using camera render texture but in steroid
*if you'r project is in URP
I'm using URP with a 2D project, glow from a shader I made isn't working. I'm not trying to do anything fancy, just apply a glow to a moon texture I have
The way I have it set up, the moon doesn't glow the background, but regular 2D lights will
From this:
To this:
This is the shader I have, I just copied it from a tutorial I found
it's just a warning, I think you could just ignore it. usually the editor will automatically replace UNITY_MATRIX_MV to UnityObjectToViewPos
But if the warning bothers you, try replacing
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0)
with
UnityObjectToViewPos(0,0,0)
that's true actually, using camera render texture could be more performant since you can control how big the render texture size. And you'll have more control on mirror fov(car rear mirror usually have larger fov than plain mirror) and range (limited range means usually more performant)
As for the problem, check your mirror uv, seems like the uv is too small so it only shows a small portion of the texture
Interesting, thanks!
I ended up using a cylinder as my "mirror" instead, thanks anyway
Can you rephrase what you mean by "the moon doesn't glow the background"
Do you expect it to illuminate the background?
Also that's one of the glow tutorials that have it wrong
Multiplying the sprite color doesn't make it glow in the darkness because it's multiplied by the light texture also
- Using view space didn't work
- Subtracting the cam's position didn't work either
- Multiplying the UV by the aspect ratio V2 (1, aspectRatio) still yielded the same results as the old graph did
Also, because these are RectTransforms, maybe there's some way to use the rects' width/height properties for the aspect ratio calculations instead..?
Came up with this solution and now it works.. somewhat
Because it is getting the aspect ratio from the screen, the rect's aspect ratio must also always match the screen's aspect ratio. So this leads to stretched results when the aspect ratios don't match..
hi so i'm using a packed texture in order to separate the three textures later and I want to know how can I apply the tiling and offset node onto an individual channel cause I want two textures to use one offset curve and the third texture to use a different offset curve.
is it possible to mask a urp decal using stencils so that it only draws where the stencil value is equal?
I tried making a lit shader that writes an arbitrary stencil value
Stencil
{
Ref [_StencilValue]
Comp Always
Pass Replace
}
and then in the decal shader
Stencil
{
Ref [_Stencil_Ref]
Comp Equal
Pass Keep
}
but no matter what Stencil Value I set, the decal only seems to pass if its Stencil Ref is between 0 and 1
Both shaders were originally generated via shader graph and I copied the generated shader into a new one so I could add the stencil sections manually. I added a stencil block to each generated pass, and added a int _Stencil_Ref; to each passes cbuffer.
In this case yeah I want the background sprite to be illiminated by this moon sprite. Just as a test to get something to work, not the final implementation of this
Bloom isn't a light source and doesn't light up objects
Maybe you'll want some type of light attached to the moon instead
Well the ultimate goal is to have a light source along the length of a line renderer which changes programatically. If bloom isn't the right approach, there should be another way to dynamically make a lightsource match the shape of another object
You may be able to do that using a Freeform light
#💥┃post-processing if you have more bloom concerns
#archived-urp for future non-shader 2D Renderer questions
Yeah I just found out you can dynamically make freeform lights. It seems to be working in some testing I am doing, but I haven't finished the script yet. Thanks for the help
You cant. You need another texture sample with different uv’s practically eliminating the efficiency of having the texture be packed
sadge ok well thanks
Hello, I have a question about shaders. I bought the asset where creator said it's support the HDRP and URP. I use HDRP in my project so I bought it.
I convert materials to HDRP but I have a problem with custom shader from this creator. How to convert them to work in HDRP?
The creator assumed that it was easy and everyone could handle it, so the question is: can it be done with a few clicks?
Hey so, I've got a custom shader that implements a 'damage flash' for sprites, and that's about all the shader does. However, I also have 3D objects in the scene and when I apply the custom shader to a rendering pipeline asset and use that asset in Project Settings > Graphics, then the 3D objects go pink and if I use 'none' there instead, then the sprites go pink instead. I understand that I probably need to implement a 3D shader myself inside of the custom shader for both of them to work together, but I don't really know how to do that.
If an asset supports HDRP that either means HDRP version of it is included, or it has no custom shaders so it can be freely converted
Maybe you missed the HDRP version / HDRP compatible materials/assets
Or there are none and the labeling is a mistake
Totally custom shaders can't be converted at all
If they're URP Shader Graph shaders then they may work just by changing the Target to HDRP in Graph settings, but that's not usually expected of the user
Which render pipeline is your project using and which render pipeline are your shaders made for?
This is this asset:
https://assetstore.unity.com/packages/3d/environments/sci-fi/sci-fi-facility-116916
It has a RenderPipelines folder that contains unitypackages for HDRP and URP
I.. honestly am not good at shaders so I might tell you the wrong things, but we'll see. I'm using an UniversalRenderingPipelineAsset which has one thing in it's Renderer List, being an UniversalRenderingPipelineAsset_Renderer. The shader itself is as seen on the picture. I used this video as a guide https://www.youtube.com/watch?v=rq6yGh-piIU&t=646s, but as far as I remember, I needed to make some adjustments to the shader in the video because some stuff was different for me than it was for them. The npc textures/materials have their shader set to the DamageFlash shader
I imported this and now I have a bunch of errors:
Totally sure you have HDRP installed and configured?
hello does anyone know how i can rotate the simple noise texture so its displaced like on the xz axis and not zy axis in the shader graph?
yes, from almost a year in this project 🙂
What did you mean here by "apply the custom shader to a render pipeline asset"
Normally shaders are applied to materials which are applied to gameobjects
I'd like to see the Graph Settings tab of your shader also
so the i would like to let the right one look "correct"
Use a Swizzle node (e.g. Position -> Swizzle "xz" -> UV port)
and i am using world position
I meant setting the value there to be the Universal Rendering Pipeline Asset that I created. I had misremember a bit how I made all of this exactly, so that wording was a bit misleading
I have ShaderGraph in project but I can't see this file:
do u mean smth like that?
sure but use xz as the mask, like they said
Looks right if you intend to use URP
Make sure the shader has Universal target in its Graph Settings, in case the issue is it's targetting BiRP or something else
I'd try reimporting and restarting in case it helps, but you may have to contact the asset's support otherwise
oh that makes sense ...thank u! @vocal narwhal @regal stag
Is the problem not in me not having any 3D shader magic in the shader? Or does unity automatically have a shader for 3D objects going as well if I've set the shader to something that doesn't support 3D. This is a 2D project as well so maybe I'm missing some packages or smth
Wait no, I'm dumb
Mixed up a couple things there
Pink usually means that the render pipeline is incompatible
With the shaders, or vice versa
With Shader Graph this compatibility is defined in Graph Settings
What would I be looking for there? Or do you want me to show you my settings?
Could it be this?
I detailed some things to look for in my earlier reply, but it may help to show it
2D Renderer doesn't support Lit shading, but it wouldn't appear pink
Sure. Also I don't remember if I used the Unlit URP shader graph or lit one, could it matter?
Might be related to this : https://forum.unity.com/threads/tons-of-assets-broke-with-minor-editor-release-2022-3-10f1.1496333/
If there are shader files containing that include, maybe swap it to the #include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" one mentioned in that post, or try updating Unity.
Would depend if you need it to account for lighting/shading or not. Either way, it shouldn't be pink if the graph target and render pipeline are both Universal.
Since you have the Universal dropdown that probably means it's listed as an Active Target above it as well
So there shouldn't be an issue there
Just in case clearing it up. The sprites are fine if I have the URP set in graphics. The 3D objects are pink when it's set. The Sprites are pink the the URP asset is set to none
This means the 3D objects likely have shaders for built-in render pipeline and the 2D objects have URP shaders
They should match the render pipeline you want to be using
Yeah, if you've swapped render pipeline, other materials in the scene will still be using old shaders intended for Built-in RP. There is a material converter that can fix that.
Switching pipeline affects other things too though, like post processing and various assets. You should be sure you need URP before switching. Shadergraph can also target Built-in if necessary.
When I set the 3D object's material to use any URP shader it doesn't have any shading, it's just a plain color on screen.
That's what the 2D renderer does for you
If by renderer you mean the one I have on the 3D objects then that's a Mesh Renderer.
There has to be a way to get both working at the same
I mean if you're using the "URP 2D Renderer" instead of "URP Renderer" then 3D shaders and rendering features are disabled
Oh wow. I created a new asset as URP with renderer something and now it works, thanks!
Not practically, but there's some ways around it #archived-lighting message
You can do 2D without the 2D Renderer, and you only lose some 2D features like 2D lighting and Pixel Perfect Camera component
Wait, I had that discussion with you 
I am having an issue with the vertex shader that I am using for terrain, the subshader setup is -
Tags {
"Queue" = "Geometry-100"
"RenderType" = "Opaque"
"TerrainCompatible" = "True"
}
CGPROGRAM
#pragma surface surf Standard vertex:SplatmapVertEx finalcolor:SplatmapFinalColor finalgbuffer:SplatmapFinalGBuffer addshadow fullforwardshadows
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
#pragma multi_compile_fog // needed because finalcolor oppresses fog code generation.
#pragma target 4.0
#include "UnityPBSLighting.cginc"
#include "UnityCG.cginc"
#pragma multi_compile_local __ _ALPHATEST_ON
#pragma multi_compile_local __ _NORMALMAP
#define TERRAIN_STANDARD_SHADER
#define TERRAIN_INSTANCED_PERPIXEL_NORMAL
#define TERRAIN_SURFACE_OUTPUT SurfaceOutputStandard
#include "TerrainSplatmapCommon.cginc"
The problem is that the vertex shader code stops working after camera is some distance away from the patch of terrain, is this something that can be fixed? The only solution I found is to increase base map distance, but that also has a side effect of having more textures loaded in vram which I dont really want.
I rather have it render at a lower vertex count that stop working all together...
Close up (1st picture) and Far away (2nd picture) where you can see that the terrain starts to clip the water line (Which is a separate plane with a custom material)
If it's based on distance that sounds related to the terrain swapping LOD level
Well I assume so, here you can see it better with the white lines/gaps
I could increase base map distance and decrease the resolution of that base map to mitigate vram problem but thats also not ideal
okay so i opened up an older file thats unfinished and have no idea what im looking at. looks like i lost all my work
is there a way to get it back. kinda desperate
ive got the shader graph downloaded from the package manager and i cant even make a new shader graph even if i wanted to
How would we know what it's supposed to look like?
Try opening another scene besides the sample scene
What do you mean by "can't make a new shader graph"
when i go to where i usually would select to make one, its not there. maybe ive got a newer version of unity is my guess
ill try making a new scene like you said too
just checked, my shader folder is empty...
the file is low key just gone...
welp, guess im gonna have to do my task again. ah well..
In URP in a shader graph, how do I get information from a point light?
The point light does change position, but I only have to care about one point light
If it's just one you could simply pass the needed component properties to a shader property with a script
But you also have the option to get all lighting using this package
https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
Thanks so much. It's weird that Unity natively supports getting a sun light but not a point light in shader graphs
I've done it in HLSL before but really struggled lol
Hey everyone! Does somebody know why the alpha channel gets ignored here?
the noise texture on the bottom is scrolling with time, as it should, but the upper left texture is not affected, even though the noise output is connected to its alpha channel
Or, maybe a simpler example of the same problem:
Node previews don't show transparency, and the "Base Color" port in the master stack is a Vector3. So the Vector4 input is being truncated to it's RGB components.
If you want the graph output to be transparent, you need to change the Surface Type under the Graph Settings, then an Alpha port will appear where you can connect your sample output (or Split/Swizzle the Vector4 to obtain the A output)
Thanks! Looks horrible but works haha
Can anyone give me any feedback on all the mistakes I am making here? Would be highly appreciated!
For example I am wondering if I really need to be multiplying up the textures (the original one on the upper left, and the scrolling noise) so heavily - but otherwise my output gets very dark
Also, if I understood the original video I am following (the VFX of Diablo 3, he doesn't really say much, just show the end result and quickly discuss it), he uses the above thing for RGB and the below cloudy texture only as alpha...but when I do it, it just looks like the above texture with a greyish cloudy stuff hovering above it, quite bad unforunately. So what I do is this multiplication stuff which looks better in the shader graph outputs
(I am trying to implement what he is doing at 29:05 https://www.gdcvault.com/play/1017660/Technical-Artist-Bootcamp-The-VFX)
I'd add a Saturate (which clamps between 0 and 1) before the Multiply in the top left to make sure there isn't any negative values.
Also, the video you're following isn't using Alpha blending. If you only need the shader to work on dark backgrounds, Additive may work better. For that you don't really need alpha.
If you need it to work on lighter backgrounds too, at 21m into the video it shows an alternative blending which they name "Blend Add". I'm not entirely sure... but I think this is "Premultiply"
Thank you very much! Going to try this now! 🙂
Oh and I just checked your profile and found your website, really nice! Maybe you should try to do some seo haha, I searched for shader graph tutorials a few times, and never found nice stuff, and your website seems to have a few things that really interest me a lot
Will check the tornado shader tomorrow in more detail, I recently made a my first vfx graph for a tornado (so using particles, not a shader), really excited to see another implementation
do you think your shader will look good when viewed from an above angle? (Think diablo games or RTS)
Hmm maybe, not sure
Still need help with this, anyone know if it's possible to get properties of a rect transform (width, height)?
In the shader graph ofc
so i msde a float in the shader graph but when it connect it and add the shader im making to a material, nothing appears in the surface inputs section
also, this is what im meant to be seeing btw for added context
fixed it
i saw a very good package of skyboxes, just want to add a flowmap, is there any way i can just write inside this material shader?
i didn't find the script in assets
Generate lighting from the lighting window
#archived-lighting next time
thank you
Does anyone know a resource which explains how to create a "circular cutoff" shader? Like where you have a black background for example, and then a white circle, wherever that circle is it will cut a "window" into the black background, which will show what's behind
Tryna make a tutorial for my game where there is this kind of shader and the circle is positioned at an UI element the user needs to click at
It doesn't even have to be circular, anything that explains cutoffs and stuff in 2d
does anyone can help?
Instead of the solid colour , how do i tell the shader to use the colours ive placed the obejcts uv in? on the left is the tree with the shader and the solid colour, i wanna add the same shader to the tree on the right but keep the colours I assigned it with an atlas from blender
Sample the atlas texture, using the Sample Texture 2D node
Scaling by -1 would flip the mesh, so showing back faces. Shaders default to culling those, but you can specify Cull Off under the Pass.
yep i didnt acc thing that wold work omg thaks
omg ty its works i appreciate your help
With Sprites you can use the sprite mask component, no need for shaders
https://docs.unity3d.com/Manual/class-SpriteMask.html
Does it also work in UI Images?
Or just sprite renderers
UI has a mask component also that works much the same way
https://docs.unity3d.com/Packages/com.unity.ugui@2.0/manual/script-Mask.html
Seems like it's only meant for Sprite Renderers
Yeah I've tried using the UI mask but there's no option for "reverse mask" for the lack of a better term
Like if I had the circle as the parent and the full bg as the child, and the mask on the circle, it would make the bg shaped like a circle
Maybe I misunderstand, but the official tutorial seems to be showing just what you're describing
https://youtu.be/g3gpXmo8zRo
The configuration is the exact same as in the video (without the scroll rect because that isn't needed) and these are the results:
The image on the left has the mask set to off on the circle (the parent), and on the right it has it set to on. As you can see the right side essentially turns everything into a circle, because that's what a mask is supposed to do (don't render anything outside some area, in this case the circle). I want the reverse of this to happen, aka. render everything outside the circle, but nothing inside.
I could just use an image that's shaped like this. with there being a circular cutoff in the center, but then when I want to scale the cutoff problems arise (unless I used a very oversized image, which I do not want. There must be an easier way).
https://youtu.be/ZoiNP5IfBBo this? I'll be your googler today it seems
I've tried googling but all results have been not what I wanted. Like for example a circular transition using shaders, not what I want
Okay I actually didn't google reverse masks yet, I'll watch this video
I have just started learning shader graph, and don't understand why my texture is not tiling or offsetting even we I change the values
Okay that was exactly what I wanted, and I got it working! Tysm!
yay! 
What does it look like if you set both Tiling values to something like 5
same.. no change at all
there is a change in tile and offset node.. but in final out no change at all
So you're saying it's working in the nodes and Shader Graph preview, but not on the mesh? If so, that suggests your mesh doesn't have proper UV maps
no its not working in shader graph preview
just color of tile and offset node in node editor changes
Can you show that happening?
Specifically changing the Tiling in X axis
Changes to Y tiling and XY Offset may be imperceptible due to the content of the texture
hey thanks.. its working now
Random question, is there a way to get the transformed vertices from a shader that deforms a mesh in like the vertex buffer or something?
Hey there, I asked this question a while back in a different channel to no avail, but I'd like to know if it's possible to have a transparent self-occluding shader with URP's Shader Graph, and if not, is there anyway to translate that shader graph to a regular shader and get this function. Here's my original post just for reference: #archived-urp message
Well then, after pressing random buttons and trying out all the graph settings I found out that by setting Depth Write to ForcedEnabled and not Auto did the trick. That would explain why in the scene view it would go back and forth.
I don’t know where to ask this so lmk if this is the wrong place, but is using a thin cylinder as a line a good idea or is there something else that I should use that’s less power heavy
Use a line renderer?
Thats why its called a LINE renderer
Cuz it renders lines....
Using shadergraph, is there any perf benefit to creating my own tiling/offset vector2s and feeding them to a single tiling and offset node, vs. just enabling "use tiling and offset" on each of my texture2D's?
Not without modifying the vertex shader to write the modified vertices to another buffer. There's no guarantee that the vertex shader will be doing the modification in object space, and the vertex shader ultimately is transforming all the vertices into the camera's clip space, so the output vertices are not very useful if you want to render them again from a different camera.
You'd switch to specular workflow from metallic first
hello again. any tips for my stupid self on killing these ugly seams?
- Putting the seams elsewhere
- Using a trim sheet and placing trim geometry over the seams
- Doing some custom shader thing
Ok thanks. Been relying on smart UV project in blender. Guess I gotta learn how to actually manipulate seams, ha
In shadergraph, how do you make the shader render on top of everything else?
Mark seams where you want seams to end up in blender.
Easy to google that one.
sure is. thanks, bud.
👍
Didn't mean to come off like a dick. I should have just said "In edit mode, select edges, mark seams, etc." was being literal in the "easy to google" part since I've also had to do it recently.
i took it quite literally no worries
Cool
I am trying to make the Texture on the Model appear using a Progress Bar, however since the Texture is a color palette my approach does not work as intended. I have a solution in mind, but I don't really know how to implement it. 😕
Has anyone an idea how this can be fixed or could give me a reference to read?
If anyone is interested, I was able to make it work by using the Vertex Position (I previously didn't know that the Position Node referred to the Vertex Position)
You can try using "follow active quads" for this instead. With this the uvs will follow the highlighted/active quad . Its much better for things like this
With follow active quads all the quads that youve selected will be placed on after another getting rid of seems
@burnt pollenIs that texture seamless to begin with? If not and if you can pull it off, use seamless textures. 😉
There's a way to take a texture sheet and make it seamless. You have to be good at graphic editing though, and it won't work for all sheets. But for Bricks/rocks it can work out.
What you do is to "cut" the existing texture sheet in half on both x and y axis. So you start with upper-left quadrant, lower left quad, upper right, and lower right. You than copy/paste them into a new identical sized sheet in a different order. IIRC you swap them so that you swap diagonals. So upper left becomes lower right, and vise versa. And upper right becomes lower left.
You'll be left with a new sheet that has the seams in the centers as a "cross" in the sheet....but the important thing is that they will wrap around properly in x and y and TILE well. You then have to use a graphic editor to fix up the seams manually, and make the sheet look good WITHOUT TOUCHING THE EDGE PIXELS. And of course your modeling has to respect the seams so they end up meeting properly.
Hello i use Shader graph (i am also new to modeling so that could be wrong as well)
and i made a model and shader and all it clips for some reason, but only if the camera is lower than the model itself
if any body knows why this happens or has any tips i would apreciate it
Beacuse that pole thing model dosnt have a bottom in the first place
that pole thing is atached to the ball(aka one modell) and it should normaly render behind or in fron if it actually is
Your ball is transparent so your pole shows up
they all use the same material and depending on a diffrent texture it chooses how transparent it should be
is that bad?
It just... dosnt work like that
you mean the internal logic or what?
Yes it has to do with some weird z buffer shit i dont understand
Did you look up ur problem on google first?
Beacuse im seeing some forum posts with the exast same issue
I'm trying to write a custom shader, with some stencil buffer thing going on.
Stencil
{
Ref 1
Comp Always
Pass Replace
}
Is there a way I can somehow tie Ref, to not be 1 for all the pixels on the shader, but instead use some sort of function to drive the Ref value.
I am trying to create a material that supports UI canvas masking. And I would like an image texture / alpha value of the fragment shader to drive the Ref value of the stencil shader
no i forgot, it works now, thanks for your help
The fragment shader can't alter the reference, but if you discard fragments (e.g. clip(alpha - threshold)) it won't write for those
Stencil on the GPU is fixed function. That means that the GPU does it in one fixed way, but lets you configure some settings before it does, like what Ref value to use, which comparison function to use, etc. You can't hook into when the GPU does the stencil operation with your own code.
what I am trying to achieve requires writing to the stencil buffer.
When using the Mask component, with a custom material, the mask component does not work at all
however when only using Image component with a Mask component, areas with 0 alpha are also masked out
im talking about canvas
I have a shader that creates a black and white procedural mask
and was hoping to apply this black and white mask to the stencil shader
It is seamless my friend
Well, it sounds like "the hard way" somehow, but IDK your process.
OK, so if you have a camera with active render targets and depth/stencil buffers, you can run a stencil pass over/from something and set or reset the stencil bits. The only thing you'd do it set or reset the stencil buffer, you'd use COLOR MASK 0 to not write to the color buffer and also turn depth writes off to not write to the depth buffer. Like Cyan said, you could possibly do a discard operation at the pixel level if you want to apply a conditional operation there.
I suppose another way is to write the color buffer, for example, that "shader that creates a black and white procedural mask" might also be a candidate to write to the stencil buffer if you started with a full-white texture and just wrote the black pixels into the texture AND set the stencil buffer value for them, discarding the white pixels (because they're already white from a previous blit or something).
But like MentallyStable said above, stencil operations are not directly in the programmable stage, you can't control it via code. It's a per-pixel automatic operation (for setting). For testing, your fragment program will never be called if the stencil test doesn't pass. It's built-in logic in the rasterization process that happens between vertex and fragment stages.
Im pretty new to using shader graph and was wondering the proper way of using a height map in shader graph as im seeing the option for directly inputing a map seems to not be there
I have a problem that I can not figure out how to fix.
In shadergraph, I want to use flipbook uv and use the output texture as tiles to fill up a 10x10 2d space.
It works.
But when I try to randomize the flipbook index with a 10x10 texture that contains random number, even though the output result is what I want, it has very thin lines between each tile
basically between tiles that have different flipbook index, there is a thin line between them
How do I remove these lines?
@neon blade possible a offset i had this type of issue creating procedural terrain and applying a material with a sprite sheet
There is no offset input, and even if there is, it is still not going to have this issue because the neighboring tiles have similar color
Sounds related to this - https://www.cyanilux.com/faq/#sg-pixellated-seams
In short, use Sample LOD to ignore mipmaps or SAMPLE_TEXTURE2D_GRAD to use different continuous uvs for derivatives
Heightmaps are usually applied using parallax mapping, there is a node for it.
https://docs.unity3d.com/Packages/com.unity.shadergraph@10.2/manual/Parallax-Mapping-Node.html
It replaces the UV for sampling the other textures
Thanks I will try it out
Hey Im generating a 2D polygon mesh (orange) and Im trying to add a color to it which is shifted down to create fake depth. Is this possible?
anyone have good resource for realtime audio visualization shader?
for example there's Lasp for VFX but i never heard about audio input for shader
It works, thank you so much, you are my hero.
draw it with stencil and draw it a second time down below with the stencil mask, or output depth in the shader
and use the depth as "real" fake depth
depends on what you're trying to do honestly, both of these can be tricky to seamlessly use with other things drawing in the same spot
I'd think you'd want to know the "inside" from the "outside" of your (orange) mesh.
If you don't know that directly somehow, you'll have to compute it. This is often done with outlines too. There's a flood fill method (Jump Flood) that can be used to fill the empty space inside. Once known, that is a mask if it includes the mesh's edges too.
Then you'd clip the blue to the mask, probably with a vertical offset .
This entire article is well worth reading, but if you're in a hurry the jump flood part starts about 1/2 way down.
https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9
Hey
why is my scene "glowing" when getting close to my cube ?
hmm, could be local post processing
does your scene have post processing?
that's weird
example
That's not a black output like the rectangle had though. HDRP is probably adjusting the camera exposure based on the colours on screen. I don't know where the settings for it is though, maybe ask in #archived-hdrp
good guess, it was the black the issue
no problem anymore
ty
//Take outputted mesh from vert function, and run frag function
half4 frag(Attributes IN) : SV_Target
{
// color.rgb = IN.uv.y;
// return color;
half4 color = 0;
float f, cells;
Unity_Voronoi_Deterministic_float(IN.uv, _Time*40, 10, f, cells);
color.rgb = f;
color.a = 0;
return color;
}
This is my frag function
for some reason even though I set color.a to 0
the object is not transparent
more relevant information
Tags { "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
LOD 100
You need to specify a Blend mode under the Pass. e.g. Blend SrcAlpha OneMinusSrcAlpha for traditional alpha blending
https://docs.unity3d.com/Manual/SL-Blend.html
Not sure what I'm looking at, but may also want "Queue"="Transparent" in the tags, and ZWrite Off
regarding the "shape" node, how can i make the color transparent EXCEPT for the shape ?
for now i can only change the whole shader output alpha, when i try using colors with alpha 0, its just black
Connect the shape to the Alpha port
ty, didint know it accepted other than just a float
currently i have this rectangle effect
can i make the full retancle (screen 2) go all the way down ? (so like "inside" of the mesh), right now it disapears
do you mean the flashing rectangle on the top face?
you would like it to stay longer?
wait im doing a animation rlly fast to show what i would like
ok
ty for waiting, here is the idea
i would like the rectangle to start at the top of the mesh, and move all the way to the bottom (a bit like the cyan shader)
ofc still have the infinite repeat effect (here you can see only 2)
oh, you want an internal face
i suppose yes
like you want a top face for the bottom rectangle
idk the correct name for this
That will not be possible with a shader alone, as a shader will only draw onto a surface that exists
but yes the rectangle is "inside the mesh", not only at the faces
oh, do you know what could do this ?
one way would be to have a mesh with an internal face, and manipulate the geometry itself through code,
or easier would probably be to get 2 cuboids and create a keyframe animation for this effect
in blender or something
in any case, for it to draw a face 'inside' there will actually have to be a face inside
before making the shaders i thought about just doing some rectangls moving
one of the issue is to make the animation seamless, particulary when the rectngle comes at the top
yeah, it will be a bit tricky, maybe there is some solution that i'm missing though
i know a bit of maya, how would you make a face "inside" a 3d object ?
since the shader is making a "sliding" down effect
can I know what you are making this for?
the goal is to represent a zone where the player will unlock a input acion
i wanted to make a sort of "sci fi" rectangle effect
i see.. to me personally it seems like too big of a solution to make a seamless animation for this purpose
i would recommend trying to find and achieve a slightly different effect that fits your need
i will try
ty for your time
np anytime
Hello there, does anyone know how to somehow make Graphics.Blit() work properly ?
It works fine in editor. Though, when I build my game, I have a black screen and only UI is rendered.
Here's the function I'm using (note that it comes from a free plug-in I've found) :
@cosmic prairie @meager pelican Thank you, I’ll look into it!
Thoughts:
I wouldn't call Resources.Load for the shader every frame if I were you. I'd call it at some other initialization level. When doing that, check that it worked.
Make sure the shader is included in the build. There's logs and the graphics settings screen has a "always include this shader" slot.
Make sure OnRenderImage is being called with a debug statement in a debug build.
Thank you for your answer. I forgot to mention that I forgot to get rid of the Resources.Load, which was just to test a solution I saw online. Though, it didn't seem to work either way.
I've also already put the shader in the Always Include Shader list in project settings 😟
I'll check if it's called. But pretty sure it is, as if I disable the component, the build works properly.
Change the shader. Have it output red. return float4(1., 0, 0, 1); in the fragment stage of whatever it is.
Do you get red instead of black? If so you have NANs or zeroes for something in your values if you think the shader is being called.
Wait, actually, I have a null ref in my build hum (which is called at each OnRenderImage bc it's the material)
There you go. Enjoy. 😉 Debuggers are your friend.
I didn't think about doing a dev build here, as there was eveyrthing working properly in the Editor, which was a stupid mistake.
I'll still try this if I can't find the solution to my problem
Alright, it says my Material field is null, though it is set in the editor and is never set to null from script. Wtf is this ? 😂
I have a shader made with Amplify shader editor and when baking the GI the shadows are not rendered properly
but when using the default URP/Lit shader the shadows are rendered properly
Alright, I solved it @meager pelican ! The solution was to put preprocessor instructions on those two (and suddenly, the Material is included to the project) :
And put this to None, which caused the problem when it was on "HideFlags.DontSave"
I'm trying to make a custom skybox shader in built-in rp but I get a problem where envirnoment reflections/reflection probes are just pitch black, no skybox is visible there
I've been debugging this for hours at this point, really not sure what's going on, except I know its a shader problem
Having some issues with URP and a Shadergraph blur shader in 2023. I can confirm all the calls are being made and the data is all set up right via debugging, but nothing seems to happen graphically. I even was following the official blur tutorial with the only difference being the shader. 🤔
is there something I'm missing that isn't obvious?
I found something online saying that I should set it to forward rendering but there is no option for that even though I go where it says
so hmm
what unity version?
forward and defered option only shows on unity 2021+
2023
Rendering Path altogether doesn't show up
2023.1.20f1
so it's relatively recent
I got the nov 6 release of shadergraph as well
which seems up to date for non-preview
15.0.7
oh I see, I'm using the 2D renderer
because pixel perfect complains about it
but it doesn't have options
so I tried that and still nada
doesn't work on Forward, Forward+ or Deferred
the timing is set to TintRenderPass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; so I should be able to see it if I'm doing it right...
Does anyone know why a Shader Graph shader would look differently in the Game, View tab as opposed to the Editor View tab?
(First image is Game View, incorrect. Second image is Editor View, correct)
Additionally, this issue is fixed if the Canvas which the Shader Graph is in is moved to Camera Screen Space.
I did go out of my way to confirm that the shader works outside of the shader feature when set to sprite mode
Huh. First off, bake lighting if you're not doing realtime (your picture shows baked lighting).
Is the skybox material/shader set properly in the lighting tab? Did you start with a unity one (from source) and modify it?
The skybox shader is called after rendering opaque geometry. The reflection probes should be called after that.
Note that Skybox materials are a special case. Unity draws Skybox materials after all opaque geometry (after queue index 2500), but before all transparent geometry (before queue index 2501).
https://docs.unity3d.com/Manual/built-in-rendering-order.html
So check your render queue number for proper values. See the source code for one of unity's skybox shaders.
I can't tell from your post if your skybox shader is working or not. Maybe output red or something to debug it.
what mode should shader features shaders be set to?
got it 😎
This is the first time I have written shader code. I am following this tutorial to help wrap my head around it all.
Traditionally, the code on the right of the screenshot was written in a .shader file I believe, however I am using Shader Graph in 2022.3.15f1 and can't seem to find a way to edit the custom function node through a text editor in Unity.
Can anyone help me figure out how I can follow this tutorial and write the shader code?
this one?
you can only directly write the code inside the custom node tho, i prefer using "file" type instead of "string"
*if the code is long
@hollow wolf Could you provide instructions on how you were able to achieve this settup?
https://www.youtube.com/watch?v=gw31oF9qITw
This is the tutorial I'm following if it helps!
The third devlog about my yet to be named cozy creature collecting and management game. This one covers my initial implementation of cel shading in Unity.
✔️ Corrections
None yet! 🤞 If you find some information that is wrong or some visualization that looks buggy, please let me know, it’s very much appreciated!
🔗Socials
Follow me on Twitter
h...
well, just write the code inside the custom node and make sure to pay attention to the input and outpu type value
@hollow wolf Thank you!
it's case sensitive btw, so make sure the name for input/output is the same as what you write inside the block, and since there's no IntelliSense it will be pain in the ass
what happen with my node?
Looks normal, what's the issue specifically?
so that smudged is normal? i thought normal will look like this gift box
Yes, completely normal
im i wrong some where? the alpha look incorrect
I have no idea what logic you're trying to perform, but the outcome of those nodes makes sense to me
im trying to make outline but it seem . . . not right
Perform the colour logic as RGB, and separately pass a float A into the alpha output. Trying to do it all as RGBA is confusing you and hiding what the alpha looks like in certain steps
the main preview show look correct, but the "Game" show black, and the "Scene" show nothing, im so confusing @@
@vocal narwhal sir, are you there?
It's hard to tell but I imagine your material isnt set up correctly, you should feed the alpha through a preview node at the end so you can be sure what it is
@vocal narwhal ty, outline is work but now i got a weird trouble, they are all on a canvas
hit this button and see if the problem persists
2D sorting is not "supposed" to work if you're not in 2D view
here
Canvas requires it's own shader setup iirc. Are you also using the Image component?
Them being on a canvas is important information though
Canvas doesn't use 2D sorting
yes, they are all image
Does UGUI work with/have a shader graph? I forget, I haven't used it for a while and I just modified the built-in shaders
i tried to switch them up and down on Hierarchy, but nothing change
@hushed basin UI shaders in Shader Graph are not supported yet but unofficially possible, I think
Should be a Canvas type graph in 2023.2, otherwise need to use a Screenspace-Camera canvas, not Overlay.
Is it possible to do basic cubemapped/mirrorball reflection shader with just texture combiners/vertex shaders, without using pixel/fragment shaders?
How can I have a shader variable skip parts of a shader?
I have a float that, if it's zero I want it to skip a part of code, otherwise, do the part. The float can have any value, but if it's zero I just want to fully skip a part
It's a parameter, so pre set on the shader and always the same value
I know of keywords, so ideally something similar to #if defined, but #if var > 0 do something
For variables/properties you'd use a regular if statement. https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-if
Though it's a little hard to say whether that's actually going to skip the calculations or just discard the result - the compiler might choose to flatten the branch.
Keywords are probably better if you definitely need to skip the calculations and don't mind the shader variants (as they won't batch together)
adding " doesnt unity skip that feature if unused normally?"
i had dither crossfade feature in a simple unlit shader using "if def" , for example, wont this feature be excluded from the gpu computation if that is not being used?
pingu
yup, but how do you know if it's being used or not? unless you have a keyword, i think unity just doesn't compile the code rellevant to the things inside the #if statement
In my case I have a parameter dividing a set of values and then doing a texture sample. However, if that parameter is 0 i would like to skip all of that
lacking certainty about it, thats the problem
yeess..? im not sure xD
hope it will be answered
off topic , hey sapra , do you know anything about implementing light probe support on a simple fragment shader?
im just roaming here and there on the website, didnt got collided with a sense making solution
Aaaah, I got linked once a websiite that had all of that explained give me a sec
You can read the convo from here until I disappear
and also this
https://forum.unity.com/threads/light-probes-not-working-properly-with-instanced-meshes.940419/
I think going to that message and reading above and below might get what you need
thank you , im checking it out
np
Can't i treat a propertie as a keyword easily? or Force a keyword to be generated automatically from the property?
Hey folks, since I'm very new to the shader topic, I wanted to ask for some advice.
I would like to create a shader that makes a predefined square from an image transparent or cuts out a square. (At best there should be a slight alpha gradient)
There should be a function that sets a cutout at given positioning data.
The number of cutouts should be able to vary.
Background:
I would like to have a panel that shows an image. Above this there should be a full-surface black panel in which a square area always becomes transparent via positioning data . It is a part of the game in which the background should become visible as the game progresses.
Not really...
But you can use MaterialPropertyDrawers or a custom ShaderGUI to toggle keywords when adjusting property values on the material inspector. That might fit your use case.
The shader still needs the keywords and #if blocks defined though.
If you don't need any partial transparency, could look into using the stencil buffer.
Otherwise maybe use a second camera to capture the squares (rendered as gameobjects or particles), rendering to a Render Texture, which is used as an alpha mask in the black panel shader.
I'll try it, thanks 🙂
I made a shader for a transparent material that should appear opaque most of the time. However that causes the faces to render in a weird priority. Anyone know what causes this and/or how to fix it?
It is a transparent material so that I can make certain parts of it see-through, so if there's a way to that with an opaque material that would also be a possible solution
This is because transparent objects are drawn without z writing enabled, meaning there's nothing in place to ensure that pixels that are behind other pixels get occluded, except the order in which they are drawn.
Your dissolve effect appears to never be half-transparent, always either 100% opaque or 100% transparent. In this case, you can use alpha clipping instead of transparency/blending.
Oh wow that worked, I would've searched around in the options for like 2 more hours. Thank you so much!
Hi, I am making a 3d game and I think I need to make a shader mask. I have 2 walls (black). Enemies (red) spawn outside of the walls and they gradually go into the area enclosed by the walls and out the other wall (blue). I want to mask whenever a part of the enemy is outside of the wall boundaries (green). Is there a simple way to do this? It's easy to do in 2d but the enemies and wall are 3d.
Hi! There are lots of usable and easy solutions for portals in URP, I’m having trouble finding “the” solution for built in rp. Can anyone point me in the right direction? Thanks!
This ? : https://www.youtube.com/watch?v=cWpFZbjtSQg
(github repo : https://github.com/SebLague/Portals )
Experimenting with portals, for science.
The project is available here: https://github.com/SebLague/Portals/tree/master
If you'd like to get early access to new projects, or simply want to support me in creating more videos, please visit https://www.patreon.com/SebastianLague
Resources I used:
http://tomhulton.blogspot.com/2015/08/portal-rende...
Does exist a way to not save material changes in Play mode?
I need to rotate the skybox while keep it at the same initial position on scene restart
(please dont suggest to store the rotation value,I hope there's a better way)
Did you try to make an instance of the material at runtime ?
no, so in awake I should create a temp copy of my skybox, replace that and then act on the new copy?
Yep. In theory, when you reload the scene, it should again use the original material that was not changed, and the instanced one goes to garbage collection when unloading.
so how do I create a copy of the skybox?
var newMat = Instantiate(skyboxMat);
is this wrong?
Yes, tempSkybox still points to the original material. The Material type is a class, not a struct, so it is passed by reference, not by copy
ok, your "Instanciate" gives me error, is that just pseudocode?
It's a typo, sorry 😅 : https://docs.unity3d.com/ScriptReference/Object.Instantiate.html
that works, thanks!
Hi! How do I pass custom attributes to the shader graph from the VFX graph?
To clarify, I need to read them in the vertex context of the shader graph.
If I remember correctly, when you define an exposed parameter in your Shader Graph, it will appear as an input port in the output node in VFX Graph. Then you can simply connect a "Get Attribute" node to that (which is an experimental node enabled in preferences)
I'm not entirely sure what it's actually doing, whether it's passed as an instanced property or what, but it worked for me.
Yes it works, I wonder what I screwed up earlier! Thanks!
Heyo 🙂 I'm struggling a bit with stencil shaders, and I was wondering if someone would be able to identify where I'm making a misstep:
Essentially, what I'm trying to achieve is just that the green cube will only be visible when within the silhouette of the red sphere. However, the green cube is currently rendered no matter what, as seen in the GIF.
The following is my shader code:
Green Cube
Shader "Green" { SubShader { Tags { "RenderType"="Opaque" "Queue"="Geometry"} Pass { Stencil { Ref 3 Comp always pass replace }
Red Sphere
Shader "Red" { SubShader { Tags { "RenderType"="Opaque" "Queue"="Geometry+1"} Pass { Stencil { Ref 3 Comp greater }
Big thanks if anyone is able to identify the issue 🙂 I've been banging my head on this for a while, haha
In the Green Cube shader, what you're saying is that the stencil check should always succeed, and when it does (which is always), it should replace the stencil value with 3. The Red Sphere shader will only pass the stencil check if the stencil value is greater than 3.
You have the stencils a bit flipped here. To render the green inside the red, you'd need to render the red first (e.g. queue as Geometry-1) with Stencil as Comp Always, Pass Replace.
Then render the green, with Stencil Comp Equal
Thank you both 😊
It definitely helped with the silhouette issue 🙂 Now the only remaining goal would be for it to keep rendering the green as long as it's within the silhouette of the red, regardless of it being occluded by red.
I'm thankful for the help already, but I'm also all ears if anyone has any pointers to the remaining issue 😊
For that, you can specify ZTest Always in the Green Cube shader to have it always pass the z test.
That goes inside SubShader or Pass, not Stencil.
It worked! Thank you so much 😄
Whoops, using "ztest always" seems to have the side effect that the mask will now appear in fron of any object at all, does anyone know a way to bypass this? 🤔
ztest greater and higher renderqueue than red on green
That's absolutely fantastic, thank you 😁
Hi everyone. I've been creating mods for a certain game for some time now, and recently I've started a project of recovering the original unity source of the game in order to make literally any mod possible. It's been going flawlessly, apart from one issue. The shaders. No decompiler I've found can properly export the shaders, all of them get a parsing/syntax error and because this was made in Unity 5 (and is transferred to Unity 2017 as U5 is way too unreliable) I don't think there's any visual aid. My only choice really is to figure stuff out from the script and I have no idea where to begin.
"Parse error: syntax error, unexpected TVAL_ID, expecting TOK_SETTEXTURE or '}'"
this is one of the most used ones which accounts for like 90% of the materials. A solution to it would probably help with everything else
Questions about modding/decompiling is against the server #📖┃code-of-conduct - you won't find help for that here
I don't know what this is saying
Hi, I applied two materials in one mesh. One is the ToonShader material and the other is the Dissolve material. Now I want the Dissolve material to act as a mask. So, I want to make sure that only the parts of ToonShader material that overlap with the display part of the Dissolve material are displayed. Is there a way?
In Shader graph, does the Object Node > Scale output return an absolute value??? I tried getting the sign of scale.x but it is never -ve
I tried the test also by checking if scale is less than 0 but the comparison node outputs black
Even though in the inspector the scale is clearly -ve
Is there any way I can delete some built-in shaders that live on my shader list without any purpose (for myself at least), such as VR, Mobile and also the Standard one that lives there even though my project can't use because it is URP? 
If anyone tell me how I'll heavily appreciate it
searched and nope you can't, leaving the messages here if anyone ever had the doubt lol
why is this happening with my shader
this is the setting for the 1st one btw
i haven't changed anything, and it used to work just fine
it's just I've been using a new sprite sheet
it looks like you're interfering with the material property block, as the info field at the bottom of the material goes away when it breaks
how to I fix it tho
it's weird cause if i move it around a bit it unbreaks
I am not sure; the SpriteRenderer sets the texture via a material property block; and presumably touching the material directly removes that until the sprite renderer updates again
whats also strange is
it doesnt break with the other colors
only the body color
acttuallyy i think thats just because the body parts are separate
wellp um
Is it the body that you currently have selected?
mhm
Try just deselecting it and then modifying the material
how would I do that without selecting it?
oh wait nvm
yeah it doesnt break when i go directly from the material itsef
but why would it suddenly break when it worked before
and colors will change at runtime so i hope this doesn't happen then
found the issue btw, i never changed the actual material's texture so it was still the old spritesheet
Hello ! I'm really struggling to make this work. What i want the shader to do is to color my terrain, white for the peaks, green for the flat areas and gray for the steep areas. It returns a pink material tho. I'm using HDRP and the terrain is a mesh .
This shouldn't be necessary if the _MainTex property is working correctly
I am open to any other solutions as well, for achiving this result
You'll probably want to use Shader Graph, especially with HDRP, unless you need to make something it absolutely cannot do
Is it a Terrain-terrain or a non-Terrain-terrain mesh?
Terrain component shaders are bit of a nightmare to make so I don't recommend that, but for that there are other options
what would be the most performant way to change tiling/offset of a material?
using script?
or to define into the shader itself? though it would be complex because i need that same shader in some case where tiling/offset needed constant
if yes, then how? im working for mobile, so any performant way or trick?
Does anyone know how to make a shader in URP that makes an object not receive shadows from a certain object layer?
Anyone familiar with projection mapping/matrix math that could lend me a hand?
I'm rendering a scene from a primary camera (the "View") into a render texture, and want to reproject that render from the perspective of another camera (the "Projector") onto a surface.
To do this reprojection, I've made a shader that uses the View camera's projection matrix to sample the render texture. This custom material is used on the models that I want to use as the projection surface. I figure this should work, but I must missing something because it does not line up. I've attached the shadergraph source and a screensot, as well as what both cameras look like. This is the C# math that calculates the Projector Matrix:
_surfaceProjectionMaterialInstance.SetMatrix
(
projectorMatrixProperty,
projectorCamera.projectionMatrix * projectorCamera.worldToCameraMatrix
);
welp. i believe it's fixed. i was being dumb and getting the projector matrix from the projector instead of the view
Is the Bounds Size object rotation independent? Or will it also "rotate" with the object?
fps droping when close to the mesh, just using normal transparency shader and GPU instancing, any idea what can it be?
Overdraw or cost of the shader
Both are relative to pixels/fragments covered by the material
i never did a custom transparent material before
do you have any sugestion on how to do it right?
Could use opaque material with alpha clipping instead, unless semi-transparency is a necessity
You could show the kind of shader you've made so far, and explain more about what you're trying to do for better advice
It's the size of the world space bounds. It's axis aligned, so it doesn't have a rotation, but it changes size to fit the rotated renderer the best.
Hey, not sure if this is the right channel to ask this but I'll give it a shot.
I'm making a bloxorz game where when you go down the goal tile, the player goes invisible. I managed to make this work by giving the the block underneath the tile a VR/SpatialMapping/Occlusion material.
However this doesnt work when I want to add a background image using the UI/image object because its just ignoring the image entirely and just showing what it would look like without a background
also the block is only invisible when I use solid color for the camera's clear flag component
Oh, any hack to counter resizing to get the bounds at identity? I'm trying to extract object height and width.
hey i was wondering if there might be a way to turn a shader graph into a standard shader? i ask this because i have bought a prefab that uses shader graph for its material (even though it has the main options for mainly standard, photo included). Normally i would swap it to be a standard shader. however when i do this all the textures dont get properly placed in the standard shader. All that i know is that this is cause the naming convention is different so it wont carry over nad place it properly.
Things like _MainText is instead _Base_Map in the shader graph shader. (ive tried editing the shader and it either doesnt work or it makes the textures vanish)
Anyone know a way to swap it and carry over to standard or something. cause theres 100+materials in the package and like 5 textures each and i really dont wanna go through by hand going back and forth redoing them all x.x
In a shader, we have to sample a texture 2D LOD to displace the vertex position (tess/vertex animation), and have to sample texture 2D again for the sample texture to use that for color right?
Have to sample the same texture twice.
Is there anyway I can go around with sample only once?
ur right, that the naming governs the conversion.
if a texture with 2 different names between 2 shaders, there is no way the engine know which is which when you change shader. Make a Editor tool that have a dictionary<string,string> which can tell which name convert to which.
make the tool once, use it to automate the process, still worth it.
bump
No you can't. The vertex and "color" part a separate sections of the shader and the rendering pipeline (vertex stage / fragment stage).
The first one only shares information per vertex to the second, so it can not contain the "per pixel" color information you need, that's why you need to sample the texture again.
damn, thanks for the explaination.
so if I want to use triplanar: 3 samples.
antitile +3 = 6 samples + 1 blend texture = 7 samples.
then if I want to displace that in vertex, again with 7 samples with texture2D LOD, total 14 samples, just for 1 texture 💀
The cost climbs like no tomorrow.
if I want to make a environment shader with those features, antitile + triplanar + displace, that support 3 textures blending, that would be 14x3= 28 samples.
How can one do this?
I'm not sure how to do that. I mainly do stuff for effects with particle systems. Coding and doing editors and stuff like that is beyond my field of knowledge.
Is there some kinda video or article that is similar to what you're describing and how to specifically do what you're saying?
I also really appreciate the advice first of all thank you ❤️
is that the most performant way?
editor tool making is sadly a complicated process, I think I can't find u a tutorial to do that specific tool, we have to go over each features and read the doc and implement step by step until it's done.
It's even worse ^^
If you want antitile & triplanar, it's 9 samples (3x3) not 6 (3+3) as you do the antitile for each planar projection
Texture size and offset is stored in a vector 4, if you wanted to be even more "performant", you could use a SetVector function instead of the two others. But I doubt that this is something that will make you application go from 30 to 60 fps ...
@tranquil cipher And we're talking of a single texture here, if you want to have albedo + mask map + normal ....
yea, that's one set. an environment shader usually have around 4 set
Gotcha
I really appreciate it. I'll be able to do it tomorrow since it's 4 am over here and I need sleep.
Again thank you!
well, another relevant question, swapping texture on runtime vs swapping material one runtime? which would be a wise choice?
iirc, you can do triplanar with one sampling, but instead of sampling 3 texture for each axis, you 'switch' uv(worldpos axis) instead of blending the texture for each axis, there might will be visible seam though
What I meant, is that if you want to stack 4 layers of texture, each having albedo / mask / normal, and use antitile & triplanar : that's 4 x 3 x 3 x 3 + 1 (blending mask) samples = 109 total samples 😅
But I'm volontarly exagerating things here, this is the really worst case scenario where a single pixel (or more, wavefront) would have the worst blending case where everything needs to be displayed.
In reallity, there will be way less overall.
yea I understand that, I admire those asset store dev like the dude did InTerra shader, which has all those features. Sell the tool only at 25$. I guess I just buy instead of breaking my brain over this.
And you could look into some more performant methods, like biplanar sampling instead of triplanar
I think both will have the same final cost.
hi! as it was just terrible i deleted it, i'm doing the material to use in billboarding grass
i did some tests, @grizzled bolt , and found that all the unlit shaders have this problem
this and others btw
i think is something related to GPU instancing
but idk what exacly
What kind of tests and what kind of unlit shaders
Transparent unlits for example can have much different performance from opaque unlits
Which render pipeline
just the default unity unlit
opaque rendertype
oh
i found the solution on the documentation
thank you anyway @grizzled bolt !
Now i need to make it transparent xD
You need to give precise details about your goals and methods for people to be able to help you
i wasn't being ironic or anything like that
is there anything like mesh ID?
Like, a unique ID for each mesh, where multiple draw calls of the same mesh would have the same ID?
hello
do you guys have any starting point(s) or nodes to recommend using so i could change the color of a shader depending of where the player is
the idea of the end result is "painting" the floor where the player is, and fading back to init color when he move somewhere else
maybe getting the player world XZ, and "drawing" a circle with the center equal to the world XY
Sure no worries, it just can be frustrating to not get the relevant information
for what i read, i think what i want is 1 ID per "Object" in the same draw call, but this don't exist
instead i think i need to use something like MaterialPropertyBlock
If you're specifically talking about an instanced draw call, then you can use SV_InstanceID.
how do i initialize it?
It's passed through like a vertex attribute:
struct appdata
{
uint instanceID : SV_InstanceID;
float4 vertex : POSITION;
};
Unity also has macros which are more cross-platform friendly and allows other Unity functions to access it automatically.
https://docs.unity3d.com/Manual/gpu-instancing-shader.html
the only problem with this is the fact that i am not doing it for every single mesh
but in packs of 1000
can i do the single material with diferent colors in one draw?
is there a way to display numbers in the shader graph ? for better debugging
for example i have a position node and i would like to know what it shows for a specific mesh
idk in shader graph, in custom shaders i know that it isn't, so it's common to just plug the value you want to debug in something and try interpreting the result
ok ty
is there any way of taking the world position of a vertice?
In shadergraph ? There is the "position" node
i'm doing it in custom shader
Then you can use the unity_ObjectToWorld transformation matrix : https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
Instancing means multiple instances. So SV_InstanceID is always 0 unless you're doing an instanced draw call, which you are, in which case it will be different for each instance.
ty, ill try adding it
regarding the position node, i tried the last 2h in a shader graph to take as a input a vector2 and draw a ellipse with this vector as the center point
the only thing that worked was when doing something "locally" from the 3d object (plane) origin point, but i would like to be world.
for example, i give 100,50 wolrd coords and (lets say the plane takes all the scene) a ellipse is draw there with 100,50 as the center
Did you set the position node to "world" or "absolute world" ?
yes ofc
tried bunch of combination and math, but im new to how UV and Unity shader graph works
This should work for example :
thank you so much for your time it works perfectly
i guess i didnt test the combination of using xz and subtract
In Unity a default plane is on the X and Z axes, that why I used the swizzle node to "isolate" those for the input of the elipse.
The elipse node does draw an elipse centered on the origin of the "UV" that you input.
Subtracting the value you wanted to the world XZ did offset the origin, and allows to draw the elipse at the desired position.
i remember trying stuff with Z but nothing outputted, only with X and Y
i dont remember what i did exactly
How can I create a 3d mask gameobject to hide the gate's opened parts?
chunks 😎
i tried using sphere mask to make a ellipse fading but i didnt manage to make it work
is there another way ? or what could i be missing ?
Can you "cache" a result in the shader graph and reuse it somewhere else in the same graph ?
so i dont have lines crossing my entire graph because i am reusing some same output
Is there a performant way to write a multipass shader with a write+read buffer between the passes? For context: I wonder about implementing cone tracing, where you render the screen with multiple passes at increasing resolutions starting from 1x1* (conceptually, irl with something like resolution/16) and start with depth buffer to cache the SDF distance between passes. Is there any official way to do it in shaderlab alone in unity or do I have to implement something like that using command buffers? https://forum.unity.com/threads/multi-pass-shader-that-uses-texture-between-passes.561025/
what about URP?
here is the doc about conetracing for anyone interested: http://www.fulcrum-demo.org/wp-content/uploads/2012/04/Cone_Marching_Mandelbox_by_Seven_Fulcrum_LongVersion.pdf
No, but this editor package adds that - https://github.com/Cyanilux/ShaderGraphVariables
with shadergraph (i'm using builtIn pipeline if it matters), whats the easiest or best way to support GPU Instancing?
hi! do you guys have any material sugestion for studying geometry shaders? i need to create a quad but it's kinda harder than i first thought
anyone have any sources or specific things i should research to make a shader like this? (Game is called Buckshot Roulette)
that game is fire! I think toon shader may be a good starting point to replicate the colors
I'm using cloud points technique to make a ton of grass in unity, is there any way i can pass custom info that isn't normals/uvs etc to my mesh?
for instance if i want every vertice to have a number given by a perlin noise
small question, shader noob here.
i'd like to create a shader that acts sort of like a mask and applies distortion to everything behind it.
what would be the basic approach towards something like this?
(for example, a 3D Sphere with that Material/Shader should be invisible, but everything that it's occluding should suffer distortion)
Look up "posterize" as a post process effect
The dither patterns visible on some objects are probably a part of the asset or lightmap textures, but if not that could be implemented as a post process as well
omg a posturize effect is like exactly what i was looking for tysm
Can someone help me with a shadergraph that skews objects towards the camera at all angles? I can skew it in 2 directions, but not able to stack it to be seen in all angles.
How do I make Shader Graph VR compatible?\
im using a fragment shader that supports a single texture and baked lightmap.
now which one seems the best method for performance? picture 1 ? or picture 2? or both are same?
honestly they both look about the same
one way to check if you are actually reducing the amount of instructions and such
is to view the compiled shader
compare them instruction wise
any idea why when in the sample "terminal scene" when I walk into some of the rooms it keeps showing this compiling shader all the time as I move? it keeps popping up basically all the time when I enter the room, finishing in 1-2s and reappearing maybe 0.5s after
in the other sample scenes it compiled the shaders fine without showing a popup, just doing it while the game runs
thank you)
is it possible to merge shadow caster pass and a lightmap pass into one?
i see, though it will cost only 1 set pass call, but i was afraid of having several materials on that same shader
but...wouldn’t it be a wise choice to use fallback (to a simple shader that has shadow caster pass) instead of writing the pass on several shader where required?
your answer requires a few questions to be asked
sure
does your project require the use of realtime shadow casting? does your project use camera depth to do any effects? do you prefer to keep your shaders small code wise?
because in theory if your project does not use any realtime shadow casting, or uses camera depth to do any effects you don't need a shadow caster pass at all in any of your shaders
and sure using a fallback will keep your shader code small, but it wont make it run any faster or make it any better on that front
- no realtime shadow, a completely baked world.
2.but yes, to use a special decal shader instead of blob shadow or any projector, it needs depth reading
- as im working for mobile, i actually try to make the codes efficient as possible
oh.. I see
I know I mentioned this before though I forget if you responded to it, but I would only worry about optimizations if you start hitting performance problems in your project when deploying and testing on mobile
yeah, you told it before, first to sum up all the things and then optimizing... But I was actually targeting from low end devices, that's why i was aware on every steps
I had another question, is it possible to have realtime point/spot light supported on the fragment shader while being lightmapped at the same time?
yes
It needs one extra pass? right?
that pass only gets used and added to the setpass calls if in the engine shadowcasting is used, or if you are using the camera depth texture
it depends, in BIRP yes but there is a caveat
if for example the only realtime light you'll have is a point light/spot light I think you can use them in the forward base pass
and keep it all in that one pass
but if you are using a directional light, and another point light at the same time, you need another pass
ForwardAdd
Yeah, According to the condition, im gonna need forward base, because i wont need directional light anymore after baking out the scene
could you show an example if you get any free time... like just implementating such on "mobile /unlit (supports lightmap)" shader? i tried before but couldn’t at least succeeded with point or spot light, all i could do with was the directional light which i really wont need
didn't know that too, thx
i know im being stupid...but pretty please( , i just needed to learn the way of implementing it
Is there a way to get ShaderGraph's Scene Color working in URP?
Currently, anything I try to do with it, it just returns black
I'm trying to create a shockwave effect, and every tutorial I checked used that
but for some reason it just doesn't give the same output as it does in tutorials.
how can i make all faces show the same output i am giving ? (the 45d rotation on first screen)
also, is there a way to make the position node ignore the scale (so the lines dont stretch when scaling up)?
You need the Opaque Texture enabled in the currently active URP asset for it to work
oh wait hold on
still doesnt do anything
its just transparent now
(with only scene color)
messing around a bit, I created a black hole singularity
it started rendering things behind it
but I can't get it to do the pulsing effect
That's kinda the point. The scene color returns the colour of opaque objects (& skybox) behind it. If you don't alter the input coordinates, it'll appear as if it was invisible.
thing is, I now altered it
and it did that
the preview is good
Is the graph set to Transparent under the graph settings? That is required for scene color to function correctly
but it doesnt do anything
yes
this is all I get in gameview though
it works fine in the preview too
but not in game
@regal stag any ideas?
Am confused, you were using Scene Color above but now are using Sample Texture 2D? You'd typically only use MainTex in a sprite shader or fullscreen/blit effect.
im using both?
and yes I started using Sample Texture2D too
the sphere works
the circle doesnt
@regal stag how could I make the "black" parts transparent?
because otherwise it almost works
Could use that as an input to the Alpha port on the master stack
Maybe Saturate first to make sure the black parts are 0 and not negative values
it just became even more white
i swear this'd be easier in code
I'd check your graph against tutorials using scene color. You need to be adjusting the UV input, not it's output. e.g. For distortions you typically do something like Screen Position + ShockwaveUV + OptionalNoiseTexture -> Scene Color -> Base Color (master stack)
i tried something like that
im getting weird artefacting
hold up
it works! kinda?
Yep that looks better
I went a bit off-tutorial at the scene color thing because I realized that the one I tried actually did it for objects
so a shockwave for objects, not as an actual effect
there are some issues though
first of all, it really fucks the rendering of everything behind it
they become pixelated, that weapon just completely disappears
it only seems to be able to affect opaque materials
changing downsampling fixes the quality
it still completely prevents other Transparent materials from rendering though
Yes using the Scene Color / Opaque Texture does that. It's not designed to show transparents. If you need them, you could maybe blit the screen to a custom texture and sample that instead of the scene color. Would require some custom renderer features though.
lord
tf am i meant to do then
I'm trying to spice up this kind of blocking feature
but I have no idea how to
i thought maybe a cool shockwave would do it
but that wouldn't work because most of the projectiles are transparent to a degree
welcome to what I've been researching the past few weeks
and the shockwave would just make them completely invisible
You could also change the Render Queue on the shockwave materials (or Sorting Queue) so other transparents always render ontop. They wouldn't be distorted but would keep rendering at least
over-use of transparents is quite problematic
i did that
but yeah
maybe do you have any ideas on overall creating an effect for it?
keep your projectiles opaque or use additive blending
I assume this is because the shockwave is creating problems with the other transparent projectiles?
yeah
but i think i just wont use a shockwave here overall
I'll use it somewhere else where it won't be trouble
Maybe just a solid coloured ring and some other hit effects/flashes would be enough to improve the look without using distortion
thank you for the help though!
the problem is that shields are really not mainstream when it comes to combat
so it hard to look up stuff for them
alpha clipping and opaque has been a good alternative for my systems
because games rarely use them
i messed around with alpha clipping, no use
Is there a text editor that will highlight syntax errors for ShaderLab shaders?
maybe a trail for the shield?
so i am doing some testing with a fullscreen shader
my goal is to do a fish eye effect
how can i "get" the screen colors and use it in the "spherize" ?
or is there a another way
If it's a Fullscreen Graph in URP, you'd use the URP Sample Buffer node to sample the "BlitSource". That'll contain the camera view.
Should also be a Spherize node iirc to alter the UV coordinates
Though I think the URP post processing volumes might also already have a fish eye warping effect too
Ah I don't know anything about HDRP. Maybe check the post processing effects though first. There might already be one
how could I create a trail for a cylinder type object?
tutorials only talk about point trails or sword trails
I'd kinda want to have this shield's outer edges kind of create a trail somehow
@junior copper try HDRP's panini projection or lens distortion overrides
ill try panini, lens distortion couldnt do what i wanted
"limited" settings
even when giving the sample buffer to "color" with the blend mode set to "disabled" i dont have all the same colours
anyone?
I was thinking perhaps having a simple 2D circle
and that circle, when it's being moved, it creates a trail on its edges
Why not just use a particle emitter, matching the size of the emitter and some emitter normal direction to the shield's edges, emitting particles? If that doesn't work, I guess you could create an array of previous-frame positions with a center and normal and then do some effect with it, but you'd have to have a mesh or a full screen pass (which is basically a quad mesh the size of the screen) to draw into. I mean, something has to make it to rasterization.
and some emitter normal direction to the shield's edges, emitting particles? sorry, I don't get this part
I was thinking of getting a circle that matches the size of the shield yes
yup, just make the particle shape as circle then match the size with the shield, and then use rate over distance if you want the trail always on
wouldnt it cause particles to be emitted everywhere inside the circle though?
and not just on the edges?
well you can play with the lifetime and the velocity
what does that have to do with where they appear?
oh, no, you can make it emit in the edge area
this
as you can see, all the particle is right in the edge of the circle
just play with the radius and Rad thickness value
any ideas ?
alright, ill check it out later
thank you!
btw is this using VFX graph?
default particle system
i mean sure you can use VFX, but i belive particle system is already enough
oh yeah that one has a built in circle emission
also what about making something flash?
kind of like a pulse?
you can do a point cache with vfx graph if you want trails
pulse? usually i am using code to change the value during runtime or you can use animation
Hey, not sure if this is the correct channel to ask in. but i had a question on importing fbx's and materials/textures
Thank you, I'll ask in there
You could try the triplanar mapping node, and use worldspace as a tiling system. Or maybe you want some kind of scaled object space or view space, with tiling node, not sure from your description.
https://www.youtube.com/watch?v=HKTIuvFHAPQ
To use the scale of an object in shader graph we need to modify UV values that we pass to the rest of our shader. In this video I will show you how to use Object node and Tiling and Offset node to do just that.
@Jettelly
Learn all there is about shaders in Unity
https://learn.jettelly.com/unity-shader-bible/
Learn to write more maintainable...
ty man
scale fixed, now the rotation :')
How is rotation impacting your uv mapping on a quad? What do you want to happen?
The triplanar will map "to the outside world" as if a projector is projecting the pattern onto the object from the outside, in three directions.
But it may look a bit odd as things rotate. OTOH, you can map to the object itself, in which case the object's rotation shouldn't matter, but scale will.
So without more information as to what you want to see, I'm not sure what to tell you.
i didn't do the triplanar yet
Have a shader graph prolem right now when i use my material with my shader in the particle system, the problem is that if i change my color, my alpha changes, so if its all white the alpha is visible and if its all black its invisible even though im not moving the alpha slider
Is the blend mode additive?
where do i set the blend mode? Im new to unity
in graph settings
Ok, yes the blend mode is additive
That's what it do
Maybe you want alpha blended instead
Even tried splitting every single texture/color and combined only the rgb values but id didnt work