#archived-shaders
1 messages Β· Page 38 of 1
It may be best to try it in regular Forward path as well, so you can compare.
I would expect the object to appear shaded, not black though. Unless you've changed something in the CalculateMainLight subgraph too.
okay, gonna try that soon
Hmm, I'm not sure if that worked. I guess what I'm trying to do might not be possible. I want an object to draw itself only if it's either lined up with a stencil value of 0, or it's in front of the object that is setting the stencil to 1. To do this I figured that I'd have to make the object that's setting the stencil value to 1 only do that if nothing is in the way, but I suppose it won't know if anything is in the way without the other objects being drawn first which means that they won't be affected by what it does to the stencil value.
Sorry for the big jumble of text, but do you know if there's any other way to do this?
I'm not sure I understand what you're trying to do
Sorry it was a bit confusing. I want an object to only render if it either lines up with a stencil value of 0, or it is in front of the object that is setting the stencil value to 1.
The object is still black
That is the calculateMainLight shader
so no, I didn't change it
Small video to show that it doesn't change
that power is going black, i think thats whats confusing me here
..Nevermind, you're right: main light intensity was 0 π€¦ββοΈ
That's with a normal rendering
@regal stag I can confirm, outputting distanceAttenuation directly from the CalculateMainLight subgraph to the diffuse and using it as a base color, is the only thing that changes
so distanceAttenuation calculation is different and completely black in Forward+
Looking at the URP/Lit shader, I've noticed there's a new keyword _FORWARD_PLUS which likely needs to be setup in the blackboard like the others.
It.. works? It fixes the main light and no light flickers, but additional lights (point lights in my case) don't work anymore T.T
so close...
That's probably because the code needs changing. There's new macros like LIGHT_LOOP_BEGIN and LIGHT_LOOP_END. The additional lights section of the UniversalFragmentBlinnPhong function in Lighting.hlsl should provide an example. https://github.com/Unity-Technologies/Graphics/blob/6738efc532da5d49188ffe403fea90555faf1a3e/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl#L386
Well, that's the master branch so might be too new. Could check Lighting.hlsl in your package files
I am trying to follow the guide for creating a post processing shader in HDRP. The default example has an intensity property, and I can't for the life of me figure out how to set that property. When I added it to a volume, it has an input for the shader material, but not the actual intensity.
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);```
Tried using what's in the #ifdef USE_FORWARD_PLUS, didn't work
(commented code was the old code)
Also, I noticed that the LOOP_BEGIN and END is used outside the #if USE_FORWARD_PLUS
I'd assume you need both loops (the one in USE_FORWARD_PLUS and the LIGHT_LOOP_BEGIN/END). Since there's no #else, so if USE_FORWARD_PLUS is true, both of those would run.
Here's defined the GetAdditionalLightsForToon
yeah, they're.. doing different things, I suppose? Code is completely different, in the example they're using a custom struct to hold values that I do not use and I have no clue what changes between the two
In the first loop he loads the color, in the second.. no idea
they're using a lot of code that I've never seen, I'm trying to understand it by the names and logic, but that's very advanced for my humble hlsl knowledge
I was directed here to see if anyone has encountered this. My Main Preview in Shader Graph has been empty for a while now. I have tried clicking and dragging in the Main Preview window, but nothing changes. I have also tried different meshes, but it doesn't change. Not even a gray mesh. I have closed and opened the Main Preview. I have closed the Graph and reopened it. I have tried different Shaders. I have tried different projects, but it is all the same. I am using 2021.3.20f1, was using 2021.3.3.1f1, where the problem started. I have rebooted my computer, and restarted Unity multiple time. I haven't been able to find anything from Google Searches, so I am pretty lost, and having to save the shader and go into scene view for each change is getting bothersome.
By chance does anyone know any plugins that allow for like bindless textures for compute shaders? I am really needing them but unity doesnt have them by default
Compiling Subshader: 0, Pass: Blit, Vertex program with <no keywords>
Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_RGBM_ENCODING UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING```
anyone knows how to fix this error ?
Hi, can I get some help on this? I'm trying to use an image effect shader to modify a texture like so:
RWTexture2D<fixed4> _Tex2;
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = 1. - tex2D(_MainTex, i.uv);
_Tex2[int2(0, 0)] = fixed4(1, 0, 0, 1);
return col;
}```
I needed to use #pragma target 4.5 for it to not throw an error, but even now it's still not modifying _Tex2
I'm currently just trying to change a single pixel to red to see if it works, but the texture is still entirely black.
How can I scale the circle of a fresnel effect? Because I want to make the circle a little bit smaller so that I can have a border (which is gonna have a different effect than the the fresnel circle)

anyways, I tried binding _Tex2 to a register (u1) as some people suggested online, as well as marking it as uniform in case the compiler somehow screwed that up, but neither of those helped.
you allready have a control for the power
Yeah but how can I separate the fresnel effect from an outside border?
do you mean inverting the effect?
just cut off any values that are too high
if you're trying to separate it from the edges
I am doing a black hole shader, and I want the fresnel effect to be like purple for the black hole, and then around it have a distortion circle
can u maybe draw what you're talking about, i dont think blend or i really know what you're trying to do
idk man, but what if you use graphics.Blit to modify a texture instead.
Not gonna work, I need unordered access
This is what I have now... the black hole currently has the fresnel effect as a color, and then there is a quad mesh that has a distortion shader, but the distortion doesn't look right. So I thought about unifying those two shaders and still have the black hole like this, but then have the borders distorted
I'll actually be using data from one texture to decide which pixels to modify within another
I'll eventually switch to a buffer but right now I'm using a texture so it's easier to see if it works
oh, i see lol. yeah so use a branch node. if fresnel is above a certain amount, use the distortion rather than the fresnel color
if you're worried about the fresnel not reaching 1 at the edges you can just multiply it before the branch
ok thanks!
np
but yeah the issue here is that i'm developing for a platform that doesn't play well with compute shaders, so i need to use an image effect or something similar
as stated, i need unordered access, which is what i'm testing right now. but, the texture isn't being modified
hello, i have a problem with 2d shaders
i have an object with an empty mesh fillter and a mesh renderer
i waant to add a 2d transparent material to it
i'm using universal render pipeline
but there is no urp shader time that accepts Albino and texture
@tender tuskAlso maybe check out the step() function/node.
URP Lit and Simple Lit support transparent rendering, colour texture and colour tint
Thanks, I'll try later!
i tried it but it can't render png image
i want to add a cutout transparent image
Why multiplying that twirled noise with a mask gives this weird effect?
It's like the result is distorted (but not the twist distortion)
The preview is in 3D, not 2D
My understanding of this is very limited, but afaik it's required to use Graphics.SetRandomWriteTarget on the C# side : https://docs.unity3d.com/ScriptReference/Graphics.SetRandomWriteTarget.html
(then Blit/DrawMesh/etc, and ClearRandomWriteTargets after)
I've also read that the third param must be true for pixel shaders, but may be outdated info. This thread might help.
https://forum.unity.com/threads/how-to-write-to-an-unordered-access-compute-buffer-from-a-pixel-shader.403783/
I haven't seen it used often though, so it may not be well supported or something.
And later on how could I merge the two effects without adding the black outside of the black hole? Because now, as you can see from the shader, the outside where there should the distortion effect has some black
Yeah for now I am not doing any distortion, just picking the color already present in the screen.. But it shouldn't be black (with that weird green border) the outside of the black hole, I shouldn't even be able to see it if I am sampling the same color of the screen
Great, thank you so much! I'll give it a shot soon
You should really use a branch for these things...
The green is likely an artifact from not cutting off the fresnel effect properly.
Like replace the Step with a branch or add another branch?
And for the Predicate I should use a comparison node?
Hello, I'm trying to understand how to get additional lights with Forward+ setting. Does anyone knows what InputData represents?
https://github.com/Unity-Technologies/Graphics/blob/6738efc532da5d49188ffe403fea90555faf1a3e/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl#L386 (that's the complete link)
It uses the InputData to get lights
Also SurfaceData, can't find any docs online
I have some explanations of these structs in my shader code for URP post, might be useful
https://www.cyanilux.com/tutorials/urp-shader-code/#lighting
Explains how shader code (ShaderLab & HLSL) is written to support the Universal RP
SurfaceData is basically the ports you'd get on the Lit master stack
InputData is stuff like position, world normal, view direction, bakedGI - things you'd use during lighting/shading calculations
anyone got a clue on how I can save the original unmodified position of a vertex in shaderscript?
im using unlit shader preset
As in you need the unmodified vertex pos in the fragment shader? You'd pass it through an interpolator (e.g. TEXCOORDn)
yeah so basically the position of where it was at the moment I started running the program
so I can just add
struct v2f {
float2 uv : TEXCOORD0;
float3 worldNormal : TEXCOORD1;
float4 vertex : SV_POSITION;
float4 originalPos : TEXCOORD2; //added
};
or something and then simply never modify it?? sorry I'm really new to shaders
nvm i think i found it
yep i got it
i was trying to make a waving shader but wanted it to work on 3d objects so it doesnt smash it flat in the Sin wave graph kinda thing
i just saved the displacement from the graph in a member float above all structs etc. then i can subtract that from the vertex position before calculating the new displacement and then add it again.
hey i get an error and i dont know what i do wrong her.
CGPROGRAM
//define vertex and fragment shader functions
#pragma vertex vert
#pragma fragment frag
#define M_PI 3.14159265358979323846
float4 computeDerivatives(float4 position, float4 velocity, float s_R)
{
float t = position.x;
float r = position.y;
float theta = fmod(position.z, 2.0f * (float)M_PI);
float phi = fmod(position.w, 2.0f * (float)M_PI);
float T = velocity.x;
float R = velocity.y;
float Theta = velocity.z;
float Phi = velocity.w;
float sintheta = sin(theta);
float scale = abs(sintheta);
float sign = sintheta < 0.0f ? -1.0f : 1.0f;
float T_prime = R * s_R * T * scale;
float R_prime = -1 / (2 * pow(r, 3) * s_R - 2 * pow(r, 4)) * ((2 * pow(r, 3) * pow(s_R, 2) - 4 * pow(r, 4) * s_R + 2 * pow(r, 5)) * pow(Theta, 2) + (2 * pow(Phi, 2) * pow(r, 3) * pow(s_R, 2) - 4 * pow(Phi, 2) * pow(r, 4) * s_R + 2 * pow(Phi, 2) * pow(r, 5)) * pow(sin(theta), 2) + (-pow(s_R, 3) + 2 * r * pow(s_R, 2) - pow(r, 2) * s_R) * pow(T, 2) + pow(r, 2) * pow(R, 2) * s_R) * scale;
float Theta_prime = -(2 * r * Theta - pow(Phi, 2) * r * cos(theta) * sin(theta)) / r * scale;
float Phi_prime = -(2 * Phi * r * Theta * cos(theta) + 2 * Phi * R * sin(theta)) / (r * sin(theta)) * sign;
return float4(T_prime, R_prime, Theta_prime, Phi_prime);
}
do i use fmod wrong? or do someone know what my problem her is?
I think it's not about fmod but M_PI ?
Did you try without the cast (float) for the M_PI value ?
i tryed it first without
Try to add some spaces chars around M_PI ?
Or, just to make sure, does it still give the fmod error if you replace the two M_PI by the value
Oh, what was it at the end ?
the (float) thing
i thik i tried it before without define the variable M_PI because i thought it mite know it.
yes
sorry had to go sleep lol
this is what i'm talking about
you multiply by a number then use a comparison to switch to a different value once the fresnel effect has reached 1
currently i'm just making the border black, but you would plug in your distorted screen color or whatever it is you're doing into the false input of the branch node
Ok thanks β€οΈ
np
I am working on a shader and I noticed a faint square grid in it
What are possible causes for faint square grid like that?
more obvious when I make it small π€
I am using a render texture in this, its it maybe due to the size of the render texture?
maybe one of these parameters is responsible?
How can I make the black parts of gradient noise transparent
So that when put into emission the parts that aren't white are the base color
I've remapped the color intensity of the gradient noise to a range from -10 - 10, and then used that to recombine the colors back together with the remapped value as the alpha
Hey how does unity take things like indirect lighting and apply it to objects? I want to override it with my own indirect lighting but idk how unity does it to start with
Thanks
Spherical harmonics, either the one from RenderSettings.ambientProbe or a combination of that and the interpolated light probe if you have those in the scene.
hmmmm ok
guess I need to come up with a way to apply screenspace indirect lighting to the scene then instead of just overriding the output
I have seen similiar effect with normals that are not normalized in fragment shader (interpolation may change the length of normal vectors a bit). I think it has to do with interpolation, either normals or something other
I know in the BiRP you can specify your own lighting functions in the surface shaders:
https://docs.unity3d.com/Manual/SL-SurfaceShaderLighting.html
Hey, I'm trying to understand why the UVs map in this particular way when you connect the output of the lerp node to the input of the rectangle node... I guessed at first that pixels were being multiplied or added but that doesn't make any sense
Is there any resource for better understanding or gaining intuition on what said UV map will end up looking like / why it looks that way?
I'm aware already of what UV spaces are and how they map to 3D geometry but I don't understand the non-linear transformation that is occurring here
Anyone exported a project to itch.io and have the colors come out weird and washed out? Mine did
coudl be shader compilation, possibly? Post-processing, lighting settings maybe
anyone know why is this shader file not working on URP?
whats a simple way in URP to populate a buffer with an id based on the layer that a mesh has in the camera's view?
i cant figure out how to do it
like this
i cant use the stencil buffer
so i need another way
How to use a shader for having multiple effects that can be tagged around and offer if somebody knows how can I do that or video or something that would be really helpful
I just wanted to learn how to make a shader and apply that shader to material which allows you to have multiple effects which can be turned on and off with the check mark
Is there a good way to do light wrapping? Basically it's like having a light behind you still affect the front edges.
We have the fresnel effect but I don't know how to get the light data from behind an object or how to modify its range of effect.
Is it possible to toggle the geometry pass with a define?
I can wrap the pragma in a define but if I also wrap the Geometry method I get an error that the geometry kernel is missing.
This works:
#ifdef _WIREFRAME_ON
#pragma require geometry
#pragma geometry Geometry
#endif
But this breaks:
#ifdef _WIREFRAME_ON
[maxvertexcount(3)]
void Geometry(triangle Varyings IN[3], inout TriangleStream<g2f> triangleStream)
...
#endif
Hi, I'm trying to understand your post, but I have some doubts, I'm not sure I understood correctly
- I have to declare the struct Varyings, but since I can't input/output different types in the shadergraph I think I have to input all the three variables as 3 different varibles in the graph inspector, right? Then I initialize my struct with those values
And with it I inizialize InputData, right?
- What is Position in clip space? In the shader graph, I've got world, view but not clip space π¦
The post is written from the point of view of shader code, not shader graph. It's still useful, but there's a lot of things that shader graph already does for you behind the scenes - such as creating the Varyings struct which is used to pass data between the vertex and fragment stages.
You don't have direct access to that struct, but it's used automatically when you need data (like Position, Normal Vector, View Direction nodes) in the fragment stage.
It's basically one step before the screen position. You can multiply a world position by the ViewProjection matrix from the Transformation Matrix node to obtain it. But you shouldn't need it for setting up the InputData/SurfaceData structs, if that's what you're trying to do.
Unless you actually plan on calling the UniversalFragmentPBR or UniversalFragmentBlinnPhong functions in Lighting.hlsl, you also shouldn't need to worry about the structs. They're basically just used for organising the input params.
If this doesn't work, probably not. I imagine the pragmas are maybe collected/handled before the #ifdef stuff.
It may be better to split it into two separate shader files. Can use include files (and #include .. to include them) so you don't have to duplicate the code.
You mean one with the wireframe and geometry shader and the other one without it?
The shader without wireframe stuff would just be the default lit shader
I had to copy it to integrate the wireframe. Its sad that geometry shaders dont work with Shader Graph
Then I guess just switch between materials using the default lit shader and your wireframe one, rather than trying to toggle a keyword
Would depend what pipeline your using and whether it's code or graph.
But for URP & shader graph, I have some custom functions / subgraphs that can obtain lighting data : https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
In it's simplest form, you'd likely use a dot product with the normal vector and light direction and use that to mask the Fresnel effect.
You'd currently have to make the shader include all these effects, and have properties to adjust their strength,
or keywords to create multiple shader variants & toggle them - If you're using Shader Graph, there's Boolean Keyword or Enum Keywords to do that. (Some info here : https://www.cyanilux.com/tutorials/intro-to-shader-graph/#keywords)
does anyone know how i could make a shader of some form for bullet holes? (probably using decal projection unless ive missed something) I want to shoot an object and when i do it makes a transparent hole in it (like its been shot) i have no idea how to go about this since the only solution ive been able to find is for legacy rp, and im on hdrp. Ive attempted to adapt it to hdrp with little luck, and am wondering if im missing something obvious.
Mmh, okay, but as you adviced me some days ago my additionalLights hlsl function (that I use in a shader graph) might be broken for a Forward+ rendering, and if I want to use what should be compatible with Forward+ (LIGHTS_LOOP_BEGIN/END, for example) I need to build my InputData struct. And since this function is inside a shader graph, I think I need to get those variables from the shader graph. Right? or am I in the completely wrong path to resolve my problem?
digging deep into my function (outputting some values directly to BaseColor), it seems like the object doesn't find any additional light, so I guess that the getLight function that I was using is not compatible with Forward+. And the new one also needs InputData - at least it needs it in the code example that you gave me some days ago -
URP id buffer
No, I don't actually want to call them. I just needed to copy what they were doing so I could create my GetAdditionalLights function π¦
As an example, using a simple code like that:
always says that
and including the package that has InputData, returns annother undeclared error π¦ (this time pointing at the LIGHT_LOOP_BEGIN row)
Right yeah okay, I see that some of the functions and the LIGHT_LOOP macros in that code use lightData. You can create it though. Should be able to do this before the loop :
// Create struct, initialising all values to 0
InputData inputData = (InputData)0;
// LIGHT_LOOP_BEGIN needs :
inputData.normalizedScreenSpaceUV = ScreenPosition;
// I think? Will need to add a param to your function to pass this in (with Screen Position node connected to the port)
inputData.positionWS = WorldPosition;
// (positionWS also required for GetAdditionalLight, if you use the version with the inputData param)
// if you use CalculateBlinnPhong, that needs :
inputData.normalWS = WorldNormal;
inputData.viewDirectionWS = WorldView;
Hmm, actually looking deeper it might not be the Screen Position node. Seems to use GetNormalizedScreenSpaceUV(positionCS);
So I have to do this
I guess so :\
gonna try that
That's the code part
is it... right? it's giving me a "generic" error, meaning that there's no particular row underlined
Property _AddAdditionalLightsCustomFunction_d0b15a3a729646a89a7b75ce9b309ffd_New_10 already exists in the property sheet with a different type: 1
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
You might also need to Split, and Divide the output of this by it's A component.
There should be a red icon next to the Custom Function node you can hover over to view an error message?
How fast does the Time node's time value increase?
It's in seconds, (though may be scaled by the time multiplier in project settings)
Okay
Are you defining _MainLightColor in the code at all?
Or trying to add any includes?
It looks like HDRP supports decals https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/Decal.html
Might be something to look into?
removed that, the error is gone
Yeah shader graph is probably already doing the include for you somewhere
@regal stag It won't make "holes" through thing surface though.
This would need some sort of stencil mask maybe
Ah right, I misread that part
Oh, it's almost working!
i got it to work with a stencil mask ty anyways!
It now has got a point light!
There's still two problems, 1) the point light is not applying any color - as if it's always white, and the cube has a weird white light even when both directional and point light are disabled. I'm gonna try to resolve them
I still haven't done that
By "A" component, you mean the alpha of the texture?
I mean the forth component of that Vector4 from the multiply with matrix. (replicates the "perspective divide" step between the vert/frag stages)
But I'd also probably try it with the Screen Position node and see if that works. I'm a little confused by what the difference is between that and this GetNormalizedScreenSpaceUV(positionCS). Seems there's some _ScaleBiasRt and _ScaledScreenParams but I'm not too sure what these are doing.
Eh sure, I would just divide the Out(4) by the A(1) output but this works too
Not really what I meant, but again this is equivalent π
I gotta go, so hopefully it works now / you can figure it out / or someone else can help out further maybe π
Ok, thanks a lot
Is there a meaningful getting scene depth with the Scene Depth node vs Screen Position W
all the three methods does the same, the light doesn't change the object's color and the object has light even if there are no lights π€ but at least I'm sure the GetAdditionalLight function is working!
I'm sure this is a different bug btw, something that is not linked to the code
Scene depth node and screen position W are not the same thing. What are you trying to do ?
I might have modified something in the way to get there, something that was needed and now it's broken, so I'll just rollback everything and apply what I've done now
They get different depth values. The Raw Screen Position W is the depth to the current fragment.
Typically you'd only use the Scene Depth in a transparent shader, as it samples the depth texture which may not be generated yet (if using CopyDepthPass). It would be the depth to a opaque object behind (or infront) of that transparent object.
Might help, https://www.cyanilux.com/tutorials/depth/
(okay actually leaving now π )
In this case I'm dithering out an opaque surface when it gets right up close to the camera, and looking at the different ways to do it
Well everything works correctly, but...
This is exactly the same error that this guy gets: https://forum.unity.com/threads/forward-additional-lights-in-a-customlighting-function-and-a-crash.1378932/
anyone got any idea of what's causing it?
That's the type of crash you get if you have an infinite/very long loop in a shader.
You can see here for reference what URP/Simple Lit uses to get all additional lights:
https://github.com/Unity-Technologies/Graphics/blob/0cca56cfa8607ef30aa38e64bad73fd9c593d633/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl#L386
Is there any way to make multiple sprites use 1 global texture. From this:
to this:
With shadergraph*
(@tag me or reply to me; thanks in advance!)
use a sampletexture2d node, and a position node - plug the position (maybe the xy, or xz, depending on your game) into the UV input on the sampletexture2d
you might also want to use a tiling and offset node to make it easier
make sure the position node is set to worldspace
Thanks! This works great
EDIT:
Resolved:
Seems that simply moving the following macros from the Vertex shader pass to the Geometry shader pass (and the UNITY_VERTEX_INPUT_INSTANCE_ID statement to the Geometry input struct) did the trick .
I was surprised to see that it was possible to pass the Geometry input Triangle and TriangleStream variables directly.
UNITY_SETUP_INSTANCE_ID(IN);
UNITY_TRANSFER_INSTANCE_ID(IN, triangleStream);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(triangleStream);
Then, just call the UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN) macro in the fragment stage.
Original Message:
Is there any direction on configuring a custom shader with a geometry pass in URP to work for VR?
Specifically implementation on the following areas:
UNITY_VERTEX_INPUT_INSTANCE_ID and
UNITY_VERTEX_OUTPUT_STEREO
I've successfully implemented these two in a standard Vert/Frag shader but am a little stumped at the correct implementation in a Vert/Geom/Frag shader.
Implementation in the Vert/Frag was by the following:
Added UNITY_VERTEX_INPUT_INSTANCE_ID to my Attributes struct,
Added UNITY_VERTEX_INPUT_INSTANCE_ID and UNITY_VERTEX_OUTPUT_STEREO to my Varyings struct
Added UNITY_SETUP_INSTANCE_ID(IN), UNITY_TRANSFER_INSTANCE_ID(IN, OUT), and UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT) to my Vertex pass
Added UNITY_SETUP_INSTANCE_ID(IN) and UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN) to my Fragment pass
That worked fine. When I try the same in the Vert/Geom/Frag shader, I get errors such as "invalid subscript 'instanceID'".
What else would I need to do, or what would I do differently, to get this working with the Geometry pass? I'm specifically unsure how to handle the Geometry pass. I suppose I need to call some of these methods in it, but I'm not quite clear on how I would do that?
Iβm really new to the channels in the discord so I just joined but is there anyone that might know why all my shader graf shaders appear correctly when Iβm playing my game through steamvr and yes itβs a VR game but when I build a apk it shows up as purple when Iβm playing on standalone quest? Please help me could it have something to do with the xr interaction toolkit or what plz help?
It could be different settings set between the various platforms
you can see them in preferences
I had that problem too but betweeen the build and the editor, in the same PC, it was some setting different from the build to the editor playmode
Has anyone any idea why my light act again as a "black" light when it has a low intensity value?
Like that:
The dark spot under the player is actually a light, but compared to the campfire light it is too much low so it just "decreases" the campfire's light, applying only the torch light
I'm almost 100% sure it depends on this code; that sums all the lights color, diffuse and specular. I tried to play a bit with all the settings (you can see the commented code), and all had similar behaviours, but none of them actually fixed the black light - except one, the one where I just summed all the lights colors between them without conditions, but it turned the whole world bright
Does anyone know how to get an unlit shader that renders a different texture in each eye (for a headset)? I'm able to get it to work for a surface shader, but I don't want lighting, and for unlit shaders, it either doesn't render in the right eye, or it uses the same texture for both. (Sorry, not sure if this should be in virtual reality or shaders).
The best effect I obtained was with comparing the various diffuses and checking which was the highest, and using that color. The problem is that sometimes the diffuse of the torch is higher than the Campfire's lights, so a darker color gets selected instead of the brighter one. That's a problem!
Here, the light is darker but more uniform - as it should, in a toon shader
How can I make a mesh from Camera A get replaced with Camera B's render output? I am using the default renderer.
Like this, sortof.
Also, not highest priority, but if possible, I would also like to make the camera only render where it will actually need to, since most data will be discarded. It doesn't need to be pixel perfect, but if I could reduce how much it rendered, that would be nice.
I am not sure how well this fits the channel, but I didn't see a better one.
Specifically what I am doing is creating an overly-realistic scope which can be viewed from any angle. I have a script which correctly places the camera in the right position, sets the FOV, and does some weird clipping plane shenanigans to make it only show what happens after the scope. All I need to do is to place what it renders ontop of the main camera's view where the scope is.
IDK, but I did find these threads that might be of help:
https://answers.unity.com/questions/1702908/geometry-shader-in-vr-stereo-rendering-mode-single.html
https://forum.unity.com/threads/is-it-possible-to-have-gpu-instancing-with-geometry-shader.898070/
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
I'd investigate using a stencil.
IDK what pipeline you're in though.
But the idea is that the object in #1 would set the stencil mask (and not even draw itself, see COLORMASK) and then when combining the render texture #2 (maybe with a blit), it would call the pixel shader only for those pixels that pass the stencil test. Stenciling is pretty fast.
I am using whatever pipeline is default.
I got it π Updated the original, thanks π
Does anyone know how to get an unlit shader that renders a different texture in each eye (for a headset)? I'm able to get it to work for a surface shader, but I don't want lighting, and for unlit shaders, it either doesn't render in the right eye, or it uses the same texture for both. (Sorry, not sure if this should be in virtual reality or shaders).
If you use single-pass instanced mode, there's an example here of how to set it up properly for both eyes : https://docs.unity3d.com/Manual/SinglePassInstancing.html
At the bottom there's an example with different colours in each eye too. You'd do something similar, but swap the properties out for texture samples.
Oh, thank you. I've been looking for something like that.
It worked, thank you!
Any one has shader for pinch distortion use for camera mobile?
I want to pinch at a position that i create by code?
hey guys, so I'm pretty new to all this and I don't know anything about rendering stuff or shaders and I barely know anything about materials in unity, but can anyone help me make this look more like it does in this render?
I brought over my shader graph from unity 2019 over to 2021 and suddenly it's broken. please help.
in 2019 it was called LRP
i recreated it and it's working
Took me a while to realize that this is the exact same package that a tutorial (that I've been struggling to follow for the past 8 hours) required me to have out of nowhere.
It does not want to install. When it did install, it caused more confusion and new errors popped up.
I have no clue where to go with the package or what other resources to help figure out how to get the result I'm aiming for.
The best chance you've got is to have the exact same version of ShaderGraph + SRP + Editor the tutorial is using and get rid of any compilation errors in your own code to allow the editor to compile the new packages.
Hello! Is there a way (and if possible using ShaderGraph/a custom node/Amplify) to render and object only in one eye, left or right, in VR ?
Dont ask in multiple channels. I answered in #π₯½βvirtual-reality
Use opaque instead of transparent?
How do I make a shader that applies over the entire screen with shadergraph in urp?
Either do a regular shader and apply it to a quad that is close to the camera (yeah, dumb solution, but works π )
Or use a custom post process with fullscreen shader graph : https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@15.0/manual/post-processing/post-processing-custom-effect-low-code.html
I'm trying to get these clouds (two separate objects) to move and bob at different speeds, though when I change the exposed material properties it changes for both of them, how can I make exposed material properties unique?
most objects in my game will be using the same material to handle sprite effects (wiggle, panning, bobbing, etc), but will need the properties to be different depending on the context:
https://gyazo.com/b2a35da239c1299ab3cefad01d17b232
Dupplicate the material and apply the new one to one of the objects so that they don't share the same material asset
so each object/sprite will need it's own material instance?
I'm trying to make it translucent though
wouldn't that be extremely inefficient? I feel as if that would make the material call of a more complex scene go from 1 to 30+ or worse
The render does not show this, that looks opaque with light texture baked on it. It's very hard and expensive to make it render physically accurate and partially translucent. That would need a custom shader for sure
Or at least for each "group" of objects.
Theorically, the SRP batcher should help to avoid multiplying the draw calls in that case
I've done no baking. The blender render just has a light source inside the object
I know, but for realtime games you probably just need to bake the lighting onto the texture and maybe emission maps and put a light inside for the objects around it to receive the crystal lighting
so, how do I do that?
Look for UV unwrapping and texturing guides
what key words should I look for?
I've done uv unwrapping and texturing, at least I think. That's how I put that texture on the model. But there has to be more that I'm missing
custom shader graph material causes my sprite renderer to turn invisible and play no animations? any ideas?
blender bake lighting into texture or something like that? And then for the modeling tool you used.
Otherwise manual painting might work as well
how i can fix it
What's the goal exactly?
The red wall has to look like orange
You probably mean the stretching, that happens because of trying to project a 2D texture in 3D space
You probably want to use Triplanar
Oh okay, thx i will try
Anyone know the name of the float in the HDRP/Lit shader to get/set the Iridescence thickness ? I looked inside the shader code but can't figure it out.
Did you try _IridescenceThickness
i tried with a _ between the two words, i'll try this one
Shows up with that name when looking through the debug inspector
Say I have 3 compuite buffers I want to merge into 1 large compute buffer?
whats the absolute fastest way to do this?
I need it to be fast as hell because its actually 6000 objects and 20 million total entries...
Currently I use a compute shader to transfer each of those 6000 buffers into the big one but its not fast enough anymore
it was probably asked a million times, but why doesn't ctrl+s work in shader graph "by design"? π€
https://issuetracker.unity3d.com/issues/shader-graph-ctrl-plus-s-shortcut-does-not-save-the-graph
Thats true for a few different windows that have a save button
No idea why, but at least its consistent
isn't that blend node just overriding the texture?
if you want it orange why not multiply the noise with the texture?
It's orange in the graphic shader because of position. I just want to add on texture noise and make it move
I did it, but it looks weird on the wall with red color
And i use the overlay method that's why I use it correctly ig
ah you had me confused with the similar colors, thought you wanted an actual orange wall xD
use 3D noise with this: https://github.com/JimmyCushnie/Noisy-Nodes
would be way better if you baked seamless noise tho and used triplanar sampling
Oh okay I'll try
Thx
Wym by that?
Are you looking for shader to replace every shader in your game with or post processing shader?
smoother
how about one that forces the blurriest LOD level
Guaranteed not heavy 
Smaller render scale is also guaranteed not too sharp
im trying to make a custom shader node and i get this error that tells me smth about smth missing at line 174 but my shader is only 13 lines long
Is it possible to make shaders in Shader Graph, build them, and use them in Unity 2017.2.5 or under?
Reason is because we have a project which is built with 5.6.7 and we were only able to upgrade up to Unity 2017.2.5. We want to build make new shaders but none of us know how to program in ShaderLab
I have watched this tutorial, hit play and it did not work:
https://youtube.com/watch?v=77Lc43yTREo&si=EnSIkaIECMiOmarE
β
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=77Lc43yTREo
Let's learn how to make Awesome Custom Post Processing Effects!
π
π Get Code Monkey on Steam!
π Interactive Tutorials, Complete Games and More!
β
Add to your Wishlist! π https://store.steampowered.com/app/1294220/
This is how we can create Custom Post P...
This is the code:
https://pastebin.com/ETSxyK1q
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Please someone help
I'm using Shader graph v12 (Feb 2023) but i don't see any "color header" on my nodes, anyone knows if it's something i have to enable somewhere ? I can't find any option about it in Project Settings / ShaderGraph
Those are enabled via the "Color Mode" dropdown in the top right of the graph
oooh ! nice ! thanks π
No this wouldn't work. The shader graph package is required for the graphs to function and that won't work in versions that old. Might be able to try Shader Forge instead. Or you'd have to learn how to write shader code.
Make sure you have added the Inputs and Outputs to the Custom Function node in the Node Settings. It looks like it's currently trying to find a function without any parameters
Dang it, take to learn some shaderlab
Hello! I've spent the past two days playing around with this code:
It's a hlsl code that creates an uniform lighting for a toon shader. The lighting ramp is applied in another shader graph, it's not there
The problem is when a light is nearby another and it has a lower intensity than the first one
it has a higher diffuse (and a lower luminosity) so it creates a "bubble" of low intensity light π¦
I've spent many hours trying to fix that, I tried to sum all the lights, to set a limit of intensity and many more solutions, but everything fixed some problems and introduced others T.T
I think you might need to move/replicate the lighting ramp calculation inside the loop, on the thisDiffuse
Is there a way to blit through code in urp without the need for render features
Likely depends what you're blitting. But there's Graphics.Blit
https://docs.unity3d.com/ScriptReference/Graphics.Blit.html
Oh cool, just want a fullscreen blit
That's a bit bad because I'd lose the possibility of easy modifying the light ramp values by a gradient inside a shader graph... but I don't get how that would fix the problem
Hmm, maybe instead of using Diffuse += thisDiffuse, could try Diffuse = max(Diffuse, thisDiffuse)
This created a more round light
but didn't fix negative lighting
Maybe you need a saturate somewhere? I'm not sure where the negative part is coming from
It's the light itself
That's the same scene but without the brighter lights
the light color gets selected via diffuse, and when a light with lower intensity has a higher diffuse, it is used instead of the brighter one
Also summing all lights creates this effect:
every object that touches the range is illuminated (so a huge chunk is completely light up) and lights intensity influence each other π¦
It seems like summing lights by color only if their diffuse is greater than 0 is working... but at this point I've had so many failures when it seems it was working that I don't know it anymore T.T
Really? No one?
What unity version and pipeline are you using?
Nvm I think I'm just gonna copy your script
Hopefully that works
I wish I could understand this on a fundamental level but
oh well
If you're in 2022.2+ there's a Fullscreen graph and Fullscreen Renderer feature included in URP now.
But yeah, for older versions I've got https://github.com/Cyanilux/URP_BlitRenderFeature
wait serioiusly
oh my god
is 2022 stable enough for that?
I haven't used it much so not sure
hmm alright thank you very much
For some reason the transparency doesn't appear in the shader...
- Surface Type is set to Opaque
- Would need to
Splitcolour property, connect A output to Alpha port on master
Though still not sure if transparency really works with blits. The usual way is to sample the source texture & use a Lerp.
(to obtain source texture can use _MainTex reference for older versions, or _BlitTexture in 2022+ but there's also a URP Sample Buffer node)
ohh thank you, I think I'm gonna upgrade to 2022 and see if it's simpler
Btw what do you recommend to learn shaders from the ground up?
I have basically zero experience except maybe some stuff on blender
Freya HolmΓ©r has some videos that are a good introduction imo. https://www.youtube.com/playlist?list=PLImQaTpSAdsCnJon-Eir92SZMl7tPBS4Z
There's also some beginner stuff linked in the pinned messages such as the Book of Shaders. I've also got some tutorials, mostly focused on shader graph : https://www.cyanilux.com/contents/
Plenty of other tutorial creators too. My resources page lists some, https://www.cyanilux.com/resources/
Alright, thank you very much
Hey guys, do you have a tutorial or something else to be able to have an "additive blending" shader and have it work on URP?
how do I make the noise texture kind of average out into 0.5 (gray) depending on a value
like
as you raise the value it becomes more and more uniform
like decreasing the strength in a sense
and does someone know why this doesn't work on a plane
(it just makes it invisible
How do i make it work in unity 2022? https://github.com/UnityLabs/procedural-stochastic-texturing
Or is there any other way to remove tiling in shader graph?
if you plug stuff into the vertex stage it will be per vertex
the vertices are all at position values now between 0 and 1 like your noise
add noise to the position(object space) and plug that into the position in the vertex output
You could use the hex tilling from this package https://docs.unity3d.com/Packages/com.unity.surface-gradient-bump-mapping@0.2/manual/index.html
Works faster than the stochastic stuff
oh
ty
and btw does this affect the physical geometry of the plane
or is it just visual
if it is, then how can I make it affect the physics as well
Howdy folks. In unity 2022.1 using URP, generally speaking does the number of Currently Tracked shaders and variants from the Project Settings->Graphics tab affect performance on slow systems/mobile in any significant way? Or is it only which shaders are being actively displayed simultaneously that counts?
It's about the latter, I'd suppose. As those are context switches. Of course they have to be loaded from a file, but there's a cache of them on the CPU side IIRC.
The total # of variants impacts build time and file size more than execution speed. Of course a large array of variants might slightly slow disk access to various individual ones, but I doubt there's much impact...unused variants are just that...unused.
Ok. For PC I have one set of Shaders and for Mobile/Slow I have another, and I didn't know if it made sense to try and further optimize by completely eliminating the unused ones.
Some of these older Adreno CPUs have the computing power of a blade of grass, and I'm still learning the ropes of it all π
You practically can't, really. Assuming you mean CPU physics. It's probably theoretically possible, with a lot of hoop jumping, but the easier way is to modify the mesh on the CPU side and recalc the colliders. It depends on the use case. Generally, think about the GPU as the destination of data, not the source of it, from the CPU side's perspective. There ARE ways to get data back from the GPU, but they're generally considered SLOW.
Many optimization tutorials talk of using "mobile shaders" for best performance, but I've never seen those using URP 2D in this version. I assume its either for 3D or older versions of Unity? Is the Sprite-Unlit and Sprite-Default-Lit the "fast" materials for this version? I've made my own advanced shadergraph based materials for PC, and am avoiding shadergraph for mobile. But it is unclear if Shader-Lit-Default is sufficiently optimized for basic stuff on these older platforms.
π
The default lit 3D shaders are PBR, IIUC. So that's more sophisticated lighting calcs with 32 bit floats. Whereas simpler lighting can get away with quicker calcs per pixel. And vertex lighting is even quicker, but it mostly sucks. Might work for 2D though. I don't do 2D much so...
IMO the documentation and videos are a bit of a mess for a newbie like myself, as things changed significantly (both in terms of names and location) going from 2019->2022, and 2D is different than 3D. I don't see any kind of Vertex shaders or mobile shaders defined anywhere in this URP 2D project.
"visual" - but a more accurate explanation would be, the data you are getting is only temporary (live for a fraction of a frame) and is only on the GPU. For physics you would need to bake an actual mesh, which you could do efficiently in burst compiled jobs or compute shaders
Yeah. And there's different "things" going on for sprite shaders (sprite renderers on the CPU side) and mesh shaders. Then there's 2D lighting, which I can't really discuss as I don't do 2D. But vertex lighting is a concept in shaders...you do the lighting calcs at the vertex level and assign a custom interpolator to smear it across the polygon.
:nod:
it's pretty much displacing
so it'd just be getting the result that goes into position and displacing the mesh on the cpu as well
Hi, does anyone know how can I access vertex id in a surface shader?
Hi all, I just discovered a difference of data using the exact same UV node in ShaderGraph, depending of the URP 2D and URP 3D templates
The data can't really be different since UV coordinates are linear 0 to 1 in all programs
But if you're rendering them as color then the appearance will depend on your project's color space as well as post processing settings
Oh indeed thanks @grizzled bolt ! The color space is by default Gamma in 2D URP template
Why does the same material act different on two separate meshes?
I'm using a shader with a _Coverage parameter. It makes the color change by increasing it's surface area.
You're using UV coordinates which depend on how the mesh is UV mapped
ohhh
It wasn't unwrapped
Yea, now it works. Thanks.
Does anyone have any resources on how to convert an HLSL shader from built in to URP? The shader doesn't seem particularly involved and I'd like to try to salvage an asset I quite like by converting it
You could recreate what it does in Shader Graph, or learn to write URP shaders with a guide such as this
https://www.cyanilux.com/tutorials/urp-shader-code/
Hello I'm trying to create a procedurale skybox using shader graph. I have problem with texture UV. This is exactly the same problem than this guy: https://forum.unity.com/threads/having-some-problem-with-the-skybox-uv-on-shadergraph.1103827/
Do you know how to solve this problem ?
Use Sample Texture 2D LOD or disable mipmaps on the texture
I disabled mimaps and now it works. Thanks a lot. π
any ideas why I am getting such bad banding during my nighttime using my skybox shader?
even more aparent after i made my clouds look reasonable during the day and sunset
and it looks fine during the day
im using URP btw
can you not modify the UVS of a URP unlit Sprite?
is that not what you just did?
looks like texture compression
check you skybox texture setting and try disabling compression
its not a texture
then what is it?
what kind of shader?
uh its a shadergraph i can send screenshots rq
its unlit
also im using ACES tonemapping and HDR is enabled
and linear color space
try disabling those (although its unlikely HDR is causing those banding)
it's stretchingthe texture instead of tiling it
thats an import setting issue
also check your shader if it's using full float or just half
single precisionm
uh ok i dont know whwat info to ask for but as long as that texture IS the one in your shader it should worjk
well at least in terms of import settings
yea i'm super confused here
i tried that as well, lemme doublecheck
the results are in, still insanely horrible banding @tacit parcel
incoming screenshots of shaders holdo n
this is how im rendering my sun (it also doubles as moon)
that feeds into the B output of this multiply
this is the subgraph that blends my skybox colors together
(ofc it is using defaults rn so it wont match what is in the image)
and my clouds shader
hopefully these are still reasonably readable
btw the smoothstep in my clouds is because they look horrible without it, way too many clouds
so i smoothstep to widen the gap between clouds
I'd say you can try to plug those nodes to output step by step and check where does the banding starts showing
ok, is there a reason it would only be during nighttime?
not a clue sorry π
ok with just skybox blend it still bands horribly
with just my clouds it looks fine
π€ really? So, even a simple gradient still result in banding?
and clouds + moon/sun no band
the clouds look ugly tho once i turn on skybox because of the banding im assuming
yeah, im gonna head to bed but i will still be awake for a while if you have any questions or suggestions that i can try to remember for tommorow
I dont know about the banding, but maybe you can add dithering to make it less visible
But still looks more like a hack though XD
Yep, a fresh mind after a good sleep might help solving problem, really
No
I just want it to work lol
That banding is so weird
Maybe you can check how default skybox works
Or if it suffers the same banding at night too
Idk that the default HAS night
It does have night...
And the banding too unfortunately
Just a thought (You may have already turned off tone mapping) but when you start getting values approaching floating point zero, and then apply tone mapping or even do linear to gamma conversion, you can get banding IIUC.
I'd like to see you try a sky gradient from 0 to 1 rgb and see if you get banding across it.
Hey guys, is it possible to add sub surface scattering in unity to the default rendering pipeline (neither URP nor HDRP)?
Some packages provide this, like Alloy : https://github.com/Josh015/Alloy
that banding isnt horrible like mine
very light banding
Yeah, OK. So more color-resolution = less banding.
Floating point resolution issues, I assume.
grr how to doubles in shader !!!
Post processing doesn't seem to be the main thing, nor linear to gamma.
yeah
See the double data type for floats.
IIUC you can create
double2 foo;
Which would have foo.x and foo.y. Or for colors a double3 or double4. You can't really pass them between stages though, but you can use them in calcs. Warning, likely expensive in terms of cycles.
Another thing you can do is multiply your floats by 1000 or something. do all the math. And then divide by 1000 at the end.
I tend to just add some noise, generally blue noise to solve banding problems
i guess i can try that but i just want it to work lolll
@distant dirge There's something weird happening in your shader. Color picking the colors in the banding shows it jumps more than just 1 shade.
(ignore the additional banding in the GIF compression)
? im not sure i understand
also would this even fix my weird cloud issue, at night my clouds warp around the banding lines, not sure if noise would fix it
Banding is something that happens because there's only so many colors your screen can show, but your shader isn't using all the shades of grey available to it. It jumps from (7,7,7) to (10,10,10) to (13,13,13).
could that not just be image compression through uploading it
So it's as if you're using half precision floats, but that shouldn't be possible on a desktop GPU, as far as I know.
Sure, that's possible.
graph is set to single
not half
Blue noise can help hide all sorts of banding, but whether it's enough for that there... no idea π
this is so painful
@distant dirge Does it look like this in-game or does it look worse in this screenshot?
Like, if you count the individual bands
Are you sampling a texture here or something? The banding does look quite severe
last time it was like that yeah
no
hmmm even during the day there is some banding
hard to see tho
Are you using a render texture somewhere that you created? If so what is the format?
I see you're using a Power node in your graph. I feel like that could cause imprecision if you're taking a small range of values and increasing the range.
maybe
Yeah, I meant for the skybox.
can anyone tell a rookie like me why I cant add the smoothness block note to the fragment? clicking on it doesnt do anything
more demonstration of the banding
@low lichen can you check the shades on this one
Yep, the upper bands are jumping two shades, whereas the lower part is normal.
tbf i want my night to be dark so its not super surprising that its banding i think, it goes from 20/255 to 0/255
Which could be explained by the Power node, because it's stretching the outer parts more.
I think if you want to avoid the precision issues with the Power node, you will have to follow @meager pelican's advice to multiply the value with a high value, then use the Power node on it, then divide down again.
setting power node input to 1
i probably dont need it
i was just following a tutorial
Possibly a bug, not sure. But typically you don't need to add blocks manually. Changing the graph type in the Graph Settings (tab of Graph Inspector window) does this automatically. Smoothness would only be used by a Lit graph.
it was indeed a bug. restarting fixed it
@distant dirge I recreated your shader from the graph screenshot you posted and I'm not able to recreate the same banding you're seeing.
There's still banding, but just from 24-bit color banding.
Can you screenshot the property values you're using?
It's probably post effects and perhaps the project's color space contributing to the issue
its linear color space
my only post effects are exposure at about 0.2 (its also based on game settings), and ACES tonemapping
and i am using HDR
these are my night settings
first is 0,0,0 and second is 20,20,20
the nadir is just arbitrary since the player never sees it
I thought you turned those off and the problem was still there.
yeah the tonemapping i can try exposure too
turning off all post makes it worse because its brighter lol
Yeah, but you have to isolate the problem. To know what you're looking at.
That is worse, lol. But it might tell you something about the calcs
Anyone knows how to make this shader work on a particle system material?
I tried everything and still couldn't figure it out
@meager pelican btw what am i even supposed to multiply?
this is also really weird
im gonna try out gamma again rq
since its the default
well now its just pitch black
back to linear ig
btw in editor banding looks like this
ok ok ok this one is NO POST game view
this one is scene view
still has banding but id argue this is much more reasonable to dither with noise
@low lichen if you are still here can you check the differences on scene view and game view in this version
I don't know what's causing the banding in the game view, but if it's because of some post processing, then you should still be able to benefit from adding dithering.
I turned off all post
Afaik at least
I have one volume and its global
So i turned it off
Maybe there is some weird thing in my renderer asset breaking stuff
If i create a new one will settings be the defaults?
I have made noise, but I have some questions
How may I convert the 2D texture that is generated in Shader Graph trough Worley-Perlin noise, into something 3D?
Another thing is, how may I create a custom ray-marching algorithm for rendering this noise as volumetric clouds in Shader Graph?
If you want to make a rayMarching shader I would advice not to use shader graf. Hlsl is better for things like that. Also there are many 3D perlin noise implementations online you can have a look at :)
whats wrong with shader graph for this
You can still use shadergraph, but for raymarching you'd need a Custom Function node as you'd need a loop which can't be done in the graph itself
interesting
Hi, I'm calculating additional light with this function. I'm using Forward+, currently got about 8 lights in my scene. The game crashes when I press start, saying this:
It seems like the workload is too much, but switching to Deferred or Forward, with the same amount of lights, stops the crashes.
That's a problem because I need many lights on my game, way more than 8, and if Forward+ can't even handle the same amount of lights that Forward or Deferred can, that's pointless...
Any way to fix it? maybe I'm doing something wrong in the loop?
i think this looks ok now, i just recreated my renderer, now to reset settings to the old one until it breaks
oh yeah image compression messes this up as well, looks reasonable in the game but fairly bad still here
Thanks for answering!
OHH ok ok i found it, I had render scale set to 2, and that made the horrible banding i was having @low lichen @meager pelican @vocal narwhal
Does someone know how to make an object to have emissive edges?
Should I do it with shaders?
That's not an easy thing to answer. If you want it outlined always, then you would need to do some screen shaders (there are outline shaders on the store that you might be able to use, like FlatKit), that also hook into post processing.
If you want it on the edge of the actual model, then you would have to UV your model such that you can give a separate emissive material to. Or find something on the store that might work for you: https://assetstore.unity.com/packages/vfx/shaders/chroma-easy-pro-shaders-231313
How do i create a shader? I cant find it
shader graph or what?
yes
this one?
which?
whichever?
no diff?
I'm going to try making water shader
Is there a way to shift a part of a UV using ShaderGraph? Imagine a screen that looks like this
123 123
456 -> 645
789 788
so which one for water?
depends on what you mean by water
like when you under water
in the surface of water
what
and do you want the water to be affected by light if its the first one
second one****
sorry
sorry but is there any where I can read or watch a tut on this
by googling?
Hey!
Anybody knows how to apply the Material Override component? I read a lot and saw videos about it but just can't find it when using Add Component ? Has it already been removed again or what is happening?
are you using DOTS?
Hello! I might be missing something obvious, but is there no way to make a Depth Mask in URP? I just want to hide what is behind an object. I have tried several shaders found on forums but to no avail... And even with a simple shader setting ColorMask 0, I do not get correct results
is it possible to toggle zwrite for a shader from a script? i have a transparency toggle to change the opacity of the object, but zwrite stays the same, so the object becomes transparent but still blocks the objects behind it.
never mind, i found a workaround
{
float theta = v.vertex.z * 0.1f;
v.vertex.x = v.vertex.x * cos(theta) - v.vertex.y * sin(theta);
v.vertex.y = v.vertex.x * sin(theta) + v.vertex.y * cos(theta);
}```
this is giving some weird results, looking for a more "spiral corridor" type thing
no... is that relevant? Is that Component a part of the DOTS package? Or do I have to go completely with the DOTS paradigm to make this work? I thought it's just a simple standalone component without any dependency to a large package π€
You need to cache the coordinates before doing the rotation, as in you case the v.vertex.y line is influenced already by the rotation of v.vertex.x
lit is well, if you want your mats to sort of glow or have some reflection using metallic and smooth
unlit, well the opposite of lit
ofc there's many difference other than that you can google it if you want. And if you want to create water to have reflection then use lit, but if you just want simple water without any reflection then just use unlit
note: URP doesnt have default SSR (screen space reflection) you can use Kmirror plugin in github instead
(i mean you can use reflection prob and set it to realtime, but the reflection is really weird sometime)
Anyone has any idea? T.T I tried optimizing the code a bit but it hasn't changed anything π¦
Does hlsl have something like #pragma once?
#pragma is a bit specific to unity's shader preprocessor.
What type of use are you searching for ?
okay I have following issue I wrote a math .cginc file with some basic math function for hlsl but I get the error Redefinition of ....
Sorry, haven't tried custom lighting with forward+ yet ( @regal stag might have some clues).
Maybe try to dig in urp source code to find how the lighting in that case is done ?
Shader error in 'Unlit/LineEstimation': redefinition of 'Lerp' at Assets/Shaders/HLSLMath.cginc(1) (on d3d11)
So, it's CG, not HLSL ? π (.cginc)
But anyway, this kind of error always means that you are trying to declare a function/variable that already exists.
lerp (although, lower case ...) is already defined in CG
I'd avoid using the same term, even if the case is different
yes this happens when I have for example
File A //Has a function called Lerp
File B #include FileA
File C #include FileA
File D #include FileB, #include FileC
therefore I need some kind of #pragma once, which tells the compiler to check if the file is being included multiple times at least that s what it does in cpp
Okay, I see.
We have this in a lot of places in our include files and circumvent it by using defines like this :
#ifndef MyFileIncluded
#define MyFileIncluded
Code here
#endif // MyFileIncluded
So you can include this file anywhere you want, and the code will be included only once
why does File D need to include B if it's already included through C?
sorry, both B and C include A
okay thx alot
Taking as an example this code https://github.com/Unity-Technologies/Graphics/blob/0cca56cfa8607ef30aa38e64bad73fd9c593d633/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl#L386 it should work, I mean I almost copied the code...
and it does, with small amount of lights
Forward+ seems to have a slightly different code path :
https://github.com/Unity-Technologies/Graphics/blob/0cca56cfa8607ef30aa38e64bad73fd9c593d633/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl#L389
#if USE_FORWARD_PLUS
does anyone know a good video for making a Auto Terrain material based off height using Shader Graph
uh, seems like I missed the loop under forward plus. Well I need to load both InputData and SurfaceData, and that's a bit complicated π for example surfaceData takes a lot of variables that needs to be passed as inputs from the shader graph, and that will definitely mess up totally my code
The custom function already has 3 input, I'd need other 10 inputs to make it work
How can I sample the screens texture in a shader graph?
idk if you can in shader graph but i may be wrong
Scene color node
is that what that does
idk
Hello everyone! I am new here, I have a question.. why does the main preview stop playing? I cant get it to refresh
it stays in gray and still
does it still work in the scene
havent tried it yet, I am learning about shaders right now. but I cant get the main preview to refresh the new changes I make in there
do you have a time node
I do yeah
i couldnt tell you really, that weird
i mean as long as it works in the scene it should be fine
okok will try it in the scene, thank you for answering π
Thats what it looks like after a quick google
or ig you can call its procedural terrain painting using shader graph
Does anyone know why my alpha channel is not working in amplify shader?
a semen shader?
Oh block it out LOL, well what exactly are you trying to do
Yes this was on transparant
Was just testing to change it
Also is not working when I change the surface to transparant
Some parts should be transparent, other not
well you need to have a color that can change opacity
you need a HDR color
i belive
Youre right about the HDR color. So how can I use a mask texture for alpha?
If it wont take the input
you need alpha clipping enabled with transparency i do believe
hm, I dont see such option
the alpha clip threshold
you got to make a value for it if im not mistaken
same with the alpha
Ive already set it to a slider value from 1 - 0
let me make a shader rq
Ok I still managed to make it work! But somehow seems like lights stays active until some other event happens, like another light gets activated. It's almost like a cache
@polar granite Thats weird mine worked just fine
oh your using amplify
yea
im dumb, no this was wiht just the regular shader graph
So you think its a amplify limitation? that would be so weird since its so featureful
i doubt it probably just hidden in plain sight
oh probably
see about the mode setting up top
Haven't working with amplify for a while, but could it be that the surface type (opque/transparent) is overriden at the material level ?
or the type
I found it!
nice
bruh
Thanks for the help! Im sure the HDR setting was also important
Got to love it man
Well I can see the texture in the nodes! I had no idea you had to set the default name as well
@polar granite ik fr what the hell
Thanks again
No problem
Ill be back to ... work again!
Non-HDR color does support alpha as well
HDR just includes intensity for the color channels
hi guys this isnt neccessarily a shader issue but cant find right channel! If i drag and drop a material onto an object, how do i remove that so that the object goes back to using the materials specified on the imports "materials" tab here :
Hi, has anyone any idea where this variable has been declared in the URP code? URP_FP_DIRECTIONAL_LIGHTS_COUNT
I need to do this, but not for directional lights - so for the lights count
It seems it's in the https://github.com/Unity-Technologies/Graphics/blob/ce1905322722287c1420a6d85de14158c1648a84/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl, but there's no URP_FP_LIGHTS_COUNT T.T
Searching the Graphics repo yielded this:
https://github.com/Unity-Technologies/Graphics/blob/0e4ca4d79b2c502c28bffd50739c05647dae9611/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl#L127
β¬οΈ
https://github.com/Unity-Technologies/Graphics/blob/0e4ca4d79b2c502c28bffd50739c05647dae9611/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs#L437
uhh additional lights is one term ive heard
It's what I'm calculating
sadly with Forward+ GetAdditionalLightsCount(); doesn't work
and every example that I've found uses URP_FP_DIRECTIONAL_LIGHTS_COUNT, which is used to calculate Forward+ lighting per directional light, and not additional ones
I'm assuming the first loop in the Lighting.hlsl functions might be for extra directional lights, then the second is for point/spot lights. Either way, I'd still copy their setup
Uh, well the second loop crashes π¦ it's what's giving me the D3D11 error...
Also, the first loop works, if I set a static number for the light count
but since the number most likely exceeds the light count, bad behaviour happens
as an example, lights stays on even when they're disabled
It seems with forward+ you don't need the light count, as they're in "clusters" and it uses a while loop. But I don't fully understand it to help.
#define LIGHT_LOOP_BEGIN(lightCount) { \
uint lightIndex; \
ClusterIterator _urp_internal_clusterIterator = ClusterInit(inputData.normalizedScreenSpaceUV, inputData.positionWS, 0); \
[loop] while (ClusterNext(_urp_internal_clusterIterator, lightIndex)) { \
lightIndex += URP_FP_DIRECTIONAL_LIGHTS_COUNT; \
FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
#define LIGHT_LOOP_END } }
It's based on that normalizedScreenSpaceUV, so maybe that's what is wrong π€·
uh...well setting it to ScreenPosition seemed to be the only thing that worked correctly with the shader
Makes sense given the name "normalized ScreenSpace UV" too. I would assume this is the same thing as the ScreenPos.
But how it's calculated in the URP/Lit shader is a little odd. They use GetNormalizedScreenSpaceUV(input.positionCS);. https://github.com/Unity-Technologies/Graphics/blob/0e4ca4d79b2c502c28bffd50739c05647dae9611/Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl#L118
yup
I assume calculating it from the clipPos after perspective divide. But the usual way Screen Position is handled is with ComputeScreenPos in the vertex stage. I guess this saves an interpolator but it's a bit confusing.
Afaik yeah
but when I input it in my function as a float3, and use it in the GetNormalizedScreenSpaceUV, the lights behave in a weird way: they are shown not when you can see them, but when the camera is in the light's range
as if the camera was an object
that needs to be light up
Okayy, but it doesn't crash?
Guess it's caused by something else then
Does the crash occur without using your shader? What about with the URP/Lit?
well, there are many materials in my scene, but I think it would not crash... in fact, it doesn't even crash in the menu with 2x more lights.
trying it with Lit would mean taking half an hour to modify every material
I can try with threes and the terrain (the main objects, wayyy more common than the others), wait a minute
Maybe you can test in a smaller scene with only this shader/material with the forward+ lights setup. You need to be sure this crash/error is even caused by that
And if you test it and it crashes even with the URP/Lit, then there's a problem with URP itself and you should make a bug report
In a smaller scene - like the menu - it works
In the game, I've got thousands of objects and about 8 lights (loaded in my save). But the light touch at max 50 objects
Even with a fresh world with just a point light, the game will crash... maybe it's some other shader
Ok I found a way to test better what's making the game crash. I'll brb with more data.
If i want the sun to reflect but not anything else witch one should I chose?
Hey Im confused about something:
How can I create a fragment shader graph?? I dont see an option for fragment or vertex sahder when I go to create one
also, what the union node? I dont seem to have that either
I loo up a guide on every node in unity shader graph, and union is not there
but its in this persons video
The shader graph will have fragment and vertex stages automatically, especially in the newest versions
bah, I'm on the latest 2019 release, and I thinkk updating further would entirely break my project
well shit
Also I think it depends on which type of graph you're making
where do I find the shadergraph version?
Shadergraph will generate fragment and vertex shader for you
In the "output stack", you have two blocks, one for vertex and one for fragment / surface
except I dont
only in the newer versions
Ah, hum, yes, 2019 might not have it π
Still, it will generate vertex and fragment/surface
it's basically a surface shader
I dont need the vertex part at all, just fragment
what exactly are you trying to do
make a shader that takes in a render texture of the screen that can only see a particle system.
in that particle system, I have red semi-transparent particles. I want to take the overlaapping portions, and step them to another color depending on how opaque they are
which, I have the graph and nodes mostly working for that so far
I'm trying to follow along with someones stream where they are doing this effect, but they are using a newer version of unity and shadergraph
and I dont know how or if I even can do what the union node is doing
which is just overlapping the output of 2 nodes with a top and bottom input
I tried a blend node, in screen mode, and this sort of works
but it also creates unwanted interactions between the layers
I dont want them blended, just overlapped
There is no union node in shadergraph.
Maybe it is a custom node or subgraph from the stream / user ?
possibly, he doesnt mentioned it anywhere though, as he is explaining the shadergraph
Don't know about this Union node, but it sounds like you want a Lerp, or Blend (Overwrite mode)
Maybe a Max node ? (sdf union)
overwrite doesnt work, it pretty much just deletes one of the inputs
how do i set the intensity value of a HDR color from a c# script?
using .setColor() makes it default to 1
nvm i found out
I found what's causing the problem! Is a single shader, the Grass shader. Even a single object makes everything crash. However, I have no clue what could be wrong with this shader, and it's very messy...
I'll cut out various parts, trying to find what's wrong with it
I'll cut out various parts, trying to find what's wrong with it
this why i like shadergraph
shaders are so complicated and just being able to extremely easily cut stuff out makes solving problems so much easier lol
..... It was a missing _FORWARD_PLUS keyword in the grass shader π€¦ββοΈ Hours and hours spent for that
Yeah but jeez, usually bugs are something harder and not that low-level dumb
nope
thats just how bugs go
they can be super simple fixes but not super simple finds
Do you mean "light" or the skybox?
If you want to reflect the skybox you can use simple reflection probe
If you want the mats look bit shiny then use lit and crank up the the metallic(or smoothness I forgot) value
=========
In reflection probe you can choose what obj will show up in the reflection via layer mask
I'm writing a ray marching compute shader for iOS, and I need to use the depth texture to occlude stuff
It works fine on Windows and Android, but on both my Mac and on iOS the depth texture seems to be in a different format
I'm calling Linear01Depth, which supposedly fixes reversed depth texture, so that's prrrrrobably not the problem
What could be the culprit of a shader not rendering? I've applied it to a material and I can visibly see it on the preview, but it's not rendering on a quad. What gives?
vertex shader or just normal shader? maybe you can use "two side" setting
It's a normal shader
I have tried selecting both in the render direction if that's what you mean
well,if you already doing that then i dont know any other possible solution 
Hi Gamers, if I want to actually WRITE shaders, is URP basically a dead-end?
I see I can write surface shaders, but would that work for 2D textures or post-processing effects?
Surface shaders are only for the built-in RP and won't work in URP
So is there any way at all to write shaders in URP or is it only shadergraph
Yes, you can still write shaders for URP. Though it is typically easier to use shadergraph, especially for lit shaders. Actually most "unlit" vert/frag shaders even from BiRP might already work still.
Though if you want to support the SRP Batcher (good for batching Mesh Renderers) you need to use the render pipeline ShaderLibrary with HLSLPROGRAM (rather than CGPROGRAM & UnityCG.cginc which is intended for BiRP).
I've got an article which covers most of the basics :
https://www.cyanilux.com/tutorials/urp-shader-code/
Also some templates/examples : https://github.com/Cyanilux/URP_ShaderCodeTemplates
Can also view the shaders URP provides an examples : https://github.com/Unity-Technologies/Graphics/tree/master/Packages/com.unity.render-pipelines.universal/Shaders
That's a big article π³
Yep π
So for a 2D project, which rendering pipeline would you recommend and why?
I trust your knowledge
I prefer URP, it has a 2D Renderer + 2D lighting system too which is quite nice. But I typically work in 3D so probably aren't the best to ask.
What pipeline is this for? What's the shader doing?
URP has Shader Graph and interesting 2D features, but you cannot mix any form of 3D meshes or cameras with the 2D Renderer
I have a question about windwaker hd's toon shader
It looks like the character has some lighting being processed even in the dark parts
Im assuming this could be using ambient light or maybe light probes?
This has been bothering me for weeks trying to figure out how they give the characters depth
Is it possible they combine diffuse lighting with toon shading?
Im wondering if simply taking the lit shader and replacing the diffuse function with a toon function would achieve the same effect
Something like that probably would be quite close yeah. It looks like the smoothness / fresnel effect you'd get on the lit shader. I guess it's replacing the diffuse with a toon effect, but not the specular and ambient parts?
So use 2d renderer only with strictly 2d games?
I feel like most 2d games now probably arent strictly 2d
If you don't want strictly 2D, you can still use 2D/sprite components in the 3D / Universal Renderer as well. But you don't have access to the 2D lighting features then.
For now yes
They're working on expanding it
Some 2D features of BiRP has universally, like pixel perfect camera won't work on URP without the 2D Renderer which really sucks
Ah yeah :\
It's annoying they don't properly communicate the pros and cons and instead let you truck on and bump into the cons along the way
Cool thanks for the reply
Does anyone know how to use UDIM Textures in unity?
I know unreal supports them, but how would I do it in unity?
Well, what exactly do you need? From a quick Google it looks like a texture atlas to me.
Well, I have a object textured using UDIM in substance painter and I was wondering how to import the materials to unity
You'd need to know how it's implemented in substance painter to recreate the shader in unity
Also, did you even try to google?
Oh alright, I see now
There seems to be a plugin/asset implementing substance painter materials in unity.
And it's free even.
Just Google it. One of the results should be a link to unity asset store.
Near the top of a Subshader Pass, I'm defining
#define GPUI_STRUCT_NAME appdata // the name of your input struct
which is used in a cginc file like so
void gpuiAnimate(inout GPUI_STRUCT_NAME v)
However, upon compilation, the following errors are thrown
Shader error in 'Collapse/Toon': unrecognized identifier 'appdata' at Assets/GPUInstancer-CrowdAnimations/Shaders/Include/GPUICrowdInclude.cginc(18) (on metal)
Compiling Subshader: 0, Pass: Outline, Vertex program
appdata is a struct defined as
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
// GPU Instancer
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
//
};
However, for some reason the cginc file isn't recognizing the struct appdata
This is URP btw. Does anyone know where I went wrong? I'm guessing that HLSL has to make a struct "public"?
Hello, I'm trying to overlay a sprite onto another sprite that use the bottom's sprite's alpha as a mask. The desired effect can be seen in the preview window
The problem is when I put a sprite sheet as the maintex, the scaling is messed up. I'm trying to figure out how to achieve the same effect as using a single sprite, can anyone help?
this is what it look like in the editor when using the sprite sheet
this is what it should look like
Should your texture be sampling with UV2?
Surely you want to be using UV1
I change it to UV1 but I don't see any changes. Are there any ways to manipulate the UV so it can achieve the result?
UV0, sorry
hmm I'm not seeing any changes neither, I have tried plugging random things into it too
Can you pipe the bottom sprite's alpha into a preview node so I can see it? Perhaps the top one too
like this?
There is a Preview Node you can use
I understand what the issue is, and I have no idea how you can fix it.
I think the way this works is that the UVs that are used for the mesh are generated so they point at the maintex sprite in its spritesheet
there are no UVs generated for your other texture, so you can only pull the uvs associated with the main tex
which are presumably pointing to that section in your mask
so unless your mask tex was in the same place in its spritesheet, this can't work
The flipbook is giving you a window into the original provided UVs
I see
Like if your maintex is at the red square, your flipbook's first index might be at the green square, but seeing as your mask texture probably has nothing to do with the red square in the first place it's nonsense UVs
oh ok I can kinda picture it in my head now
If your masks are always matching your main textures, it's just they're atlasing differently I believe there's a thing called secondary textures where you can get those atlased the same as your first
I did come across atlasing when I searched for an answer
I will come back to that article
thank you for pointing that out
Anyone know a good tutorial to auto pain textures using shader graph to terrain
@regal stag I got it working :)
This doesn't seem like a #archived-shaders question and is easily googled https://stackoverflow.com/questions/23529592/how-are-c-sharp-const-members-allocated-in-memory
Nice this looks class :O
I found this cool glass shader
https://github.com/omid3098/Unity-URP-GlassShader
But for a reason I don't understand it is trasparent but doesnt render stuff behind the glass
can somebody help?
Here's the graph inspector
Its surely some setting here, I tried to detach every one and still didnt rendered
It uses the Scene Color / aka camera's Opaque Texture. It's a snapshot of the screen after rendering opaque geometry, so doesn't include transparents yet. When rendering transparent objects they can sample this texture and do stuff like distortions. But it'll never have any transparent objects in.
It's meant to replace the older GrabPass technique which handles multiple screen grabs before rendering the object, which can be expensive.
Oh ok so from the base its a technique that doesnt work, or at least in this context where I need to render things behind
Seems strange tho, cause the video demo looked fine
It works fine, as long as everything you want to render behind the window is opaque
If you haven't already, make sure the Opaque Texture is enabled on the URP asset too.
Does anyone know how you can write shaders in HDRP instead of using shader graph
Is the struct defined before the cginc file is included?
One last thing, the image behind is now way darker, what causes this behaviour?
You'd typically use an Unlit graph, or at least put the Scene Color in the Emission on a Lit graph
Yep, it turns out that was the issue I moved the struct definition up a bit
In URP, what does Raw depth value means, I dragged it in to the color, my object turn black,I think if it is the distance from the camera to the pixel, It should be white
Raw depth value from the depth buffer.
I don't remember if URP uses inversed depth, apparently no, so the values range from 0 at camera near plane to 1 at camera far place, in a non linear way (more precision for closer objects)
How do I get the distance from the objects to the camera using scene depth?
Use the eye space depth
thanks, It worked
@amber saffron I still got some bug here, Only object inside the light circle at the center of the screen show correct value, outside is gray
I have been trying to make a simple fog effect in shadergraph with URP, as a sort of introduction to shaders. Currently I have two questions, the first being that the fog seems to flicker a lot at a distance, but if observed closely, also up close, albeit to a lesser extent. This reeks of a precision problem, but if the depth value were somehow off by a small amount and flickering, wouldn't the problem instead appear on the edge of the transition to fog?
My second question has to do with making the fog radial as opposed to the rather menacing "Fog Plane", that currently rotates with the view, I understand this has to do with how I'm using the depth texture (Currently just a scene depth node in eye mode), and that I want it in "Clip space", but I have no idea how to convert to said clip space from eye space (As a third question, what even is eye space exactly?)
I'm currently applying the fog effect through sampling the URP render buffer before post processing in a Fullscreen Pass Renderer Feature and lerping to a fog color
nevermind, I figured it out
a nooby question
how can i get the unity graph shader
when i go to packages
i cant find the render pipeline package
you are searching packages in your project, you need to search them in unity registery
well i found that shader graph is installed
but i don't have the options
to create one
If you are trying to make a fog post processing effect you want your depth to be linear in the 0 to 1 range
you can set the mode of the scene depth over here, although linear 01 is allready default usually
show me a screen shot of what you can create
sec
Did you also import the package into your project? (You need to first install it then import it)
no
do that
That.. sort of answers my first question, do you mean that if I use linear01 it will resolve the flickering? (I still don't know why the flickering happens)
I do not know what you mean by sort of answers my question. Also you never showed us the full extend of your shader. The only thing I know that you are lerping between the BlitSource and a color, using probably the depth texture, so if you want to lerp something you want it to be linear between 01
Hi! I have some troubles with the shader graph... So, I was messing around with the Shader Graph and I tried to make some water shader. I found out someone who just did what I almost want to achieve but something went wrong and I have no idea what... So basically the water should look something like in the second picture but I my project it looks... (first picture) Also I am leaving an image wit the shader graph if there is someone who can help it would be much appreciated.
If this is URP, is the Opaque Texture enabled on the URP asset? (It's required for the Scene Color node)
Also check the alpha value of your colour properties
Also have you set your surface type to transparent in your graf settings, the shader won't work properly without
Thanks for answers! I checked alpha values and it's good and the surface type of the graph is transparent, but how do I enable that Opaque Texture?
@lunar valley Thanks for the help man π
Oh, sorry, here is the full .shadergraph
So in both fragment and compute shaders I have long time had big issues sampling textures correctly. In my case I have a 3D tile array in C# that I write to a texture as per pixel information. But when I try to read it using something like this:
c = _texCol3D.SampleLevel(sampler_point_clamp,
float3(
tileX / (_texCol3D_Dimensions.x - 0.01),
tileY / (_texCol3D_Dimensions.y - 0.01),
tileSheet / (_texCol3D_Dimensions.z - 0.01)
),
0
);
I have to add - 0.01 to the texture dimensions otherwise it will sample the incorrect texture position. I assume this is because the texture is actually 0 - 0.99 and 1 is the repeat of the texture, but sometimes I get the correct values doing nothing, sometimes doing - 0.01, and sometimes doing - 1, but it feels extremely inconsistent which I assume is caused by texture size affecting precision. What's the correct way to approach this??
a screenshot would have been enough I don't want to open that
Alright then
It's not that the shader doesn't work, but as shown in the video, there are issues with the fog not being circular and with distance based flickering
What about -0.5 to the tile value instead. That would be the pixel center right?
I think there is also texture.Load() which uses pixel values rather than the 0-1 uv, could try that
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-load
i'll try load
Should try disconnecting some sections to see if you can find which part causes the flickering.
~~The use of the Position node specifically might not be what you intend, as the shader is applied to a fullscreen quad in the renderer feature.
If you want "height fog" for objects in the scene, you'll need to reconstruct the world position from the depth texture first.
I use this : https://www.cyanilux.com/tutorials/depth/#blit-perspective~~
nvm, seems the fullscreen graph is automatically reconstructing the world pos. Didn't know it did that.
As far as I can tell, the height fog, and the position node, both work as I intend, and it provides some version of world space, not screen space coordinates by default
Yeah I just tested, it's not what I expected but nice to know shadergraph is doing the reconstruction for us
I would still try each section separately to see if a particular part is causing the flickering
Turns out the issue comes to the depth, which must be flickering somehow, though it is in eye space, aka, unity world units, and would have to be flickering back a lot for the fog to dissappear
Because position I assume is reconstructed using depth somehow, the position node output flickers too
Does it flicker if you just output a solid colour?
If so, might be something with the renderer feature setup, not the shader itself
I'll try that hold on
Nope, definitely depth flickering
Huh, that's interesting, mapping that same depth input to 0-1 and moving the camera has no effect, something weirder must be at play
no flickering with this at all
Turns out flickering is coming from the position node, and that I was confusing some of my tests by leaving post processing on after trying to output something like a depth texture
Hello
Hey, I have a Render Texture from a camera output that I am rendering over the entire screen. Its meant to look at a particle engine, and do some neat shader magic to it to achieve this result
https://streamable.com/happn5
However I have a problem... I currently have the material from the shader on a Mesh Renderer... but I can't get this to interact with my sprite layers... I want it to render behind the player
any idea how to do this, WITHOUT converting the rendertexture to a sprite at runtime (I know how to do this, I'm doing it for a different effect, but its a very costly operation, and actually does not keep up with the framerate)
nevermind, got it working! it renders to a sprite, just needed to change the input from _MainTex to a different secondary texture
is there some equivalent to the standard shader in URP/HDRP? There's this model i made using crocotile that needs the cutout mode to allow for transparency on the sprites since transparent mode breaks a lot of the sprite rendering.
"Standard" equivalent would be "Lit"
I am having an issue with a "Wind" shader that I'm trying to apply to tilemaps to have it wave like trees in the wind. The "waving" is working, but the textures are being replaced, or maybe stretched into squares? its not using the tile textures. I will send a picture of my shadergraph, a video of whats happening at the moment, and what the tiles actually are supposed to look like
(what the textures are supposed to be)