#archived-shaders

1 messages Β· Page 148 of 1

grand jolt
#

so I guess the same issue as adding, except half the issue. because its getting a color midway between the two.

#

and it extra doesnt work if you use one of the spritesheets that arent bugging out like that, because it'll just interpolate between the desired color and black.

wraith haven
#

ok

#

let's put aside the weird preview thing πŸ˜„

#

I think this is just packing showing up, and you haven't answered on what component you used the material on in the editor, so I can't help you

#

BUT, I can tell you about the blending

#

here's the issue, afaik

grand jolt
#

oh. i used it on a spriterenderer.

#

my bad.

wraith haven
#

ok there you go, so the sprite renderer doesn't have unit uv coordinates, it has the ones that match the atlas

#

if you apply the material to a quad mesh, or the default plane, it'll show the preview you have

grand jolt
#

indeed. and thats an issue if I offset it enough for the next image in the atlas to show up "close" enough to render in the slice. but im not doing that. let me try that tho.

wraith haven
#

anyway, it shouldn't matter, as long as your offset doesn't make your sprites bleed onto each other

grand jolt
#

yup. and im not offsetting enough to let one show in the other.

wraith haven
#

so

#

you need to blend rgb channels and alpha differently

grand jolt
#

from the MainTex to the sampletexture2d?

wraith haven
#

you need to lerp your rgb channels, based on the mask you made (the substract + clamp)

#

and then you need to add together the original alpha and the new one, and saturate them

grand jolt
#

oh. yeah I can think of ways of solving this for this specific spritesheet. but the issue is that whatever I do to "ignore" the bleeding in the background, will look weird on spritesheets that dont bleed in the background.

wraith haven
#

I don't understand your wording I'm sorry

#

sprites are rgb and alpha, done

regal stag
#

It shouldn't matter what sprite you use if you lerp between the two colours based on the subtracted alpha

wraith haven
#

some of them have preumtiplied alpha, some don't, but this is alpha blended

grand jolt
#

Good point Cyan. Problem is that the alpha in the bleeding background isnt 0. Its 255 too. So if I do blend between the interpolation of thhem it`ll just give me a color in the middle.

regal stag
#

Huh?

#

Whether the alpha is 0 or 1 (255), it wouldn't give you a blend between the two colours, it would output one colour.

#

Where T=0, it outputs A, and T=1 it outputs B.

wraith haven
#

the bilinear would, but you should use PointSampling Shapis

grand jolt
#

ah. right.

wraith haven
#

do you?

grand jolt
#

Yes. I've been using point in filter mode.

#

if that's what you meant.

wraith haven
#

yes, ok so no interpolation problem πŸ™‚

#

alright, so, lemme rephrase your objective πŸ˜„

#

you have an alpha sprite ( or sequence of sprites that are packed, irrelevant)

#

and you want to have an offset version of that sprite with a flat color "underneath", correct?

grand jolt
#

yes, above underneath. anywhere.

wraith haven
#

it matters

grand jolt
#

so Im doubling the initial sprite, offsetting one of them. subtracting the alpha of the offset by teh original one. clamping it so the 0 alpha but non 0 rgbs go away.

wraith haven
#

the original, un-offsetted sprite is 'on top' of the flat color, as in layers, not position wise

#

correct?

grand jolt
#

I dont understand that line. What flat color?

#

I'm having them both going through different channels and only adding together when Im inputing the color on master.

wraith haven
#

the photoshop analogy : you duplicate the sprite, the one under is offsetted and has a color overlay style

grand jolt
#

other than the alpha subtraction, they dont interact til being added at the end.

wraith haven
#

the objective man

grand jolt
#

oh derp. do you know what could work. just cutting off the sampletexture from its alpha.

#

and doing everything from there.

regal stag
grand jolt
#

yup. and it does work, on every single spritesheet except this one.

wraith haven
#

thx Cyan, I'm off πŸ˜„

regal stag
#

If you preview the alpha output from the sample texture node what does it look like?

grand jolt
#

it looks proper, it doesnt bleed into the edges.

#

it looks just like the sprite, but without any color. and yeah. thats a good idea. just cutting that off of the weird bleeding sprite.

regal stag
#

In my sprite I have it bleeding/stretching to the edges and the result is still fine

wraith haven
grand jolt
#

huh. indeed.

regal stag
#

It's likely just the offset isn't perfect

grand jolt
#

mhmm.

#

btw thanks for the help guys, it has helped lots. im gonna try both ways, the way cyan did it and check if just cutting off the alpha works in an intuitive way too

regal stag
#

Yeah, the sprite is an awkward height of 46 pixels, so the proper pixel offset would be -1/46. I just did 0.05 to test it.

wraith haven
#

ooor it could be just dealt with properly

regal stag
#

How do you mean?

wraith haven
#

lerp rgb, add and saturate the alpha

regal stag
#

I think that would just produce the same result. The gap is due to the incorrect uv offset.

#

It's already lerping between the original sprite alpha and 1 from the colour.

wraith haven
#

it wouldn't

#

you're doing the lerp from the original alpha to the solid 1.0 alpha of the color

#

based on the difference

#

if you add them, it has no chance of being anything alse than 1 on the transition

regal stag
#

Right, but with point filtering there is no transition.

wraith haven
#

and it would also work with other sampling, because you rely on it being always point

regal stag
#

Guess it just depends on what you need the shader to do / support.

#

If you wanted an outline around a semi-transparent shader for example you wouldn't be able to add + saturate the alpha values or it would remove that transparency.

grand jolt
wraith haven
#

so would your difference

grand jolt
#

huh. that works in the shadergraph preview, it works in the camrea, but not in the scene in the editor. huh.

#

i wonder if it has to do with opacity in the renderer.

regal stag
#

Hmm, you likely don't need the Color Mask, just One Minus the alpha result. You might want to Saturate (aka clamp01) to remove negative values after the Subtract).
Probably could also instead Multiply the RGBA and A outputs.

grand jolt
#

lemme try it that way.

#

good call. it works that way and its simpler.

#

Thanks lots btw guys. Sorry im retarded sometimes. ❀️

grand jolt
#

hey @regal stag and @wraith haven , thanks for the help earlier. Finally got it done. basically did what u guys told me to, oh and had to adjust cause it being applied to sprite atlases it was being distorted a bit.

rose remnant
#

I have been stuck for a long time now, trying to find out in my vertex/fragment shader if the current pixel is in the radius of any point light in the scene. Is that just not possible? I want to change the color based on if a light shines on it or not (no matter the intensity, just based on the range of the lights).
I have already tried using unity_4LightAtten0[i] and _LightPositionRange, together with the world position of the pixel, but they both seem to not give me correct results. Sometimes it does look like I get correct results, but then only in the scene view and not in the game view...
Any tips?

mystic geyser
rose remnant
#

@mystic geyser I have seen that link, but I'm having difficulty finding out what's the important part in that shader that I should copy. And it seems like they just duplicated the pass and made it ForwardAdd rather than ForwardBase? But there are still some changes, so overall it stays unclear to me what exactly I should do in my shader...

#

Right now I have one pass in my shader, neither ForwardBase or ForwardAdd, and this is how I calculate if the pixel should be visible or not:

float distanceToLight = length(_LightPositionRange.xyz - i.worldPosition.xyz);
float attenuation = 1 - (distanceToLight * _LightPositionRange.w);
attenuation = (attenuation > 0) ? 1.f : 0.f;
```I use the attenuation to multiply the pixel color with. And that works as long as there's only one point light on the screen. But of course it doesn't work with multiple lights.
I guess that a pass happens for every point light on the screen? I just don't know how to add the results of those different passes together, if possible? Maybe your link describes how to do it but I don't really understand.
meager pelican
#

Are the objects static, and the light positions static?

#

Is it a binary - is in range true/false?

rose remnant
#

I just want to check if the pixel is in range of a light or not, yes. The lights can move around though.

#

instead of checking if the pixel is in range, it would be nice to just check if the pixel is in a shadow or not. But i don't know if that would be easier/more difficult to achieve, or even possible at all?

meager pelican
#

Sure, you could have a separate custom shadow pass. There's a shadowmap created that you sample IIRC.

That said, what happens if it's in shadow? what happens to the pixel color?

low lichen
#

The shadow map is just going to be of the main directional light, it won't take additional lights into account

#

Unless you enable shadows on all lights and sample all of them

#

and compare

meager pelican
rose remnant
#

