#archived-shaders

1 messages ยท Page 82 of 1

molten wave
#

nvm found it, uv are between 0 and 1, it's working thanks for the help Bunkins!

tacit parcel
#

define "this"
if you mean that there's bright and dark part, thats because mobile diffuse is a 'lit' shader, means that it calculates light

gilded spade
#

So I was learning Unity Shader Graph and was trying to create a stylized grass shader. I got the result but i am unable to see any shadows of the assets in the scene. Any help with it? How can i cast the shadows on top of the grass. I am using terrain and scattered the grass on it. Plus I am using Unity URP.

ebon moss
#

Does anyone know what kind of shader shader graph makes?

strange basalt
#

its output depends on what render pipeline its used with, but it outputs a HLSL shader

#

you can easily view the generated code from it if wanted, its a bit of a mess to read though

ebon moss
strange basalt
#

compute shaders are there own thing, but rendering you got vert and fragment shaders that are jsut different functions defined in hlsl

steep wigeon
#

Why i cant modify values?

waxen grove
#

Does anyone know how to do depth textures for surface shaders HLSL?

#

I can't seem to find ANYTHING on it online

copper falcon
#

The game Turbo Overkill has this shader where a surface shows a different place. In this case, the breakable holographic material shows that nice nature background. In Unreal Engine 1 ( yes 1, from the 90ies) they did that for skyboxes.
I wonder how this is done in Unity. It's not just a render texture and not some sampled cubemap. Both spaces exist in 1:1 scale.

copper falcon
eager folio
#

Then just have areas that don't clear before rendering on the second camera

copper falcon
amber saffron
topaz quartz
#

