#archived-shaders

1 messages · Page 198 of 1

mint storm
#

the handle should be on the other side, like this

#

but when I look at it from this angle, I am still able to see through it

#

I'm using URP material with Surface Type set to "Transparency" as I want to make it being able to do a fade away animation later on.

low lichen
#

A transparent material with 100% alpha will not render the same way as an opaque material

mint storm
#

setting it to Opaque does solve the problem but I won't be able to fade it away later on.

#

So i'm asking what would be the best approach to do a Fade Away Animation and at the same time not encountering this issue.

mint storm
#

any help would be much appreciated. coz I'm stuck here. Thought it would be a simple solve. Thanks in advance!

shadow kraken
#

The issue appears when you have more complex meshes with transparent materials

#

It has to do with how the renderer sorts faces. In your case you should leave the handle as its own mesh, so it will not conflict with the larger mesh

clever saddle
#

I wanna add a shooting range,just like this

#

Like the mark when painting terrain

#

How to do this?

brittle arrow
#

Hey, so I'm not sure if this is the right place to post this but the project I was working on was updated (without my knowledge) from unity 2019 to 2020 now the problem is that I build some shader graph shaders and I was using the Custom Function node to get the lightDir after the upgrade was done all my materials were erroring out(getting syntax error in the custom node). Has anyone else encountered this problem or have any solutions? Any help would be greatly appreciated. Thx

regal stag
# brittle arrow Hey, so I'm not sure if this is the right place to post this but the project I w...

Usually the syntax error gives you more information about what the problem is, but if it's been upgraded to URP v10 I would assume it might be because #if SHADERGRAPH_PREVIEW is being used instead of #ifdef SHADERGRAPH_PREVIEW as that's a common issue. You may also want to check the things listed here to see other changes : https://docs.unity3d.com/Packages/com.unity.shadergraph@10.3/manual/Upgrade-Guide-10-0-x.html

brittle arrow
lean lotus
#

are there any good resources for more in depth/complex use of compute shaders in unity? I can only seem to find the ones that get you started
Also anyone have any more suggestions for debugging compute shaders/profiling parts of them?(again, I know where the slow downs is, but I dont know what parts of it do so(recursive looping using a stack for BVH traversal))

pale ravine
#

Hi, is there an easy way to randomly rotate Quad of the mesh?

#

I have created a billboard from a quad. But it's repetitive on sides

low lichen
pale ravine
#

yes

#

i've turned this

#

into this

#

the last thing I need is to quasi-randomly rotate the texture on a quad.

amber saffron
#

You could rotate the UVs (or the quads) based on the quad center position 🤔

pale ravine
#

How could I get quad center position?

summer quest
#

How do we get syntax highlight, intelisence and tabs working properly with compute shader on visual studio?

odd dagger
#

Hi, I just wanted to know how to make an additive shader with shader graph. Essentially what I want is for my bullets to be brighter as they overlap with things and I wasn't sure how to do that. This is what I have so far

#

From what I understand, additive blending is adding the RGB values of the pixels to what is already there, but how do I portray that using shader graph? I'm guessing it's fairly easy but I'm very new to this

regal stag
#

You'd probably have to generate shader code from the graph (right click master node), and save it as a separate shader and edit the Blend mode manually. Blend One One would be additive.

odd dagger
#

Ah

#

I've never played with code using shaders ever

#

Do you know where I could look to learn how that works?

regal stag
# odd dagger Do you know where I could look to learn how that works?

There are tutorials for shader code in general but editing the code generated by the graph shouldn't be too difficult. It would be completely separate from the graph then though so if you want to make further changes you'd have to generate code and edit it again.

You'd only need to change a couple lines that probably include Blend SrcAlpha OneMinusSrcAlpha to Blend One One. Blend is part of the shaderlab syntax. https://docs.unity3d.com/Manual/SL-Blend.html

odd dagger
#

When I tried to open it I was getting this error:

regal stag
#

5000 lines seems quite long. It's only roughly 750 lines in v10+ but maybe it generates differently in older versions idk. You'd probably just need to alter the Blend on the Pass tagged as Universal2D.

normal cape
#

how do i make a property a whole number?

lean lotus
#

where can I find more in depth/complex uses/examples of compute shaders? most of the stuff I am finding is based around introducing compute shaders, but im trying to find ways of optimizing it

restive radish
grand jolt
#

can anybody help me?

royal prism
#

could someone please help 🙂

wary horizon
#

Don't suppose anyone's made a god-ray shader for URP?

eager folio
#

@royal prism just render the 3d object to a render texture and use that texture in your ui.

fallen sparrow
#

anyone know of a method to use the same shader for an in-world quad and something in a canvas?

eager folio
#

Just... apply it to both?

fallen sparrow
#

don't you normally need a material to use a shader?

#

hm ... apparently images have a material, didn't realize that

fallen sparrow
#

Can someone explain why this is ending up as a flat white square instead of the actual image?

_MainTex("MainTex", 2D) = "white" {}

Tags {"RenderType"="Transparent" "Queue"="Transparent" }

float4 frag(Interpolators i) : SV_Target
{
    float3 circle = tex2D(_MainTex, i.uv);
    return float4(circle,1);
}
vocal narwhal
#

because you're not using the alpha at all

fallen sparrow
#

is there a version of tex2D that returns alpha info?

eager folio
#

It is the 4th channel

fallen sparrow
#

I know it is rgba but how do you access it?

#

ignore me, I must have had some other issue the last time I tried having it return a float4

eager folio
#

Use float4 inst... oh, you got it =p

fallen sparrow
#

because the last time I tried my code wouldn't compile, there must have been something else that I just happened to screw up at the same time

mint storm
#

even just the wall itself, I can see through it and see the edges.. the wall is just a cube stretched to be a rectangular cube

#

then when i switch back to "Opaque", everything just works fine

#

I disabled every other Object to make it clearer. So this is the wall (cube)

#

there is a handle below it as a different object

#

once i make the material Transparent, it becomes like this

#

but I want it to look like this even with the Material set to Transparent. I only manage to make it look like this when Material is set to Opaque

#

Reason why I need to set the Material to Transparent is because I needed to do a Fade Animation later on.

restive radish
#

My grass shader is currently looking like this, darker in the bottom and lighter in the top. I wanted the color to be uniform so they would blend together. Does anyone know how to do it?

#

I also want it to have the same color as the ground below it, so it blends and become a single color.

#

code at the moment is this, on the surface part:

#

`void surf (Input IN, inout SurfaceOutput o)
{
float2 spriteSize = float2(8.0,1.0);
float vel = 100.0;
float2 animTex = IN.uv_MainTex * 1.0/spriteSize;
animTex.x += floor(fmod(_Time.xvel,spriteSize.x))/spriteSize.x;
animTex.y += 1.0-((1.0+floor(fmod(_Time.x
vel/spriteSize.x,spriteSize.y)))/spriteSize.y);
fixed4 c = tex2D(_MainTex, animTex) * IN.color;

o.Albedo = c.rgb;
o.Alpha = c.a;
clip (o.Alpha - _Cutoff);
o.Alpha *= IN.color.a;

}`

#

it is set to have no light or shadows, like:
#pragma surface surf NoLighting vertex:WavingGrassBillboardVert noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nofog nometa noforwardadd nolppv noshadowmask

#

WavingGrassBillboardVert is all commented, excepted the call to this function:

#

void TerrainBillboardGrass( inout float4 pos, float2 offset ) { float3 grasspos = pos.xyz - _CameraPosition.xyz; if (dot(grasspos, grasspos) > _WaveAndDistance.w) offset = 0.0; pos.xyz += offset.x * _CameraRight.xyz; pos.xyz += offset.y * _CameraUp.xyz; }

#

I'm trying to achieve a grass similar to this

#

any tips?

royal prism
#

@eager folio but it wont have animations in that case 😦

eager folio
#

The characters in my game are done that way, and they are animated.

royal prism
# eager folio <@168725676113920010> just render the 3d object to a render texture and use that...

Sorry maybe i didnt understand render texture before but as i read now it will update realtime my 3d mesh it renders, so if the 3d mesh has animation, it will work. To givd you some context; i use it for a loading screen, the loading screen has 2 or 4 area’s containing the 4 player. But their mesh is sticking out of their area, so the sword of character 1 enters the area of character 2 making it look messy. So rendee texture could be the solution?

eager folio
#

Yes.

#

Can a shader access mesh blendshape positions?

leaden radish
#

kind ghibli style?

#

i want to achieve ghibli style too in my projects 😄

mild dirge
#

Hey, I made a (kind of) fire shader with some noise and so on (pretty beginner). I wanted to test how it looks with text (burning numbers seemed cool).

As expected it didn'T work 😅

With standard Unity UI Text it just got invisble when I assigned the shader.
With TMP I get the blocks in Scene View, but nothing ends up getting rendered.

Can someone point me in a direction on what I'd need to look after to get that to work?

amber saffron
low lichen
#

Doesn't TMP use SDF rendering?

amber saffron
#

It does.

mild dirge
#

Okay, will try that. Grabbing the text texture was also my thought, but I was still looking what node or smth I should use for that

amber saffron
mild dirge
#

I just need to find the standard TMP text shader again 😅 xD

#

I suppose this is what I need?

amber saffron
#

Yep, "_MainTex" seems to be the one

mild dirge
#

There seems to be more to it 😅, doesn't work yet
I have a lot to learn

thick fulcrum
mild dirge
#

Would it help for more tips to give a screenshot or smth to you? Or should I for now just try to do more tutorials on shadergraph?

amber saffron
mild dirge
#

Shadergraph

#

Scene View

mild dirge
amber saffron
#

Is the reference name of the texture property also "_MainTex" ?

mild dirge
#

xD, nope
Texture2D_73a64a6ace094b1bb7563de9698c4731 atm

amber saffron
#

I think you should try changing that

raven helm
#

Hey guys, how do I add a delay to this?

mild dirge
#

Maybe an Add (substract) between the time and multiply?

mild dirge
raven helm
#

It's just pulsing once a sec, i want it to pulse the exact same speed, but with a delay between pulses

mild dirge
#

it grabbed the corresponding texture, but now the text is invisible in every view

shadow matrix
#

Hello guys, I am trying to learn shaders but I am having this issue. Visual Studio is not showing solutions. For other scripts works fine, but for shaders don't

amber saffron
mild dirge
mild dirge
amber saffron
#

sample node -> take only R output to multiply node.

mild dirge
#

Like this

#

Hm. For a moment it uses turquoise blocks, but then invisible again when I hit play.

raven helm
#

Essentially i think I'm looking for a sawtooth pattern that has delay

#

looks terrible lmao

mild dirge
#

Yeah, thinking of a way to fake it

amber saffron
mild dirge
mild dirge
mild dirge
pale ravine
#

Hi, is there any way to get Quad Center position information?

frigid pelican
#

Hey there! I straight up copied this shader graph: https://www.youtube.com/watch?v=kCaVBAlwaCg