The lights have shadows enabled.
When the pixel is in the shadow, I would just want it to be a certain color (or have an alpha of zero, doesn't really matter). But when the light hits the pixel, I want to just show my shader (as if it was an unlit shader not influenced by the amount of light on it)

meager pelican
#

So "magic lights" illuminating the scene.
Is that you @grand jolt ? (inside joke, sorry).

OK, there's a few ways. But do I understand that the lights and shadows don't influence the color? What about shadows "darkening" it?

rose remnant
#

That's correct. The lights and shadows shouldn't influence the color. Just shadow -> one color. No shadow -> something else.

meager pelican
#

So a sphere in the range of only one light would look like a hemi-sphere? (and maybe hollow one at that)

rose remnant
#

If I understand correctly, yes. As you might have guessed, my team is working with stylized toon-y graphics.

#

So not going for anything realistic here.

#

Basically, we want to have an even colour everywhere in the scene except for where there's light shining on stuff

meager pelican
#

By "even color" could it be like a middle grey everywhere, for example? (or whatever single color)
But the "lit" side of things would show up?

It's going to look really strange. IDK that's what you want. No ambient?

rose remnant
#

I mean, the even color kinda becomes the ambient color, right? But yes, we are going for that strange look.

meager pelican
#

Do you have a mock-up/sample? like a sphere or character? Before I lead you any further into left field?

#

Worst possible case I can think of is for you to pass in a list of light locations and ranges, and run through them per pixel. Not saying you SHOULD do that. But then you could set the original color however you want it.

How many lights?

rose remnant
#

We already have the base toon shader, which does what we want it to do. I'm now working on the water shader, which is a vertex shader while the previous toon shader was a surface shader. That's why I can't copy the workflow to this shader.
Here's a quick example of how we want things to look:

#

in the upper left of the screenshot, there's still geometry but it all becomes the same color because it is in the dark.

#

I'd rather not pass in all the light info by hand, but I'll look into it if there's no other possibility

#

(With "by hand" I mean via code of course)

meager pelican
#

OK! But for the stuff in the light it's shaded kind of "normal"! except for where the shadow falls on the floor...I think.

Can I ask what you did in the surface shader? Did you inspect that generated code to see what it did?

#

Because Surface shaders become vert/frags after generation.

#

There's passes for lighting and for shadows.

rose remnant
#

The surface shader has a Lighting function that takes lightDirection, viewDirection and shadowAttenuation as parameters, but I don't know where they come from

#

I did not look at the generated code, how would I do that?

meager pelican
#

If you select the shader you should see an option in the inspector to "view generated code". Warning: There's a lot of variants generated, so don't be intimidated.

Sounds like custom lighting. There's sections in unity docs about that too.
https://docs.unity3d.com/Manual/SL-SurfaceShaderLighting.html
Again, don't get discouraged, patience wins the day.

#

So maybe take a look at it all first so you know what it's all doing, THEN you can figure out how to make it work in your custom vert/frag/water.

rose remnant
#

do you mean "view compiled code"?

meager pelican
#

Mine says "show generated code".

There's also a "compile and show code" but that's different.

rose remnant
#

I don't see "show generated code". But I also notice now that it doesn't even see the shader as a surface shader to begin with πŸ€”

#

oh wait never mind, I was looking at the wrong shader. Sorry about that

#

I should go to bed soon haha

meager pelican
#

lol

rose remnant
#

I will take a look at that, and the links you shared, tomorrow. Thanks for trying to help me out!

meager pelican
#

It's a start. It will give you an overview of lighting and shadows. Also see unity doc and the catlike coding site, among any others you find.

You'll want to look at what passes do what. And also your existing methodology. You should be able to customize things from there. For water...might be interesting. πŸ˜‰

rose remnant
#

I feel like the Unity documentation regarding shaders contains some of the worst pieces of documentation written ever, but yes I'll try to figure stuff out starting from the generated code and the catlike site πŸ™‚

meager pelican
#

lol

magic thorn
#

something is wrong with the standard SSAO shaders in this unity version (2017.4.28f1)

#

I click run and it spits out about SSAO shaders "can't find include file frag_ao.cginc"

#

scratch that, i reimported all of it, now it's giving me an error related to VignetteAndChromaticAberration.cs

#

these are built in shaders

upper kite
#

@magic thorn Sounds like you're using the legacy image effects, I'm fairly sure these no longer work in 2017.1+

devout quarry
#

My users and myself have several issues with shadergraph where it loses or 'forgets' the reference to the file in a custom function node

#

this happens frequently when upgrading SRP versions or doing reimports, or when moving around the .hlsl file

#

I get the console error 'failed to open source file'

#

but reimporting the graph always fixes it

#

are there some known bugs with custom function nodes and references to their .hlsl files?

naive mural
#

hello, what's the best way of going about calculating min/max values of pixels in a texture inside a compute shader? Is it possible to do it in a single call? The only way i can think of is to take the resolution of the texture, lets say 1024x1024 and call a function of size 512x512 which would take 4 pixels and calculate min/max from them, then from 512x512 to 256x256, to 128x128, to 64x64... with the same process until we just have 1 pixel.

night tiger
#

Did non exposed properties of Shader Graph always not appear with MaterialEditor.GetMaterialProperties or is it something new to 2019.3?

fervent tinsel
#

"when it's ready"

#

(yeah I know)

#

was about to do some SG modifications but then realized it's all changed under the hood on current master and chances are it's going to keep changing until this thing is fully done :p

meager pelican
#

@naive mural It's possible, but you'll need to use shared memory and atomics, and that might slow it down a bit. That should also tell you what to research. πŸ˜‰

#

note the data type restrictions

fallen cypress
#

Hi

#

Is it possible to put c code shader and compile it to a hlsl shader

#

creating a shader through c script

#

Moreover I want to convert the ultimate principled shader from blender to unity and add my own subshaders

plucky bone
#

No

#

You have to create it from scratch in shadergraph or hlsl/cg

fallen cypress
#

Is there any tool to use like a cross compiler

#

hlsl and similarly cg are based on c language

#

so gotta be a way to do that

plucky bone
#

No

naive mural
#

@meager pelican thanks

frail salmon
#

can anyone help me problem about adapting a shader to a plugin

devout quarry
#

just ask the questions

#

not many people will say 'yes' to 'can you help me' when they don't know what it is about

#

we're all here to help πŸ™‚

frail salmon
#

well i converted a shader to use this alpha masking thing

#

and now its like twice as bright

#

idk anything about shaders really haha

devout quarry
#

you got any code/nodes?

frail salmon
#

this is the instruction i followed

#

i put breakpoints on the lines i added

#

and those properties etc above

#

gotta be honest at first I had

#

TOJ_APPLY_MASK(v2f, tex2.a)

torn widget
#

Hi I've got this weird shading glitch on all of my environment assets, they work fine in Blender but once they in Unity they all have this black/white part that makes it look awful

#

but I'm not certain

torn widget
#

nvm it definitely was that, instead of letting Unity triangulate my models I'm now gonna triangulate them in Blender because Blender's algorithm seems to be just generally better for some reason and doesn't create those weird problems

river dawn
#

Hello! I'm trying to apply an offset to make a texture moves, but when I pass certain value, the texture gets distorted in a way that I don't understand, any help? thanks!

low lichen
#

@river dawn The texture might not be set to repeat.

#

It's probably set to clamped

#

It's a field in the texture asset

river dawn
#

Ok thanks!!

warped field
#

everything else works fine except for that

amber saffron
#

@warped field I'm not sure if this is an issue or not.
Distortion beeing an effect that uses the screen texture, I'm not surprised to :

  • See the pixels wrap on the border when you offset the uvs
  • See the "mesh" twice on the water because of the offset.
meager pelican
#

@warped field Make sure it's set to wrap if that's what you want. Also look into seamless textures for both the source and the distortion textures.

timber carbon
#

I have a Quad hosting a Mat with a PBR Master (PBRM) Node with a Sample Text 2D RGBA(4) -> Albedo (PBRM) hooked up, and that has a Texture 2D Asset Out (T2) -> Texture (T2) hookup. My Texture 2D Asset is a Render Texture which I'm writing to using MJPEG stream (all dandy and working) -- it acts as a big giant light inside any scene unless i'm super zoomed into the quad.. woah, thats a lot of text

#

how can I get it to not emit

#

on, in HDRP

mild kayak
#

Hello people! I want to mask off wind in our cloth shader using AO. I really dont want to have to manually paint all the models vert alphas since there are over 300...

#

no idea how πŸ˜…

steel hawk
#

Hey
How can I create a Blur UI shader in HDRP?
I didn't find anything so please help πŸ™‚

regal stag
#

@steel hawk I think you can make a pretty convincing blur with only the HD Scene Color node. It has multiple lod/mip map levels, each higher one being a smaller texture size, so more blurred when sampled.

steel hawk
#

@regal stag And should I plug it in the emission slot?

#

The result

regal stag
#

You'd probably want to use the Unlit master. I don't use HDRP much but have had UI shaders work in URP using Unlit Master + transparent surface mode, as there isn't a real way to do UI shadergraphs yet.

steel hawk
#

Ok thank you very much

#

I'll try it and tell you if it works

#

I've also set the mode to transparent

#

@regal stag

#

Sorry I'm new to shader graph

regal stag
#

It's probably not you. UI shaders aren't really properly supported in shadergraph yet.

#

This links to a discussion we had before, but they had it blurring on the full screen rather than the UI Image it was applied to.

steel hawk
#

Ok I copied the graph you sent me, but it still does nothing

#

I think it works in URP

regal stag
#

Are you sure you've saved + applied the material to something?

steel hawk
#

but not in HDRP

#

Yes and i set the material to the image I want

regal stag
#

Olento had it working in HDRP, but it may have been on a quad rather than UI, not sure.

steel hawk
#

Maybe I should Set the canvas render mode to camera

#

and then try again

thorny bronze
#

Hi guys! Does anyone know how to set a Keyword using a material property block?
I have a replacement shader to display different shades on screen
but I wish to use it by each material, so I am using the following code:

#pragma multi_compile_local SHADE_RED SHADE_GREEN SHADE_BLUE
then later I am using inside frag #ifdef SHADE_RED ....

regal stag
#

@thorny bronze Could be wrong but I don't think it's possible to set keywords with material property blocks, only properties. Could you not have a colour property instead?

thorny bronze
#

Hi @regal stag , unfortunately not =/, maybe is there another approach using the new URP?

#

on URP there is a RenderFeature/Render Objects(Experimental) πŸ€”

steel hawk
#

@regal stag Thank you it worked

#

I am soo happy πŸ™‚

regal stag
#

I think replacement shaders don't work in URP, but it's possible to override materials per layer using that render feature. I'm not too sure what you are doing though or whether it would do what you want. Also don't think Material Property Blocks play well with the SRP Batcher, although that's optional.

thorny bronze
#

you're right replacement shaders don't work in URP, you have to use a different function that I don't remember now

regal stag
#

Probably the overrideMaterial option in the render feature stuff.

thorny bronze
#

yes! πŸ˜„

#

tnks, I will look on URP

#

but, why did you said that " SRP Batcher, although that's optional"?

meager pelican
#

I'd say @regal stag is correct. Use a property. And conditional logic to set the color to Red, Green or Blue.

Since it comes in as a uniform value, it shouldn't impact the performance much.

#

Or just pass the color as a Red, green, or blue.

regal stag
#

Yeah, depends if there's more differences than just a colour

meager pelican
#

Sure, but if it's based on a uniform, maybe a custom code block? Or whatever.

regal stag
#

@thorny bronze I don't know a whole lot about the SRP Batcher. It's something that can batch multiple materials in URP using the same shader even if they use different property values. It doesn't play well when using material property blocks though from what I've heard others mention. I think it's designed as a sort of replacement to the GPU Instancing shader stuff?

thorny bronze
#

Hmm ok thank you πŸ˜„

regal stag
#

Am I right in thinking that when using replacement shaders the properties (like colours/textures) are carried over to the replacement?

low lichen
#

Yeah, that's like the best thing about it

#

We don't have that with override material

regal stag
#

Right, because the URP overrideMaterial works differently. It replaces the material entirely.

low lichen
#

But if you use a material property block, it will behave in that way. The properties in the block overwrite the properties in both the original and override material

thorny bronze
#

@meager pelican I am learning shaders, I know that would be much easier implement using properties, but I am studing other ways to implement different stuff πŸ˜„

regal stag
#

Yeah was about to ask if that would happen. Probably not a great option when using the SRP Batcher though.

low lichen
#

Yeah, it breaks the batching

thorny bronze
#

I started to study Unity Shader the last month, and there is some many "tricks" and hide features , and I dont find a good documentation which explain everything I could do. Like C# Microsoft documentation, so I am trying stuff to see what works and what doesn't

#

Thank you guys πŸ˜„

regal stag
#

Probably even worse with the newer SRPs (URP/HDRP). Don't think there's that much documentation for any of it, except some small pages on each shadergraph node.

meager pelican
#

Shader features are more about chaning gross functionality (often via a toggle or some set of Enums) of the shader.

Like a shader that just colors using a texture, or optionally blends two or three textures. So you could have shader feature for One, Two or Three textures, and then have appropriate code for each option, adding additional tex2D lookups. That way, you have one shader that acts 3 different ways, and doesn't have to do 2 extra "fake" reads of a "null" texture when it doesn't have to. Just for example.

#

Similar to c# conditional compilation.

regal stag
idle steppe
#

hey, i'm new to unity and i'm having trouble getting a quad to cast shadows when using directional lighting

modern bane
#

Hey guys, I had a question. Can you use actual .shader files in HDRP or URP?

#

or are they both strictly shadergraph

amber saffron
#

You can, if you're brave enough

regal stag
#

You can write hlsl code shaders for URP (and I assume HDRP too). It's a bit different from the built-in pipeline, and some things like surface shaders aren't supported.

low lichen
#

As long as you don't need lighting, it's not so bad. Only difference is a couple of macros if you want it to be batched by the SRP Batcher

modern bane
#

I see. When you say "some things like surface shaders aren't supported" does that mean there's no built-in library for it, or that it's somehow incompatible with the renderer?

low lichen
#

There's nothing like surface shaders in SRPs

#

You have to write vert/frag shaders

#

Surface shaders generate shader code for the built-in pipeline

#

Which won't be compatible with SRPs

modern bane
#

I see.

low lichen
#

But thinking about it, @amber saffron couldn't you get something kinda similar to a surface shader with a custom function node, for those that want to write their own shader but want lighting to be handled? The custom function would just return the PBR properties, Albedo, Normal, etc...

#

Which then connect to the master output

amber saffron
#

Yes, totally.

modern bane
#

I'm concerned about setting the game up early to be able to look good long-term, and unfortunately have never really touched rendering pipelines in unity before. I was interested in HDRP, but we have a handful of shaders that I've made over the last couple of months that it would suck to re-do.

river dawn
#

Hello! My shadergraph is not showing previews in the multiply nodes, what can I do? thanks!

stone sandal
#

hey, we need more information to help with that. what do you mean by "not showing previews"? what does your graph look like?

river dawn
#

hey, we need more information to help with that. what do you mean by "not showing previews"? what does your graph look like?
@stone sandal for example this

low lichen
#

@river dawn Does it change if you set the alpha of the color to 1 instead of 0?

river dawn
#

same

regal stag
#

Probably not, the previews don't show alpha

stone sandal
#

hmm that looks like a bug though, it should still have the 3d sphere in it

#

what version of the package and unity editor are you using? some of our releases for 2019.2 had a lot of bugs with the preview window

river dawn
#

Yes I'm on 2019.2

#

with 6.9.2

#

Should I update?

stone sandal
#

if you're able to

#

the 7.x packages for 2019.3 have a lot of good bug fixes for shader graph rendering

river dawn
#

Ok, I'll try, thanks @stone sandal

warped field
#

I got it solved I had to reduce the addition to the distort it fixed it

proven sundial
#

uv map the fuse first @grand jolt

regal stag
#

A height dissolve shader would probably work. It might only need a One Minus to go the other way.

proven sundial
#

yeah i guess that should work. Just pan thee mask texture along the uv

maiden stag
regal stag
#

@maiden stag When some nodes are connected, like the Position or Normal Vector, it turns all nodes after it into a 3D sphere preview rather than the 2D square. It's meant to be like that. The second image is likely in an older version where it was bugged. (Though I'm hoping something that allows us to choose which previews to display is added though, as I prefer the 2D ones)