Hello, I saw this topic on Unity forums (https://forum.unity.com/threads/setting-an-array-of-textures-possible.1021246/) which states that is possible to declare a texture array as a sampler2D variable[numOfItems] inside a HLSL shader.

My question is, is possible to pass from _TextureArray ("Texture Array", 2DArray) = "" { } property to this field inside the CGPROGRAMof a HLSL shader?

regal stag
rancid shuttle
#

is there a way to get rid of that white line when using Skybox/Panoramic shader?

topaz quartz
# regal stag Probably not. As bgolus mentions if the compiler even allows it it's probably un...

Yes I'm using those macros, the point is that I'm using UNITY_SAMPLE_TEX2DARRAY then how can I get the sampler2D from this? I'd like to adapt this code: https://github.com/jensnt/TerrainHeightBlend-Shader/blob/main/textureNoTile.cginc to use a Texture2DArray.

Neither I can't use this as an argument for a function: float3 getAlbedo(Input IN, Texture2DArray side, Texture2DArray top, int arrayIndex, float2x2 rotationMatrix) because: Unexpected identifier "Texture2DArray". Expected one of: in inout out uniform sampler sampler1D sampler2D sampler3D samplerCUBE sampler_state SamplerState SamplerComparisonState bool int or a user-defined type.

So I'm not sure how to continue developing my shader

GitHub

Unity Terrain Shader with Height Blending and more features - jensnt/TerrainHeightBlend-Shader

smoky widget
#

How can I use two clip calls in a single URP shadergraph?

#

i used to have a clip(x) and later in code a clip(y) in a fragment shader, but now moving to URP im not sure how to use alpha and alpha clip to make it work

regal stag
waxen grove
regal stag
smoky widget
#

I was trying to add, or multiply them but was getting weird values

#

That's so much more clean

waxen merlin
#

Hi, not sure the best place to ask this as it covers particles, compute shaders and rendering. Essentially I'd like to do the following set of things:

  1. Have some simple particles running on the GPU (Spawned from CPU).
  2. Have these particles collide with the environment - somewhat accurately, and including backfaces, so depth buffer collisions are out. I'm currently thinking voxel or SDF representation of the world.
  3. When these particles collide with the world I want to generate (append) some data that a subsequent compute shader will process to generate some simple geometry.
  4. After that, I want to render this generated geometry into a rendertexture.

So, it's complicated and I don't know if any parts of this can be done inside existing tech - like VFX graphs (though I don't think they will let me do the collision data generation). Apart from the CPU particle spawning, I know all of the rest can live on the GPU. I'm guessing I'm going to have to write all of this from scratch aren't I? Anybody done anything like this?

topaz quartz
#

Then for example, I could pass my texture array into the textureNoTile code (https://github.com/jensnt/TerrainHeightBlend-Shader/blob/main/textureNoTile.cginc). But I have questions, for example, we have:

fixed4 textureNoTile( sampler2D samp, in NoTileUVs ntuvs )
{
    // Use modified UVs to sample a texture
    return lerp( lerp( tex2D( samp, ntuvs.uva, ntuvs.ddxa, ntuvs.ddya ),
                       tex2D( samp, ntuvs.uvb, ntuvs.ddxb, ntuvs.ddyb ), ntuvs.b.x ),
                 lerp( tex2D( samp, ntuvs.uvc, ntuvs.ddxc, ntuvs.ddyc ),
                       tex2D( samp, ntuvs.uvd, ntuvs.ddxd, ntuvs.ddyd ), ntuvs.b.x ), ntuvs.b.y );
}

Where is declare this tex2D constructor? Because in HLSLSupport.gcinc I only see float4 tex2D(sampler2D_f x, float2 v) { return x.t.Sample(x.s, v); } and which is the equivalent for UNITY_SAMPLE_TEX2DARRAY(), because uva, ddxa, ddya, ... they are fixed2 types

#

Because as we said, we cannot recover the sampler2D from a UNITY_SAMPLE_TEX2DARRAY() call, no?

#

But I don't think we have such thing on UNITY_SAMPLE_TEX2DARRAY

topaz quartz
#

I found this: https://forum.unity.com/threads/texture2d-array-mipmap-troubles.416799/#post-2730309

#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)
    #define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex, coord, dx, dy) tex.SampleGrad(sampler##tex, coord, dx, dy)
#else
    #if defined(UNITY_COMPILER_HLSL2GLSL) || defined(SHADER_TARGET_SURFACE_ANALYSIS)
        #define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex, coord, dx, dy) tex2DArray(tex, coord, dx, dy)
    #endif
#endif

But the following prompts: undeclared identifier 'UNITY_SAMPLE_TEX2DARRAY_GRAD' how can I check the SHADER_API_xxx directive I'm using?

amber saffron
waxen grove
#

Alright
How can I convert that to a float I can use? I'd also like to covert it to alpha

amber saffron
#

Well, it is a texture, so you need to sample it to get the float value. It's a single channel texture, so either .r or .a value is the raw depth.
Look into UnityCG.cginc for helper functions to convert the depth to other spaces (like eye space : aka distance in meters)

#

Once you have the float value, up to you to do anything you'd want and plug it into the alpha output

waxen grove
#

Thank you

smoky widget
#

Hi! I have a pretty complicated sub graph that i would like to use in a compute shader, is it possible?

smoky widget
#

actually nvm! I forgot that yhe important code is already in an hlsl

hexed sorrel
#

Hey all! I am currently trying to find a way to efficiently create a outline/stroke effect on my Render Texture, currently I have a white/black image and am trying to add/expand extra mass similarly to the blue area is done in this image (blue area is an example to show area made in photoshop, actual result would ideally be white as-well). Does anyone know of a shader effect I could use to expand the white area as such, any help would be amazing, thanks!

grizzled bolt
hexed sorrel
#

I did end up getting my old system working, just looking to make it even faster than it is currently by reducing the amount of blur passes needed!

grizzled bolt
hexed sorrel
# grizzled bolt Not necessarily It can be used to expand a region of pixels with diminishing int...

Alright, I'll have another look into it! I mostly stopped looking into it prior since I had found a working way to implement the "blur" method, which gives the exact result I was aiming for for only a 10%~ fps cost in editor. However, if I were to find a cheap way to give an outline/stroke effect I could probably bring that down 80% since the blur passes would be able to fill a lot more area with less passes, but I'll look more into flood fill since I'll likely need to use it in other areas of my project down the line either way, appreciate it!

grizzled bolt
#

The my knowledge there are many different methods and algorithms to make a flood fill outline, the best of which depends by platform and use case
I would guess they are cheaper than blurs, on average

hexed sorrel
#

I was really just wondering if there would be a really standout obvious solution to creating a stroke/outline cheaply that I had been missing, but I'll definitely give this a try if that isn't the case.

#

The flood fill definitely seems like it has a lot more potential as far as additional parameters + I could probably reuse a lot of the flood fill outputs for a variety of different systems in my project, definitely a good one to keep in mind!

grizzled bolt
#

As well as the link in there

hexed sorrel
#

Yeah just off a quick glance, the extrusion method shown in the link you sent looks like exactly what I was looking for!

grizzled bolt
hexed sorrel
#

The first one I was referring to, but it seems there isn't a title for it "fresnel effect" potentially?

grizzled bolt
#

Fresnel effect is also for geometry

#

Only blur and specifically jump flood are relevant to your case

hexed sorrel
waxen grove
#

float _depth = Linear01Depth(tex2D(_CameraDepthTexture, IN.pos).a);
And in the vert function

o.pos = UnityObjectToClipPos(v.vertex);
UNITY_TRANSFER_DEPTH(o.depth);```
#

The result I want is LIKE this, this was made in shadergraph

regal stag
waxen grove
#

Yeah it's not working

#

I used .x...

fair wadi
#

what are the uv naming conventions i need to follow so that i can use multiple uvs per mesh, is it simply uv(0), uv1, uv2 etc etc?

fair wadi
#

and now i have two normal maps. one on uv0 and one on uv1, if i simply add them together, will they only affect their respective uv or will it turn into a mess?

grizzled bolt
#

I don't think any names for UV maps will be kept when exporting the mesh

fair wadi
#

bc this does (obviously) now work

fair wadi
grizzled bolt
#

After that you only have the color of the pixel you got by sampling to work with

fair wadi
grizzled bolt
fair wadi
#

ok, so there is no way to have a different texture on the green flats considering im constricted to a single material

grizzled bolt
#

If you want them to be on two different ones for some reason, you'll additionally need some way to separate or mask the different parts
Otherwise you're sampling two overlapping UV maps on every fragment

fair wadi
grizzled bolt
#

I would increase poly count and texture resolution to accomodate the leaves
To have extra UVs and and a mask map or vertex colors to mask between them has its own cost that's probably higher anyway

fair wadi
#

hmmm, ill do that then

shadow thistle
#

Please I need help with a math formula. I need a shader that accepts parameters _Rotation and _Segment and gives me the shape seen on the image (ignore the test image lol). The shader calculates the angle of a point from the pivot and saves it as variable angle. I can't figure out what the right thing is.

shadow thistle
#

nvm i realised i need a different one

#

which works

amber saffron
shadow thistle
hexed sorrel
# grizzled bolt Only blur and specifically jump flood are relevant to your case

Hey! So I've been looking into jump flood a lot more and it seems extremely efficient especially at higher pass counts than gaussian blur so it's basically a perfect match for what I am looking for, however I am still quite unsure if it would work with diminishing light values, since it is being used as a "passthrough" through walls as we discussed prior a few months ago, adding an outline directly would likely not account for varying light opacities as shown below, would you know of a way/work around to allow that to work, and also account for color in the flood fill? (Example below)

#

The only way I can currently theorize as potentially working is individually passing each light to a separate render texture and separately masking/jump flood filling each of them in their respective colors and blurring them together afterward, but that still has the opacity problem as to my knowledge the stroke would effectively force all the area in the light to be fully opaque in whatever color the flood fill "outline" is set to be?

#

this is the current documentation I am referencing, which I've found to be great at explaining how jump flood works and directly comparing them to other methods (such as gaussian blur).

grizzled bolt
#

I guess you would have to sample a texture that differentiates empty space and filled space
Usually you would fill around a light, accounting for walls, rather than fill around a redundantly filled area (this also prevents your light from passing through walls)
I don't know how colored lights work with this method, maybe they're calculated separately and composited

hexed sorrel
grizzled bolt
#

I think we expect light to diminish over distance and to be impeded by walls

hexed sorrel
#

I do have the "outline" mask which I can use to separate the "filled" and unfilled space.

hexed sorrel
#

A really high blur pass does this amazingly but is super computationally heavy.

hexed sorrel
grizzled bolt
#

Blurs are not generally used for this

hexed sorrel
# grizzled bolt Blurs are not generally used for this

Yeah, I see why. But it seems to be almost required to get a starbound-esk light system that isn't insanely complicated. (even a low blur pass combined with other techniques for blurring the result if jump flood fill was used).

grizzled bolt
#

I think you're overcomplicating it, and overcomplicating it even more in an effort to avoid the jump flood algorithm

hexed sorrel
grizzled bolt
#

I don't understand what you mean by that
All your reference games get by with it fine

#

Ben Golus' example is for outlines, so it's not 100% the same case

hexed sorrel
grizzled bolt
#

I don't understand how photoshop is relevant here

hexed sorrel
#

I'll give the flood fill a try and see how it goes, the only real way to know is to try I suppose.

stark shell
#

Is it possible to change the bayer matrix used with alpha to coverage?

topaz quartz
#

I defined a macro like: #define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex, coord, dx, dy) tex.SampleGrad(sampler##tex, coord, dx, dy) to be used on this code:

fixed3 textureArrayNoTileNormal( UNITY_ARGS_TEX2DARRAY(texArray), in NoTileUVs ntuvs, in half normalScale )
{
    // Use modified UVs to sample a normal map, also inverting red and green channels where needed due to mirroring
    return lerp( lerp( fixed3( ntuvs.ofa.z, ntuvs.ofa.w, 1 ) * UnpackNormalWithScale( UNITY_SAMPLE_TEX2DARRAY_GRAD( UNITY_PASS_TEX2DARRAY(texArray), ntuvs.uva, ntuvs.ddxa, ntuvs.ddya ), normalScale ),
                       fixed3( ntuvs.ofb.z, ntuvs.ofb.w, 1 ) * UnpackNormalWithScale( UNITY_SAMPLE_TEX2DARRAY_GRAD( UNITY_PASS_TEX2DARRAY(texArray), ntuvs.uvb, ntuvs.ddxb, ntuvs.ddyb ), normalScale ), ntuvs.b.x ),
                 lerp( fixed3( ntuvs.ofc.z, ntuvs.ofc.w, 1 ) * UnpackNormalWithScale( UNITY_SAMPLE_TEX2DARRAY_GRAD( UNITY_PASS_TEX2DARRAY(texArray), ntuvs.uvc, ntuvs.ddxc, ntuvs.ddyc ), normalScale ),
                       fixed3( ntuvs.ofd.z, ntuvs.ofd.w, 1 ) * UnpackNormalWithScale( UNITY_SAMPLE_TEX2DARRAY_GRAD( UNITY_PASS_TEX2DARRAY(texArray), ntuvs.uvd, ntuvs.ddxd, ntuvs.ddyd ), normalScale ), ntuvs.b.x ), ntuvs.b.y );
}

The following error prompts: Unexpected token '('. Expected one of: ',' ')' at Assets/Resources/Shaders/Terrain/textureNoTile.cginc(93)

I have two questions, can I see the character position where the errors occurs? I understand that is caused because tex.SampleGrad isn't allowed, but why? Do I need to share some project settings?

tender edge
#

i cant find where the error is, but im only getting the normal on one of the sides

karmic hatch
tender edge
karmic hatch
#

I think Tangent space still requires the UVs to be good on the mesh (the UVs are part of the mesh, they aren't just made by the shader); can you try outputting UV as base color and see what it looks like? (All faces should have gradients on them, like the unity default cube)

tender edge
#

the mesh has no uvs at all

karmic hatch
#

what do the tangent and bitangent vectors look like?

#

they form the red and green components of the normal afaik

tender edge
regal stag
# tender edge what do you mean with output node? i dont have any triplanar nodes. but am calcu...

Usually if you're doing triplanar mapping you avoid using tangent space as those are aligned to the regular UVs.
The Triplanar node gets around this by doing a World->Tangent transform at the end, but that's kinda an unnecessary calculation as you can change the Normal Output Space under Graph Settings to World instead)
See the code snippet on that node page, and/or this article - I think Unity's node uses the "whiteout" blend iirc

tender edge
#

does what i'm doing count as triplanar?

regal stag
#

If you don't need different textures on each axis you can just use a couple Triplanar nodes to handle all this for you

tender edge
#

#archived-shaders message i looked into other options because someone mentioned you could get a similair effect without using it. but i couldn't find a different option

#

i only want a different texture for the topside and try to blend it into the sides. was also thinking of using a vertex shader again so i could change the textures at certain locations

#

but ill have to call it a day for now, thanks for the links and ill be busy working on this again tomorrow

tacit parcel
quartz sail
#

is there any reason why my shader looks different in scene view (Image 1) than in game view (Image 2)? it seems like the alpha clipping is just not working in scene view and i dont know why? when i make the surface type transparent, the clipping works but it was give it that weird affect where you can see the trunk (Image 3)

quartz sail
frank elbow
#

I been trying to follow this tutorial
https://youtu.be/eYzihHPtGJE?si=quUZOWNPT-pV9k9x&t=726
But i have noticed that when ever i try to animate the uv offset the Voronoi noise it breaks apart.

On this tutorial let's see how this Stylized Vertical Beam attack is done in Unity! We are gonna use Shader Graph and VFX Graph to build this bad boy and by the end you will have a great start to improve on.

00:00 Intro
01:07 Starting the VFX
02:10 Cylinder Mesh in Blender
03:02 Vertical Beam Core
04:58 Beam Background
05:56 Fresnel Cylinder
0...

โ–ถ Play video
#

Am i missing how you can animate this noise, i also tried on amplify shader as well and it had the same effect

hybrid carbon
#

Does anyone know how to apply different mixtures of this texture to a material, so like, 100% lighting, that bright part is nothing, 50~75% is the small dots, 25~50% is mixed of small dots and heavy dots, and 0~25% is heavy dotting

#

wait- I just figured it out

tender edge
tender edge
#

i've taken this screenshot from the game timberborn and i want to achieve something similair. where i can give a different texture to the top of the mesh and for the sides. with ideally some controll with how those edges blend with eachother. and being able to render different textures that also blend depending on fe if water is in range

#

for now im guessing i could achieve this with vertex coloring. but i would have to add a vertex in the middle on top of the mesh to hold the information and keep the texture centered on the voxel. or could that be solved another way?

tacit parcel
#

I think you can combine world space xz texture mapping and uv mapping.
worldspace for the top surface so they dont have any seam, then mask it using texture with uv mapping
You'll need an auto tile algorithm though

amber saffron
#

Now, that's purely based on the normals, it won't blend the edges of the top faces.
Like it was mentioned, if you want this sort of edge blending, the distance to the edge information is needed, probably in the form of some additional vertices and UV / Color

tender edge
tender edge
lucid perch
#

hey when im editing my material settings for example of my water shader is there a way to preview the animation if im editing the waves?

amber saffron
#

I just hope it still works with recent versions ...

regal stag
amber saffron
#

Exact ๐Ÿ™‚
For next time you want to grab a github repo :

tender edge
#

ty got it now

#

i've added some uvs to my mesh aswell, is 0 to 1 per face good enough or do i need to tile those uv's how i want them for that shader?

amber saffron
#

๐Ÿคทโ€โ™‚๏ธ That depends on the way to plan to use them

minor rune
#

Hello, its a project in HDRP, in unity 2022.3.10f1 and my colors are in green here in my shader butin the scene my color 2 is ok, it can change but color 1 does not work and stays black and dosn't change when i do

viscid knoll
# minor rune

don't you have a script somewhere that set this color to black?

#

otherway you can try recreate and rename a color property to see if that solve your case

minor rune
#

mayeb its just a bug

grand jolt
#

can anyon help me

viscid knoll
#

bayer is a recognized good algo

kind juniper
fair wadi
#

im currently trying to make a shader (graph) where no matter in which rotation the prefab is placed in the scene, it will face the same direction based on a vector3 like in the pic. never worked with any sort of orientation/rotation in shaders so i dont really know where to start

warm pulsar
#

Is there a reason you can't just rotate the renderer correctly?

fair wadi
warm pulsar
#

I guess you could pass the shader a transform matrix and use that to transform the vertices

#

I've used this when trying to use local-space in a shader that's used on an overlay canvas

#

local space gets lost (it's just the canvas's local space)

fair wadi
#

i made a windshader, but i am kind of confused, it works with noise. what i want is that the wind isnt so uniform and moves everything in waves, but to have it more random. how can i do that?

fair wadi
rapid marsh
#

guys, super massive noob just starting with unity, do shaders made with the shader graph works with all render pipelines or are they render pipeline specific?

rapid marsh
#

thank you very much

cunning sundial
#

(for reference this same screenshot would easily yield 200+ fps in editor with the lit shader since theres really nothing graphically intensive going on at all)

#

Did you ever solve this? I am encountering this now

eager folio
grizzled bolt
cunning sundial
#

And again, only happened with the new shader but thanks for the insight I'll do some more investigation

dim yoke
grizzled bolt
#

Both cpu and gpu rendering performance can bug out in the editor for various vague editor reasons
Restarting and library deletion may help, but ultimately you want to measure performance in a build

#

I've only used the toon shader package on URP where batches aren't a problem

#

Though it does support BiRP

cunning sundial
cunning sundial
dim yoke
grizzled bolt
# cunning sundial What do you mean by library deletion sorry?

Library is a folder in your project's filesystem that contains all temporary editor-generated data
If this problem appears to have no logical cause (though here it seems like it might have), consider deleting Library and letting the editor rebuild it
But restarting is usually the first remedy in that case

cunning sundial
cunning sundial
#

Is there any indication that unitys toon shader doesn't do batching properly?

grizzled bolt
#

And since they're mesh outlines they also increase the polycount by rendering the mesh an extra time

cunning sundial
#

Ah

#

That sounds like the probably reason then, theres many meshes technically even if each one is low poly sigh

#

I thought the outline might be the reason, I don't think there's much way for me to have my scene the way it is without rendering every mesh twice

#

Even though theres like 4 materials rip okay I'm thinking thanks

#

I guess other games get around it by having essentially a single mesh and material for whole buildings and objects rather than many little ones like I have

kind juniper
cunning sundial
#

Ty will try

grizzled bolt
cunning sundial
#

Probably can roll my own outline or something if it's all that I need

tender birch
#

Got a shader graph for ice from an older version of unity cause i was following a guide, but then tried to import it as a package into a newer verison of unity and it won't work even after i've tried the Converter

#

Any ideas on what to do?

#

The project im working in, is the 3D URP Core base, preset, whatever it's called

hexed sorrel
tender birch
#

doesn't the converter do a swathing upgrade to everything in the project?

#

and i just created this Material raw on the spot and tried to apply the shader

#

so it SHOULD already be convertred since i just created itin the newer verison, right?

#

could i copy everything IN the shader's node graph, create a new empty node graph, and just paste all the settings in there?

#

I'll try that as soon as i remember how to create a new node graph lmao

tender birch
#

Ok, got it working. I could manally change the vector's settings to use URP instead of Built In

#

Auto converter doesn't work on it, so had to manually do it

sand ember
#

how do I get loops to work in shader graph?

tender birch
#

I was worng, the material looks like it should in the preview, but when i apply it...and that piece on the mesh literally shifts around as i move the camera, the shader on it does

tender edge
eager folio
#

What I mean is that you know the size of the grid, so rather than using vertex data to tell where to blend, you can use the modulo of the world position since that will be the same for every block

amber saffron
#

It works for blending the edges of a "top square", but it would do it for all the sides, ignoring adgacent tiles that have the same texture/height.
This information needs to be passed to the shader in some way, and other than using vertex data like UVs / Color, I don't really see how it could be done. (Or have some sort of terrain heightmap sampled to check neighbours ...)

sand ember
#

I'm almost tearing my hair out trying to figure why my shader isn't working

#

So, I created a script to index a texture according to its colours into 16 separate colours

#

using this formula Color(i / 16f, i / 16f, i / 16f, alpha) where i is the index of the colour

#

this gives me a grayscale texture

#

but when i multiply the values back again by 16 in the shader graph, I don't get the correct values

#

I have compression set to none and filter mode set to point

#

so Idk what I'm doing wrong

#

so if I store the values as 0, 1/16, 2/16, 3/16, ... in the grayscale texture and multiply them back by 16 in the fragment shader, it doesn't work

#

they should give me 0, 1, 2, 3, 4, ... but that doesn't seem to be the case

#

I've tried rounding, flooring and ceiling the values but it still doesn't work

#

If someone is willing to help, I can send the shader graph file as well as the textures

#

I'm using urp as the render pipeline

regal stag
#

Or try unticking sRGB in texture import settings

vital scroll
#

Oi! I'm pretty new to shaders and have been trying to fix a small isue i'm having. Where the render feature is overriding a shader i have for portals. I've added in two images one is with the feature on and the other off. Anyone got any ideas on how to solve this?

Render feature:
https://paste.ofcode.org/396Cj478z6HVdMZHX9fY2iE // The shader
https://paste.ofcode.org/ppkTGYaAXQWRTqLQZUME6t // The feature
https://paste.ofcode.org/QXiDihNtYgVJY2Zj3UYEph // The pass
https://paste.ofcode.org/ermYKRHFGFQktTzsCc9yxH // Controller for the feature

Portal shader:
https://paste.ofcode.org/njtzEihcUA8TVfEvLFdFZz // Portal shader
https://paste.ofcode.org/unNb2ySypsKvusQDTbNjQx // Portal code

sand ember
#

I have spent frickin hours trying to figure out whats wrong

tender edge
#

wanted to post this here aswell, apparantly the shader issues i had dont seem to be caused by the shader, it works fine on the test cube but not on my mesh

amber saffron
#

Maybe the mesh has bad normals ? If it's imported, you could try enabling "recalculate normals" in the import settings.

tender edge
amber saffron
#

Maybe also tangents

tender edge
#

i dont call mesh.recalctangents yet, i could give it a try

amber saffron
#

Normal mapping requires proper mesh tangents for tangent space normals, or you use object space normals

tender edge
#

only problem with recalculate tangents is that it massively slows down my mesh generation, i'm currently rerendering the entire chunk for every minor change

amber saffron
#

Well, if you use the position .XY, .XZ or .YZ coord to project the texture, you need to invert one axis when looking at the other side, it makes sense.

amber saffron
tender edge
#

i think i could manage that for the normals, but i dont even have a clue what tangents are๐Ÿ˜…

amber saffron
#

To put it short, the tangent if a normalized vector, perpendicular to the normal, and pointing "toward" the UV.X axis on the mesh

#

(well, more or less perpendicular to the normal, but you get the point I hope)

tender edge
#

i think so, ill look some more into it. thanks for the suggestions and the help๐Ÿ™‚

amber saffron
#

In the case of your mesh, the tangents could all be easilly guessed from the normal.
If the normal is 1,0,0, the tangent is 0,0,1 for example

#

(or 0,0,-1 ... I always mess up the right or left hand rule)

tender edge
#

Well, if you use the position .XY, .XZ

bitter lily
#

hey guys i wanna create a game where the visuals are similiar to fall guys. notice how the mesh shines and looks kinda like a wet chewy bubblegum?? or more like a shiny colorful assets ? well how to create it?? i want my assets to look just like how fall guys assets are made.

amber saffron
vital token
#

I need a bit of help. I'm trying to get a fog of war like effect for my games map, but my current shader graph doesn't seem to be doing the trick and I don't know what else to add to it.
My biggest problem right now is that the fog just looks REALLY watered down. Like I want the fog to be thick.
I was thinking maybe adding tiles beneath these ones with the same shader but the fog has a different scale/offset,

I just tried it out and it gives a decent result. I might need to do 3 layers, but I was wondering if there's anything else I can do with my shadergraph to enhance the result.

ALSO, what could I do to make the fog move across all the tiles? Because currently you can focus on a dark spot in the noise on one tile and watch it just disappear as it gets to the end of the tile because the noise is basically a copy paste between all the tiles, same exact offsets

warm pulsar
#

I'm using the shader graph in an HDRP project. Unity isn't letting me change a property named _EmissionColor. If I change the name to _EmissionColor2, it works fine.

This seems a bit weird!

trail nymph
#

Heya, can someone help explain what's going on with the rendering order in my scene?

I have 5 "layers", just RawImages with a shader graph material attached. Queue Control on all of them is set to "Auto". I have a fish as another RawImage in the middle of all of them, and I'm expecting it to show up tinted green/blueish from the transparent images in front, however it doesn't render at all. I tried attaching a non-default material to the fish, in case that was the problem, but the result persisted.

I'm using URP if that changes anything.

vale spruce
#

urp or built in

#

which one easier

grizzled bolt
#

Only UI components can go on a Canvas, and their shaders must support UI rendering

#

Canvas components are depth-sorted by their hierarchy order

trail nymph
grizzled bolt
#

I'd try removing all Materials from the image components, to reset to using default shaders

#

Then at least the sorting should work as expected

trail nymph
#

I'm on 2021.3.16f, no option to update.

Not sure what you mean by "Only Canvas in Shader Graph"

trail nymph
trail nymph
grizzled bolt
trail nymph
#

Oh, that option in the dropdown does not exist in 2021.3.16f1

grizzled bolt
#

Indeed

trail nymph
#

Does that mean making shader graphs for UI is unsupported?

grizzled bolt
#

Officially

#

There might be some hacky ways to enable SGs for Canvases pre-2023

#

But if those don't work out, you'll have to abandon either SGs or Canvas in this case

trail nymph
#

.....how deligtful

grizzled bolt
#

But first of all verify that the shader is the problem by emptying the Material field of the image components

trail nymph
#

Huh yeah without the shader hiearchy changes the visibility

grizzled bolt
#

Something to try is to split the foreground and background into separate Canvases, with the fish in between on its own Canvas
Even if your custom shaders will break sorting within a Canvas, there's a change it'll still work between them

burnt crown
#

how would i make the firework effect here in URP shadergraph? it's not clicking for my brain

trail nymph
#

oh wait sorry took a sec to process the message

#

hold on lemme try

grizzled bolt
#

A Canvas is a mesh, once generated from its components

#

So kinda yea

#

Which is also why it requires special shaders within

trail nymph
#

It's so weird though, I was using Sprites earlier and they rendered as expected when set to Opaque, but had the same issue when switched to Transparent

grizzled bolt
#

Still best to research a bit if there's some other missing features or potential pitfalls to using the unsupported shader, and if there's something to remedy it

grizzled bolt
trail nymph
#

Incredible

#

Thanks so much for you help! I was at a complete loss here

grizzled bolt
grizzled bolt
# vale spruce which one easier

Ultimately it depends on what you intend to make
If URP doesn't support something, there's less resources about customizing it
But out of the box it has many tools that can speed up development like shader graph, vfx graph, 2d lighting and most importantly SRP Batching

#

Currently it has more features than BiRP, but is still missing support for a few very specific ones

grizzled bolt
burnt crown
#

yeah figured the rest. was only confused by the firework shape. was split between a spritesheet and polar coord manipulation

odd dagger
#

I need some help with a 2D shader. I wrote a very simple shader in accordance with a YT tutorial and it seems fine except for this weird translucent white box around the sprite

#

I tried to put it over a BG to illustrate the weird box. I can post the shader's code if needed

grizzled bolt
odd dagger
#

Hmmm well the background of the spritesheet seems to be fully transparent. Is it possible putting it into Unity caused something like that?

#

When I give it the normal sprite default material it doesn't have this issue

#

Should I share the code to see if it's the second suggestion?

grizzled bolt
odd dagger
#

URP and I tried to code this shader

#

I often use shader graph but I don't think it can do what I'm looking to use the shader for. But if it could that'd be amazing

grizzled bolt
#

Which is what?

odd dagger
#

Which is that I'd like to be able to build or find some kind of a template so I can easily make shaders that apply any blending mode I might need based on the calculations for them that I've learned

#

I'm not sure if shader graph can give a material itself a blend mode as opposed to using blend modes in nodes

#

Either way, this is the code

grizzled bolt
odd dagger
#

Well, I already have access to materials for additive and multiplicative blending

#

But I'm exploring what kinds of effects I can make so I felt like the best way to do it would be to do this so I theoretically have any of them at my disposal that I might need

#

It's a bullet hell game. I'm trying to create an effect for warning the player of a certain area that's about to be attacked. I tried using multiply but that doesn't work on dark backgrounds. Additive would run into a similar issue on light backgrounds. So maybe something like overlay would yield good results but really just being able to easily experiment would be massive

grizzled bolt
#

Overlay would be neat
I don't see what the issue could be in the shader since it looks like you're just directly using the texture color and alpha

odd dagger
#

Ok I'll try using the material on some other sprites and see what happens

#

Same sort of deal seems to be happening

#

Something isn't quite right with the alpha

#

If I put it on a blue fireball

#

Oh wait hang on I might have it

#

Changed Blend One OneMinusSrcAlpha to Blend SrcAlpha OneMinusSrcAlpha

#

It does indeed appear to work on any sprite

#

I get the feeling that's not everything and that the problem isn't truly solved by that but I'll just keep going and hopefully nothing new comes up

#

Thank you for your help

warm pulsar
#

I ran a build just a few hours ago. I'm running another build now, and it looks like all of my Shader Graph shaders are being recompiled -- I'm seeing zero cache hits in the editor logs.

I did switch from development mode to non development mode, but this still feels wrong..

#

It does look like I got hits on the next build (for macOS, after this most recent Windows build...)

tender edge
#

i've been thinking about how i could get some blending between my top and side faces for my procedural mesh, and i was wondering if it would be possible to do height based blending for every individual XZ's height? im currently storing that in an 3d array but dont know how to access those values from a shader

vital token
#

The video explains my problem and shows my current ShaderGraph, but incase you don't want to watch it.

My problem is that is there is no accompanying fog tile, my fog doesn't fade out as it gets closer to the edges, so you can see a sharp edge. I'd like to know if there's any way I can fix that.

Example: There are 4 fog tiles, bottom left, upper left, bottom right, upper right. The player explores the bottom left fog tile so it fades out and disappears. The player can easily see the edges of the rest of the fog tiles because the fog doesn't fade out as it gets closer to the edge where the explored fog tile was

#

Is the result I'm looking for even possible with a shadergraph?

pastel stratus
#

Hey so in my game I have a primarily rainy/wet environment, and I want my gun models and FPS arms to have raindrops on them and appear wet, does anyone know how i'd do this? (I am just assuming it would be a shader.)
(Something like the image is what I am going for)

shrewd plaza
# vital token The video explains my problem and shows my current ShaderGraph, but incase you d...

i can't give you a clear answer because im trying to make a fog of war myself right now but i saw a simmilar problem on a video but it's quite a long one i'll link it to you just in case it might help : https://youtu.be/Y7r5n5TsX_E?si=YJcFRA-KA-qGIz_y

Sign up via my link will get two FREE months of Skillshare Premium https://skl.sh/romanpapush
โ€”โ€”โ€”โ€”โ€”
#Update: Blender 2.8 is out! https://www.blender.org/
โ€”โ€”โ€”โ€”โ€”
Heyo my dudes!
I really hope you will enjoy this advanced tutorial for complete beginners!
By the end of this video you will master the Air-Bending techniques of the ancients and will le...

โ–ถ Play video
#

i also saw a lot of people using Gaussian blur

#

but not sure

#

sorry for not giving you a clear answer

vital token
tacit parcel
# vital token Anything helps at this point XD I tried finding an answer myself, but I haven't ...

ChatGPT SEEMED to know what it was doing, but it didn't help at all, as expected XD
Well, that's what chatGPT good at, it's good on making itself look smart XD
as for your problem, I can only think of some options

  • using autotile fog (not shader stuff actually), but you'll need to make fog 'tiles' for it
  • Or, render the fog to a rendertexture, then blur it, if you want to keep your scrolling fog unblurred, you need to blur only the fog tile and use it as masking for the scrolling fog
#

๐Ÿค” actually, you might not need to blur at all, just render the fog 'mask' at low resolution, and upscale it, as long as you dont use point filtering for the render texture, it should 'blur' it on upscale

shrewd plaza
#

did any one tried to upragade a shader from built in to urp by hand ?

vital token
#

I'm better at scripting than using shadergraphs lol

tender birch
#

I"m in the same Unity version across two projects. My shaders work in one, but i try to click and drag them over to the other proejct window, and they turn purple.

#

I don't know why it's doing this

kind juniper
pastel stratus
#

does anyone know how to make an easy wetness shader? I want to make rocks in my scene appear wet

#

if you respond please ping me ty ๐Ÿ™‚

smoky widget
#

Hey guys, I made this custom node called from_to_rotation imitating the unity built in function (using a method that works from git). It does exactly as I would expect, I have a lerp to interpolate between two normals and it rotates as expected

#

however, you can see how it's jarring

#

How could I add an offset/how could I calculate how much to move the ground position so that the circle doesn't look so suddent

#

instead of looking like A, it should look like B

#

Alright found the way, i just had to displace it by an amount of the vector

hearty obsidian
#

Hi, could someone explain to me what "eye" sampling in the scene depth shadergraph node means?

hearty obsidian
#

@regal stag Thanks, how does it differ from raw?

regal stag
grand jolt
jovial moon
#

What package should i include to use Linear01Depth() function in shader?

regal stag
chilly robin
#

What is the proper way to mix two smoothness maps together? Lerp just gives me a transition between the two. I think Adding is what I want, yeah?

regal stag
chilly robin
#

To be more descriptive, I have a base smoothness map for my rock, and a detail smoothness for when you're up close. I want to mix these, but without losing the information from the base smoothness.

jovial moon
regal stag
# jovial moon Urp

I think it should be auto included along with the main Core.hlsl one then. But for SRPs the function has an extra param, so use Linear01Depth(rawDepth, _ZBufferParams)

hearty obsidian
#

How do shore lines work broadly for water shaders?

#

Initially I thought they worked a bit like intersection effects based on depth but then the camera angle would affect the thickness of the shore line, and that doesn't seem to be how things work physically?

regal stag
hearty obsidian
#

@regal stag Okay, thanks again. I guess there is no method addressing this specific issue other than manually constructing a representation of the shore in a texture or something of the likes?

dim yoke
#

I have seen the depth texture been rendered from top down view prior to the actual water shader to get the actual depth but that will obviously have it's impact on performance

hearty obsidian
#

@dim yoke Thanks, any pointers towards the direction they took to achieve it? It's a small game, I may be able to get away with a large hit from water

dim yoke
dim yoke
hearty obsidian
#

Hm, stylized simple lines slowing slowly washing up the shore

#

problem is camera is orbital

dim yoke
hearty obsidian
#

Oh, so then by having that camera at a fixed angle, shore lines thickness would be consistent

#

Is that hte idea?

dim yoke
hearty obsidian
#

holy this guy has done work

dim yoke
#

It was actually something else that they used but I don't see why the idea wouldn't work. If you could prebake the depth texture in your modelling software (or in unity), it would be even better for performance thought in theory you would only need to render the depth texture once at the start of the game

hearty obsidian
#

Ah yeah now I get you. So basically every pixel on the texture points to a depth, which is the compared against sea level.

dim yoke
hearty obsidian
#

@dim yoke Well, here I go! Thanks for your help

pseudo wagon
#

How do I display the texture on the left of the text on a custom shader ?

round dome
#

what is this blue-ish shader?

#

and how can i remove it?

#

nevermind, it was due to the skybox

hexed sorrel
#

I understand this may be a very dumb question, but I am confused as to why this wouldn't be clipping the sprite, based on the "_UVOffset" variable which is being set through code, I have tried subtracting vector from the "Y" of the UV, and nothing seems to alter the sprite itself, I understand I am very likely being dumb but I cannot for the life of me seem to get it working, any help would be amazing! Thanks.

#

the intended outcome is having the sprite shown below, update it's visible "height" based on the "fill" parameter I have set via code, I am currently setting it as follows:

#

liquidInstance.GetComponent<SpriteRenderer>().material.SetVector("_UVOffset", new Vector2(0f, 1f - (liquidHeight / 16f)));

^ my tile is 16x16, and "liquidHeight" is an int of how many pixels tall the tile should be, so / 16f is a normalized value which can be used as a Vector for UV, (in theory).

regal stag
# hexed sorrel I understand this may be a very dumb question, but I am confused as to why this ...

Offsetting will cause the texture to be sampled outside the 0-1 range, but that doesn't mean it'll clip pixels or make them transparent. It'll either tile/repeat the texture or clamp to the same pixel colour at the 0/1 edge - depends on the texture's wrap mode. Though for a full blue texture the outcome is the same.

For a height/fill, it's likely you'd want to Step using the UV node and the height value and use that as the alpha output

hexed sorrel
regal stag
# hexed sorrel

Also for future reference, putting a property into the UV port on a Sample Texture 2D doesn't offset it, but overrides every pixel to use that coordinate. You'd use a Tiling And Offset node to apply an offset

hexed sorrel
regal stag
#

Yea that way works too, though bit more wires to deal with

hexed sorrel
#

From what I've tried the output is clear which I assume means the Step is outputting 0, is there possibly something I am missing?

regal stag
#

I'd probably split and only use Y axis

hexed sorrel
# hexed sorrel

This is plugged directly into the "Alpha" output of the "Sprite Lit" shader graph.

hexed sorrel
hexed sorrel
# regal stag I'd probably split and only use Y axis

Hmm, still no dice unfortunately. The closest output was a small sliver was shown when the "fill" of the tile was 1, but it would disappear at any value lower. For simplicity I have converted the Vector 2 to a float, and I am either constantly getting a "filled" tile or a completely blank invisible one, should my float be normalized to for example 0.5f/1f if I wanted half of the sprite visible?

hexed sorrel
regal stag
regal stag
# hexed sorrel

It won't change the output as it's truncating down anyway, but I'd split the UV to only the G/Y axis as well

hexed sorrel
regal stag
hexed sorrel
#

Still no dice, but just for future reference the shader graph separates each pixel in the UV separately, so having a step node would be "pixel based" and not alpha for the entire UV? Because if the step node is always outputting 0, or 1 I'd assume if that weren't the case I would either get a "filled" tile or an empty one?

hexed sorrel
hexed sorrel
regal stag
#

Maybe try it without the property and just hard code 0.5? I'm not sure why it wouldn't be working

hexed sorrel
#

Ah, I figured it out. I have two liquid creation scripts so it was only working for the falling liquid creation!

elfin token
#

How to make a water like distortion shader?

#

Via visual studio (not shader graph)

hexed sorrel
#

If you want to learn about shaders I'd look into getting to know HLSL syntax and starting there, if you want to have player movement affect it I'd recommend looking into emitters and how to utilize them while making shaders.

proven glacier
#

Anyone on here familiar with custom pass volumes? Specifically I have a bunch of objects on an interactable layer that I have a selection shader for, and I only want it to render on that one specific object when the mouse hovers over it. I just cant figure out how to mask out all the other objects to only render the shader on that specific one when the cursor is over it.

hexed sorrel
#

When I get home I'll link a good video which may help push you in the right direction.

elfin token
hexed sorrel
flint yew
#

u can basically copy this approach

#

use a โ€œselectedโ€ layer

proven glacier
# flint yew use a โ€œselectedโ€ layer

So I have the selected layer I want, the problem I'm running into is its rendering over all those objects in the layer. Essentially its a selection effect, and I just want it to render over the one object when the cursor is over it and I want to mask out all the others that are on that same layer, but I still want them to render. So I'm wondering if there is a way to do that without having to turn on and off the custom pass.

harsh marsh
#

Trying to write a compute shader for frustum culling. Arkano on the unity forums described a pretty simple method but I'm having trouble implementing it. Does anyone know of any examples online (github repos, etc) of this method for frustum culling? All I can find is examples of GPU frustum culling that uses parallel prefix sum which is a pretty complicated algorithm that I just can't wrap my head around.

proven glacier
# flint yew u can basically copy this approach

So I have everything on the layer I want it to render on, my problem is I only want it to render on the exact object I have set to that layer when my cursor is over it. And that's the problem I'm having. I have no way to reference the specific game object if it's a part of that layer and set the custom pass to only render on that specific object in the scene.

brisk totem
#

Anyone have a good tutorial for water shaders?

quaint grotto
#

if i have an object with many child objects of different materials how can i greyscale the whole heirarchy from the parent down with some shader that replaces the child materials but the issue is if i need to no longer be greyscale i need to re-apply the previous materials it currently seems very tedious to go throug them all swap the material and store what the previous material was, or give all of them a custom mader shader which has its own problems too

dim yoke
# harsh marsh Trying to write a compute shader for frustum culling. Arkano on the unity forums...

Correct me if I'm wrong but to me it seems what arkano is suggesting is to use InterlockedAdd in order to calculate the prefix sum sequentially. The problem with that is that GPUs are designed to to do extremely parallel work and therefore a question arises: why not do the work in CPU if you are doing it sequentially anyway? Unfortunately in order to do frustum culling, you must calculate the prefix sum and parallel algorithm is the only way to make it extremely fast whether you like it or not. To me the Hillis Steele scan doesn't look easy per say but not too bad either. Maybe the best resource I could find on it was this slideshow https://people.cs.pitt.edu/~bmills/docs/teaching/cs1645/lecture_scan.pdf. Is there some specific part of the Hillis Steele implementation that you are specifically unsure about?

vague spade
#

hey, chatGPT created a shader and material that basically change all of the tilemap colors to gray, but the lightning doesn't work after that, how can I fix it?

code to shader: https://gdl.space/ixamigidig.cs

pseudo wagon
#

I assigned a normal map in the vertex shader, but when I access the "normal" property in the fragment shader, I still get the default normal of the mesh. Is that expected behaviour ?

#

Not sure what is wrong, should I also assign the tangent ?

dim yoke
pseudo wagon
#

The block called "normal vector"

#

Or more specifically, getting the view direction in tangent space

dim yoke
# pseudo wagon The block called "normal vector"

Oh you meant assigning the normal map in vertex shader, I see now. I'm pretty sure it should change accordingly. Does setting the normal have any effect otherwise? What type of normal map is that?

pseudo wagon
#

Aaaah I edited fragment to vertex but I changed the wrong one >.<"

#

I think I got the issue, the vertex shader is only evaluated for each vertex insead of each pixel, so the details of the normal map don't carry over

dim yoke
pseudo wagon
#

Then, when I get a vector in tangent space, how do have that tengent space be affected by the normal map ?

jovial moon
#

what is the alternative for shaderGraph node "IsFrontFace" in hlsl unity shader (URP)?

regal stag
jovial moon
regal stag
#

It's set automatically yes (probably not Unity but by the graphics API)

jovial moon
dim yoke
harsh marsh
#

Trying to debug a compute shader using unity's renderdoc thingy. How can I see the contents of a compute buffer from within renderdoc?

#

I can see the dispatch calls but I can't seem to figure out how to see the data of the compute buffers

frigid jay
#

@harsh marsh

harsh marsh
#

How would I get translation/position from a TRS matrix in a compute shader that is made like this on the CPU:

TRS = Matrix4x4.TRS(
    vertex, 
    Quaternion.identity,
    Vector3.one
)
dim yoke
harsh marsh
#

thanks!

#

Having a weird issue with my culling. Is there anything that I could be doing wrong from just this gif?

#

there's a lot of code (nearly 1000) to deal with this so it's not very easy to post my code atm

elfin token
#

hum guys i have a shader that seem to work in editor but when i enter play mode it stops working, how can i paste it here so you can check it?

elfin token
harsh marsh
#

arkano states that it may be caused by the fact there's no check to make sure id.x is within the range of valid date

#

but I'm not entirely sure how I would do that.

elfin token
#

@hexed sorrel how can i paste something ina kind of grey square? like for code

harsh marsh
# harsh marsh Having a weird issue with my culling. Is there anything that I could be doing wr...

https://gist.github.com/BradFitz66/0066d105e9b4e003f8c9b6049d393433 Attempted to do bounds checking for id.x but it didn't seem to work. Here's all the relevant code that I feel like I can share (this is modifications to a paid asset so I'm only really comfortable posting code that is mostly my own and not part of the paid asset)

Gist

GitHub Gist: instantly share code, notes, and snippets.

#

includes:

  • Entire ComputeShader
  • When the ComputeShader is ran, just before DrawMeshInstancedIndirect is called
  • Code for setting up the ComputeShader's buffers and their data.
echo moatBOT
harsh marsh
#

Stil having issues. I've gone and replaced the compute shader and it's initialization with the exact code Acerola used in their project, but I'm still getting these artifacts.

#

Another thing I've noticed is that it doesn't work with an orthographic camera at all. I assume I have to do something different here?

//Calculate VP of camera before sending it to compute shader to determine if a point is within view
Matrix4x4 P = Camera.main.projectionMatrix;
Matrix4x4 V = Camera.main.transform.worldToLocalMatrix;

Matrix4x4 VP = P * V;

or here?

    //Vote on whether or not a grass blade is within view of camera.
    float4 position = float4(_GrassDataBuffer[id.x].TRS._m03_m13_m23, 1.0f);
    
    float4 viewspace = mul(MATRIX_VP, position);

    float3 clipspace = viewspace.xyz;
    clipspace /= -viewspace.w;

    clipspace.x = clipspace.x / 2.0f + 0.5f;
    clipspace.y = clipspace.y / 2.0f + 0.5f;
    clipspace.z = -viewspace.w;

    bool inView = clipspace.x < -0.2f || clipspace.x > 1.2f || clipspace.z <= -0.1f ? 0 : 1;
    bool withinDistance = distance(_CameraPosition, position.xyz) < _Distance;
#

I'd appreciate any help since I'm way out of my depth here.

sand hatch
#

I don't think I understand

#

Why does my shader still show like it's the basic one in the preview?

viscid knoll
#

because the preview of the scene color is grey

sand hatch
#

Oh, that makes a lot of sense now that I think about it

#

Also, dunno if I can ask this but

#

where can I find some 3D noise?

viscid knoll
sand hatch
grizzled bolt
sand hatch
#

The problem I have is that I need the noise as a 3D texture, not as pure 3D noise

#

How can I convert 3D noise into a 3D texture?

harsh marsh
#

My only issue with that theory is that its the exact same as Acerola's code and they didnt have this issue in their video

#

But they also had a chunking system that was culling chunks on the CPU so maybe that hid the issue?

#

The bigger problem for me is that orthographic cameras dont work and my game uses orthographic cameras

elfin token
echo moatBOT
elfin token
#

oopsie

harsh marsh
#

Do I need to do anything different for the camera MVP if I'm using an orthographic camera?

harsh marsh
#

Have I not given enough info?

sand hatch
#

I've no idea what I'm doing wrong

#

Why can't I assign a value to this float?

tame topaz
#

Where are you expecting to assign a value to it?

sand hatch
#

Turns out Unity staight up wouldn't open the graph inspector

#

I had to restart the editor

white acorn
#

crossposting [this question](#archived-urp message) here for better visibility. hope that's not deemed spam... I'm not sure which channel is more suitable for such URP-meets-shaders questions ๐Ÿ˜›

short pier
#

hi, anyone know how what I'm doing wrong with this shader? It appears to be custom-made for one specific type of object (right), how do I apply it to other objects?

vagrant dagger
#

Could someone please share a screenshot of a Shader Graph using the URP Triplaner node

vagrant dagger
amber saffron
# short pier

It seems to start to do the effect on th left sphere.
Maybe you just need to tweak some parameters ?

short pier
#

the shader effect works but it has this packaged in 3d model

dim yoke
tacit parcel
vital token
#

I have 3 cloud sprites, and I want to apply a shader to them. Currently I just want a noise that moves across the image, and then maybe distort the clouds in a way to make them seem like they're "floating" in a way. But what I'm finding right now is applying a noise effect to the entire image, even the pixels that are supposed to be transparent. How could I get around this?
It seems I'm horrible at finding solutions on the internet because the way I'm wording my problem is not resulting in anything related to it XD

amber saffron
vital token
grizzled bolt
amber saffron
vital token
amber saffron
cyan maple
#

hey guys, does anybody know why my alpha clipping thing isn't working?

#

I'm not very good at shadergraph but I think it's set up right in the preview ๐Ÿซ 

regal stag
# cyan maple

Try unconnecting from Alpha Clip Threshold and set that at 0.5

cyan maple
#

same problem

#

manually setting alpha clip doesn't change the preview

amber saffron
#

Is alpha clip also enabled on the material ?

sudden spear
#

Hello !
I noticed all my meshes have indices like [0, 1, 2, 3, ...] because each triangle needs its own 3 vertices and I add them in the correct order.
Is there any way to get rid of this useless buffer and to only keep the vertices buffer ? (I guess it could be faster ? )

#

I use the advanced mesh API with SetVertexBufferData, SetVertexBufferParams, ...

cyan maple
#

is there another material tab somewhere I should be looking at?

regal stag
cyan maple
#

yeah I

#

it's a VFX graph thing

#

let me see

#

I think it is supposed to read from the shader

#

if I remove the shader graph from the output the alpha clipping and all the other options come back

#

(in vfx graph)

#

the trails seem to look better in scene view

#

but still not getting that alpha clip I'm looking for

cyan maple
low lichen
sudden spear
tired verge
#

Hi all! Is it possible in unity urp to write a fragment shader which doesn't return a float but a specific datatype like a uint16. I know, it may not make any kind of sense. But is it technically possible when I write a simple shader pass or do I need to define a custom rendering pipeline from the ground I?

tired verge
#

I mean I would write a fragment shader which returns uint and put it into a custom rendering buffer. Then could Unity visualize it?

rugged fjord
#

i didn't see a material help channel so i guess this belongs here. i have this transparent material trying to make it look like dark glass or like a crystal, but i can't see the back of the object through the front i just see right through it

rugged fjord
#

how come i only have 5 types of shaders to add but none of the graphs the guy has in the tutorial i'm following?

sand hatch
#

Is there any way to turn black textures into alpha? Like, I want to convert the level of "whiteness" of a texture into level of alpha

grizzled bolt
uneven sinew
smoky widget
#

Is there any way for me to get the maximum allowed thread group beforehand?

low lichen
smoky widget
#

I see, okay

#

Also, is there any way to divide two long values so that it ceils instead of flooring the value?

#

Ah using the systen.math.ceiling and working with doubles

smoky widget
smoky widget
#

That's what I tried but got 32

#

no worries, Im just gonna stay to 256 and use that as a boundary

cyan maple
#

does anybody know how I can edit that vfx asset?

sacred jewel
#

Yo can someone help me out with fixing my shader. I've copied one from a unity 2017 tutorial and made the changes suggested by the unity manuals to make it work for unity 6 (or at least work for the URP) however apparently the surface shader can't be used for vertex displacement. Does anyone know how to fix it? Before changing it all to use the URP syntax it shows the mesh displacement working when in wire frame shaded, however it's stuck on the missing texture pink. But if I change it it stays on default white and doesn't do anything.

#

If it's easier please feel free to dm and I can share the code I have there

silk sky
#

Question about shaders and theyr performance impact, I've set up a shader that is something like an abstract screensaver, its animated and seamless.
I've made up 7 different version of them by just chaning up the value of the variables.
Currently when I need to change from one to another I use the same material and change the values stored in the script.
In terms of performances is it lighter in this way or by just creating 7 different materials for every combination that gets swapped it via when the event is raised?

#

Here's an example, since when changing from one to other I fade everything to black, I can potentially swap the material

cyan apex
#

hey guys bit of a noob here - just comparing preview to play mode and i see there are white dots on the model... is this due to the mesh / texture not being properly alinged ?

elfin bison
#

Hello i create an underwater game but i want to have fade of black here but i can't find how i can do that if anybody have idea , thank a lot ๐Ÿ˜‰

regal stag
regal stag
tired verge
# grizzled bolt Why uint16?

I would like to use another datatype, namely bfloat. My hardware not supports it, however I believe it is possible to emulate somehow.

grizzled bolt
#

The context may be important

grizzled bolt
cyan apex
#

Gotcha - these models are exported from BlockBench so Im' guessing the texturing / uv is the issue

#

Yup looks like the UV's are jammed up too close - moved some stuff quickly to see and you can see the difference, much thanks!

vague pilot
#

hey, i created a custom renderer-feature and a render-pass (see link) in the render pass execute method im bliting the cameraColor texture onto a texture, that is defined in the pass by using a material. then this texture that is being modified by the material (and its shader) is blited back to the cameraColorTarget-thing. (Is this correct?) And how to reference this texture handle that i created in the render-pass in shadergraph to modify it? https://pastebin.com/yAQKnnrP

sacred jewel
silk sky
#

I'm trying to use this shader but it stretches really badly when on an object that is not flat, is there a way flatted the objcet uv based on the camera view so the shader will loke more like the one on plane? This object and its camera will never move in the scene so that will not be an issue...

low lichen
#

But basically, you take the Screen Position, offset it by the screen position of the object's center and then scale it by the screen-size of the object. That last bit is the difficult bit, figuring out how big the object is in screen space.

#

If you know the object is always going to be a sphere, you can calculate it manually in the shader. Otherwise, you probably need to use the object's bounds and calculate the screen positions of the corners or edges to get the screen bounds.

silk sky
regal stag
silk sky
#

I've tried thtis butt it unfortunately denatures the rest of the shader ๐Ÿ˜

tired verge
silk sky
#

Just to be sure, is this the right spot to insert the screen pos node?

#

is it where the old UV node was

regal stag
#

Hmmm yeah, but maybe you want to override the UV0 on the Tiling And Offset nodes too with that

#

May also still want to use these groups too

silk sky
#

Mhh maybe adding it also to tiling and offset solved the problem

#

it a bit tricky since the effect is a bit abstract its hard to figure out if is the result is the one I was looking for ๐Ÿ˜…

silk sky
#

Let me simplify it: Source-wise, is it ok to run 2 shaders in one and switching from one to another by a lerp or is it better to have 2 separate shaders anche swapping it via code?

grizzled bolt
silk sky
grizzled bolt
silk sky
grizzled bolt
#

Unless there's some runtime shader variant thing to prevent it that I don't fully understand

shrewd geode
#

Hey. I'm trying to transform a Shader Graph shader used for billboarding sprites towards the camera to HLSL code.

I've attached the shader graph in an image, and the HLSL code in a file.

I am getting a syntax error in my HLSL code because I'm not sure how to convert the Transformation Matrix to HLSL:

regal stag
# shrewd geode Hey. I'm trying to transform a Shader Graph shader used for billboarding sprites...

The transformation matrix for InverseView should be something like UNITY_MATRIX_I_V rather than a property.

Though you might be able to use a slightly different method. Graphs use the inverse view as the Position port is expected in object space, while vertex shaders can output directly to clip - might be cheaper

float3 vpos = mul((float3x3)unity_ObjectToWorld, v.vertex.xyz);
float4 worldCoord = float4(unity_ObjectToWorld._m03, unity_ObjectToWorld._m13, unity_ObjectToWorld._m23, 1);
float4 viewPos = mul(UNITY_MATRIX_V, worldCoord) + float4(vpos, 0);
o.pos = mul(UNITY_MATRIX_P, viewPos);

(From https://gist.github.com/kaiware007/8ebad2d28638ff83b6b74970a4f70c9a)

quick sonnet
#

I am trying to make a transparent unlit shader in URP, but when I set the surface type to transparent and the alpha to 1 it is still completely transparent. It shows an opaque preview but when I put it on an object it is invisible, which makes no sense. Does anyone know why this might be happening?

regal stag
quick sonnet
#

my post processing is a full screen pass renderer feature

#

also just checked and transparent layer mask is set to everything so its this for sure

regal stag
#

I guess you could also remove all layers from the Transparent Layer Mask and use a RenderObjects in After Rendering Post Processing to render them all. But that's a bit messy imo

quick sonnet
#

oh I fixed it, there is an option for before rendering transparents. Thanks

regal stag
#

Ah good, wasn't sure if it was limited to later events

quick sonnet
#

yeah, if it was anything complicated like that I think I would have been out of luck lol. The rendering and shading stuff is so complicated, I just started learning it recently

dark flare
#

Question about shaders and theyr

mellow hare
#

hey guys what shader would you recommend for high performance on mobile? i used unity's built in mobile shader thinking it was the best in terms of performance but it doesn't receive realtime lighting and that's a dealbreaker for me. the perfect shader for me would be a simple diffuse shader which receives realtime lights. any recommendation is welcome.

lean shuttle
#

im pretty newbie when it comes to shaders, how can I make it so the pixels in my censor shader will scale based on distance?

#

because when you are too close the detail is too high and when you are too far the detail is too low

broken vigil
#

This line took four hours to create...

#

I managed to code a shader that takes in two points and draws a pixel perfect line between them. Now the next step is... Making it actually useful. I think what I need to do is make this code somehow access the screen size, and somehow use that to render its pixels???

Anyone who wants to help, I have a unity package with the work I've done so far.

#

Right now, the line is drawn in the texture space of the object using the material, but ideally, it would render to something like a quad in the scene, and somehow take the main camera and use that as a reference to draw it "right"

white acorn
vague pilot
#

hey, i created a custom renderer-feature and a render-pass (see link) in the render pass execute method im bliting the cameraColor texture onto a texture, that is defined in the pass by using a material. then this texture that is being modified by the material (and its shader) is blited back to the cameraColorTarget-thing. (Is this correct?) And how to reference this texture handle that i created in the render-pass in shadergraph to modify it? https://pastebin.com/yAQKnnrP

somber zenith
#

Hello, I'm trying to enable GPU Instancing on a HDRP project without success, the shader graph and material inspectors are greyed out. How could I enable it?

amber saffron
somber zenith
amber saffron
#

The SRP batcher basically takes over previous unity batches optimisation (dynamic batching and auto GPU instancing).
Enabling GPU instancing on a material in HDRP is usefull if you are manually drawing instances using the Graphics API

somber zenith
amber saffron
somber zenith
marble anchor
#

Is that possible to render a color based on dest color without using the GrabPass?

So I have a map which has color1 and a background with color2. I want to do next: if geometry is on color1 than render color2 and vice versa.

regal stag
# marble anchor Is that possible to render a color based on dest color without using the GrabPas...

If you don't want grabpass (or a similar custom texture), I think the only other way would be Blending commands.
https://docs.unity3d.com/Manual/SL-Blend.html
https://docs.unity3d.com/Manual/SL-BlendOp.html
Probably won't work with specific colours, but you could use black/white and apply an image effect to swap those out for actual colours later.
Haven't tried it but the BlendOp LogicalInvert sounds cool, assuming the target platform can support it. Otherwise Blend OneMinusDstColor OneMinusSrcColor might work, based on : https://forum.unity.com/threads/invert-colors-shader.205244/

marble anchor
#

But the idea of using post processing after inversion ๐Ÿ‘

#

Thanks

mental bone
#

I'm trying to create a rather simple fog shader using the Full Screen Pass Renderer Feature and I'm trying to emulate how the default cubemap skybox shader does exposure, however at a value of 1 my sky is completely overblown.

#

Or I'm completly missing the point on how to blend the skybox with a simple exponential fog

#

Also there appears to be a rather big difference between the scene and game view when it comes to the density

low lichen
mental bone
#

I am not. I dont understand what the decode instructions do ```// Decodes HDR textures
// handles dLDR, RGBM formats
inline half3 DecodeHDR (half4 data, half4 decodeInstructions)
{
// Take into account texture alpha if decodeInstructions.w is true(the alpha value affects the RGB channels)
half alpha = decodeInstructions.w * (data.a - 1.0) + 1.0;

// If Linear mode is not supported we can skip exponent part
#if defined(UNITY_COLORSPACE_GAMMA)
    return (decodeInstructions.x * alpha) * data.rgb;
#else
#   if defined(UNITY_USE_NATIVE_HDR)
        return decodeInstructions.x * data.rgb; // Multiplier for future HDRI relative to absolute conversion.
#   else
        return (decodeInstructions.x * pow(alpha, decodeInstructions.y)) * data.rgb;
#   endif
#endif

}``` this is the code that decodes it

#

in the skybox shader half4 _Tex_HDR; is simply declared and never filled with anything

low lichen
# mental bone I am not. I dont understand what the decode instructions do ```// Decodes HDR te...

If your texture format is already HDR, you don't need to decode it. You only need to decode it if it's encoded using dLDR og RGBM. dLDR means the values are saved at half their intensity to fit into a normal LDR texture, and the shader is supposed to multiply by 2 to get the real values. RGBM is similar, but instead of a hardcoded 2 as multiplier, the multiplier gets stored in the alpha channel as M for magnitude.

#

This sort of encoding is more common on mobile platforms, where HDR texture support can be missing or slower on some low end devices.

mental bone
#

As it happens this is intended for a mobile platform. But I cant figure out if it is RGBM or dLDR or what ever

modest wasp
#

what does this do ColorMask[_LightLayersMaskBuffer4] 4 as it fails unity 6 hdrp when on older hdrp it worked

low lichen
mental bone
#

Cause it does not in shadergraph

low lichen
mental bone
#

it does not let me just do a half4 _Cubemap_HDR; in the custom funtion it says it is not initialized.

low lichen
low lichen
keen thorn
#

On Blender I see for a material there is a checkbox for "backface culling" which stops rendering the opposite side of faces.
I also see a checkbox for "Show backface", which does something I don't know how to describe so I have attached a screenshot where the left side has it enabled and right side has it disabled.

I know in unity I can enable/disable culling in a shader. Is there an equivalent option I can enable/disable in a shader that corresponds to what blender's "Show backface" checkbox seems to do, based on the screenshot?

rare perch
#

Hello, I'm rather new to unity shaders but I'm curious about something. I wanted to implement a simple gaussian blur effect to an image and I understand the process is to convolve each kernel in an image with a given matrix in order to achieve the effect. I'm trying to understand how I would do this process efficiently

steel notch
#

Looking to replicate this effect. Any tips?

#

Specifically the wispy line between the two planets.

#

Seems like a line renderer with a reduced width in the center.

wintry mauve
grizzled bolt
grizzled bolt
#

Stretching could be accomplished with a skinned mesh renderer or a vertex shader

steel notch
#

Maybe even a third in there for that spike.

grizzled bolt
tired skiff
#

sorry wrong conversation it was for a particle system. anyway could be helpfull for shaders too!

neon gale
#

Shader Graph 'compiles' down to HLSL right? So, there is no reason that i should assume ShaderGraph is inherently slower than typed HLSL

tacit parcel
broken vigil
#

https://hastebin.com/share/zudopixehi.cpp

Can someone help me? I'm having trouble with this shader I'm writing, specifically, I'm having trouble getting the top and bottom of an object, then converting those points into points in screenspace.

#

The idea with this shader is that, if you put it on a flat plane, it will draw a line from the top of the plane to the bottom, converted into Screenspace coordinates.

pseudo meadow
#

Hello all!
Can someone explain to me, how does the Texture Size Node currently work in shadergraph?
For example, documentation says for "Width" port: "The width of the Texture 2D asset in texels.".
But it seems to always return 1. I tried using 64x64 and 128x128 sized textures and there was no difference.

Also "Texel Width" seems to return the size in pixels also return 1 no matter what.

So how do I now get the actual texel/pixel size in UV units?
It worked differently some time ago.

I am confused. Am I missing something?

pseudo meadow
tacit parcel
tacit parcel
#

And it seems that they rename the node from Texel Size to Texture Size? I wonder why? ๐Ÿค”

pseudo meadow
#

Yes, that's how it should be, how I understood it from documentation.
But it doesn't work that way for me currently..
Texture Size Width just returns 1 no matter what. Same with Texel Size.

#

These two work identically

#

Which is the same as

#

Idk how to get texel size/ texture size currently. Is this node broken?

#

I tried this is in Unity 2023.1 and the latest versions of Unity 6 as well.

untold otter
#

anyone know if canvas shaders support emission in hdrp? im not getting anything with a basic example

#

https://www.youtube.com/watch?v=6faMCg6oohc this video seems like it works but i dont think its using HDRP

Hj

In Unity 2023.2, a dedicated UI shader called Canvas Shader will be available in the Shader Graph. I briefly tested it in the beta version and would like to share the results in this video. You can check what has been improved, how does it work, and how to use it.

00:19 Introduction
01:10 Shader Graph Problems in UGUI
03:58 Canvas Shader
08:34...

โ–ถ Play video
untold otter
#

figured it out

#

didnt watch the video close enough, canvas has to be in camera space

fair wadi
#

i made a simple billboard shader for my LoD trees, the textures all have the same color but as you can see, they all have different shades, why is that?

regal stag
fair wadi
fossil cloak
#

Hey, im using a subshader inside my shadergraph shader and want to access the subshader via code to edit a color i am using in the subgraph.
Is it possible to adjust values in a subgraph via script or do i have to add a property in the main shader (which i edit via script) and plug it into the subgraph?

regal stag
mental bone
lapis oar
#

hey everyone, i'm working on a chunk lighting system for a mod of a game that was made in unity and i have a few questions. Disclaimer, i am NOT using shader graph. up until now, i've been using scripts to assign material instances to different cells, but i've been wondering, is there was a way i could get the nearest cell with a CellLight component attached to it via my custom shader?

broken vigil
#

Can anyone here tell me where I'm going wrong?

https://hastebin.com/share/ofowacayod.cpp

For some reason, this shader, intended to be used on a Fullscreen render pass feature, is blurring the screen, no matter what I do.

regal stag
broken vigil
#

Is there a good way I can find this stuff? I'm having a really hard time finding any resources I can use.

Right now, I'm struggling to figure out how to make this script do some stuff to the pixel's depth.

broken vigil
#

https://hastebin.com/share/ogihawelag.cpp

Okay, so, I've managed to get the post-processing shader to draw a line, now I'm trying to make that line have a depth value, and clip into and out of the world, by adjusting the depth value of the pixels being rendered in the line

#

I'm not sure it's working, though, since adjusting the depth values never makes the line disappear

chilly robin
#

Going through Unity's new production ready shaders, I saw this keyword for applying feature only to LOD0

#

How does this work? I'm not seeing any differences with any of the other LODs

broken vigil
#

https://hastebin.com/share/oziwivigej.cpp

(Spoilered due to flashing)

So, I have the setup... Mostly working, but I'm having an issue where the depth checking for the line seems to be behaving EXTREMELY erratically, and I have no clue why or what might be causing it.

I'm basically trying to sample the render texture that my camera is rendering to, and use that to determine if the line should be drawn or not.

broken vigil
#

I think what's happening is, the render texture I'm providing isn't actually letting me access the Depth Texture embedded in it?

#

Like, the render texture HAS depth, but I don't know how to access it.

flint yew
#

iโ€™ve struggled with that too

#

but it is possible

#

:/

wild grove
#

How do you go about rotating a mesh with a surf shader?

grand jolt
#

so im trying to like create this blob texture but i dont really know the way to blend this seam to make a seamless texture or shader sort of thing

chilly robin
#

Does anyone know why I get a null exception error when I try to convert some nodes to sub-graph?

kind juniper
halcyon panther
# grand jolt so im trying to like create this blob texture but i dont really know the way to ...

You need to either use a shader or make a shader that remaps the uv coordinates of the texture to that of a sphere.

If you want to try making your own...
First, wide picture is how you can do it in shader graph. The Texture field of the two Calculate Level of Detail Texture 2D nodes is your main texture, whichever texture you are applying to your object. From that final Minimum node, connect it to either the Base Color or the Emission of your Fragment shader.

grand jolt
#

i mean my texture is already complicated enough lmao

halcyon panther
#

I just also have some other stuff going on there, hence the extra blue lines coming out of the final Minimum node to the right.

grand jolt
#

oh ok thanks loll

waxen grove
marble anchor
#

I want to make a full screen vfx like in the image I attached. It has to be animated: start crashing white with black color until it is completely black. Doing it with sprites would decrease game's performance. Maybe some shader exists which can solve my issue?

dusk lily
#

how do I make my character show up in the mirror

karmic hatch
karmic hatch
raw cliff
#

Sup. Can you tell if SOLID principle applies to shaders? I'm thinking if i should make master-shader with togglable dissolve, parallax, self-illumination etc. for 90% of surfaces, or is it a bad idea?

jovial moon
#

How to Acces _MainLightPosition (Like in URP) in HDRP custom hlsl shader?

hexed sorrel
#

Hey! I'm having a peculiar issue while working with a custom render pass,

public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get();
            using (new ProfilingScope(cmd, _profilingSampler))
            {
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                SortingCriteria sortingCriteria = SortingCriteria.CommonTransparent;
                DrawingSettings drawingSettings = CreateDrawingSettings(shaderTagsList2, ref renderingData, sortingCriteria);

                // draw output of lightMaskMAT to rtMaskedLightTexture ?

                liquidSettings.liquidPassMAT.SetTexture("_LiquidMaskTexture", globalLiquidMask);

                Blit(cmd, rtGlobalShadedLiquid, rtGlobalShadedLiquid, liquidSettings.liquidPassMAT, 0);

                //context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
                cmd.SetGlobalTexture("_GlobalShadedLiquidTexture", rtGlobalShadedLiquid);
            }
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }

In my "Blit" my intended output is an identical output to the above "_LiquidMaskTexture" (for testing purposes), and while checking the frame debugger I can see that it is indeed sampling correctly however, the output is always whatever I set here above: "ConfigureClear(ClearFlag.Color, Color.white);", my shader/ liquidPassMAT is a texture2D which simply grabs the _LiquidMaskTexture and samples it directly to the material output. Any ideas would be extremely appreciated as this issue is preventing me making any actual progress on my water shader, haha!

hexed sorrel
#

Here I can see the global texture is being properly set, however the output remains blank.

hexed sorrel
hexed sorrel
#

On the only pass that I am having issues with I am also noticing that the "Format" is set to "None" which to my understanding means it isn't interpreting any data being passed through the blit?

hexed sorrel
#

I swear every time I make a new shader I find myself facing a strange hard to diagnose issue it seems haha.

#

The strangest part is that the code works perfectly fine in another renderer feature I've created prior, everything in seemingly the exact same order of what has worked prior. I can only assume it is a problem outside of the shader itself somehow, but the material is set properly in the inspector, I've tried many diagnosing methods (debug logging, changing the clear color (which changed the blank output's color leaving me to believe it's a blit issue), reshuffling the order and clear amounts, changing the SetTexture names, using the global texture directly from the prior pass, and likely more I can't remember off the top of my head). I've been trying to debug this for a few hours now and no dice unfortunately!

regal stag
#

@hexed sorrel don't really have time to go through this completely, but I can see _Depth after the RenderTarget name in the debugger, if you meant it to be a color target make sure you set the depthBufferBits = 0 on the descriptor before allocating the RTHandle

#

Also if you have another RTHandle you can just pass that as the source of the blit and use the URP Sample Buffer node instead of using a global texture property

hexed sorrel
hexed sorrel
regal stag
#

If it's a separate feature not really (AllocateIfNeeded can kinda grab it again if everything is the same, but not ideal), but multiple passes in one you should be able to pass a reference

hexed sorrel
#

Actually I suppose I don't necessarily need two passes either, if I were to just grab the HTHandle and adjust it in one pass.

#

I'll definitely try that whenever I wake up, I've been up now for almost an entire day and should probably get some sleep haha! I really appreciate the suggestions though, I'll be sure to let you know if they work! Thanks a lot. ๐Ÿซ‚

lean lotus
#

Hey so I have a big issue with shader compilation that I was wondering if anyone else knew how to solve
In image 1, heres the error
Globaldefines is an include file
but when I go to GlobalDefines.cginc, I dont see any issue?
Reimporting the original file(RayGenKernels.compute) fixes it, but as soon as I change something else in the include file it breaks again
This would be fine if its just one file, but I have 13 files that have the exact same issue
what do I do?
The way Ive fixed it in the past is to create an entire new file for each of the affected files, manually copy the code from old to new, and delete the old file, but this keeps happening
restarting unity or my pc doesnt fix it either

wild grove
#

I have a surface shader that I need modified to first mess with things in the object space before it does anything in the clip space. How should a shader of that type be structured?

jovial moon
#

how must hlsl shader in FullScreen Pass Render Feature URP look like? Please, tell me where i can find any examples?

jovial moon
jovial moon
final rampart
#

How can you make a water shader without having to use the other 3d platform?

#

The one called SRP

wild grove
#

I essentially need to be able to use this function ```cginc
half4 calculateRotations(appdata v, half4 input, int normalsCheck, half pan, half tilt)
{
// input = IF(worldspacecheck == 1, half4(UnityObjectToWorldNormal(v.normal).x * -1.0, UnityObjectToWorldNormal(v.normal).y * -1.0, UnityObjectToWorldNormal(v.normal).z * -1.0, 1), input)
//CALCULATE BASE ROTATION. MORE FUN MATH. THIS IS FOR PAN.
half angleY = radians(getOffsetY() + pan);
half c, s;
sincos(angleY, s, c);

half3x3 rotateYMatrix = half3x3(c, -s, 0,
                                s, c, 0,
                                0, 0, 1);
half3 BaseAndFixturePos = input.xyz;

//INVERSION CHECK
rotateYMatrix = checkPanInvertY() == 1 ? transpose(rotateYMatrix) : rotateYMatrix;

half3 localRotY = mul(rotateYMatrix, BaseAndFixturePos);
//LOCALROTY IS NEW ROTATION


//CALCULATE FIXTURE ROTATION. WOO FUN MATH. THIS IS FOR TILT.

//set new origin to do transform
half3 newOrigin = input.w * _FixtureRotationOrigin.xyz;
//if input.w is 1 (vertex), origin changes
//if input.w is 0 (normal/tangent), origin doesn't change

//subtract new origin from original origin for blue vertexes
input.xyz = v.color.b == 1.0 ? input.xyz - newOrigin : input.xyz;


//DO ROTATION


//#if defined(PROJECTION_YES)
//buffer[3] = GetTiltValue(sector);
//#endif
half angleX = radians(getOffsetX() + tilt);
sincos(angleX, s, c);
half3x3 rotateXMatrix = half3x3(1, 0, 0,
                                0, c, -s,
                                0, s, c);
    
//half4 fixtureVertexPos = input;
    
//INVERSION CHECK
rotateXMatrix = checkTiltInvertZ() == 1 ? transpose(rotateXMatrix) : rotateXMatrix;

//half4 localRotX = mul(rotateXMatrix, fixtureVertexPos);
//LOCALROTX IS NEW ROTATION



//COMBINED ROTATION FOR FIXTURE

half3x3 rotateXYMatrix = mul(rotateYMatrix, rotateXMatrix);
half3 localRotXY = mul(rotateXYMatrix, input.xyz);
//LOCALROTXY IS COMBINED ROTATION

//Apply fixture rotation ONLY to those with blue vertex colors

//apply LocalRotXY rotation then add back old origin
input.xyz = v.color.b == 1.0 ? localRotXY + newOrigin : input.xyz;
//input.xyz = v.color.b == 1.0 ? input.xyz + newOrigin : input.xyz;

//appy LocalRotY rotation to lightfixture base;
input.xyz = v.color.g == 1.0 ? localRotY : input.xyz;

return input;

}```

tacit parcel
hexed sorrel
# regal stag If it's a separate feature not really (AllocateIfNeeded can kinda grab it again ...
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
        {
            var colorDesc = renderingData.cameraData.cameraTargetDescriptor;

            colorDesc.depthBufferBits = 0;

            RenderingUtils.ReAllocateIfNeeded(ref rtLiquidMask, colorDesc, name: "_LiquidMask");
            //RenderingUtils.ReAllocateIfNeeded(ref rtTempTexture, colorDesc, name: "_TempTexture");

            ConfigureTarget(rtLiquidMask);
            ConfigureClear(ClearFlag.Color, Color.black);
        }

        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get();
            using (new ProfilingScope(cmd, _profilingSampler))
            {
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                SortingCriteria sortingCriteria = SortingCriteria.CommonTransparent;
                DrawingSettings drawingSettings = CreateDrawingSettings(shaderTagsList, ref renderingData, sortingCriteria);


                context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
                cmd.SetGlobalTexture("_GlobalLiquidMask", rtLiquidMask);

                settings.liquidPassMAT.SetTexture("_LiquidMaskTexture", rtLiquidMask);

                Blit(cmd, rtLiquidMask, rtTempTexture, settings.liquidPassMAT, 0);

                cmd.SetGlobalTexture("_GlobalShadedLiquidTexture", rtTempTexture);
            }
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }

        public override void OnCameraCleanup(CommandBuffer cmd) { }

    }

I have attempted to merge the two passes to allow me to pass the liquid directly without needing global textures, however I believe something behind the scenes is going horribly wrong as I am getting a strange unity inspector visual bug while it runs haha!

#

For some reason it seems to "work" or at-least do something while "rtTempTexture" is declared as a Texture rather than a RTHandle. Which could be the cause of the initial problem before merging the two passes, I am still unable to see any direct issues. But I would like the material to be able to adjust the entire "_GlobalShadedLiquidTexture" to simulate waves, after drawing it to a quad.

#

If anyone sees anything glaringly wrong I would really appreciate some diagnostics as neither me or AI are able to notice anything wrong notlikethis

hexed sorrel
#

Anyone have any ideas potentially? Coming back to it again and seemingly everything I am trying is either resulting in a buggy texture or no output atwhatcost

honest bison
#

How do I project testures on a skinned mesh?

stiff halo
#

Hello,
I created an ocean using my custom lighting model (works perfectly). Now, I want to use the HDRP PBR lighting model for my ocean, so I started rewriting my shader code in Shader Graph. However, Iโ€™ve run into an issue with outputting the correct normals, which is causing the lighting to look incorrect. In my normal texture, the red channel (r) represents the x slope (tangent vector) and the green channel (g) represents the z slope (bitangent vector). I suspect thereโ€™s a simple mistake that Iโ€™m missing. Any help with fixing the normals would be greatly appreciated.

Here is the vertex shader, where I displace vertices:

    float2 uvWorld = mul(unity_ObjectToWorld, v.vertex).xz;
    float2 uvWorld1 = uvWorld / _LengthScale1;
    float3 displacement = tex2Dlod(_DisplacementMap1, float4(uvWorld1, 0, 0));
    v.vertex.xyz += displacement.xyz;

Fragment shader:

    float3 posWorld = i.posWorld;
    float2 uvWorld1 = i.uvWorld / _LengthScale1;
    float2 derivatives = tex2Dlod(_NormalMap1, float4(uvWorld1, 0, 0)).rg;
    float3 normal = normalize(float3(-derivatives.x, 1, -derivatives.y));

Attaching shader graph:

dim yoke
warm moss
dim yoke
tawny shard
#

why does this work

#

and this doesnt

#

for pixelating

#

I want to change the alpha of an image but keeping it pixelated and not so smooth like the noise

stiff nexus
#

Hey hol, been a while, I am currently making another effect for my game. However, this time I need a way to make it render on top of UI no matter what, so if the UI is set to overlay, the effect still applies. Do you know any way I could accomplish this?

#

This is what the effect looks like as a post process.

deep moth
#

Looks cool! This one I'd imagine is going to be pretty hdrp specific. I'm on holiday & away from my computer for a while but got your @. You might wanna check in the hdrp channel! I'd imagine this could be solved either with timing of your post process event or with something related to the canvas. For problems like this I like to have the frame debugger open to get a better sense of timing.

honest bison
#

Shader graph is not really good for expressing more complex ideas.

grizzled bolt
# tawny shard for pixelating

In the first example you're pixelating the texture coordinates, while in the second you're doing the operation to the color result, which is referred to as posterization
Notice how the Simple Noise has an UV input, you can plug your pixelated UV there if you want to pixelate the noise

tawny shard
keen thorn
#

#archived-shaders message
bumping this question, anyone know if there's something that I can do with shaders to not render faces of a material that are part of the same mesh? the link is an explanation of how blender has a "show backface" checkbox, which appears to do exactly what I want. I'm wondering how i could accomplish it in unity.

kind juniper
#

Thinking about it, if that's what it does, it shouldn't really change anything visually.

keen thorn
# kind juniper Well, it's impossible to help you without k owing what that option actually does...

From: https://docs.blender.org/manual/en/latest/render/eevee/materials/settings.html

Show Backface

If enabled, all transparent fragments will be rendered. If disabled, only the front-most surface fragments will be rendered. Disable this option to ensure correct appearance of transparency from any point of view. When using Alpha Blending this option should be disabled because with Alpha Blending, the order in which triangles are sorted is important.
#

in Unity, the "not-front-most surface fragment" (?) is being rendered on top, and I'd like it to not do that.

kind juniper
#

Ah, so it disables culling of the faces of the same transparent mesh.

kind juniper
#

What you can do is separate your mesh into 2 meshes and use a transparent material on both. That should have the same effect.

keen thorn
#

Yeah I thought I might have to split it into 2 different meshes ๐Ÿ˜ญ Thanks for confirming

kind juniper
sullen mauve
#

hi! when using a shader with screen color, the quality seems to get worse. can i fix this or is it a unity issue?
(off/on, you can especially see it on the dummy)

regal stag
#

Can set it to none and it should look better

rich wolf
#

hi, iโ€™m a complete beginner with using shaders in unity. iโ€™m trying to follow this tutorial online and it seems like they have a bunch more options than i do when creating a new shader, and i canโ€™t find anything online about why that is, and im not entirely sure what i should do. i just installed URP and activated it as well. any help would be greatly appreciated! thanks

quick sandal
rich wolf
#

is that in the package manager thing?

quick sandal
#

yes!

rich wolf
#

awesome, thanks!

#

it says i already have it installed :/

quick sandal
#

then it probably had trouble installing or updating the menus ๐Ÿ˜ฎ
the options might reappear upon restarting Unity

rich wolf
#

hmmm, nope

#

oh wait i think i got it

quick sandal
#

You have a "shader graph" submenu just above in your first screenshot

#

They just split the menu in two separate sections

rich wolf
#

thanks for your help!

quick sandal
#

no problem! have fun with the tutorial ๐Ÿ™‚

waxen grove
#

I'm modifying the built-in procedural skybox shader, and I'm having trouble trying to make the sun have a texture. Could anyone give me some pointers?

(Yes, I do know about the sphere UVs and such, I just need help figuring it out)

quick sandal
#

In the meantime... I have an issue with the UnityEngine.UI.VertexHelper class and I really hope someone can point out where I'm wrong ๐Ÿ™
I'm overriding the Image component to make my own graphics, more specifically I want to edit the generated mesh with OnPopulateMesh() to embed more information in the vertices.
And it seems like not all data passed via the VertexHelper makes it to the shader :/

protected override void OnPopulateMesh(VertexHelper vh)
{
    vh.Clear();
    base.OnPopulateMesh(vh);
    if (overrideSprite == null) return;

    // browse each vertex then add data
    int vertCount = vh.currentVertCount;
    if (vertCount > 0)
    {
        for (int i = 0; i < vertCount; i++)
        {
            UIVertex v = UIVertex.simpleVert;
            vh.PopulateUIVertex(ref v, i);
            v.uv0 = Vector4.zero; // this works
            v.tangent = new Vector4(1, 0.5f, 0, 1); // this does not
            vh.SetUIVertex(v, i);
        }
    }
}

Then I'm trying to get my newly-added data in a vertex shader:

struct appdata_t
{
    float4 vertex   : POSITION;
    float4 color    : COLOR;
    float4 texcoord : TEXCOORD0;
    float4 foo : TANGENT;
    UNITY_VERTEX_INPUT_INSTANCE_ID
};

Only the POSITION and TEXCOORD0 semantics contain data from the VertexHelper. Setting UIVertex.normal, .tangent or the extra UV channels does nothing. Is it a known bug?

quick sandal
#

the tricky thing would be to figure out the exact UV coordinates for any given pixel in the sky

#

I'm guessing calcSunAttenuation gives you an approximation of how close to the center of the sun you are, then it's a matter of angle

waxen grove
#

That's what I was worried about

#

I have the point, I need the uv of a circle

sullen mauve
rich wolf
#

would anyone know why my shader options thing is greyed out/how to fix it? i cant click on anything. im making my own shader with the shader graph

halcyon panther
#

They'll be grayed out on the GameObject while not in play mode.

sleek radish
#

this shader is stretching when blocks of the same type are next to each other, does anyone know how to fix this?

{
    Properties
    {
        _Color("Main Color", Color) = (1,1,1,1)
        _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
        _Cutoff("Alpha cutoff", Range(0,1)) = 0.5
    }

    SubShader
    {
        Tags { "Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" }
        LOD 150

        CGPROGRAM
        #pragma surface surf Lambert vertex:vert alphatest:_Cutoff

        sampler2D _MainTex;
        fixed4 _Color;

        struct Input
        {
                float2 uv_MainTex;
                float3 vertColor;
        };

        void vert(inout appdata_full v, out Input o)
        {
                UNITY_INITIALIZE_OUTPUT(Input, o);
                o.vertColor = v.color;
                o.uv_MainTex = v.texcoord.xy;
        }

        void surf(Input IN, inout SurfaceOutput o)
        {
                fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
                o.Albedo = c.rgb * IN.vertColor;
                o.Alpha = c.a;
        }
        ENDCG
    }
        
    Fallback "Diffuse"
}```
amber saffron
rich wolf
sleek radish
amber saffron
# sleek radish How would I use the vertices positions?

The position is available in the vertex input appdata_full, passe it to the Input struct out of the vertex shader to the fragment shader, through a new variable.
Then you can use the position (X & Z values) as uv input for sampling for example.

tacit parcel
quick sandal
smoky widget
#

Is there any way to check with a #isdef if the shader is running inside a shadows only pass or not?

smoky widget
#

code shader

regal stag
# smoky widget code shader

You can add your own defines then. Add #define IN_SHADOWCASTER to the shadowcaster then #ifdef IN_SHADOWCASTER where you want to test for it

smoky widget
#

Okay sorry, code shader that is inside a custom function of a graph

#

I don't know how to do a custom pass for the shadowcaster there

regal stag
# smoky widget Okay sorry, code shader that is inside a custom function of a graph

Okay, the graph adds it's own defines, so this should work

#ifdef SHADERGRAPH_PREVIEW
    Out = 1;
#else
    // For URP this is needed :
    #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
    
    // Test if we are in the SHADOWCASTER pass
    #if (SHADERPASS == SHADERPASS_SHADOWCASTER)
        Out = 1;
    #else
        Out = 0;
    #endif
#endif
#

In URP at least, for HDRP remove the include and use SHADERPASS_SHADOWS

smoky widget
smoky widget
#

And im guessing I cannot check which render pipeline im in directly from the shader...

regal stag
#

Not that I'm aware of really. But URP and Built-in both use a value of 3 for shadows, so #if (SHADERPASS == 3) should also work for both of those, even without the includes.

rare wren
deft frost
rare wren
#

You could just use the (world) position, right?
And then animate the vertices based on the distance to that position.

#

There are many ripple shaders online/on YouTube

deft frost
#

I've been looking for Ripple Shaders that fit what I'm looking for. But say if a humanoid shape intersects with the rippling shape, I'd like to have a humanoid shaped ripple effect.

smoky widget
#

I thought it would offset the Unity_InstanceID by the amount set there, but not really, so Im not sure what is doing

deft frost
wild grove
#

Would anyone be willing to help me convert a relatively lengthy surface shader into a standard shader? Every issue I'm running into with what I'm trying to do is because I'm using a surface shader and it's driving me nuts

#

I don't mean to ask to ask but it's more than likely way too lengthy to post here

#

it's about 400 lines rn

#

not including the functions file

simple panther
#

Hello. I have a question about materials and MeshRenderer component.

Lets say I have a mesh that is split on 3 sub meshes and my MeshRenderer has 3 materials. This way Unity connects submesh to proper material by index.
This is part I understand. I dont understand what happen if you add FOURTH material, lets say, manually via inspector. I know that it will be applied to whole mesh, but how it will is not clear to me. Will it override my previous material or render the same object again with different material?

My question arise because I am looking at QuickOutline asset source code. Asset is free so I'll post the picture of code.
Here, they add two additional materials to material list with specialized shader and suddenly - outlines start to work. But I would love to understand why/how.

Adding that material will make my object to be rendered again? Or two materials become blended somehow?
Could anyone help me understand how this works?

grizzled bolt
simple panther
#

Thank you!

grizzled bolt
#

Specify what you mean by "try doing anything"
It looks like your'e specifically swapping to an unsupported shader
That kind of mesh shouldn't need to have a double sided material
If it seems like it needs to, you likely have inverted normals

#

Metallic materials only receive specular reflections
You must ensure there are light sources and/or a reflection probe to reflect

#

I cannot tell what shader that is but it doesn't support metallicness
You should use URP Lit shader

#

That is metallic enough but you need reflections to make sense for where the object is

#

You should bake a reflection probe for the area first, so that there's something to show up in the metal's reflections

simple panther
#

I've one more question. How I can override ShaderGraph's shader "Surface" property via code? I'd like to turn Opaque object into Transparent via runtime.

What I was trying to do:

    material.SetFloat("_Alpha", alpha);
    material.SetFloat("_Surface", isTransparent ? 1.0f : 0.0f);
    material.SetFloat("_ZWrite", isTransparent ? 0.0f : 1.0f);
    material.SetFloat("_DstBlend", isTransparent ? 10f : 0.0f);

This does not work, my object is not changing to transparent. But if I open inspector at runtime, go to this particular material instance and modify whatever, even just a 0.01 alpha, then it suddenly start to work, like Unity could set something else behind the scenes that I did not set through code. I've got all float variables with GetPropertyNames(), compared it and its exactly the same.

grizzled bolt
#

Create a reflection probe, position it near the lamp, adjust its bounds to encompass the room, set any meshes to reflection probe static that should appear in the reflection, bake probe
When in doubt look up reflection probes in the documentation

simple panther
# simple panther I've one more question. How I can override ShaderGraph's shader "Surface" proper...

In case someone would stumble on this, here is solution:

material.SetFloat("_Alpha", alpha);
material.SetFloat("_Surface", isTransparent ? 1.0f : 0.0f);
material.SetFloat("_ZWrite", isTransparent ? 0.0f : 1.0f);
material.SetFloat("_DstBlend", isTransparent ? 10f : 0.0f);
material.SetOverrideTag("RenderType", isTransparent ? "Transparent" : "Opaque");
material.SetOverrideTag("Queue", isTransparent ? "Transparent" : "Geometry");
material.shader = material.shader;

and yes.. the last line fixes the issue #justunitythings

topaz marsh
#

Hey, do any of you have any resources on how to sample a texture in a [shader("closesthit")] shader, and how to get the vertex attributes here? I'm only able to get "barycentrics" and I have no clue what to do with them.

#

I am using custom srp (no srp core) for ray tracing

#

sampler2D doesn't even compile?

#
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Name "RayTracingPass"
        Tags{ "LightMode" = "RayTracing" }

        Pass
        {
            HLSLPROGRAM

            #pragma target 5.0
            #pragma raytracing shader

            #include "RayPayload.hlsl"
            #include "Attributes.hlsl"

            sampler2D _MainTex;

            [shader("closesthit")]
            void Terrain(inout RayPayload payload : SV_RayPayload, Attributes attributes : SV_IntersectionAttributes) // BuiltInTriangleIntersectionAttributes?
            {
                payload.color = tex2D(_MainTex, attributes.barycentrics);
            }

            ENDHLSL
        }
    }
}```
wild grove
#

Is there any way to use #pragma surface surf StandardDefaultGI and #pragma surface surf Lambert vertex:vert together?

tacit parcel
wild grove
# tacit parcel what are you trying to achieve actually?

I'm writing a custom shader for a VRChat asset called VRSL, which essentially allows you to have lighting fixtures controllable in real time via OSC or DMX. I already have the code to control all of the emissions and such, the only thing my shader is missing in terms of functionality is controlling the rotation of the fixture

#

which I'm only gonna be able to do with either a vertex modifier or by rewriting the entire shader from scratch, at least as far as I know

tacit parcel
#

well, you can just add/copy the vertex shader to your custom shader (and the needed variables)
that's if I get what you meant right

wild grove
#

In order to use that, I need #pragma surface surf StandardDefaultGI

#

which is preventing me from using #pragma surface surf Lambet vertex:vert

#

So I assume I either need a way to be able to use them together, or a way to be able to use metallic and smoothness without SurfaceOutputStandard

#

Because otherwise, using o.Metallic gives me Shader error in 'VRSL/Custom/JDC1': invalid subscript 'Metallic' at line 187 (on d3d11)

kind juniper
#

IF you need a vertex shader, can't you just use:

#pragma surface surf StandardDefaultGI vertex:vert

?

wild grove
kind juniper
#

That implies an issue with the surface shader, not vertex

wild grove
#

Yeah I just still had the output set to SurfaceOutput

#

that fixed the error, gonna see if I can't get the thing working now

#

well, it's not giving me any errors and doing something simple like moving it along one axis kinda works, but something's up with my code logic preventing the rotation controls from working, not sure what

#
void vert (inout appdata_full v)
{
    //UNITY_INITIALIZE_OUTPUT(Input,o);
    
    int dmx = getDMXChannel();
    float tiltValue = GetTiltValue(dmx);
    v.vertex = calculateRotations(v, v.vertex, 0, 0, tiltValue);

    half4 newNormals = half4(v.normal.x, v.normal.y, v.normal.z, 0);
    newNormals = calculateRotations(v, newNormals, 1, 0, tiltValue);
    v.normal = newNormals.xyz;
}```
#

I'm guessing I'm gonna have to write a new calculateRotations from scratch, since I'm just using the one provided with VRSL

#
half4 calculateRotations(appdata_full v, half4 input, int normalsCheck, half pan, half tilt)
{
    //    input = IF(worldspacecheck == 1, half4(UnityObjectToWorldNormal(v.normal).x * -1.0, UnityObjectToWorldNormal(v.normal).y * -1.0, UnityObjectToWorldNormal(v.normal).z * -1.0, 1), input)
    //CALCULATE BASE ROTATION. MORE FUN MATH. THIS IS FOR PAN.
    half angleY = radians(getOffsetY() + pan);
    half c, s;
    sincos(angleY, s, c);

    half3x3 rotateYMatrix = half3x3(c, -s, 0,
                                        s, c, 0,
                                        0, 0, 1);
    half3 BaseAndFixturePos = input.xyz;

    //INVERSION CHECK
    rotateYMatrix = checkPanInvertY() == 1 ? transpose(rotateYMatrix) : rotateYMatrix;

    half3 localRotY = mul(rotateYMatrix, BaseAndFixturePos);
    //LOCALROTY IS NEW ROTATION


    //CALCULATE FIXTURE ROTATION. WOO FUN MATH. THIS IS FOR TILT.

    //set new origin to do transform
    half3 newOrigin = input.w * _FixtureRotationOrigin.xyz;
    //if input.w is 1 (vertex), origin changes
    //if input.w is 0 (normal/tangent), origin doesn't change

    //subtract new origin from original origin for blue vertexes
    input.xyz = v.color.b == 1.0 ? input.xyz - newOrigin : input.xyz;


    //DO ROTATION


    //#if defined(PROJECTION_YES)
    //buffer[3] = GetTiltValue(sector);
    //#endif
    half angleX = radians(getOffsetX() + tilt);
    sincos(angleX, s, c);
    half3x3 rotateXMatrix = half3x3(1, 0, 0,
                                        0, c, -s,
                                        0, s, c);
            
    //half4 fixtureVertexPos = input;
            
    //INVERSION CHECK
    rotateXMatrix = checkTiltInvertZ() == 1 ? transpose(rotateXMatrix) : rotateXMatrix;

    //half4 localRotX = mul(rotateXMatrix, fixtureVertexPos);
    //LOCALROTX IS NEW ROTATION


    //COMBINED ROTATION FOR FIXTURE

    half3x3 rotateXYMatrix = mul(rotateYMatrix, rotateXMatrix);
    half3 localRotXY = mul(rotateXYMatrix, input.xyz);
    //LOCALROTXY IS COMBINED ROTATION

    //Apply fixture rotation ONLY to those with blue vertex colors

    //apply LocalRotXY rotation then add back old origin
    input.xyz = v.color.b == 1.0 ? localRotXY + newOrigin : input.xyz;
    //input.xyz = v.color.b == 1.0 ? input.xyz + newOrigin : input.xyz;
        
    //appy LocalRotY rotation to lightfixture base;
    input.xyz = v.color.g == 1.0 ? localRotY : input.xyz;

    return input;
}```
#

I'm not sure what's wrong with this

#

mainly because the only modification I've made to the original function is changing the parameter type of v from appdata to appdata_full

wild grove
#

Okay so I finally have the vertex rotation working as shown in this first pic, but there's still some issues

#

specifically, whatever the hell this is

#

this is my code so far:

float GetTiltValue_Fixed(uint DMXChannel)
{
    float inputValue = getValueAtCoords(DMXChannel, _Udon_DMXGridRenderTextureMovement);
    //inputValue = (inputValue + (GetFineTiltValue(DMXChannel) * 0.01));
    #if defined(VOLUMETRIC_YES) || defined(PROJECTION_YES) || defined(FIXTURE_EMIT) || defined(FIXTURE_SHADOWCAST) || defined(VRSL_SURFACE) || defined(VRSL_FLARE)
        return (((getMinMaxTilt() * 2) * (inputValue)) - getMinMaxTilt());
    #else
        return ((_MaxMinTiltAngle * 2) * (inputValue)) - _MaxMinTiltAngle);
    #endif 
}

        float4 RotateAroundYInDegrees (float4 vertex, float degrees)
        {
            float alpha = degrees * UNITY_PI / 180.0;
            float sina, cosa;
            sincos(alpha, sina, cosa);
            float2x2 m = float2x2(cosa, -sina, sina, cosa);
            return float4(vertex.x, mul(m, vertex.yz), vertex.w).xyzw;
        }

        void vert (inout appdata_full v)
        {
            //UNITY_INITIALIZE_OUTPUT(Input,o);
            int dmx = getDMXChannel();

            //Channel 1: Coarse Tilt (MSB)
            float tiltValue = GetTiltValue_Fixed(dmx);
            //v.vertex = calculateRotations(v, v.vertex, 0, 0, tiltValue);
            v.vertex = RotateAroundYInDegrees(v.vertex, -tiltValue+90);
            
            half4 newNormals = half4(v.normal.x, v.normal.y, v.normal.z, 0);
            newNormals = RotateAroundYInDegrees(newNormals, -tiltValue+90);
            v.normal = newNormals.xyz; 
        }