This is a quick Tut on creating a portal shader in Unity 2019 using shader graph, it uses the camera texture with some fake refraction on it

This material is part of the LWRP Material Pack Vol 2:
https://bit.ly/lwrp-materials-2

Checkout my Low Poly Floating Islands package:
https://bit.ly/lwrp-floating-insland

Buy my LWRP Material Pack to su...

▶ Play video
#

and my result isn't the same as in the tutorial at all:

#

(URP is on )

amber saffron
frigid pelican
#

here, or on the other one?

#

OH MY LORD

#

okok i got it, thanks so much!

#

(so now i figured why all my shaders didn't work)

amber saffron
# mild dirge

So I was wrong, the tmp texture is alpha channel only, so you need to use the A output of the sample node.

#

Also, I figured out that tmp is a bit ... agressive about the material assigned on the mesh renderer, and systematically replaces it with the one generated from the font asset.

mild dirge
#

It looks like this now in Scene mode xD.
Waving around in the atlas

#

but still disappears on start, which probably is connected to your second message

amber saffron
#

It should look like this if you display the tmp texture :

mild dirge
#

Maybe because I am pulling the UVs from a lerp with noise?

amber saffron
#

If you pass the sample result in a smoothstep node you can vary the "width" of the effect, and blend with you fire. 0.5 is the glyph "base" edge

amber saffron
#

If you want to distord UVs, don't lerp with the noise, but add the noise to them

mild dirge
#

I mean, I sent a screenshot of the whole thing earlier. I am not very experienced yet, so I just followed a tutorial

mild dirge
amber saffron
#

Here is a good example of how to distord the UVs :

mild dirge
#

Man, you're fast....

amber saffron
#

Lerping toward the noise value will distord but doesn't give you good control over the effect, as it will result in uniformly changing the UVs toward a static value.
Adding the noise will act like offseting them, keeping the initial information.
In my case, I take the 0;1 noise value, transform it to -1;1 range, and multiply with an intensity (0.003) to control the effect. Adding this to the UV will keep the general "shape" of the glyph (as the middle of the noise is 0) and will distord it.

mild dirge
#

ah okay. Thanks for that explanation.

mild dirge
raven helm
#

well, thanks @mild dirge

#

it worked

#

this is scuffed

#

im sure there r some unnecessary stuff there

mild dirge
raven helm
#

oooh

inner coral
#

Ok, seriously.. How are you supposed to write shaders for URP?
Is Shader Graph the only option???

thick fulcrum
inner coral
#

Editing the generated shader doesn't work, nor does "Compile and show code"

#

I want to edit the actual source of the shader, no visual scripting

mild dirge
thick fulcrum
inner coral
mild dirge
amber saffron
#

I my case the shader was set to alpha blend mode.
I only need the alpha to mask the output and wanted a flat color. If I'd multiplied the color I would have a black outline visible on the effect.

amber saffron
#

The "blend" setting, yes.

mild dirge
#

hm, kinda interesting. The thing with not visible in play mode way due to settings in the canvas I noticed.

#

Sadly the glyphs move out of their bounds xD. But has a nice neon effect I guess

#

This is what I ended up with though

#

Thanks a lot for all the help @amber saffron

#

❤️

amber saffron
#

It's probably the distortion that is pushing the glyphs out of the mesh rectangles.
Try raising the scale and lowering amount

mild dirge
#

Yeah, that helps a bit. Still sometimes cut edges, but better overall 😄

#

I think my inital hope was, I could just apply it to the finished texture or whatever TMP has at the end, but on this way I understood, that the approach that this shader uses isn't fit for that.

#

How it was used in the tutorial was feeding a kind of flame texture (only consisting of different alphas of white) to be distorted and then they just put that on a Quad or smth

#

So they disregarded the original look of the object and only manipulated the the one texture that was provided.

But in TMP case the texture they used is an Atlas which they cut the different glyphs out of, so if I distort the values too much, they no longer fit TMP interal copy and paste stencil.

Also, sorry if I use words wrongly xD. I kinda get the feeling that stencil has its own meaning in the context of shaders

near tree
#

I'm thinking a shader would be the best way to fake this visual effect? Does anybody have a suggestion as to if there is a better thing to use? 👀
https://youtu.be/txkRCIPSsjM

frigid pelican
#

and it does that nice animated texture:

#

but i'd want to implement it into a shader graph, to combine it up, for example, with this other shader:

#

that was previously made in shadergraph

#

how may i do...

#

i thought with a custom fonction, but i don't really know how

mild dirge
#

Yeah, I think there's a way to make custom nodes and/or subshaders. But sadly I can't tell you how

frigid pelican
#

okay, don't worry, i can easily wait for you or someone else :)

amber saffron
frigid pelican
#

i tried, and... Got a bunch of errors ^^'
Plus, what is the return type of this custom function?

#

so, of my shader, basically? It's a Float4, i get it, but... Where can i input this next? Do i need to put inputs on this function?

amber saffron
frigid pelican
#

well i don't know lol, does it need input? It used to calmly play this texture, so i guess not, right?

#

i-

#

sorry, i really don't get what i'm doing with custom functions 🥺

amber saffron
#

Are you trying to use one of the output values of the node in the code without it beeing assigned something beforehand ?

frigid pelican
#

my bad, i didn't type the name of the fonction ^^'

amber saffron
frigid pelican
#

well, problem here is my code, i believe

#

seems to have a bunch of errors

#

(i imported it into a text asset, with hlsl extension... would that be the way i should do?)

frigid pelican
amber saffron
#

Ok.
The custom function node acts just like a way to write your nodes easilly, it doesn't replace a full shader.
You need to "extract" the vertex and fragment operation of your file into indivudual functions with their inputs and outputs, and link this in shadergraph.

frigid pelican
#

ooooooooooh!

#

so basically i've got several "blocks" here, several "functions"

#

and i'd have to put one function node per function, with each corresponding-

#

inputs and outputs?

#

"one function per function"

amber saffron
#

Not all, only the ones you'll actually use. Because all the code functions are in the same file, then can call each other, but you need to identify the ones that are the final "output" of the shader.
You should probably look at a function named "frag"

frigid pelican
#

yup, definetly

amber saffron
#

(sorry, it's in the last screen)

frigid pelican
#

it's the one

amber saffron
#

So, the frag function here is all what your need

frigid pelican
#

but something's bugging me, it's that it needs a "v2f", right?

amber saffron
#

To "convert" it to a custom function node, you need to get rid of "v2f i", which is the vertex input to fragment.
Note that in the code the only relevant input is "i.uv" => those are the texture coordinates.
Also, a custom function doesn't output value, but modifies out variables.
So :

  • Change the fonction declaration to something like MyFunction_float( float2 uv, out float4 o) (remove SV_Target)
  • remove the float2 uv ... line as the variable is declared before
  • change return float4(... to o= ...
#

In the node settings, add a "uv" float 2 input and a "o" float4 output to match the function declaration, and type the same function name MyFunction without _float (precistion identifier).
and connect a UV node as input

lavish kernel
#

@amber saffron Would you mind helping me with something?

frigid pelican
amber saffron
frigid pelican
#

(just before i "leave":

#

`float4 frag_float (float2 uv, out float4 o){

uv = i.uv * 10.;

float a = abs(n(float3(i.uv + _Time.y * 3.14, sin(_Time.y))) - n(float3(i.uv + _Time.y, cos(_Time.y + 3.))));
o=(0, .5 - pow(a, .2) / 2., 1. - pow(a, .2), 1);
}`

lavish kernel
#

I need help with developing a custom lighting shader for my voxel game and with Unity, it seems a bit complicated. Pseudocode here https://gamedev.stackexchange.com/questions/152559/achieving-2d-lighting-for-terraria-like-game

frigid pelican
#

is this what you meant?)

amber saffron
#

Yep, that's good. You could even get rid of the line uv = i.uv * 10.; as this is something you could control (uv scale) with nodes.

lavish kernel
#
for each light on scene:
    if light is on screen:
        add light to the drawing queue

draw frame:
    render frame color map:
        draw each visible tile and object

    for each light in queue:
        trace secondary lights on visible cells and add them to the drawing queue                

    render frame light map:
        set blending to additive
        for each light in queue:
            move light object to the light position
            set light object width and height to the light radius
            set light object color to the light color
            draw light object
        //then we render shadows for solid places
        set blending to subtraction
        for each visible cell:
            if cell is surrounded by other cells from every side:
                move light object to the cell
                set light width and height to the radius slightly bigger than cell
                set light color to white//to subtract any kind of light color
                draw light object

    set blending to normal
    draw color map
    set blending to multiplication
    draw light map
frigid pelican
amber saffron
#

no i.uv, just uv

frigid pelican
#

(nevermind, i got rid of i

#

yeah x)

#

)

frigid pelican
#

(all this for that .__.)

amber saffron
#

Nice sphere

frigid pelican
#

x)

frigid pelican
lavish kernel
# amber saffron What did you already try ?

I have a mesh with vertex colours which work as a pre-calculated light, but I have no idea how to implement this in order to have it normally working even on objets which are not part of Voxels

amber saffron
#

Did you input UVs to the custom function node ?

frigid pelican
#

(i cut the output for now)

#

but basically what i did was simply adding it to my other graph:

amber saffron
lavish kernel
amber saffron
# frigid pelican

Oh, I missed the _Time variable in the code. You'll need to add a float1 input to your node where you can plug in the time node

amber saffron
frigid pelican
#

oooh, that's what i thought! thanks!

lavish kernel
frigid pelican
#

`float4 frag_float (float2 uv, out float4 o, float1 _Time){

float a = abs(n(float3(uv + _Time * 3.14, sin(_Time))) - n(float3(uv + _Time, cos(_Time + 3.))));
o=(0, .5 - pow(a, .2) / 2., 1. - pow(a, .2), 1);
return o;

}`

frigid pelican
#

(removed the ".y". Was i right, since it's a float1?)

amber saffron
#

and no "return o;"

frigid pelican
#

oooooh okay

#

wait so

#

there's still an output here, right?

#

oh wait, realised i affected a float1 value to my "o"

#

oh no, nvm

amber saffron
#

Yes, it's the variable with "out" in the declaration. BTW, order is important, inputs firsts. :
void frag_float (float2 uv, float _Time, out float4 o)

frigid pelican
#

ooooh okay!

amber saffron
#

Just to avoid any naming issue, rename the function please 😓

#

"frag" is very frequently used for declaring the fragment shader function, and it might conflict with something

frigid pelican
#

lol, if i rename it, it'd be "void" because it's a void texture for our void bending mage 😭

#

i'll manage lol

#

yup, done, i've renamed it

amber saffron
#

Hum ... Can you show the current full code (use a service like hastebin if necessary) ? This error message doesn't really help me.

frigid pelican
#

my shader code, or the error code?

amber saffron
#

shader code

frigid pelican
#
float n(float3 x)
{
    float s = noise(x);
    for (float i = 2.; i < 10.; i++)
    {
        s += noise(x / i) / i;
        
    }
    return s;
}

void darkness_float(float2 uv, float1 _Time, out float4 o)
{

    float a = abs(n(float3(uv + _Time * 3.14, sin(_Time))) - n(float3(uv + _Time, cos(_Time + 3.))));
    o = float4(0, .5 - pow(a, .2) / 2., 1. - pow(a, .2), 1);
}

#

apparently, the third line is what makes it bug

amber saffron
frigid pelican
#

IT : WORKS

amber saffron
#

finally 🙂

frigid pelican
#

i'll put you on my special thanks in my game, Remy

#

i won't forget about what you did for me

amber saffron
#

Happy to help

lavish kernel
#

@amber saffron Wow, thank you Remy for help. Those 2D sprite lights are a nice compensation for vertex calculation

#

I can finally move forward

amber saffron
#

I don't really know what's I'm looking at in this screenshot, but if you're happy, I'm happy

lavish kernel
#

Well, just made voxels and needed some sort of lighting like in Terraria/Starbound

#

The current presentation is purely for testing

severe sluice
#

Can I use the same shader on different meshes to use different data? I have a terrain split into multiple meshes (not using Terrain) and I'm trying to use one shader to show different parts of heightmap/etc. on each of them. I swear my calculations are at least vaguely correct but it looks like nothing even gets offset.

restive radish
#

Is there a way to make a material pop something at given intervals?

severe sluice
#

to show what's going on: left is unsplit mesh of 224x224. Middle is split. Right is 512x512 split. All same seeds.

#

there's some other weirdness going on too but no offset at all is way more upsetting

frigid pelican
#

I might want to... Reach out for help, again ^^'

#

so i've got my shader, again, but thing is it's a bit too """"zoomed in""""... What should i do if i want to """"unzoom"""" the "texture"?

regal stag
frigid pelican
#

well thing is, it multiplies the pixel's color, soooo ^^'

amber saffron
#

No, multiply the -->UV<-- node

frigid pelican
#

oooooooooh .__.

#

thanks so much lol

amber saffron
severe sluice
#

so this wouldn't actually work?

#

and I have to split the heightmap data just like my mesh?

amber saffron
#

If i'm not wrong, this is simply sampling the heightmap based on the vertex index.
What are you expecting/trying to do ?

#

If it's to have a single heightmap, but multiple terrain meshes, you could offset the X/Z value with the mesh pivot position to also offset the sampling

#

Sorry, I've read to fast, that's what you're already doing, right ?

severe sluice
amber saffron
severe sluice
#

you can? 😮

amber saffron
#

Else, if you want to keep the split mesh route, you need to pass a different MeshIDs to each section. It can be done by using multiple materials (but still same shader), material property attributes or maybe additional vertex stream

severe sluice
#

considering I don't even know how to do lighting yet, it seems a lot to bite through. But I'll look into both options.

#

I but I thought materials were for texturing, which makes partly sense as I'm also colouring, but meshes are also near-identical (only one row has weird issues)

plush oasis
#

some shader graph experts here?

regal stag
plush oasis
#

i look for someone that can help me integrate a shader into terrain

#

i have zero exerience so thats why i look for someone

mint storm
severe sluice
#

I created a new material for each of my meshes and offsetting it. It definitely has an effect on my colouring (almost fixed it already) but my mesh vertices are still, of course, not offset like before...

#

I was technically giving each section a different MeshID. On the CPU side, I'm creating the initial meshes, and to the attached script component I'm giving them a (x,z) position, so when it's 4x4 meshes the value ranges from (0,0) to (3,3). Those values are fed into the shader as input, so e.g. (1,0) should have offset by 127, and (1,1) offset by 127 (x) + 127 rows (z)

frigid pelican
#

(ayo Remy, remember the shader we worked so hard on? I made another one and went like "oh well, that was way simpler and looks way better, and is closer to what we wanted" lmao)

#

closer to the d a r k n e s s

#

but now i'd want some kind heat distortion that'd fit well, but i don't know where to begin with

#

any ideas? 🥺

amber saffron
#

Scene color node will be your friend here ?

frigid pelican
#

clearly, yeah

#

i learnt what it was like 2hours ago, and i was pretty impressed

amber saffron
#

Well, if you know how to use it, simply distord the screen space UVs as input and you'll have a distortion effect

rare wren
#

I am looking for a way to add per instance normal maps to a shader.
Currently only the colors are per instance as in the shader below

Does anyone know if this is possible and how I would implement this?
I am lost since most guides only cover colors being changed.

{
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
    }
 
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200
        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows
        // Use Shader model 3.0 target
        #pragma target 3.0
        sampler2D _MainTex;
        struct Input {
            float2 uv_MainTex;
        };
        half _Glossiness;
        half _Metallic;
        UNITY_INSTANCING_BUFFER_START(Props)
           UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
        UNITY_INSTANCING_BUFFER_END(Props)
        void surf (Input IN, inout SurfaceOutputStandard o) {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}```
tranquil bronze
#

How can I pass in a struct to a shader

#

like this

            struct Shape 
            {
                int Type;
                float4 Settings;
                float4 Color;
                float3 Position;
                float3 Scale;
            };
low lichen
regal stag
# rare wren I am looking for a way to add per instance normal maps to a shader. Currently on...

I don't think it's possible to GPU Instance textures. Everything in the draw call needs to use the same texture afaik. You might be able to pass in a Texture2DArray of multiple textures (assuming they are supported on your target platform), and instance a float to pick which slice index of the texture to use though.
Or maybe use something like a texture atlas and instance a tiling/offset value to alter the uvs to pick which part of the texture to use.

tranquil bronze
#

i tried that but i get the error setdata must be blittable

low lichen
rare wren
#

Thanks!

tranquil bronze
#

I fixed it i was passing in the component instead of the struct

willow wren
#

Hey guys ! does any of these error talk to someone ? i'm quite lost with shader ...

shadow locust
#

those are pretty standard syntax errors

#

but - if it's an HDRP shader

#

they're notoriously difficult to write manually in HDRP

willow wren
#

i just contacted the author he had to recompile it with Amplify Shader Editor with latest version and it worked ! 🙂

spring fiber
#

I've got a problem and maybe someone knows more than me about this.

If I use a material other than the auto-default in on a rawimage, it isn't rendered. It's just invisible, not a white box or anything.

The problem is only on MacOS builds. Windows builds are fine as is the editor in both Windows and MacOS.

The problem persists both with the current 2019 LTS and 2020 LTS. Tested with built-in pipeline and URP.

trim ermine
#

Is a company's style copywrite?

#

As in could you actually use this in a game?https://www.youtube.com/watch?v=Frx8FNkt9HU

In this video we will show how to re-create Zelda Zelda Breath of The Wild Toon Shader Graph in Unity engine.
Download project files (Patrons only): https://www.patreon.com/BinaryLunar

00:00 Intro.
02:00 Setting up the scene and the character.
03:50 Creating a Custom Function node to get the main directional light data.
05:25 Calculating the p...

▶ Play video
fallen sparrow
#

how would you go about creating a rotation effect in shaders?
I have this:

float2 adjustedCoord = i.uv * 10 -5;
float sdf = SDF(adjustedCoord, float2(0, 0));
float2 rotatedCoord = float2(.5,.5)-i.uv;
float angle = atan(rotatedCoord.y/rotatedCoord.x);
angle += _CosTime.a/2+UNITY_PI;
rotatedCoord = float2(cos(angle),sin(angle))*sdf/10;
rotatedCoord = float2(.5,.5)-rotatedCoord;

and it kind of works, but, the texture gets some artifacting at the top and bottom as it rotates throw that axis, is there a standard/better way to achieve something like this?

regal stag
regal stag
fallen sparrow
#

Thanks, that solved the issue I was having! still not sure why my solution wasn't working, but I'll take it lol

jaunty wren
#

hi we have strange problem with nature shaders
anyone know what causes this?

restive radish
#

as long as you make your own models

#

shader's can't be copyrighted

trim ermine
#

I'm gonna just buy RealToon

dusky tusk
#

Hello, I am working on a terrain shader using Shader Graph and would like to ask how to get the steepness of the mesh?
I want to apply rock texture where the terrain is steep enough, how could I achieve that? Also I am not using Unity's terrain, but rather custom generated mesh (plane)

meager pelican
#

@dusky tusk Store vertex normals in the mesh. Do some googling to figure all this out and if you've otherwise messed with the mesh's orientation, but otherwise it's some dot-product with a worldspace up vector. Line N dot U (where u is up, and N is the pixel's surface normal). But I didn't look it up. So what you get back is the "steepness" in a float.

#

May have negatives, so you may need an abs() or reverse some signs. Play with it and/or ranges.

#

It's a lot like a lighting calculation, since steepness is basically how much it points away from "up".

severe sluice
# dusky tusk Hello, I am working on a terrain shader using Shader Graph and would like to ask...

If your terrain mesh is an even square grid then no dot-product is needed. I'll put a Stack Overflow link here that explains math in detail: https://stackoverflow.com/questions/6656358/calculating-normals-in-a-triangle-mesh/21660173#21660173

dusky tusk
#

Hey, I've achieved the more or less desired result using the following graph

#

And then I connect the saturate output to a lerp node that interpolates from one texture to another

severe sluice
#

oh you had normal vectors already? yea that works fine 😄

dusky tusk
#

I am using this to lerp the albedo maps, although is there a way to interpolate normals?

#

If I use lerp it doesn't seem to do anything. And normal blend just combines normals

severe sluice
#

You'd most likely have the same effect if you could

raven helm
#

Hi guys, how do I use shader graph shaders with ui image? I already have canvas set to camera, and it was working before. Guess it stopped when unity restarted..

royal prism
#

Old material setting:

#

urp -> lit

#

changed it to simple lit like this

#

will this increase performance or since i use such a 'basic' lit version it doesnt?

#

(mobile)

final wind
#

Hi! I'm having an issue and I guess it's related to Shaders rendering, I'm getting around 60k Tris count when running my HDRP project on Windows machine with 2080s GPU, same project runs on Mac machine with Metal API GPU and I get 30+ million Tris! any idea what's the reason/how to fix it for the Mac?

#

PC stats

#

Mac stats

#

same scene, same camera angle and everything

frigid pelican
#

hi there! i've got a "simple" shader graph here:

#

and what i'd want is to have my darkness output to be applied on a texture, that i could put here:

#

(its a radial slider from a certain asset)

#

how could i do? Apply it to a render texture? how? 🤔

#

(knowing my custom function outputs a float4, which is basically some UV mapping i believe?)

#

(Hi @amber saffron lol, finally found an utility to this hell of a custom function)

amber saffron
frigid pelican
amber saffron
#

No, but it connects to a color output of the shader ...
Why don't you use this shader on the material you want to directly, instead of trying to render it to a texture and assign it in an other material ?

frigid pelican
#

oh, because my famous "radial slider" is a shader itself

amber saffron
#

Oh, okay.
I guess you can't (or don't want to) create a new shader to combine them together.
Well, the easy, but not optimal, way is to assign the "darkness" material to a quad, and have it rendered to a render texture by a dedicated camera.
Else, you could use a custom render texture object, but you have to write the shader code for it, so basically, do the job again (but it's not that hard)

frigid pelican
#

Oh. Just realized the asset is too old and not made with shadergraphs 🤡

#

well, how to make a custom render texture object? 🤡

frigid pelican
#

thanks! i'm looking into that right now

rain niche
#

what could cause SetGlobalFloat to crash the game without warning on mobile devices?\

#

seems like either a driver issue or a memory leak in the unity engine

dusky cobalt
#

Hey Y'all, I recently set up Daniel Ilett's Dithered transparency shader in my game: https://www.youtube.com/watch?v=VG-Ux8RHMoA

However, the game is in VR, and the Dither node is Screen-based, which means the dither pattern moves whenever you move your head (which is.. disconcerting to say the least). is there any way to do a world based Dither pattern?

Learn how to create a dithering transparency effect similar to the one used in Super Mario Odyssey using Unity Shader Graph! This tutorial is also available in text format here: https://danielilett.com/2020-04-19-tut5-5-urp-dither-transparency/

💻 Get the source on GitHub:
https://github.com/daniel-ilett/dither-transparency-urp
✨ ...

▶ Play video
meager pelican
# dusky tusk I am using this to lerp the albedo maps, although is there a way to interpolate ...

The normals SHOULD BE interpolated. You want to deal with the normals at the vertex level, not the fragment level. The newer SG versions separate out vert and frag stages. So regardless of how many pixels a polygon covers, there's 3 vertex normal calcs for it, the rest is automatic interpolation. You should NOT want to calc it for each frag in the frag stage. Ugh! Like you say, it should "come in" interpolated.

#

@final wind Tessellation?

final wind
lucid lily
#

Anyone know if it's possible to use/create a shader featuring a displacement map that works on 2D sprites, that have also animated with in Unity itself (using the skinning editor)?

final wind
grand jolt
#

@dusky tusk you could maybe tighten up the transition using abs(ddx(normal) + ddy(normal)) as a mask.

#

It's basically fwidth and gives you the rate of change of a value across neighbour pixels.

oblique hornet
#

not sure if this is the right place to ask but got this toon shader on my model and its totally messing up on the arm mesh...help

frigid pelican
#

Hey! I want to create a shader that does heat distortion around a sphere, but i don't know how to use the scene color node correctly... How could i do to have a distortion around a sphere, but not the sphere itself? I was seearching for tutorials on youtube, but couldn't find any that matches :/

amber saffron
grand jolt
oblique hornet
#

and heres teh shader ive got

grand jolt
#

let me help you in dms @oblique hornet

oblique hornet
#

thank you TT

quiet silo
#

im trying to use viewdir in my shader but it doesnt work on imported models. This is what I have in my frag function
float3 viewDir = UNITY_MATRIX_IT_MV[2].xyz;
return float4(viewDir, 1);

#

this is what I have on my model

low lichen
regal stag
#

Also Shader Graph uses float3 _Camera_Direction = -1 * mul(UNITY_MATRIX_M, transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) [2].xyz); for it's camera forward, so kinda curious if that fixes your issues (assuming that the vector you want).

quiet silo
#

if I try to use that line it says UNITY_MATRIX_I_M is an undeclared indentifier

#

I got it working by using mul((float3x3)UNITY_MATRIX_V,float3(0,0,1));

regal stag
#

Oh right, that would be unity_WorldToObject instead. Actually it looks like it's mostly the same as what UNITY_MATRIX_IT_MV is anyway. I think the equivalent would be float3 _Camera_Direction = -1 * mul(unity_ObjectToWorld, UNITY_MATRIX_IT_MV[2].xyz);. So I guess SG is just converting it to world space.

quiet silo
#

that also works

sly breach
#

how much bits can be stored in float4 ?

#

i think i got it - 16 bytes ?

low lichen
sly breach
#

any ideas how to split a float into bits in hlsl ?

#

i want to encode some information before passing it to the shader

low lichen
#

I think HLSL has all the same bitwise operators as C#.

sly breach
#

ah right , ill try that

low lichen
#

But apparently only work in int and uint

#

There is int4

#

Which is also 16 bytes

sly breach
#

that's handy

sly breach
#

trying to use DrawMeshInstanced to read string data

#

and render a string *

low lichen
#

Strings on the GPU? 👀

#

What blasphemy is this

sly breach
#

well those are just coordinates on the texture

#

bitmap fonts

low lichen
#

Can't you just send an array of those coordinates then?

sly breach
#

can we do arrays ?

low lichen
#

Yes, there's SetVectorArray

sly breach
#

interesting

low lichen
#

You can also use structured buffers if you don't need to support lower end hardware

sly breach
#

its for WebGL

low lichen
#

Yeah, it's not supported there

#

But arrays are

#

In HLSL, you define an array like this:

float2 characters[32];
#

You must define a size for it, it can't be dynamic

sly breach
#

excellent , i can use this

#

will break long strings into chunks

low lichen
#

But are you sure this will be better than just generating a mesh with the proper UV offsets?

#

That's what TMP and Unity Text do

sly breach
#

something tells me indexing is faster then mesh generation

#

or did you mean that they are fitting a string into a single quad with something like alternating UV's ?

low lichen
#

They just make a new mesh that has separate quads, each with their own UV corresponding to their character.

#

It's definitely faster than using instancing. You only need to generate the mesh once (and when the text changes) and it's such a simple mesh that it can't take very long to do on the CPU.

sly breach
#

ah i see, using Graphics.DrawMesh i can feed in array of matrices for a single quad and set data into the material property block ( each frame )

#

i'd prefer mutable / dynamic drawing method

#

but that's a cool idea with the UV's

low lichen
#

I don't see meshes as necessarily less mutable or dynamic. I don't think they're any more work to upload to the GPU than an array of properties.

sly breach
#

including matrices for position and the single mesh ( quad )

#

but yes on this scale it is similarly mutable i guess - ( not much load on the CPU as u said )

low lichen
#

The matrices probably account for most of the bytes

#

It's a whole 64 bytes per matrix

sly breach
#

don't u need matrices for the UV's method as well ?

low lichen
#

Just one for the whole mesh

sly breach
#

seems like unity default text is also using Tex-coordinates

sly breach
low lichen
#

On the other hand, one quad takes up 80 bytes

sly breach
#

i heard that what DrawMesh does is similar to uploading data via compute buffer but its limited to 1024 elements due to the platform and browser differences to try and support everything

low lichen
#

And maybe one matrix that gets applied to all of them.

sly breach
#

DrawMeshInstancedProcedural :: does it work on webGL tho ?

low lichen
#

I don't know...

sly breach
#

time to try and test it

#

anyhow thanks for the info

low lichen
#

The not so nice thing about DrawMeshInstanced is it's probably uploading that matrix array every frame, regardless of whether it has changed or not.

sly breach
#

its also a very dangerous thing to allow execute in edit mode

#

i had multiple bluescreens and editor crashes when using it

#

sorry i meant drawmeshinstanced-indirect

polar dragon
#

any fake shadows projector for urp in assets store yet ?

grand jolt
#

How can I make an outline shader that works with objects that have flipped normals?

sly breach
torpid oak
#

hi there, is there a reason why instancing would work on shadows pass but not on deffered ?

sly breach
#

does integer division produce floating points ? ( in HLSL )

torpid oak
#

might have a lead : does Unity disable Instancing when rendering on multiple attachments (GBuffers) somehow ?

torpid oak
gritty zephyr
#

@ornate cloud

#

maybe here?

#

seems a shadow/shading issue

dreamy pewter
#

hi huys hope your doing well!
i have a quetion : dose anyone have an idea how to achive this kind of 2d 1bit dithering lighting ??

torpid oak
#

@dreamy pewter it seems to be a post process pass discarding pixels following a pattern the further you are from a given point

#

that's my guess at least

dreamy pewter
ornate cloud
#

i have this flickering shadows problem

#

can someone help me?

teal breach
#

Did you try adjusting the shadow bias setting? It looks like it could be caused by the mesh shadowing itself - typically you add a small offset (the bias) to prevent that from happening

#

@ornate cloud

woven violet
#

Hey! I'm here with a (probably very annoying and over asked) question. I have created a GraphShader and a material to go with it. I've set the Shader to be transparent but I've set the alpha channel to 1, and yet the object equipped with the resulting material are transparent even though the alpha is set to 1, again. I've tried a good 10 15 questions in google but I can't find the answer. Any tips, hints, solutions or tracks to hunt for me please? ^^' Thanks in advance!

woven violet
#

Ok it seems to be an issue with probuilder objects I guess

balmy lichen
#
#pragma kernel Draw

RWTexture2D<float4> Output;
Texture3D<float> Field;
RWStructuredBuffer<float3> Debug;

uniform uint3 Size;
uniform float3 CamPos;

uniform bool IsPathtracing;

SamplerState Sampler {
    AddressU = Wrap;
    AddressV = Wrap;
    AddressW = Wrap;

    MinFilter = Linear;
    MagFilter = Linear;
};

float getField(float3 pos) {
    return Field[uint3(int3(pos)) % Size];
}

[numthreads(8,8,1)]
void Draw(uint3 id : SV_DispatchThreadID) {
    if(IsPathtracing) {
        float3 pos = CamPos;
        float3 dir = float3((int) id.x - 960, (int) id.y - 540, 1500);
        dir = normalize(dir);
        float dist = 1000;
        uint steps = 0;
        while(dist > 0.01 && steps < 50) {
            steps++;
            dist = Field.SampleLevel(Sampler, pos, 0);
            pos += dir * dist;
        }
        float shade = 0.;
        
        shade = float(steps) / 50.;
        Output[id.xy] = float4(shade, shade, shade, 0);
    } else {
        float3 pos = float3(id) + float3(0, 0, CamPos.x);
        if(inBounds(pos)) {
            float value = Field[pos] / 255;
            Output[id.xy] = float4(value, value, value, 0);
        } else {
            Output[id.xy] = float4(0.4, 0, 0, 0);
        }
    }
}```
#

I'm trying to sample a 3D texture. I'm getting an error. How do I make the error go away? It says that it doesn't recognize my sampler when my sampler is clearly declared and set.

fallen sparrow
#

There is something wrong with my logic here, but I can't figure out what is off.
I am trying to map a full texture to a small region of another texture.
If I assume a grid of -5 to 5 overlayed with the primary uv space I know the position of the region that I want to map the secondary texture to.
Here is what I have right in my code, and what it is giving me (white is the secondary texture)

#
float InsideRingOneMaterial(float2 pixel_coord, float angle)
{
    float2 center1_alt_grid = float2(0,0);
    float2 center1_norm_grid = center1_alt_grid*.1+.5;
    float2 rotated_coord;
    Rotate_About(pixel_coord, center1_norm_grid, angle, rotated_coord);
    float2 rotated_alt_coord = (rotated_coord-.5)*10;
    const float sdf1 = distance(rotated_alt_coord, center1_alt_grid);
    float output = tex2D(_Material1, rotated_alt_coord).a;
    return output;
    //return sdf1 < materialSDFLimit ? output : 0;
}
#

I would expect the white texture to be showing up in the center of that image. I'll also note that if I adjust the angle over time it is rotating about the center point properly, so somehow I am applying an offset incorrectly.
Additional note: if I switch out the last two return statements, it properly clips the white texture so that you only see the portion inside the open inner circle.

weary veldt
#

uhm is anyone around who can quickly help me with a shader problem? Its simple maths but i dont find the solution right now
I want my texture to be the same anywhere in the world. So when i move my object, the texture should change (like it is in some oldschool cartoons)

fallen sparrow
#

meaning you want to tie it to world position?

weary veldt
#

yes.

#

i get it to work when i just look at it from one direction, but then the edges are just repeating the color of the pixel it shows at the front

fallen sparrow
#

I saw someone do it in a video recently, I'll try to find the link

weary veldt
#

So i guess i somehow need to use the normal vector to mulitply it into the position but i dont know exactly how.

#

also thanks @fallen sparrow for helping!

tacit parcel
#

I think it's something like triplanar shader or something

weary veldt
#

is there something build in already?

#

this is the look i meant, it doesnt look good tho ^^

weary veldt
fallen sparrow
#

this is when I realize that I watch too many youtube videos

weary veldt
#

well it looks better but is still not exactly what i was looking for

#

the texture is a bit stretched ... it is logical why this happens but i need to fix it somehow

weary veldt
#

gnahh maths. So i need to map my X,Z coordinates in my world space to an X coordinate on my UV map because Y is still from world Space. I figured that out.

#

So it should be an easy mathematic solution to figure out how to use the normal vector and the X Z coordinates to get it mapped to simply X.

dusky cobalt
dreamy pewter
dreamy pewter
dusky cobalt
#

were you using any custom shaders previously?

#

custom shaders will indeed break when you change to URP. legacy standard shaders however, just need you to use the URP material upgrader

fallen sparrow
#

In case anyone is interested or runs into a similar issue later on, this bit of code takes in a color and creates a rainbow over time that respects the saturation and contrast the original color:

float time = _Time.x;
float colormax = max(_Color.x,_Color.y);
colormax = max(colormax, _Color.z);
float colormin = min(_Color.x, _Color.y);
colormin = min(colormin, _Color.z);
float colordif = colormax - colormin;
float fullcycle = colordif*6;
float color_time = 1-(time%colordif)/colordif;
float arc_cycle = colordif;
float currentcycle = time% fullcycle;
float3 color = float3(0,0,0);
if(currentcycle<=arc_cycle)
{
    color.x = lerp(colormax,colormin,color_time);
    color.y = colormax;
    color.z = colormin;
}
else if(currentcycle<=2*arc_cycle)
{
    color.x = colormax;
    color.y = lerp(colormin,colormax,color_time);
    color.z = colormin;
}
else if(currentcycle <= 3*arc_cycle)
{
    color.x = colormax;
    color.y = colormin;
    color.z = lerp(colormax,colormin,color_time);
}
else if(currentcycle <= 4*arc_cycle)
{
    color.x = lerp(colormin,colormax,color_time);
    color.y = colormin;
    color.z = colormax;
}
else if(currentcycle <= 5*arc_cycle)
{
    color.x = colormin;
    color.y = lerp(colormax,colormin,color_time);
    color.z = colormax;
}
else
{
    color.x = colormin;
    color.y = colormax;
    color.z = lerp(colormin,colormax,color_time);
}
spring frost
# dreamy pewter hi huys hope your doing well! i have a quetion : dose anyone have an idea how to...

I dont think this is a postprocessing effect, but a sprite shader, together with some sort of sprite lighting. (in the top row, you can see the light band is not confined to the entire sprites, but goes across the borders)

It's not too hard, you can play around with using the Dither ShaderGraph node, and put the light intensity or a luminance term in there. Depending on your render target resolution, that's already pretty good.

Use hand-painted dithering patterns and put them in a 2D Texture Array (that's a specific texture shape, you select that in the 2nd dropdown of the texture inspector)

There are many pretty cool series like these: https://www.gnome-look.org/p/1106497/ (there's 3 pictures to choose from there!)
You'd cut out and use one column as your texture array and put a pure white and a pure black one at the bottom or top, respectively.

Then you sample the texture array slice with the light level that you have for that fragment, and multiply the final color/alpha of the fragment with that value.

You don't need a new pattern for every texture, but you can make background and foreground dither more expressively by using diagonal lines for the one and dots for the other, etc.

rain niche
#

what could cause instanced materials be black in unity hmmm...

#

inspector shows the values are correct

#

but looks like the shader gets all the values set to default

left stump
#

How hard it will be to change two shader from using a Color to a RenderTexture?

dusky tusk
#

Hello, I am making a terrain shader using Shader Graph and for some reason the texture I have set is not sampled correctly.
At the moment, I generate a terrain by using a generated biomes map, which is just a scaled up noise map. In Shader Graph I have a biomes map texture property which I use for sampling. For testing I created a simple custom function that simply checks the current biomes map value and determent the current biome color

#

Custom Function

if (value >= 0 && value < 0.33)
{
    color = float3(1, 1, 0);
}
else if (value >= 0.33 && value < 0.66)
{
    color = float3(1, 0, 0);
}
else if (value >= 0.66 && value < 1.0)
{
    color = float3(0, 1, 0);
}
else
{
    color = float3(0, 0, 1);
}
#

There are four biomes and as seen in the image it doesn't pick the correct color

#

0 is yellow, which is the biome all the way to the right and there are two other biomes between the red one, which should be the last biome (the red one)

#

Each chunk has it's biomes map,for example

#

Which seems like it should sample the correct color, but it doesn't... :/

dusky tusk
#

Nevermind, appearantly multiplying the red channel value by 2 fixed the issue. I don't understand why, but hey

pliant jay
#

trying to apply a blur to an ui gameobject. which shader should I use, or does anyone have a shader that creates a blur?

foggy osprey
#

Are they any good resources on writing physically accurate particle engines in compute shader?

dreamy pewter
dreamy pewter
uncut valve
#

Are there any tree shaders for URP with working wind? 😛

onyx jungle
#

Hey how do I adjust a vertex based on its up direciton

#

say I wanted to move each vertex up by one in its local y position, my desired effect is for the sphere to expand

#

I already setyp the vert and all

#

Do I take the vertex normal?

#

Nevermind I got it

#

For those interested

lucid lily
#

Is it possible to use displacement maps on sprites within unity? (or would I have to use an outside program like Spine?)
Example of the effect I'm wanting to achieve: https://sta.sh/01i3ctt3l90v

median lava
#

My shader graph is missing albedo

#

It has everything else

#

Normal, metallic, color ,emission

#

Just no albedo

#

Is there any way to get it back ?

median lava
#

Nvm I think they changed to it base color

swift yoke
#

I have the following texture maps:
AO
Bump
Colour
Displacement
Gloss
Normal
Reflection

The HDRP Shader takes a mask map which is made up of:
AO
Metallic
Smoothness
Detail (which I won't be using)

Okay so apparently the reflection map shouldn't be used in a PBR workflow, and the gloss map is the smoothness map. Also the bump map shouldn't/isn't needed either. Still unsure of what the metallic map is

fallen sparrow
#

can someone help me trouble shoot this math? I expect the white texture to be in the center of the little circle, but for some reason it is too far out.

#
float InsideRingOneMaterial(float2 pixel_coord, float angle)
{
    float angle1 = angle+ .480;
    float dist = (_SpellDegree)*1.45;
    float2 center1_alt_grid = float2(cos(angle1)*dist,sin(angle1)*dist);
    float2 center1_norm_grid = center1_alt_grid*.1+.5;
    float2 rotated_coord;
    Rotate_About(pixel_coord, center1_norm_grid, angle, rotated_coord);
    float2 rotated_alt_coord = (rotated_coord-.5)*10;
    const float sdf1 = distance(rotated_alt_coord, center1_alt_grid);
    float output = tex2D(_Material1, rotated_alt_coord-center1_alt_grid).a;
    //return output;
    return sdf1 < materialSDFLimit ? output : .5;
}
#

the mask is applying to the correct location using the same information as the texture and this is really confusing me as to why it has them offset from eachother.

#

if I add +center1_norm_grid to the last tex2D line it is closer to where I would expect it to be, but then it orbits around a second point kind of like a moon instead of staying relatively stationary.

float output = tex2D(_Material1, rotated_alt_coord+center1_norm_grid-center1_alt_grid).a;
#

deal @frail granite ^

#

I think that should be enough information to explain the issue

frail granite
#

mmmm maybe heh. I obnoxiously have to head homeward now tho 😦 losing daylight for biking

fallen sparrow
#

👍 I'll be banging my head at this for a while, so just ping me if you take a look at it and have some ideas later

frail granite
#

@shadow locust sounds pretty smart sometimes.

shadow locust
#

I peeked at this one and thought "I don't have time for this" 😆

#

All of the magic numbers in there are kinda sus though

fallen sparrow
#

fair lol, I haven't extracted the methods for ConvertToAltGrid and ConvertFromAltGrid yet.

eager folio
#

@swift yoke what are those maps from? Hard to say exactly what you need to convert them since there's no guarantee that stuff will be using the same orientation, etc. even if you match the maps up.

fallen sparrow
#
float InsideRingOneMaterial(float2 pixel_coord, float angle)
{
    float angle1 = angle+ .480;
    float dist = (_SpellDegree)*1.45;
    float2 center1_alt_grid = float2(cos(angle1)*dist,sin(angle1)*dist);
    float2 center1_norm_grid = ConvertFromAltGrid(center1_alt_grid);
    float2 rotated_coord;
    Rotate_About(pixel_coord, center1_norm_grid, angle1, rotated_coord);
    float2 rotated_alt_coord = ConvertToAltGrid(rotated_coord);
    const float sdf1 = distance(rotated_alt_coord, center1_alt_grid);
    float output = tex2D(_Material1, rotated_alt_coord+center1_norm_grid-center1_alt_grid).a;
    //return output;
    return sdf1 < materialSDFLimit ? output : 0;
}

This behaves the same, but with fewer magic numbers.
The magic number in angle1 is the angle offset to get the direction of the desired location from the center.
The magic number in dist is just a multiplier to find the location based on the ring I am trying to target.

swift yoke
amber saffron
swift yoke
amber saffron
swift yoke
#

well sweet

amber saffron
#

Depending on the object, it might be not needed at all

fallen sparrow
#

has anyone created a shader with a rainbow effect, and if so have you tried to define a starting point of the rainbow effect?

eager folio
#

@swift yoke it might not be a pbr shader the maps were designed for, or it might be using a specular workflow instead of a metallic one.

#

Not sure what you mean by defining a starting point.

swift yoke
dusky cobalt
#

Gods, I want an MTG game done in Unity (yes I know Arena is a thing, I meant something like XMage)

fallen sparrow
# eager folio Not sure what you mean by defining a starting point.

I'm using starting point and offset interchangeablely here.
In one spot, I want the rainbow pattern to start from green, and another spot should start from blue, etc.

That said, I think I figured it out as soon as I laid down to sleep. I just need to open my project and test it.

grand jolt
#

Anyone here familiar with GPU Instancing?

#

For me its not batching anything, the FPS stays the same, I did turn off static on the object and its children so that cant be it either.

#

These are the settigs on my material, using Standard Unity Shader

#

Would appreciate any help or insight.

#

Here you can see the stats, its not batching any of those flowers (Im testing it by Instantiating 1000 flowers)

#

no shadows, cuts the batches in half, and proves the flowers are not being instanced by the GPU 😦

meager pelican
#

Are they all using the exact same instance of the material? What pipeline? (Assume standard)

grand jolt
#

Standard Pipeline, not using URP or HDRP

#

And yes they are

#

but now that you say that

#

let me check something because my script does change the material color during runtime

meager pelican
#

😉

#

Don't set renderer.material.anything.

#

Use renderer.sharedmaterial

#

If you use .material, it clones it and makes a new material instance. So you ended up with 1000 materials.

#

But...I'll have to look up how to do instancing.

#

Been a while.

grand jolt
#

well i commented out all the material code and its still the same...

meager pelican
#

You have to set up material property blocks, is that what you did?

grand jolt
#

no I didnt, im using the Standard Shader

#

Do I still have to set up property blocks then?

meager pelican
#

Well, yeah, when you're instancing, you still need to pass it an "array" of structures to the unique data for each instance. That's how it "plucks" out the color or whatever for the instance. I think _Color is a pre-instanced property in the standard shader though, so you don't have to write a custom one just for that. IIRC

grand jolt
#

So you are saying as far as you know, the problem in this case isnt property blocks?

meager pelican
#

The problem is that you have to make them, and didn't.
The example in that link is:

MeshRenderer renderer;

foreach (GameObject obj in objects)
{
   float r = Random.Range(0.0f, 1.0f);
   float g = Random.Range(0.0f, 1.0f);
   float b = Random.Range(0.0f, 1.0f);
   props.SetColor("_Color", new Color(r, g, b));

   renderer = obj.GetComponent<MeshRenderer>();
   renderer.SetPropertyBlock(props);
}```
#

That's set on each renderer for each object. When unity draws the scene it "batches" the MPB's up into instanced calls, for the ONE property block you should be using (that's really an array of structs with instanced properties). And one material.

grand jolt
#

I assumed the Standard Shader had this built in, but I think you are right, let me try and figure out how to do this. Thanks for all the help and your time mate, I appreciate it.

meager pelican
#

OK, the SHADER has color built in.

#

But it's up to you to make the MPB on the C# side.

#

And set the renderers to know about the MPB

#

And enable instancing on the material (with that checkbox that you already did).

#

It's a "both sides" thing.

grand jolt
#

Ok, this is going over my head, ill have to look up a tutorial how to set up MPB's and where.

meager pelican
#

It will be fun. Think of it as an adventure. You'll find it. 🙂

grand jolt
onyx jungle
#

Anyone know how I could shade an object with noise such as this (in a shader ofc)

grand jolt
#

nvm ill just watch a YT video I think

grand jolt
fallen sparrow
# grand jolt Ok, this is going over my head, ill have to look up a tutorial how to set up MPB...

here is a simple example of how to set up a MPB:

public class HealthBarUpdate : MonoBehaviour
{
    [SerializeField] MeshRenderer healthbar;
    [Range(0f,1f)]
    [SerializeField] private float percentHealth = 1;
    private MaterialPropertyBlock mpb;

    MaterialPropertyBlock MPB
    {
        get
        {
            if (mpb == null)
                mpb = new MaterialPropertyBlock();
            return mpb;
        }
    }

    // Update is called once per frame
    void Update()
    {
        ChangeHealth(percentHealth);
        healthbar.SetPropertyBlock(MPB);
    }

    public void ChangeHealth(float newHealth)
    {
        percentHealth = newHealth;
        MPB.SetFloat("_Health", percentHealth);
    }
}
#

then in unity I have an object like this

meager pelican
#

@onyx jungle In that case, you can pass in a noise texture (which is black and white) and then scale the noise to some range in any number of ways, like divide by two and add .5, or just use a remap of some type, and then multiply the result by the color you also pass in. So you get degrees of color-ness, lighter or darker.

#

And you can scale the UV's too, to zoom in/out on the noise.

onyx jungle
meager pelican
#

Meh, it was just an example. To scale the result from its 0...1 to .5...1 so that you'd not have black areas. Just one of 1000 ways. You could use a min/max function, other things.

There's really no one answer to your question, it all depends on how YOU want to do it. A max() function would cut off the black and make a min value for the color background, for example.

What pipeline are you in?

#

But you'd use a noise result (probably the red channel 's float value) and multiply by your color. Scaling the UV's for sampling zooms in and out. If you're in SG, there's an offset and tiling node to help you do that.

#

Or a formula for standard pipeline.

#

So...in pseudo code for shader:

float noiseValue = sampleTexture(myUV, myNoiseTex);
noiseValue = max(noiseValue *.8395, 0.3); // whatever you want, use a slider for stuff not hard-coded #'s
float4 resultColor = float4(noiseValue * myColor.rgb, 1);
return resultColor; ```
#

@onyx jungle

onyx jungle
#

Hmm this is very interesting @meager pelican

#

I managed to get the noise/colouring for it working

#

wait

#

However I have this

fallen sparrow
#

that is because the bounds of the noise are not necessarily smooth with their opposite bound.
you would need to make sure that the 0 and 1 x bounds are smooth with eachother and that y=1 and y=0 are both constant.

eager folio
#

@onyx jungle you are using the uvs of the mesh to generate the noise, so any distortions and discontinuities the uvs have will be there in the noise(that's why you get seams and pinching)

eager folio
#

Basically you're making a noise texture map on the existing uvs.

meager pelican
eager folio
#

You could pass the position in object space to the noise directly instrad of the uv coord, but you'd need to use 3d noise

#

Right, exactly.

fallen sparrow
#

3d noise would be the easiest solution here because it doesn't require a different interpretation for each object shape.

onyx jungle
#

at the moment, for the noise I am currently generating a noise texture which I just slap on the object

meager pelican
#

There are other types of sphere models that don't converge at the polls. Like a soccer ball uses other shapes.

onyx jungle
meager pelican
#

But....how do you generate the UV mappings? Do they converge at the polls? The standard unity sphere converges there.

#

For example. So there's TYPES of spheres

onyx jungle
meager pelican
#

And like has been said you might want to research tilable noise.

onyx jungle
#

I generated just a standard unity sphere effectively then adjusted the vertecies

fallen sparrow
#

the default converges at the top, but it is still a coordinate system, you can map that coordinate system to a different one, such as the soccer ball pattern.

meager pelican
#

Yeah, converges

onyx jungle
meager pelican
#

Yeah

fallen sparrow
#

are you zooming in on the texture at all?

#

or just wrapping it around the shape?

meager pelican
#

And you can do tri-planar projections but on a sphere, IDK. Probably works. In the end it's best to have A) The right model and B) The right UV's. That's "doing it right the first time" then you don't have to screw with stuff.

#

2-cents

onyx jungle
# fallen sparrow are you zooming in on the texture at all?

well the texture takes a zoomed in sample of some perlin noise, so when its zoomed all the way out you get the white noise looking perlin noise, but after I generate the texture I dont do anything to it other than apply it to the materials albedo on the object

#

I do the tex application in shader

#

but the texture generation in C#

fallen sparrow
#

the portion of the noise you are using needs be be tileable, that will remove the line seam

#

if you zoom in that portion is not guaranteed to be tileable

onyx jungle
#

when its converted into a texture I leave it

#

no extra processing

#

so it does not tile

onyx jungle
meager pelican
#

https://en.wikipedia.org/wiki/Truncated_icosahedron

There's no easy way to map a 2d rectangle to a 3D sphere. You'll have to research what to do. Mapmakers have this trouble all the time, BTW.

In geometry, the truncated icosahedron is an Archimedean solid, one of 13 convex isogonal nonprismatic solids whose 32 faces are two or more types of regular polygons. It is the only one of these shapes that does not contain triangles or squares.
It has 12 regular pentagonal faces, 20 regular hexagonal faces, 60 vertices and 90 edges.
It is the...

meager pelican
#

^^ that one looks to be a good read (quick google by me, so YMMV)

onyx jungle
#

ok cheers

meager pelican
#

🙂

onyx jungle
#

we can see it converging at the top as you said

dusky cobalt
#

Hey, This might be a larger ask than most, but can anyone translate a cg shader into shadergraph nodes for me? I'm trying to make the effect that this shader creates (keep a texture's size constant regardless of camera depth), but I can't read CG for the life of me.

https://gist.github.com/bgolus/c417fbbca71cdecd7dc3f747a6ff66d9

Gist

Visually stable constant screen space sized texture shader for Unity - StableConstantTextureSize.shader

#

Basically i'm trying to implement Dithered transparencies in VR.

dusky cobalt
#

@pseudo narwhal and if it were a Non-VR game, you'd be perfectly correct.

pseudo narwhal
#

Why that works in VR aswell?

dusky cobalt
#

but since we're in VR, implementing that makes the dithering move along with the camera. Trust me when I say this does not look right.

#

Meaning the dither has to be in world space, which the Dither node doesn't support.

pseudo narwhal
#

Well, its dither... thats kinda what it does

#

but hang on a sec...

dusky cobalt
#

Using a triplanar node with a custom dither texture (i'm using some blue noise) allows the dither to be static in world space, so it doesn't move with the camera.

pseudo narwhal
#

tbh, nobody ever complained about camera-static dither in any of my VR projects... but maybe they never dared to mention it

dusky cobalt
#

this makes it static to world position but not depth. I need the dither pattern to scale itself so it remains constant regardless of how far it is away from the camera

#

This is what Screen space dither looks like in VR.

meager pelican
#

Oy. So you want BOTH worldspace dithering, and somehow, magically at the same time, you want it all the same size regardless of distance.

But worldspace is...partly a function of the distance, since it scales the object according to the perspective divide that happens between vert() and frag().

I'm trying to envision how you do that, and I'm failing miserably.

Maybe, we have to change an assumption. Maybe it's OBJECT SPACE relative, so the same "spot" in the texture is either there or not, regardless of where you view it from (which eye).

#

Possibly scaled by the distance to keep it sized.

#

Since if you punched cut-outs in a piece of paper to "dither" it, and looked at it with both eyes, the perspective changes, but the holes don't.

dusky cobalt
#

And i've just been playing aorund, and you're correct

#

object space works just as well

meager pelican
#

So now, somehow, you "just" scale by distance, eh? But you might have to be careful that you use the camera-plane distance, not distance-to-eye.

#

Since both eyes are on the same plane (I think, I don't do VR, so cut me slack).

#

But pretty sure camera plane is the same when doing single-pass-stereo

#

Which gives me a thought....maybe you could compute the mid-point of the eyes, and use that same point for the dither calc for each eye. And use screen-space. Like some distance from that point = grid. Would that map to the same pixels? Then grid = same size automatically.
I'm rambling, and don't have a VR to try it out.
@dusky cobalt

dusky cobalt
#

Might have something here.. just need to tile by distance to camera

meager pelican
#

Cool.

#

You might not need that multiply either.

#

Dither = cutoff where alpha is < threshold, and the threshold is the looked-up value from the dither table, IIRC.

#

I have to think about it.

#

And your dither texture can be a 1 channel Red-texture (to save memory) unless you're packing multiple dither patterns into it.

vapid garnet
#

does anyone know how to make a custom postprocessing thing for urp

dusky cobalt
#

getting a bit closer, but keeping the texture tiling constant regardless of the distance to the camera is the real issue.

#

thanks for the headsup on using the red channel and cutting out the multiply

meager pelican
#

Try screen space, and eye-midpoint for both, but I'm guessing. Then you don't need to scale it by depth since you're in screenspace. I just don't know if you'll get fuzzies.

dusky cobalt
#

this got... close?

#

as mentioned before, I have to avoid screen space

meager pelican
#

OK, but scaling it back up by depth is basically the same thing as clip-space. 😉

#

Which isn't far from screen-space.

dusky cobalt
#

heh, i'm lost lol

#

did you have a look at the gist I posted earlier?

meager pelican
#

The vertex shader outputs clipspace position. And the simple version is that the depth is in the .w component of the vector.
So during rasterization, the clip-space stuff (which is all -1...1 range) is DIVIDED BY DEPTH. Which "squashes" it all toward (0,0) which is the center of the screen. So things farther away get squished more into the center at distance, which gives you 3D perspective.

#

Yes I did.

#

So you're saying you want to scale backwards by distance somehow to get back to clip space.

#

basically

dusky cobalt
#

Apologies for being rather unknowledgable about shaders and stuff. This is way above my pay grade atm, but I don't exactly have a tech artist on my team lol

meager pelican
#

Yeah, and I'm having a hard time envisioning what you're doing. I saw the concentric circle example that shows it best.

#

I think.

#

But IDK what happens when the camera moves

dusky cobalt
#

I just don't wanna use any transparencies in my VR game (for obvious reasons.. y'know.. quest and all)

meager pelican
#

So you want the circles to "not move" when the camera moves, so the rings stay the same for a constant opacity.

dusky cobalt
#

but it not be circles, it's supposed to be blue noise. think the Obra dinn shader, but for transparencies. :)\

meager pelican
#

but for distances you don't want that to count for some damnable reason.

#

Yeah, I've done blue-noise dithers, in screen space and not in VR and not distance agnostic

dusky cobalt
#

I'd rather not have it count, since the further away you move the camera from the object, the transparency changes

meager pelican
#

Why?

#

The opacity is the same value unless you change it. You mean, how it looks?

#

dithered

meager pelican
#

The reason for using screen space is to keep the pattern from being really small in the distance.

#

Yeah, but that's not screen space. But you're right, screen space is different as the camera moves, because the object "moved" relative to the screen.

dusky cobalt
#

that's in world/object space, yes.

meager pelican
#

If it was me, I'd use object space and let it be "smaller squares" at distance, since it logically SHOULD look smaller farther away. Think like a transporter-effect-fade, or particle vanish. The particles would be smaller farther away.

#

But yes, it covers fewer pixels.

#

Do these transparents stay on screen a long time, or is it some vanish effect?

dusky cobalt
#

looking at menus and big ass smoke particles, yeah

meager pelican
#

I've done smoke in screen space and it's OK because it was moving anyway.

dusky cobalt
#

I'm half ready to just bake dithering into the damn texture at this point lol

meager pelican
#

LOL

#

Menus would be screen space, since they're always in the same screen-relative place when "up/showing".

#

But static stuff that's "transparent/dithered" would move relative to the camera changes in respect to screenspace, but not worldspace.

#

So then you're back to worldspace again, but maybe not "same for all distance". I think that's what's throwing you.

#

I don't understand that one, but maybe I'm dull.

#

So I'll bow out since I'm not helping at this point.
Maybe you can pull something off scaling the tiling/offset and using worldspace or objectspace calcs. IDK.
I wish you luck though. I"m just not "seeing" it in my mind's eye to know what to do, guess.

dusky cobalt
#

eh. I give up.

#

at this rate it's probably easier to me to bake the dithering into the particle textures 🙂

#

thanks for the help, though

#

maybe if I just use alpha to coverage, instead?

#

...wait. have I been going about this all wrong the entire time?

#

Also note that you should never use alpha test shaders, such as Unity’s cutout shader, on a mobile device. The alpha test operation (as well as clip(), or an explicit discard in the fragment shader) forces some common mobile GPUs to opt out of certain hardware fill optimizations, making it extremely slow.

#

omfg

meager pelican
#

If you can bake dithering into the texture, it won't be the same size regardless of depth. That's the thing that's throwing me as to why you're doing it.

But as far as TBR (Tile based rendering on mobile) I think (this might vary with older or lower-end hardware) that using ANY of the alpha-blend, discard/clip, or alpha-test is going to disable the Tile-based optimizations if present. It sucks, it's a catch-22 and you should test as much as possible on as many devices as you can, or someone might know some sites that will test on various GPU's or emulations. So IDK now much using alpha will save you either. Best to test it out on device and time it. Code up a test setup with same stuff and render+time 1000 frames. Change options.

It all comes down to "how bad is bad"? How much is much? The performance gain of TBR is about being able to smartly discard pixels that have no effect as things "stack up" in the local 'chunk' of the screen (a tile), IIUC. But alpha stuff or discards disables that, I think.

#

Others will know more than me about all the mobile-space issues. 🙂

granite tangle
#

Is there an optimized easy way to do realtime reflections for a waterbody

dusky cobalt
#

@meager pelican well, thankfully we're just talking about Quest 1/2, but yeah, I've got no idea if it supposrts it nyway

pure knot
#

Hey all, is there a way to read 32bit float values from a rendertexture. I've created a rendertexture with RenderTextureFormat.RFloat. When I use the regular texture2D.ReadPixels it reads only 8 bit per channel and I lose precision.

edgy sleet
#

how can I write to a texture in shader graph such that another shader can use that texture?

#

I can only find how to read a texture (Sample Texture) node

pure knot
#

Or you can use a compute shader

edgy sleet
#

is ithat expensive? seems wierd that there is no SetPixel node?

#

im just learning so would like to stay within shader graph for now. ill try the camera route, thanks

onyx jungle
#

Anyone know how to tackle this

#

on a unity sphere I get converging at the poles

#

when I apply a texture

eager folio
#

@edgy sleet You can't do it within the shader, I believe.

#

@onyx jungle Either use a texture that is distorted to compensate, or use a mesh with different UVs

#

Or use triplanar texturing

onyx jungle
#

UVsphere, icosphere

#

cube sphere

#

unitys default sphere

#

nothing works

onyx jungle
#

what is this

eager folio
#

There's a photoshop plugin on that page that will distort a texture to compensate

#

Triplanar texturing uses vertex positions instead of UV coordinates to texture map it

onyx jungle
#

but would the texture look normal ultimately?

eager folio
#

If done correctly. You might need to experiment

onyx jungle
#

eh, seems a bit too specific and annoying

#

id rather learn how to do it properly

eager folio
#

I mean, you could probably implement the same thing in a shader

#

Scale the v as a function of itself

shadow kraken
#

There is no "proper" way, there are just ways to work around it

#

one option is to use an unwrapped cube fully smoothed, another is to use triplanar like pinballkitty said. I would probably do the latter because it gives you options for smoothing seams

onyx jungle
eager folio
#

Right. There will only be approximations because a sphere can't actually be tiled with squares mathematically.

#

So you have to either live with the small distortion, or mathematically alter your uvs or your texture to compensate.

#

A cube sphere spreads the distortion much more nicely than a default sphere, but either way requires some work to make it tile properly, etc anyway.

meager pelican
#

Mapmaker's dilemma.

meager pelican
# edgy sleet how can I write to a texture in shader graph such that another shader can use th...

If you don't actually NEED a texture, google RWStructuredBuffer or relatives. Can be read/written by "normal" shaders and by compute shaders. Note IDK how well SG deals with them. But it's basically a data buffer that you can use, rather than having to map it to an actual render texture that you never output to screen. The C# side is a compute buffer.
https://docs.unity3d.com/ScriptReference/ComputeBuffer.html

There are size limitations and API level constraints though.

spark escarp
#

hi boys

#

how i can perfectly set outline my problèmes is inside outline Add node i have some pixel who have color how i can set all pixel who match with texture to 0 ?

near pond
#

I have a unlit shader to display a mini map which is a top down camera rendering (with that unlit shader) the map on a render texture... Problem is the water is a view space calculated mesh, and it reflect what my main camera see. If i want to make that part a plain color, how could that be achieved?

meager pelican
#

The water shader could stencil what it draws, and then you could use that in your mini-map shader to tell if it's water or not and substitute a "plain color". Just throwing that out there.
So research stencil operations, and watch out for the mask so you don't have problems with mangling Unity's use of stencil. But you only need 1 bit for water-or-not.

near pond
#

thx ill check that out

toxic flume
#

How can I implement a highlight line or outline in intersection place between wall and other objects for my blue zone like pubg or cod mobile? (Mobile devices)
I want the most efficient approach
I have to use depth map or stencil buffer?

pure knot
#

I'm using sampler2D_float for sampling a RFloat Texture but its still providing me 8 bits precision instead of 32 bits. Any ideas?

main pasture
#

Is anyone able to help me with accessing the data from an AppendStructuredBuffer on the CPU? I am using Append in the structure to append float3 but reading it back as Vector3 on the CPU is just returning (0, 0, 0). After dispatching the shader, I access it by making an array the same size as the buffer and using buffer.GetData()

dusty pivot
#

how can i use the TexelSize node when the maintex is a spritesheet animation? How do i get the size of the actual sprite used, rather than the texture

median lava
#

is there anyway to get rid of this incorrect skybox reflection ?

onyx jungle
#

Anyone know how I can colour my noise properly?

#

at the moment in the shader I am multiplying the noise output by a colour, which gives me this

#

but I want to replace the black patches for example with red, and smooth between other areas with other colours

median lava
#

nvm fixed it ,, my texture wasn't set to normal

grand jolt
meager pelican
meager pelican
# grand jolt 😡

That post doesn't count it was on April 1st (April fools day). 😄
Seriously, though. Simple surface shader stuff is easily duplicated in Shader Graph.
it's the more complex stuff where you want to edit things that's not well documented yet.
But you can make a relatively simple SG and then look at and edit the code for some custom "calcs" or use a custom node.
It's a different pipeline after all.

onyx jungle
#

Because it’s generated perlin noise and so it’s not just black and white, there are lighter grey gradients in between

#

I am straying away from a simple noise texture because I was getting weird converging at the spheres poles

#

Here I just set the rgb colour of the pixel with the noise

#

So I get no stretching

left stump
#

Das any one has any shader for Rain?

#

If it's free is better ^^

fallen sparrow
#

If you want a hard cutoff instead of a gradient you can do something like

If(noise>.5)
   return red*noise
else
   return green*(1-noise)
somber snow
#

Before I start looking for a solition that might not even exist: Can you get gaussian blur through shaders?

knotty juniper
# somber snow Before I start looking for a solition that might not even exist: Can you get gau...

this might work (not 100% that its gaussian blur in particular)

https://www.youtube.com/watch?v=NLgrHFCF3oU

Zii

Scene Color*
This is an updated version of the Blur tutorial, Hope you like it. Enjoy.

  • Screenshot Available at 4:54
    Don't forget to like the video and subscribe.
    We're 50 subscribers now thanks everyone.

Music: by TheFatRat
Elevate : https://youtu.be/d9sDY3iZB0M
Envelope : https://youtu.be/F1AgdpwdGkk

▶ Play video
somber snow
#

I saw that one and I tried it but I would like it to be more modular. As in, I would like to have a subgraph that blurs any procedural texture previously made (which I've heard shader graph doesn't support multi-pass shaders)

#

Thanks for answering

mint drum
#

Would I need to go to shaders if I wanted to prevent a mesh from going through another mesh? IE, if the mesh happens to go through another, keep it from rendering on the opposite side of that mesh... or is there another route I'm missing?

#

And if that happens to be shaders, anyone happen to have a direction I can start studying?

timber pier
#

can anyone tell me on where is the toon shader? (2017.1.1f1)

median lava
#

@timber pier the unity toon shader is in the standard assets under effects i believe

onyx jungle
onyx jungle
calm marsh
#

Which shader for particle should I be using if I want my texture's background to be transparent?
Is Mobile/Particles/Additive okay? When i google it people seem to point towards using shaders under the Transparent submenu which is now under Legacy

restive radish
#

simple question: I have two passes in a shader and want to share a variable between them. To be more specific, I want the output of first fragment to be used in the second. Where should the variable be declared?

low lichen
restive radish
#

first pass paints the ground, second makes animated pixel art billboards of the same color as the ground

#

so the first pass is the one to check light and shadows, second doesn't interact with lights or shadows

#

just want to pick the color from first pass to "paint" the pixel art

#

so they blend with the ground

low lichen
#

I don't understand. You have this shader on both the ground and some number of billboards?

#

And you want to be able to share a variable between the ground and all the billboards?

restive radish
#

no, the shader has two passes: one to control the color of the surface and another to make bilboards in the surface

#

I want the output of first pass to be visible to the second pass

#

the output of fragment

low lichen
#

Okay, so by billboard you mean a quad that faces the camera, not actual billboards

restive radish
#

in other words, a simple float4 variable

restive radish
low lichen
#

What you want isn't really possible, unless you draw the first pass into a separate texture and then read that texture in the second pass

#

How do you plan on blending the color from the first pass into the second pass?

#

Maybe you can use hardware blending, basically drawing the first pass transparently on top of the second pass.

restive radish
#

I'll see what I can do here

#

thanks

low lichen
#

You would have to draw the passes manually, instead of letting Unity handle it

#

I don't have enough context about your game to know if that's a good idea or not

restive radish
#

Ok, ty

left stump
#

And it's a shader for glass

#

Glass rain

onyx jungle
#

particle systems are really low cost

#

if you do it right it will look right

#

make a localized particle system that follows the player

#

creating a rain particle system for a WHOLE scene would be stupid and as you said cause lag

#

just have a rain system that follows the player/camera

left stump
#

it's a VR game, that will be very bad, and there player can't go outside

#

So the rain will only be on glass

onyx jungle
#

then put the particle system infront of the glass

#

it all depends on what type of effect you want to acheive

#

if you want the rain to stick to the glass and trickle down in then yes a shader would be required, I personally would use some noise so create random rain droplets, render this to a texture and overlay it onto the glass.

#

however a particle system should be enough

onyx jungle
left stump
wraith wing
#

hi all, what causing new blank shader turn pink? the others was fine only new create one pink

regal stag
wraith wing
#

ah I see thanks alot @regal stag

dusky tusk
#

Hello, why do the shadows look like this on my generated terrain mesh?

#

Is this a problem with normals?

#

I think I found the source, but not sure what is the solution. I use a Texture2DArray to store different PBR maps, including normal maps. When I sample a map from the texture array it doesn't let me specify its type, so I use a normal unpack node in object space including the frag normal space. However the lerped normal map makes the terrain darker and if I rotate the mesh 90 degrees the entire mesh becomes black

meager pelican
#

And in SG you can use the node that gives you the background, if you set the shader to transparent. It's "Scene Color" I think. But you have to enable it in some settings. It takes the place of the standard pipeline's grab-pass, and it happens after the opaque and skybox passes, before the transparent pass.

#

Or if you "just" have 2 colors like I think you said originally, then you can just use lerp node/keyword, with the w being the noise float's value.

meager pelican
wraith wing
#

hi all need help. I have this strip but want make the gap more wide, what the best to achieve this? what I'm already tried to do: give another strip with different setting it's somewhat work but can't be uniform when animated

#

ok after some adjustment, it can be more clean but still is there's any non guess work workflow?

#

use blend method previously use

fallen sparrow
#

if you want larger gaps between the bars, you need to decrease the frequency. I haven't worked with shader graph, or whatever that is, but there should be a way to modify the angle being used to generate the triangle wave.

worn lion
#

So I have a mesh consisting of all these cubes. I want to raise their top vertices individually using a texture but I am at a total loss on how to do that. Right now I have only figured how to raise the top vertices but it affects all cubes and I want to be able to do it on the individual cubes. Help appreciated peepoSmile

merry rose
worn lion
#

Aight i will give it a try thank you. TT_bongocat_wave

wraith wing
fallen sparrow
#

if you apply an offset that would weight the light parts more than dark
cos(angle*freq)+offset

wraith wing
#

ah this work

#

is there's any "level" nodes on unity? like in blender / substance

foggy lantern
onyx jungle
# meager pelican When did "current color" come into play? IIRC, that wasn't in your original pos...

Yea I am going to try the lerping, to avoid the weird stretching I was getting at the poles of a sphere in unity, I opted for a technique where I generate noise in the shader to be applied to the rgb values of the surface thus eliminating the stretching, the noise however is just in greyscale at the moment and was wondering the best way to get it from grey scale to a different colour range, for example in a gradient

onyx jungle
foggy lantern
onyx jungle
#

somewhere to start with what?

#

saving a texture?

#

or sending it to the shader

#

Unity docs for saving texture

#

as for sending it to the shader on start

#

just reference the material in a C# script and using material.setTexture("tex variable name in shader", texture variable you are passing over);

#

although again, I have no idea what you are after

foggy lantern
#

thanks ill look into it

foggy lantern
#

Ok, I managed to fix the problem, sorry for being so vague. The problem was that textures I made for the planet in edit mode were lost and I needed to know how to save the textures when they were generated and then apply them to the shader. But it's fixed now, thank you for the help @onyx jungle!

onyx jungle
dusky tusk
#

And when I rotate the mesh it becomes dark...

grand jolt
#

Hey there, how would I go about creating an outline shader for urp? I would like it to work with flipped normals aswell. I have no experience with shader whatsoever, but I am willing to learn

onyx jungle
grand jolt
#

I'd prefer using shader graph

teal breach
#

I've been noticing a difficult bug for a while where sometimes materials appear differently between build and editor. It seems like on some builds, incorrect keywords get set (I'm using URP).

#

I think it relates to having multiple passes and using local keywords, but I'm still investigating - just wondering if this triggers any info from anyone?

#

my hunch is that the keywords are only set in some of the passes if you define them using local. It's a hard test to replicate though, so I'm at a bit of a loss currently

teal breach
teal breach
lucid sluice
#

Is there a way to render shadows on top of a transparent shader, or is there a way to render object depth in an opaque shader? I'm trying to render shadows on to a liquid like surface and I want to preserve the ability to render depth as well as make it receive shadows too

wraith wing
#

hi all so currently all my shader mapping were set to UV0, how to change the mapping to geometry?
already try "Normal Vector" but the result is wrong

grand jolt
teal breach
twilit ocean
#

does anyone know of any videos or resources that explain how to get a similar result to this through a shader? Right now I'm just using a cloth which is not ideal but I'm very new to shaders so don't quite know how to approach it.

thick fulcrum
twilit ocean
#

o nice that looks like the right direction I'll look into that. End goal is to have a sort of melting slime/ooze look I can put on things (or anything that resembles pine resin/liquid amber), the jiggling up while it moves isn't too important it could always drip down too.

turbid holly
#

Does anyone know the performance considerations for these approaches?
Approach A: a 256x1 texture for color lookup
Approach B: an array of colors, n = 256
In my shader(s), for every pixel I will do ~3 samples/retrievals from this texture/array. These values change every so many seconds.

noble steppe
#

Hello! I'm trying to do an UI element that looks like the screen below (a circle segmented in X different parts)

#

I thought that the best way to do it was through Shaders.

  • Is Shaders the best way to do it?
  • Does anyone know some ressources that would help to achieve a similar effect?
    Thanks! :blush:
low lichen
turbid holly
#

@low lichen Yes, I think I could use texture interpolation to my advantage here

desert orbit
noble steppe
# desert orbit Depending on what you need, UI Image component in fill mode might be sufficient ...

The problem of the round sprite is that I will not be able to change the segmentation right?
It's okay I said UI but it will be near a side scroller character like a reticule showing how many ammo you have and the direction you are aiming
I saw about the Shapes asset by Freya Holmer but I'm curious about how it is possible to achieve this without "out of the box" solution... If I can't find any way then I will probably buy this asset 🙂

desert orbit
#

Checkout shader graph shader samples in the package manager for ideas. They can be imported from there. Also tutorials. It's easy enough to do a circle shape and circular masking. But I wouldn't know how I would create segments from it.

noble steppe
thick fulcrum
eager folio
#

You could create segments by adding a mask that has the segments baked in?

noble steppe
eager folio
#

what rendering path are you using?

eager folio
#

something like this?

pale tapir
#

Hello there 👋
Would anyone able to help me on a Shadergraph problem I am facing for hours please?
I would like to know how I can get the screen space coordinates of an object from which I can only get its world space coordinates?
I tried several things and though that the "Transform" node (World->View) would do the trick but not at all... I tried this graph with no luck:

#

Basically the problem is "How to convert world space coordinates X,Y,Z to screen space coordinates X,Y?" 🙂

#

I know how to do that in C# but it would be way better to do that in the shader only without having to pass a value

noble steppe
eager folio
#

It has some serious problems but you could definitely do better