maiden stag
#

oh but my effect isn't the same it looks way worse

regal stag
#

Hard to tell what the effect is supposed to be.

#

I assume offsetting vertices based on normal direction + noise from those nodes, so it might only look good if the object/mesh is subdivided a bunch. Since that noise is sampled based on the UVs, it would need to be uv mapped too, but it would likely have seams, unless it's just being applied to a plane.

grand jolt
#

Working on a skybox shader, and trying to create stars using voronoi noise

#

However running into an issue where the noise is stretching really hard on the skybox material along the seams

#

Anyone know what's going on exactly?

#

Im using voronoi with texture coords hooked into it

wraith haven
#

well, the skybox's uv are probably not what you expect

#

it might make more sense to be a 3d vector, to fetch a cubemap

regal stag
#

The skybox UV seems to be equal to the Position node set to Object space. It's 3D rather than just 2D.

#

The Voronoi node uses a Vector2 input so it takes the XY components of the UV output. Since it ignores the Z component it appears as stretching along that axis.

grand jolt
#

Hmm

#

I have a sample texture here

wraith haven
#

yeah that seems to be it

#

the uv is the normalized view vector

grand jolt
#

It's like if a sphere was composed of two domes

wraith haven
#

and you truncate it like Cyan said

grand jolt
#

the connection is where it stretches

regal stag
grand jolt
#

I was actually just looking at that xD

wraith haven
#

your problem is a bit more complex, because even if you had texture coordinates mapping to a cube, you would still have no tiling with the top face

grand jolt
#

It goes over how to fix the issue it seems

regal stag
#

It's either that (remapping UVs / world position), or using Triplanar mapping (but that's more for textures, might be a bit expensive with generated noise).

grand jolt
#

Is it expensive to remap the UVs?

#

It doesnt seem so but im not sure