simple sage
#

I'm trying to make a shader in Shader Graph where I manipulate the UVs of the color values of a texture, as in getting the RGBA from a SampleTexture2D node and then warping the UVs of that rather than the SampleTexture2D node itself. Is there any way to do that? I haven't found any nodes that take in RGBA values and a UV map and outputs a manipulated version. My guess is it's because color values aren't mapped to UVs, but is there any way to map them and then do it?

amber saffron
simple sage
#

Okay, thanks for letting me know

#

In that case, is there a way to set the UV maps available in the shader? I see it has UV0,1,2,etc. Can I deform the UVs and then set it to one of those maps so I don't have to connect the deformed UV node to everywhere I want it?

amber saffron
#

While technically it should be something possible, it has not been implemented in shadergraph.
What you can do is deform the UVs in the vertex stage, and store them in a custom interpolator, then use that interpolator in the fragment stage.
This works if deformations are "simple", if you need per pixel deformation, you are stuck in doing it in the fragment stage only, and reroute long connections along the graph

simple sage
#

I need to do it in the fragment stage unfortunately. Thank you for the help!

stiff halo
# honest bison Did you work it out?

Didn't try. But I tried writing simple phong shader. One in HLSL unlit and the other Unlit Shader Graph and the results are diffrent even tho math is the same. Something is wrong about reading the texture....