wraith haven
#

atan is not a cheap op, but if you don't aim at mobile it's probably fine

grand jolt
#

Yeah it's for a skybox

#

for VR

#

Is this a common issue people run into when making procedural skydomes?

regal stag
#

One thing of note. In that blog post they put the UV stuff into a subgraph and use it multiple times. It would be better to only do the calculation once and reuse that output instead.

wraith haven
#

you could just use a custom mesh with your own UVs

#

VR would probably benefit from having as little wasted resources as possible

#

and you could do stars with a texture really

grand jolt
#

Question since I am new, how would I use a custom mesh for a skydome?

wraith haven
#

parent it to your camera, make sure you draw after all your opaque geometry so you waste as little fillrate as you can

grand jolt
#

Like do you mean create my own sphere and unwrap it the way i want

wraith haven
#

yeah, or a cylinder and cap anything that fits the texture repetition you need

#

since there won't be any parallax

grand jolt
#

Huh didn't know you could do that

#

Is that a common method of doing skyboxes?

#

I mean, I've done a lot of work in Gmod - not sure if you've played - but what they do in there

wraith haven
#

you decide ^^ I used to do this on PS2, since there was no built-in system

grand jolt
#

is they have a dedicated area WAY off in the middle of nowhere filled with effects and assets

#

and they somehow project that to the sky

#

Does that sound familiar?

wraith haven
#

I'm not familiar

grand jolt
#

lol oof

wraith haven
#

ah I see what you mean

grand jolt
#

I think World of Warcraft also does this

wraith haven
#

this used to be the same in early unreal afair

#

but this is a 2 step process because a first camera is rendering a mesh to a texture, which is then rendered to the main screen, or maybe rendered beforhand and the main camera doesn't clear

grand jolt
#

So for what you said earlier

wraith haven
#

in your case you could get away with just rendering a mesh with the main cam

grand jolt
#

do I parent the mesh around the camera?

#

like that?

wraith haven
#

you should probably do this in script, since you don't want the mesh to also rotate with it

#

just fetch the camera position and assign it to your transform, but not its rotation

#

probably in lateupdate as well, to ensure there's no delay in that catchup, since the camera probably moves with the game logic in a regular Update

grand jolt
wraith haven
#

then make sure that the radius of the sphere matches up with the near and far plane of the cam

grand jolt
#

and it doesn't mention having to do any of this which confused me

#

I couldn't even get the sun implementation working because my results were so drastically different

wraith haven
#

you could do anything you like in a shader tbh, but it comes at a cost

grand jolt
#

and I am pretty sure it has to do with the way the skybox unwraps

wraith haven
#

it's a tradeoff, maybe its fine for your usecase

#

but VR rasterize once for each eye, at high frame rate, for a lot of pixels

grand jolt
#

mhm

wraith haven
#

so it's still a bit perf sensitive I assume

#

if this was for any PC game, go nuts

grand jolt
#

I feel like there's not a whole lot of stuff on animated skyboxes

#

maybe I am not looking in the right spots

wraith haven
#

but also, how prevalent is it in your game experience? is it a star gazing game? or do you see the sky in a glimpse between two buildings by the window?

grand jolt
#

Very

#

The entire game is outdoors

#

And skygazing would be an important component

regal stag
#

Minions Art's skybox uses worldPos.xz / worldPos.y for the stars/voronoi texture. In shadergraph it would be :

wraith haven
#

yeah, which is what gives this "ceiling effect"

#

which could be a thing for stars if you like, and is also definitely a good way for layering clouds

grand jolt
#

Yea for sure

#

im testing it right now

#

I use Amplify but the logic is the same

wraith haven
#

gotcha

#

also the problem with computing the texture coordinates with math is that it prevents texture caching

wraith haven
#

so the fillrate is a lot worse, especially for large textures or poorly compressed

grand jolt
#

Yea speaking of the Minion's art tutorial

wraith haven
#

when you use vertex UVs the hardware knows which part of the texture will be sampled, and caches that area

grand jolt
#

I could not get the sun implementation working at all

#

Actually I will reconstruct the graph real quick just to test again

#

because I like the concept look of it

#

but yeah, ran into problems

wraith haven
#

yup, it should be pretty straighfoward as far as I can see

#

but you should look into not using distance

#

it's also an expensive function rto run for every pixel on screen

#

but again, pre-emptive optim and all πŸ™‚ root of evil yadda yadda

#

maybe it's all fine, maybe you have a dedicated hardware or a known min spec

#

I don't know

grand jolt
#

What's an expensive function, voronoi?

wraith haven
#

distance()

grand jolt
#

distance is expensive? O.o

wraith haven
#

distance has a square root

grand jolt
#

I thought distance was simple vector math

wraith haven
#

everything is simple vector math πŸ™‚

wraith haven
#

it's pythagoras, the sqrt of the power of both other sides

grand jolt
#

so by his tutorial, dist of uv coords and worldspace light pos should give him that result

#

i just get this blob

#

should be pretty straight forward

wraith haven
#

your UVs are vector 2

regal stag
#

her*, and it might be due to Amplify's UV output being a vector2

wraith haven
#

so again one axus is dropped

grand jolt
#

Oh my bad

#

Oh i found the fix

#

didn't know you can just swap texcoords to a float3

#

I suck

#

lol

wraith haven
#

so you could do "vector = wp - UV" and then dot(vector, vector) to get the squared distance

#

and then use the squared radius

#

to get the same effect, but without the square root hidden inside distance()

#

especially if you intend to do the moon and it's shadow the same way, it adds up

grand jolt
#

What would the inputs of the dot product be?

#

both vectors?

#

Oh

#

you're right

wraith haven
#

yeah the vector dotted on himself is its squared length

grand jolt
#

it's the same but a bit bigger

wraith haven
#

squared :_

#

^^

grand jolt
#

That's more performance efficient?

wraith haven
#

substantially

grand jolt
#

really? o.o

wraith haven
#

if math is your bottle neck, or battery

#