#

Why these two shader produce different results??? For some reason the shader graph does not read gradient map correctly....

EDIT - Just noticed that I'm adding object space for displacement, but it does not matter, so you can ignore it.

tacit parcel
stiff halo
stiff halo
#

Maybe it's because the sampler is clamping my values? How can I read the values in texture as they are not in 0-1 range.

left bear
#

is there a known way to disable the lighting of a material specifically in the material preview of the assets window? i have a shader that has the plane preview type, and all the materials end up just looking really dark and its hard to even see what material it is based on the preview (which i feel is... the entire point of the preview)

hasty breach
#

Compute shader with RWTexture<float4> throws error with opengl api on android

#

It seems to work with Vulcan and windows but throws error only for opengl android

#

Any idea how I can sort it

civic lantern
#

That would give you the final UV

topaz marsh
jovial moon
#

what is 'real' type and why my urp does not want to deal with it?

kind juniper
#

Sounds like you have some package version mismatch.

#

Ah, it's a custom shader. Then you probably just need to include the unity file that defines it.

jovial moon
hasty breach
#

Compute shader with RWTexture<float4> throws error with opengl api on android. It seems to work with Vulcan and windows but throws error only for opengl android.
Any ideas why it throws warning that RWTexture is unsupported in some shader but in others it seems to work.