(also crazy shit is happening on GPU, it's hard to keep up)

grand jolt
#

Do you learn this just from experience over time, or?

wraith haven
#

(maybe there's some lookup for that op on some hardwares but not others, etc)

#

the sqr distance thing is a bit of a textbook case

#

which is also why Vector3 has it

#

(but I definately learned over time because I was trained as a designer)

grand jolt
#

How long have you been doing this stuff?

wraith haven
#

about 15 years now πŸ‘΄

#

20 if you count undergrad school

grand jolt
#

Damn

wraith haven
#

post your results when you have something πŸ™‚

grand jolt
#

Oh ok

#

it's working btw, I am just adjusting πŸ˜›

#

I think I might be able to use this potentially as a mask as well

#

if need be

#

I could also distort this with a noise texture right, to maybe create a slight wavy effect

wraith haven
#

definately

#

overall, fetching large-ish textures with procedural UVs (computed with math) is bad, and with dependent texture fetches (with the influence of another texture) is worse

#

but noise can be a small tiled texture, and be pretty efficient

grand jolt
#

I was going to use a perlin noise texture that's like 256x256

wraith haven
#

same goes if you sample a gradient in a lookup for example, caching doesn't matter because the whole texture probably fits in the cache

#

256 is pretty big

grand jolt
#

o

wraith haven
#

you can probably do 1/4, and maybe sample it twice at difference scales

grand jolt
#

how would I distort the sun with the perlin noise in this situation?

wraith haven
#

I'm biased, modern GPU are beasts, but what platform do you aim at?

grand jolt
#

PCVR, HTC Vive, Oculus, and Index

wraith haven
#

meh, I guess you're fine with fancy ^^

grand jolt
#

It's a long road ahead

#

I've only really been working with this stuff for less than a week

wraith haven
#

yeah, I would watch out for Quest and that sort of lower end headset

#

anyway, if you want to distort anything, just add to it

grand jolt
#

I did try that, because usually it works, but this is kind of a different case no?

wraith haven
#

you probably want to offset the texture range before adding

#

what effect are you looking for?

wraith haven
#

technically the sun shouldnt deform, except some heat wave

wraith haven
#

ah

#

heat waves ^^

grand jolt
#

πŸ˜‰

#

at a high level that looks like a noise texture scrolling upwards

#

distorting the sun

wraith haven
#

yeah, sample your noise , then sun pos + (noise - 0.5f) * distortionintensity

#

to move the wave uward just add the time to the vertical axis of the coordinates of your noise

grand jolt
#

oh wait

#

i wonder if i'd just hook that into the texture coordinates node

#

not sure if i linked this or not

wraith haven
#

yeah same, you can add the noise to the sun pos or the other position, since you take the difference anyway

#

(i guess, it's late)

grand jolt
#

oh lord that's hella strong

#

one sec

#

Hmm this isn't working the way I thought it would

wraith haven
#

and probably use different intensity for horizontal noise btw

grand jolt
#

So I tried inputting the noise into the texture coords offset, didnt work

#

and tried adding the world space light pos with the noise texture

#

also doing weird stuff and not working

wraith haven
#

what does weird stuff looks like? it probably needs to have a very low intensity, since 1 would offset over almost 90deg

grand jolt
#

just to be clear, this is what you meant right?

wraith haven
#

before adding the texture right way, substract 0.5, and multiply by say 0.01

grand jolt
#

damn you're right

wraith haven
#

tadaaa

grand jolt
#

So why won't the regular texture work on its own?

#

is it too strong?

wraith haven
#

the texture has a range from 0 to 1

#

and the vector of the direction is normalized, which means the maximum length of its components is also 1

#

so adding something that large makes the value swing by a lot

grand jolt
#

damn

wraith haven
#

this is only to get some nice visuals anyway

grand jolt
#

yea ofc

#

and now I am noticing that my perlin noise isnt seamless

#

oof

wraith haven
#

haha, well that's pretty low frequency, and perlin is an addition of linear values anyway, so you can duplicate the layer in PS, offset, and fade the edges, and it'll look EXACTLY like another perlin noise

grand jolt
#

true

#

I wish my ShareX would actually let me take gifs

#

Looks good

wraith haven
#

I think Gyazo can, if you're lokoing for something that has hosting as well

#

but I use Screen2gif, has a bit more control

#

a lot more

grand jolt
#

I used to use gyazo

#

does gyazo auto upload to imgur

#

thats one reason why I like sharex

wraith haven
#

not imgur, I think it's their own stuff, hence their monetization I guess

grand jolt
#

Alrighty interesting

#

Thanks a lot for everything btw, super helpful

wraith haven
#

you're welcome, gl with your project

naive mantle
#

looks great!

devout quarry
#

it's mine

#

you got any specific questions?

#

The materials are all unlit, I apply a toon shader with a 'lit' color and 'shaded' color

#

based on this

naive mantle
#

@devout quarry sorry am still a super noob with shaders. Let me have a play with the link you sent and ill let you know if I get stuck! Thanks

grand jolt
#

@wraith haven I have some other questions if you are still available to help / not busy

#

regarding the same thing actually

#

Im looking at Minion Art's horizon logic and I see to be getting different results

#

This section right here

wraith haven
#

looking good Calum πŸ™‚

grand jolt
#

The Horizon should be when the sun is at, well the horizon of course

#

I implemented the logic in Amplify, yet the horizon only appears at sun's peak

wraith haven
#

what's sun peak?

grand jolt
#

When the sun is pointing straight down

wraith haven
#

could the info you have be wrong?

#

ah lemme look at the graph sorry

#

ok I get it now

grand jolt
#

I think the horizon should show up with the sun's Z value is either 180 or 0

#

or of course when they get close to those values

wraith haven
#

so, the logic here is the get a glow that is proportional to the time of the day, and the time is approximated by how high the sun is. the .y component of the sundit. is exactly that value, and saturated so that it doesn't have any influence when bellow the horizon

regal stag
#

Might want to look at this line again saturate[ (1 - horizon) * saturate(_WorldSpaceLightPos0.y) ]; I've swapped out the brackets for square ones. You seem to be doing the saturate on 1-horizon then multiplying, but it's the other way around.

grand jolt
#

Oh

#

hold on let me check

#

OH

#

yep

#

brackets

regal stag
#

Made the same mistake before. So easy to overlook the brackets when you are reading stuff kinda backwards to recreate it in graph form.

grand jolt
#

I fixed it

#

surprisingly did nothing

#

Yea you kind of have to think backwards with nodes a bit

regal stag
#

Hm, so it didn't fix the issue?

grand jolt
#

Yep did nothing

naive mantle
grand jolt
#

Are you using URP @naive mantle

naive mantle
#

woops @grand jolt , think not

grand jolt
#

Ah hmm

#

Usually that's an HDRP/URP issue

naive mantle
#

yeah I just created basic 3d project and not added any RP yet

#

can i retrospectively add URP / HDRP

#

and any advice on which one to chose?

grand jolt
#

@regal stag Okay I sort of understand the logic here, 1- abs(uv.y) give you the horizon line no matter what

#

and they are multiplying that by the worldspace light pos to essentially let it be on and off whether or not the sun is pointing at the horizon

#

I use the built in pipleine @naive mantle

regal stag
#

If I recall correctly, _WorldSpaceLightPos0, even though it says "Pos" it's actually a direction when using a directional light.

grand jolt
#

So the problem is that the worldspace light pos is only working in one direction

naive mantle
#

yeah going to use HDRP, just watched a video on the difference!

#

thanks @grand jolt

grand jolt
#

Be careful

#

HDRP isnt for everyone

#

Dont be fooled by the looks

regal stag
#

If you are using @devout quarry's shadergraphs I think you might want to use URP as that is what I assume they are written for.

naive mantle
#

Oh really? Good advice.. also good to know you cant "revert" adding HDRP according to the docs, so glad i took a backup first

grand jolt
#

Yeah I am a bit confused by how this is working

regal stag
#

Should be able to uninstall HDRP, it's likely just much harder to revert as you have to manually change all the materials and stuff back. (If you haven't upgraded materials yet that's not a problem though). Unless it is actually impossible, but I kinda doubt that.

grand jolt
#

If you point the sun down, the background turns white

#

and visa versa turns the background black

#

I don't know how they would be using that to show just the horizon

regal stag
#

Is the Power to adjust the size of the horizon?

grand jolt
#

yep

#

that's just something I added

regal stag
#

Then I think you want to do the power before the multiply too

grand jolt
#

Power isnt even hooked in right now

regal stag
#

I see, perhaps the tutorial is wrong

naive mantle
grand jolt
#

Looking at this gif

regal stag
#

I think it might be a sunset/sunrise glow

naive mantle
#

think i just need to update materials

regal stag
#

To make it orange when the sun is at the horizon

grand jolt
#

They are definitely not just multiplying a color when the horizon is visible

#

Or maybe they are

#

But i feel like that transition is way too sporadic

#

So I think to get the logic working

#

I need the background to be white when the sun points at the horizon, and black elsewhere

#

and when I multiply that by float horizon = abs(i.uv.y) ;

#

it should make the horizon only show up when it should be showing up

regal stag
#

Yeah

#

well, 1-abs(i.uv.y) I think.

grand jolt
#

That'll just output the raw horizon

#

I need the horizon to show only when my sun/directional light is angled at the horizon

#

This right now is all I have plugged into my skybox

#

when I point my sun down it turns white

#

and when I point up

#

I think the tutorial might be wrong

regal stag
#

Yeah, I meant float horizon = 1 - abs(i.uv.y), so it's white at the horizon line instead of black. But yeah it needs multiplying with some kind of direction

grand jolt
#

yea I got that ez

#

ohh

#

this might be the wrong node

#

So if I plug in JUST the world space light pos into my skybox

#

I get a bunch of colours based on the direction of the light

#

but no matter what

#

if i point it upwards, it fades to black

regal stag
grand jolt
#

yes!

#

that looks correct

#

why does abs do that?

#

absolute always returns a positive value

#

but I thought black = 0

regal stag
#

so Y is 1 when pointing up, 0 when pointing at the horizon and -1 when pointing down

grand jolt
#

OH

#

that makes sense

#

i took the colours too literal

regal stag
#

By absoluting it then taking one minus, we get 1 at the horizon

grand jolt
#

thanks a million

regal stag
#

Still confused as to why saturate was used in the tutorial post though πŸ˜…

grand jolt
#

That has to be a mistake

#

Okay multiplying the horizon actually does give a nice effect

#

Uhm this might be a dumb question

#

by say if I wanted the lighting colour to change during the night

#

would be a stupid idea to parent another directional light in the opposite direction to the sun?

#

like that

#

I mean it works but I just don't know if it's a stupid idea

naive mantle
#

guys sorry for the n00b questions but how do i fixed this pixelated shadows? It wasn't an issue before without URP and i tried uping the pixel limit to the max but thyere still really visible

grand jolt
#

This is actually why I switched from URP

naive mantle
#

it looks terrible πŸ˜‚

grand jolt
#

Someone correct me if I am wrong, but the shadows are really bad

#

I did a comparison of two project, standard vs URP

#

standard was way better

#

standard also has better support and is more stable

naive mantle
#

standard being default or is standard another RP?

grand jolt
#

standard AKA built in rendering pipeline

#

I've also seen a lot of warning posts to not use URP for game dev

#

and someone even went on a rant about how bad URP is in general discussion

naive mantle
#

whats the argument for not using HDRP? performance?

#

hmm seems people are suggesting to try adding shadow cascades

#

well ill be damned..

#

that looks a millions time better.. but at what cost πŸ˜‚

grand jolt
#

Shadow cascades look awful in URP

#

they look way better in standard

naive mantle
#

I guess back to standard it is πŸ˜›

green abyss
#

For like a surface shader, I want to reduce the attenuation of the dark areas of objects in my scenes while still receiving shadows, I've created a toon shader in shader graph and that does kinda what I'm looking for but it also doesn't receive shadows at all... Is there a well known way to do this?

acoustic idol
#

Vote Today! Tessellation HDRP for Pres!

grand jolt
#

what are matrix properties for in shader graph?

#

they cannot be exposed, they do not compile to the given names nor do I get control over the names

#

so when i compile i get names like Matrix4_47228E9D

#

and cannot control that afaik

#

and its a part of per mat cbuffer

#

so i cant treat it as a global

#

and i even get a warning that this exists even though its not declared as a property in the material

#

and the default values dont seem to be persisting to materials either so im just having trouble understanding who these properties are for and what I am supposed to do with them

stone ibex
fluid lion
#

I wrote a shader to displace vertices and it moves whenever my camera rotates/moves. Why is that and how do I fix it?

regal stag
#

@grand jolt The reference can be set in the blackboard as Lecks mentioned above. Unlike other properties they aren't exposed, but you can then set it from C# using material.SetMatrix, see https://docs.unity3d.com/ScriptReference/Material.SetMatrix.html
(There's also Shader.SetGlobalMatrix if you want multiple shaders/materials to share the same matrix property. For most properties it is "global" when the property is not exposed, but as matrices can't be exposed, I would assume the material.SetMatrix one might override the global one if both were specified?)

grand jolt
#

Yeah, im glad to see they updated that but Im working in 2019.2 where those options are not present.

#

so i am stuck with using 4 vectors

#

unless my client chooses to update unity which i doubt he would want to do for somethin as insignificant as this

regal stag
#

Ah, wasn't aware it used to be like that. If they can't update, I guess vectors might be the only option then (and construct the matrix in the graph, assuming you need it as a matrix).

grand jolt
#

yeah, was just really frustrated that that feature at least in that version has basically no use that i can imagine and the workaround of using 4 vectors hurts my soul

#

personally used to writing shaders myself but this client wanted a shader graph so just have to deal with the oddities

regal stag
#

The only other method I can think of is using a custom function to specify the matrix... although in the older versions it worked differently and I can't remember if you can specify stuff outside of the function like you can in the newer Custom Function node (at least when using the file mode).

grand jolt
#

ohh i didnt know I was able to specify stuff outside of the custom function ill definitely give that a try next time, thank you!

regal stag
#

I'd probably ask the client if updating shadergraph is possible though, as there's lots of bug fixes and newer features

#

@fluid lion Is this in shadergraph? What does your graph look like?

low lichen
#

@grand jolt I'd like some source on this

Shadow cascades look awful in URP
they look way better in standard

#

In my own testing, shadows look nearly identical in URP and standard.

#

And if I try googling "unity urp shadows bad" or "unity urp shadows cascades", I can't find anything that claims that URP is worse than the built-in renderer.

covert pawn
#

https://issuetracker.unity3d.com/issues/rotating-an-object-with-world-space-triplanar-normal-produces-different-lighting-shadows-orientation I'm experiencing this bug, which is fixed in URP 7.2.0. However, according to my package manager 7.1.8 is the latest version of URP... Any way to get the newer version?

low lichen
#

You need to press the little arrow next to the package name to reveal all the package versions

#

There you should see newer versions. If you don't, then there is no newer version for the Unity version you're using and you may have to update Unity.

covert pawn
#

Am updating now, hopefully it is stable enough. It doesn't have that verified tag yet... Thanks!

#

Sigh, it appears I have a different bug... I'm fighting these weird triplanar normals. Every time a light gets close to the surface of a texture that has a normal (even a perfectly flat RGB(128,128,255) one) it creates this weird 45 degree shadow on the surface.

coral otter
#

Is someone aware of a vr mirror shader working with HDRP ? The only one I found in asset store doesn't work for HDRP πŸ™‚

frank steppe
#

does anyone know how to kind of make the urp lit shader but in shader graph? what settings do you have to use for the texture assets? specular map for example ?
ive gotten the other maps to look lik ethey work but the specular one isnt working right

#

right now im using default except for the normal i have it set to "type normal"

#

space is "tangent" for all of them

amber saffron
#

Can you show your node layout ?

frank steppe
#

ok btw i dont actualyl know anything about what that stuff means i was just trying stuff and comparing how it looked

#

thats the relevant part

#

let me know if any of the other maps are wrong too, occlusion doesnt really seem to change anything when i change the value although it didnt on the urp default lit either

amber saffron
#

Do you mind also showing your specular map ?

frank steppe
#

ok, its from the dark city 2 asset

amber saffron
#

(you should try blending occlusion with 1, not 0)

frank steppe
#

oh i see

#

occlusion still doesnt do anything, anyway that texture there is the specular map

#

_ao texture is an occlusion map right or is that something else ?

amber saffron
#

should be this

#

are you sure that it's supposed to use the specular and not metallic workflow ?

frank steppe
#

not sure but it looks fine in the regular urp lit when i choose specular and use that map above as the specular map

#

i can see the water becomes shiny but the bricks dont

#

but on my shader graph one the whole thing becomes shiny

amber saffron
#

also, for the normal map : to control the intensity, don't blend with 0, use the normal strength node instead

frank steppe
#

oh let me try that

amber saffron
#

when using the urp/lit shader, you should have the choice for the smoothness input, either "from albedo alpha" or "from specular alpha"

#

looks like your specular map has smoothness in alpha

frank steppe
#

yes specular alpha

#

is the setting now

amber saffron
#

so, take the A output of the specular sample, multiply with the smoothness slider, and plug in smoothness of master node

frank steppe
#

and keep the map still mapped to specular ?

amber saffron
#

yes

#

RGB => specular color ; A => smoothness

grand jolt
#

@low lichen I did a direct comparison between the two with screenshots and everything. Even the guy who just asked because he had an issue also did it

#

He immediately saw his shadow issue fixed

#

I had the exact same settings

frank steppe
#

it looks different now, but im not sure, is it possible i need to invert something ?

#

like a one minus

#

or maybe i just need to change some values

#

the urp one has a sun reflected in it, i guess maybe the skybox or something or the directional light not sure but im not seeing that on this one

#

yea otherwise its looking the same now

#

nice

#

thanks i didn't know how this stuff worked. btw these assets haev an _ao file. i thought it was occlusion but it doesnt seem to do anything, even on the urp lit material. Am I wrong about that ?

amber saffron
#

Should totally be occlusion. Note that it's supposed to block ambient lighting (hence the name, Ambient Occlusion), so if you don't have ambient, it's not supposed to change anything

#

This can be as simple as baking the light in the scene to have the sky ambient probe

frank steppe
#

oh i see maybe thats it thanks

#

btw i did this just so i can have a crossfade dither animation on LOD group stuff, kind of annoying unity's built in shaders don't support it

#

do you know if essentially reimplementing the lit shader using shadergraph is worse performance than the actual lit shader ?

amber saffron
#

Should be similar

frank steppe
#

ok so i see now the skybox's sun reflection on my shadergraph one is really small in the reflection, but in the urp one its really big

#

do you know why ?

amber saffron
#

What is the graph looking now ? πŸ™‚

frank steppe
#

i just did what you said

#

this is the comparison though

#

the first one is the shadergraph

#

second one is the urp

#

you can see the sun is bigger on the urp

#

its really small on the shadergraph one

#

kind of in the middle left/upper left

amber saffron
#

Still, can you please do a screenshot of the updated graph ?

frank steppe
amber saffron
#

Hum ... should be ok ...

frank steppe
#

yea i mean it looks ok its just the sun is smaller on it than in the urp one

amber saffron
#

Maybe, for some odd reason, use R output of the AO map, instead of rgba

frank steppe
#

ok although i still dont know how to test it

amber saffron
#

oh wait

#

don't use blend for AO

#

use lerp

#

I didn't catch that

fluid lion
#

@fluid lion Is this in shadergraph? What does your graph look like?
@regal stag No this is by a shader script, not by the graph.

frank steppe
#

still looks the same to me although its probably because i dont have ambient light as you said

#

should i use rgba or R for AO after switching to lerp ?

amber saffron
#

Still use R

frank steppe
#

thats the ao

amber saffron
#

AO being a float value (light blue connection), the channel connected should be the one you use to store it. In single channel textures, it's either R or A

#

Please avoid sharing directly source assets from a paying package :/

frank steppe
#

ok so i can see the ao now

#

i can see it with either r or rgb

#

looks like lerp is what made it work

#

so you are saying r is better to use than rgba ?

amber saffron
#

using RGBA will work because at the end, only R channel will be used on the master node (when vector4 is cast to Vector1)

#

but using R since the begining will avoid to do calculation on 4 floats

frank steppe
#

ah i see right

amber saffron
#

As for the issue with the reflection ... I don't get it

frank steppe
#

is it better to manually take r g and b into a vector3 then into the destination rather than just doing the whole rgba into it ?

#

like for the specular map for example

amber saffron
#

Well, this is no easy to answer. You will have to do casts in order to do this anyway, so it will only add more code to the generated .shader code.
But in the end, the final shader compiler might optimize this very well anyway sooo ... in this case, no need to convert

#

Because you have a straight node connection

frank steppe
#

ah i see

regal stag
#

@fluid lion Okay. You should probably share the vertex shader / lines of code about how you are doing the vertex offset then, so others can check it is correct. Nobody can help just looking at the image of the result. (If it's long, use something like hastebin).

frank steppe
#

oh can you tell me how to do emission map

#

like do i use blend or multiply or lerp or what ?

amber saffron
#

emission map multiplied with emission color

frank steppe
#

ok thanks

#

i also have a boolean that only uses the map if its checked

amber saffron
#

you can also add an emission intensity multiplier, and optionally a "multiply emission with albedo" if you want

#

but I'm still trying to understand the reflection issue :/

frank steppe
#

could it be like environmental reflection or something, although i actually have that disabled right now on the urp shader

amber saffron
#

it's indeed the reflection of the environment

frank steppe
#

so is that separate from the shaders "environmental reflections" checkbox ?

amber saffron
#

I need to check this to be sure

frank steppe
#

oh ok i figured it out

#

its the smoothness value

#

sorry they were different

amber saffron
#

Well, yes, indeed you need to have the same smoothness πŸ˜„

frank steppe
#

thanks for the help

#

although now im wondering what "environment reflections" checkbox is. Also It seems the shadergraph shaders I guess automatically have the "specular highlights"

#

since they look the same as the urp ones with the specular highlights

fluid lion
regal stag
#

@fluid lion I think you should be doing the position offset before UnityObjectToClipPos, so it's in object space rather than clip space.

frank steppe
#

@amber saffron I think the occlusion value is inverted? the lower i put it the darker the lines are

#

ok i fixed it

amber saffron
#

you did set up properly the occlusion control with lerp ?

  • OC map in a
  • 1 in b
  • occlusion slider in t
frank steppe
#

yes but to make it get darker as i increased , ihad to put the map in b

#

otherwise it got darker as i decreased the slider

#

like the occluded lines would get darker

amber saffron
#

oh, true, sorry, that's my mistake

frank steppe
#

alright np, anyway thanks looks pretty good now, not sure if its 100% the same but looks pretty similar

#

oh can you check my dithering thing, it works when i tested it but i dont know if its implemented weird

#

did a bunch of trial and error

amber saffron
#

can look

frank steppe
#

i had to do the comparison because for some reason that lodfade value was inverted when i had the lod group cross fade thing triggered

#

ive seen there is also some other property you can use called like CROSSFADE_ something

#

so its a bit confusing

#

on https://docs.unity3d.com/Manual/class-LODGroup.html
it says

"Unity calculates a blend factor from the GameObject’s screen size and passes it to your shader
in the unity_LODFade.x uniform variable. Depending on the Fade Mode you choose, use either the LOD_FADE_PERCENTAGE or LOD_FADE_CROSSFADE keyword for GameObjects rendered with LOD fading."

#

so instead of those LOD_FADE I used the variable itself, was that bad ?

amber saffron
#

Those are keywords that I supposed should change how you do you fade

frank steppe
#

what do keywords do ?

amber saffron
#

It to create variants of shaders

frank steppe
#

oh i see so is it like a condition

amber saffron
#

they are compilation directives

#

you shouldn't use noise for the alpha input

frank steppe
#

really?

amber saffron
#

the dither node is actually making a screen space pattern for the dithering, if you output this in alpha of the master node, and set up a static value (like 0.5) to the alpha clip, it should work

frank steppe
#

ah i see

#

i think i did something like that in my trial and errors and it also worked, like they looked the same so i didnt know which was better

#

i think i only used this one because i saw in the unity docs that dither usually goes to the alphaclipthreshold

#

"This Node is commonly used as an input to Alpha Clip Threshold on a Master Node to give the appearance of transparency to an opaque object. "

#

i guess tahts different though

#

thats to make fake transparency

amber saffron
#

well, it's an other way to work with it πŸ˜„

frank steppe
#

ok im going to try what you said about dithering

amber saffron
#

alpha clipping is just doing a alpha and alphaclip comparison to know if the pixel should be drawn, so outputting to one of those will have an effect

frank steppe
#

i see and getting rid of the noise removes a step that isn't really needed

amber saffron
#

yes

#

as for your branch comparison stuff, I'm not very sure :/

frank steppe
#

no it didnt work

#

i dont know what dither is outputting is there a way for me to check

amber saffron
#

quick debug trick for shadergraphs : whatever you want to debut, plug it in a unlit master node πŸ˜„

frank steppe
#

oh wait my regular setup stopped working too

#

maybe missed something hold on

#

yea i got my regular to work

#

forgot to assign the material

#

but anyway what you suggested doesnt seem to work

#

it looks like my value is starting out at 0

#

so the whole object gets clipped

#

like the output of the dither is 0

#

what does pluging it into an unlit master node do ?

amber saffron
#

if you set the unlit node to active, you can more easilly see what value is renderer

frank steppe
#

ok well maybe it doesnt work due to my conditions and whatnot, so i might just keep this since i know it works this way

amber saffron
#

@astral finch You could render your specified objects in a camera with this RT assigned as target texture, with a full white replacement shader

frank steppe
#

using the noise alpha doesnt cost notable performance does it ?

amber saffron
#

noise can be costly

frank steppe
#

really? it doesnt generate in realtime right

#

isnt it just the same as any other texture ?

amber saffron
#

depends on the noise type, but some of them are generated in realtime

frank steppe
#

oh i figured it would just be what i see here on the shadergraph

amber saffron
#

@spark relic Check if I understood correctly : taking the rendered image, and some "data", you want to be able to generate a mask of some objects, to store it in a render texture ?

frank steppe
#

in that case can i just use a noise texture and it wont affect the performance ?

#

hm ok i think i can change some of these conditions to work with the way you said where it goes right into the alpha

#

nevermind i cant do that

amber saffron
#

@spark relic Apart from some color selection then, I don't see how you could do that

#

Mind sharing a screen of the effect as example ?

frank steppe
#

hm i kind of got it working

#

like it works but it seems faster or something

#

oh ok its slowre if i lower the threshold

amber saffron
#

Hum, i'm trying but I seems to have only 0 for the unity_LODFade.x value

#

oh, no, ok got it, seems to only change with the animation on

frank steppe
#

exactly

#

thats what my condition is for

#

so to do it your way i removed the one minus

#

and changed the true value to 2 for the condition

amber saffron
#

because I forgot to do the transition, silly me

frank steppe
#

anyway i do think its working just looks a little different

#

what do you mean ?

#

it seems to always be 0 until the transition

amber saffron
#

yes ... not great to work with, but manageable

#

also, it has negative values πŸ™‚

frank steppe
#

really?

amber saffron
#

yes, to make distinction between fade in and out

#

because you want to invert the dither mask depending if you fade in or out

frank steppe
#

oh didnt know that

#

what does dither output anway

#

is it kind of like noise

amber saffron
#

it outputs a pixel mask where pixels are either 0 or 1, in a dither pattern

#

Ordered dithering is an image dithering algorithm. It is commonly used to display a continuous image on a display of smaller color depth. For example, Microsoft Windows uses it in 16-color graphics modes. The algorithm is characterized by noticeable crosshatch patterns in the ...

frank steppe
#

that sounds similar to noise right ?

amber saffron
#

no

#

noise can be used as a dither pattern

frank steppe
#

can you try that and tell me if its weird

amber saffron
#

but dithering is a way to use two color to represent more

#

I'm buiding a "proper" dither cross fade to show you

frank steppe
#

i see thanks

#

ill brb in a few minutes

echo badger
#

I have a quick question that I can't quite figure out.
How do I go about making shadows lighter? Like just a normal surface shader, but where I can control the color/alpha of the shadows.
Post processing would work too I suppose, but I don't have a lot of experience with writing PP shaders.

amber saffron
#

@echo badger Either user ambient lighting to brighten up you shadows, or make a custom lighting function

frank steppe
#

im back

amber saffron
#

@astral finch I don't know how they did by just looking at this picture. Would have to analyse how they render a frame

echo badger
#

@amber saffron Yeah, I messed around with the ambient lighting, but it doesn't give what I am looking for. I figured I need to writing a custom lighting function. But I haven't been able to find much on how to go about it exactly. I'm using the built-in rp

amber saffron
#

It contains what the camera sees

#

only color and alpha

frank steppe
#

btw remy do you happen to know why the regular unity shaders dont automatically suppor that crossfade dithering ?

#

is there a particular reason ?

amber saffron
#

an omission I guess

#

You can get depth/normal based on other things

frank steppe
#

oh i see. Are you almost done with your "proper" shadergraph example? Or is it going to be awhile ?

amber saffron
#

@frank steppe shouldn't be too long now, need to figure out how to properly invert the mask

frank steppe
#

oh ok cool thanks

stable ravine
#

Hi, does anyone have experience making stereoscopic textures for vr? Like a side by side image rendering a unique material in each eye? Using shadergraph is there a way I can have unique UV's for each eyebuffer, so it isolates one part of the texture map from one eye, and a different uv map for the other eye

low lichen
#

You'd need to access the global unity_StereoEyeIndex variable

#

Which will be set to 0 for the left eye and 1 for the right

amber saffron
frank steppe
#

i see thanks ill try it

stable ravine
#

@low lichen does that work in singlepass stereo rendering?

frank steppe
#

cool just tried it out looks good thanks

heady pewter
#

is it possible to combine a surface shader with a vertex shader? i kinda want to add normal maps to my sprite shader

amber saffron
#

yes

#

but vertex shader is not to do normal maping

frank steppe
#

i have to leave soon but thanks for the help remy

heady pewter
#

yeah im aware of that, but the reason why i want to use a vertex shader is for making sure i can still extract colors from a sprite and change them to a different color.
so i figured that if i could just somehow manage to multiply/combine the normal map shader on top of the vertex shader, i could manage to keep both

amber saffron
#

ok

#

you can

heady pewter
#

hmm

#

i'll give it a shot

night tiger
#

Hello. Has anyone gotten weird behavior when using Sprites and TextMeshPro (3d one). If I have them all on the same sorting layer and order, distance testing is funky. Sometimes the text is rendered above the sprite, others under the sprite. Currently using Universal Render Pipeline. Any ideas why this is happening?

heady pewter
#

aalrighty, i dont know if i am overlooking or going crazy now..

#

so, my plan was to this surface shader that has bump mapping and add in the vertex shader for editing individual colors (for a sprite)
i thought i was doing alright, and then suddenly unity hit me with that unexpected '}' parse error and for some reason i can't even seen to pinpoint it even though they say it's at line 212

so here's the code, if anyone can explain to me what's wrong that would be super https://pastebin.com/jeYjYuhw

the shader was meant to take 2d sprites and swap their color palettes by the individual colors, as well as provide bump mapping.

steady river
#

Can anyone help me? I'm trying to use the shader graph but whenever i open it up Visual studio's opens and my shader graph is completly blank. using version 2018.4.0f1 . I swear installed all the proper add-ons. I'm trying to make a wind sim on my grass mesh...

#

Let's learn how to make realistic grass with Unity Shader Graph!

This video is sponsored by Unity

● Download grass assets: https://ole.unity.com/grasssway

● Art That Moves: https://bit.ly/2VW85He

● More realistic vegetation: https://bit.ly/2EAxC5d

● Mesh Generation: https...

β–Ά Play video
#

please dm me if you can help

slender birch
#

im trying to make SSS in unity, for that, I am using the unlit shader graph, and now that I got the SSS calculations done, I need to add that to the normal lightning

#

how can I get the normal, unity lightining?

heady pewter
#

i thought shadergraph was a visual WYSIWYG editor?

#

perhaps i should stop being scared and try to update my unity

tulip walrus
#

Would using a shader to animate wind for 2d objects be efficient? Compared to just cycling through a bunch of sprites and having them batched together to reduce draw calls

river dawn
#

Would you recommend youtube tutorials on shaders?

fluid lion
#

@fluid lion I think you should be doing the position offset before UnityObjectToClipPos, so it's in object space rather than clip space.
@regal stag Like this? https://hatebin.com/uyvmhgmetb After I do that, it just removes the displacement effect.

maiden leaf
#

Any clue why my shader is just cutting off partway through my mesh?

maiden leaf
#

I've looked through the vertex color data and the colors are all set properly for the entire mesh

#

actually just solved it: i had the right colors in my mesh color data, but a mismatch in the number of vertices and colors

heady pewter
#

ok.. so...

#

i have a

fixed4 frag(v2f i) : SV_target
{
    fixed4 col = tex2D(_MainTex, i.uv);
    if (color_within(col, _ColorFrom0)) return _ColorTo0;
    return col;
} 

and i have a

void surf(Input IN, inout SurfaceOutput o)
{
  fixed4 c = tex2D(_MainTex, IN.uv_Maintex) * IN.color;
  o.Albedo = c.rgb;
  o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  o.Normal = normalize((half3)o.Normal);
  o.Normal.z *= -1;
}

how would i reference the col value from the frag over to the surf?

mystic geyser
#

@heady pewter frag and surf gotta be in 2 different passes. you can only have vert/frag or vert/surf in a pass. am sure you are aware.

#

you can update your Input struct to store col value and send it from vert stage to frag

heady pewter
#

ah, thank you very much for hearing me out. now i just need to find an example or learn how to do this somewhere

#

i didn't even consider storing it into the Input struct

heady pewter
#

ah!

#

tyvm

mystic geyser
#

np

grand jolt
#

hi guys, just watched a brackeys tutorial on a dissolve shader where he uses shader graph, if I wanted to add the effect to my SBSAR Substance materials, I imagine I would need to replicate the effect using Substance Designer?

heady pewter
#

finally got it to work, thank you Remy, and bot πŸ™‚

mystic geyser
#

@grand jolt not really. you want to create the effect in unity right? Substance designer will only provide you with material maps/textures that you need to perform your calculation on within shader to have a proper dynamic dissolve effect. SBSAR is native container format for substance designer. you cant 'simulate' any kind of effect in it per say in unity's context. when you import it into unity , even via The official plugin , all you get is textures. and they wont have any of the dynamism you might create in designer using its nodes.

grand jolt
#

@mystic geyser ah, hmmm, not sure how I would apply the effect to the material used then....without recreating it in Unity Shader Graph

mystic geyser
#

thats what i meant. you need to make the shader in unity using code/shadergraph/amplifyshadereditor etc. you said "I would need to replicate the effect using Substance Designer" implying you need to make the dissolve effect in substance designer which is not required.

grand jolt
#

yeah I've just never actually constructed a shader from scratch, Substance sorta eliminated the need, but since I could do with these effects i'm going to have to learn graph it seems, by the way, is there a way to keep these effects disabled until they are needed on a shader? or do I just have to create multiple shaders to do each effect?

#

@mystic geyser

#

actually I think i'll need one for each, otherwise if I activate a dissolve effect it will effect every other mesh using that shader....

regal stag
#

@fluid lion No, now you are using your circle and i.pos variables before they are initialised. Vertex offset should also be +/- not *. Multiplying is for scaling vertices, but if it starts at Y=0 it's not going anywhere. You likely want something along the lines of ```circle = pow(v.vertex.x - _Mid.x, 2) + pow(v.vertex.z - _Mid.z, 2);
float yOffset = 0;
if (circle <= pow(_Radius, 2)){
yOffset = _Amount;
}

i.objPos = v.vertex + float3(0, yOffset, 0); // assuming you want this as the offset pos
i.pos = UnityObjectToClipPos(i.objPos); // otherwise, do the offset here instead (i.objPos + float3(0, yOffset, 0))```
Note that i.objPos is now the offset position, so in the fragment shader you don't really need the circle check, you could just check if the i.objPos.y is equal to _Amount (or i.objPos.y > _Amount-0.001 in case of floating point errors).

slender birch
#

is the URP shaders source anywhere?
I need to copy the lightning part to add to a custom shader I made that adds SSS

regal stag
slender birch
#

thanks

#

and is that what I'd have to do?

#

or is there any easier way to add the lightning to my SSS lightning?

regal stag
#

No idea, I haven't done any SSS stuff before.

slender birch
#

well, after the lightning calculations, you get a number that then multiply by the mesh color at that fragment position

#

I need that number, so that I can add the SSS lightning to it

#

like, literally adding, then saturating, then multiplying by the fragment color

mystic geyser
#

@grand jolt actually your shaders properties are applied to meshes via materials. materials are maintained in instances per object/batch so you can fine tune their shader state properties on per object basis via Materials without worrying about affecting all the models using same shaders in your game.

#

if you want to do multiple effects on an object , you can build uber shaders which utilize Shader Keywords to define multiple effects in same shader and compile to Shader Variants which are smaller variants of each feature you pack into your uber-shader and are used on case by case basis for different objects. am not sure if shadegraph has built in support for keywords as of now. might need to look into that.

heady pewter
#

=.= the neighborhood lost all power the very moment i was about to save, so now i gotta rewrite all that again πŸ™ƒ
good morning

thick fulcrum
#

save often, save frequently, save like the world is gonna end and then backup to git as required πŸ˜‰

half robin
#

I tried putting this in general code but no response so I thought u guys could help

Is there any way for unity to just create its own variable and shaders by its self? I’m trying to make a thing where each and every time a character is generated it has a different randomizes texture/color (shader) and stats (determined by the randomized variables in the shader. And then the facial parts are random too but that’s something I can do by myself

frank steppe
#

@amber saffron sorry to bother you again but i noticed it looks like the reflective part of the thing i was testing on seems to be whiter in the shadergraph when compared to the urp lit shader.