tacit parcel
hasty breach
amber saffron
fossil cloak
#

Does anyone have a clue, why in shadergraph a color, that is not exposed, doesnt seem to have impact onto the shader?
i am multiplying a color onto the basemap, but it only works as long as the color is exposed. (but i dont want it to be exposed in the mat) ๐Ÿ˜ฆ

fossil cloak
#

yeah

fossil cloak
amber saffron
#

Well, X mutliplied by white is X

fossil cloak
#

sure, but the fact that its exposed or not exposed makes the difference.

amber saffron
#

If you expose it and change the color on the material, it doesn't affect the output ?

fossil cloak
#

it does, but i dont want it exposed. I just change the color via script.

#

thats unexposed

#

thats exposed

#

it just multiplies as black, when unexposed

amber saffron
#

I think you need to enable "Override Property Declaration"

fossil cloak
#

oh that works

#

hybrid per instance. what ever it means

amber saffron
#

"Hybrid Per Instance" or "Per Material" should work.

fossil cloak
#

nvm. it doesnt. its just white

#

if i change color to red or something, it doesnt change ^^

somber pulsar
#

I've got a shader that reads the UVs of the model to get the correct tiling and it broke when the game moved over to 2021.3.16f1. Im just wondering where I can find the bit that does the UV reading or whatever its called so i can try and fix it.

#

I would ask the person who made the shader for me but they just ignore me for some reason now

fossil cloak
amber saffron
fossil cloak
#

yeah, but i guess i would have to write an editor script that sets the color to white to make it work like i want it ๐Ÿ˜„

#

so i just leave it exposed.. ๐Ÿ˜„

#

because i dont want my whole scene to be black in editor ^^

amber saffron
amber saffron
somber pulsar
amber saffron
#

But still, I'm surprised that a unity version update would mess with the shader UVs work.
It maybe has to do with the meshes themselves : if the shader is using the UV1 for some reason, the upgrade maybe did force the meshes to import with lightmap generation, that messed with the UV1 channel

somber pulsar
frosty fractal
#

anybody here has implemented a box/gaussian blur in Shader Graph?
I implemented a way but currently I only can blur a texture and I dont know I could get it to work with just everything else ๐Ÿค”

rancid shuttle
#

is there a way to make scene lighter but keep it the same in playing mode?

grizzled bolt
rancid shuttle
#

okay, thanks

ruby sonnet
#

so im making a Billboard shader in ShaderLab using URP, and when i try to compare 2 values to get a boolean, this error pops up

  varb24 = (0 != _Billboard);
amber saffron
ruby sonnet
amber saffron
#

Try to do 0.0 != _Billboard to compare two floats

#

or explicitely 0 != (int)_Billboard ?

ruby sonnet
#

still same error

amber saffron
#

Hum, it seems to work on my side, but I'm targetting windows on my test project, are you maybe working on a mobile project ?

ruby sonnet
#

so it is in fact windows

amber saffron
#

Oh, yeah, sorry

amber saffron
#

cg on a simple unlit shader