#archived-shaders

1 messages ยท Page 160 of 1

simple frost
#

@swift fiber yeah just change the uv being passed in to your texture lookups, probably just want a "Tiling And Offset" node

swift fiber
#

this bit is just for the emissive part @simple frost

simple frost
#

not there, into the UV slot on the SampleTexture2D ๐Ÿ™‚

swift fiber
#

oh yea lol mb

#

thanks ^^

simple frost
#

yup yup

dawn hill
#

Using Shader Graph, how can I have my grass mesh "disappear" or flatten when an object/collider is placed on top of it?

#

It doesn't need to be any realistic displacement, necessarily (although that'd be cool) just looking for a way for grass to get hidden by prefabs I place down

worldly drift
#

Does anybody know how to write depth in a post process effect (OnRenderImage). Cant get it to work

scenic furnace
#

which render pipeline are you using? I only have a solution for one of those though D:

worldly drift
#

I am using the default render pipeline

scenic furnace
#

then I don't know how to help, sorry x.x

worldly drift
#

does your solution work with urp or hdrp?

scenic furnace
#

URP

worldly drift
#

could you still share it? maybe I can derive how to do it in builtin

#

atm I am trying to write to "out float outDepth : SV_Depth" in fragment shader, but it doesnt seem to work

#

I am using a render texture in DEPTH_AUTO mode btw. but it behaves pretty wierd

scenic furnace
worldly drift
#

thx. I am using a camera which renders depth for footprint on the ground. thats why I use the depthbuffer. otherwise I would have to read depth and write it to the red channel manually. although atm I am not sure if this may have been easier as working with the depth buffer is a pain and pretty much undocumented ๐Ÿ™„

quaint coyote
#

@worldly drift what do you mean by writing depth in postprocess? You can get the depth from depth buffer and create your own render texture for writing custom depth

worldly drift
#

I have a camera writing to a RenderTexture with format DEPTH_AUTO and I have a post process on this texture which sould modify the depth after rendering

quaint coyote
#

That should be quite straightforward

meager pelican
#

Snow footprints are usually some form of height mapping for a snow effect.

#

Using a mask, not the depth buffer. The depth buffer is z-view camera depth.

quaint coyote
#

@meager pelican depth normals are to be used I guess

worldly drift
#

I am using the depthbuffer to determine how far an object penetrates the snow surface

quaint coyote
#

@worldly drift so you are not able to access depth buffer ?

worldly drift
#

For example a sphere will press down the snow in the middle deeper than at the edges

meager pelican
#

Nominally, that would be different values in the height field of the snow effect.

#

I mean, depth buffer is going to vary depending on camera angle.

worldly drift
#

I can render to it and I can read it from the snow shader (although it has a wierd quirk where it dose not update the render texture if I dont also write to the color buffer)

quaint coyote
#

Does the depth buffer contain values for clipped or occluded verts ?

meager pelican
#

No

#

Per pixel depth value.

worldly drift
#

but now I want snow fall so I need to write into the rendertexture depthbuffer

meager pelican
#

From the camera's perspective. And not quite the distance, but the z-depth

quaint coyote
#

So how will a sphere be able to push the snow in when the info about the back of the sphere is not there in the depth buffer ?

worldly drift
#

I mean, depth buffer is going to vary depending on camera angle.
@meager pelican its an additional orthographic camera from the snow plane perspective

#

the camera captures the sphere from below the plane

meager pelican
#

Oh, so you're using a camera to generate your height field.

worldly drift
#

so it exactly captures penetration

#

yep

quaint coyote
#

Ohh, multiple cameras

#

Right?

meager pelican
#

Then write it out properly the first time. You don't get to modify it, except by writing another pass I suppose.

#

Depth buffers are in hardware in most implementations and are per pixel.

#

There's output depth macros for the frag

worldly drift
#

Then write it out properly the first time. You don't get to modify it, except by writing another pass I suppose.
@meager pelican So you mean render the depth into the color buffer via replacementshaders?

meager pelican
#

IDK what I mean, because I don't know what you're doing! ๐Ÿ˜‰ But if you're using a ortho camera to generate a texture, then write the proper values into it or pass it twice or whatever.

worldly drift
#

Ohh, multiple cameras
@quaint coyote yes but the main camera that captures the scene doesnt really matter here

quaint coyote
#

@worldly drift so are you applying a command buffer to the other camera ? And it's rendering out depth properly?

worldly drift
#

I am just using a render texture which is set to DEPTH_AUTO and it renders depth perfectly into the texture. I even get these values by reading the textures r value in the snow shader

#

But if I blit to it in a postprocess effect it does not change anything

meager pelican
#

You can do a full screen pass to read Depth, do calcs, write new depth.

#

But if I blit to it in a postprocess effect it does not change anything
@worldly drift
Is depth write on? (sorry for dumb question)

#

Very often with PP it isn't.

worldly drift
#

in the post process shader?

meager pelican
#

Yes, you're wanting to write to the dept buffer, right?

worldly drift
#

kind of

#

but wouldnt that just auto write the quads depth?

meager pelican
#

GTG, later.

worldly drift
#

even with ZWrite on it does not do anything

#

it just seems like the postprocess does not work at all

quaint coyote
#

No no post process shaders need to have zwrite off

#

@worldly drift one more question. When do you want to modify the depth texture? In post process?

#

Need to understand your code flow mate, seems there's something missing in the flow... Can you help understand in steps?

worldly drift
#

@quaint coyote sure.

  1. Snow camera renders to Render Texture with DEPTH_AUTO
  2. PostFX attached to the snow camera should apply snow fall shader to change depth in render texture (refill)
  3. Snow shader uses Render Texture as displacement map
#

1 and 3 are working fine. 2. does have no effect at all. no matter if I am trying to write to color or depth or Zwrite on/off

#

Besides that the render texture is sometimes acting weird. In some cases it only updates when the inspector is updated. Using any postFX on the camera or using render with replaced shader does update the texture correctly though ๐Ÿค”

quaint coyote
#

Can you pass the rendertexture as a global texture from step 1. This way, you can have the postfx attached to the main cam and manipualte the depth buffer directly in main camera

#

I guess the postfx should be attached to main cam.

#

On snow cam you can have a command buffer to copy the render tex and pass it to the global texture

#

Then at each frame, you can fetch it in the main camera and modify the depth, and use it as well

worldly drift
#

but I am not trying to modify the depth of the main camera. The main camera should really have to do anything with it as it is not really a screen space effect.

quaint coyote
#

Exactly, that's why I suggested to have the depth tex from snowcam passed on or set as global texture

#

It's 3 am here, will try to send a prototype tomorrow or on the weekend

#

Have you tried using command buffers and global texurees ? You might want to take a look at that? Just to pass textures from one place to another's

worldly drift
#

havent tried to use command buffers in this case yet

quaint coyote
#

Also you are rendering depth after everything, and post-processing is also after everything

worldly drift
#

currently I am just using a rendertexture asset becaused the felt to be the easiest workflow

quaint coyote
#

So if you apply a command buffer son snow cam afterDepthBuffer/texture and pass the tex to main cam it should solve your purpose

#

In command buffers also you use a render texture. And blit the values to a texture or copy it to another buffer or shader

worldly drift
#

wouldnt that just make a copy of the render texture? I would then have to assign this copy back to the material shader of the snow surface wouldnt I?

#

I do not quite get what the advantage would be of blitting to another rendertexture

quaint coyote
#

Are you using the depth from snow cam in the post process of the snow cam or main cam?

worldly drift
#

post of the snow cam

quaint coyote
#

Ohh sorry, got confused here that's why :(

worldly drift
#

it should change the depth map before using it in the snow material

#

the camera renders the footprints and the postfx should refill them with falling snow

quaint coyote
#

Then your flow is perfect... How are you manipulating the depth tex? In a postfx ?

#

And then you do a blit again?

worldly drift
#

maybe using the DEPTH_AUTO format was a bad idea because it just behaves weird and isnt really documented. There seems to be some magic going on that I can just read the depth as color values in the object shader which might not work in postFX

quaint coyote
#

I tried similar with the SSAO texture, first SSAO calc and then blur

#

But I am not reading depth using DepthAuto

#

I set the camera to enable depth and normals in a c# script and then read it dirctly in the postfx

worldly drift
#

yeah that would work I guess, but I would unnessecarily render a color texture and I still cant write to depth in postfx

quaint coyote
#

That's true

worldly drift
#

but it seems like I have read depth and write it into color in order to actually use and write it

quaint coyote
#

You would be reading depth, copying to another color tex and then modifying the value

worldly drift
#

I thought I was clever by avoiding it but now it is just giving me a headache

quaint coyote
#

Unless you use a command buffer to copy to another depth rexure

#

Here it saves you the effort and memory of creating a color tex at the cost of creating a depth tex only

worldly drift
#

I am not even sure if the depth_auto format avoids rendering a color tex or if its just hiding it from me

#

cause the camera preview clearly shows the color tex

quaint coyote
#

That can't be said, but the only idea I have to avoid creating col tex is to create depth tex using a command buffer

#

But I guess a copy is reqd, direct changing depth tex I have also no experience on. Sorry :)

worldly drift
#

ok thx @quaint coyote I will just use the easy way for now and render the depth into color because I have limited time. Maybe I will try out later if this can be avoided

#

although I am still unsure if it would make more sense to do this via a post effect or a replacement shader

#

the replacement shader should be more direkt I guess

quaint coyote
#

I guess post is better, with replacement it's like an additional pass on objects...

worldly drift
#

is it additional?

#

I thought it would render only the replacement shader

quaint coyote
#

From what I saw and read, the objects are rendered with a replacement pass and then the actual pass

#

Maybe there is a way to only render with replacement pass

worldly drift
boreal anvil
#

Is this a known issue with HDRP or possible fixable? Please see the emission on faces closely aligned with the camera, The closer it is aligned (and physically further away), the more of the face the emission takes up, until its almost aligned with the camera (or further away), it will then emit from the full face:

  • Emission map I am using is just a straight line here, I would expect this to be emitted in a uniform manner

Btw: Blue is the HDRP-Lit built in shader, Red is a shader-graph to test if it worked around the artifact, no difference.. maybe this is by design? (Affecting Editor and Game)

boreal anvil
#

Another example showing on the red pillars. This doesnt seem to be an effect of use post processing or anything, and ive just played with all shader settings i could think of that may relate to this issue / rules out it doesnt seem to be project/scene settings or configurations (not post processing etc).

boreal anvil
meager pelican
#

You CAN write to the depth buffer, even in post processing.
I just have zero idea as to why the heck you'd approach it that way.

#

There's also a macro you might want to be aware of for UNITY_OUTPUT_DEPTH if it's not using the native depth buffer.

boreal anvil
#

I'm just using native depth buffer / almost out of the box hdrp setup. I dont know how I would preserve the emissive bit if i faded out with depth. Was hoping there might be some shadergraph trickery i could do. look how ugly this gets. Edit: I thought it was AA problems at first, but does the same on all settings. / Edit2: The requirements of this project would still be to see the emission as far as the LOD lets it. I can't even get into LOD until I can get around this.

boreal anvil
#

I can provide the project file to anyone who has a good solution in mind, but it's so easily reproducible by using any emissive textures it's not really worthwhile

boreal anvil
#

So, this seems to be caused by a downscaling of quality due to distance and angle with emissive layers, very weird.. hopefully someone has some suggestions to clean it up.

shy spruce
#

im having an issue with the official unity particle pack, any particle system using the URP particle shaders are just completely invisible in game for some reason

#

weirdly, they work perfectly in the scene view, but they are invisible in the game view

#

this is what i see

#

i can't at all figure out why this is happening

boreal anvil
#

@shy spruce - URP asset should be assigned under Project Settings > Graphics > SRP Settings.. Plus might need to upgrade materails?

shy spruce
#

uh

#

im not seeing an "SRP" setting

boreal anvil
#

very top

shy spruce
#

also i did upgrade my materials

boreal anvil
#

Scriptable Render Pipeline Settings

shy spruce
#

oh lol

#

well i have something assigned

#

does that have to do with the particle system tho?

boreal anvil
#

Im lazy,. but your set there.. the material looks ok

#

yeah, the particle is using a URP material, so the pipeline needs to be URP, but that all looks okay. I'm actually having some weird issues with transparent materials in hdrp as well (above pic, the nasa black background is an alpha layer). You using the latest FTS 2019?

shy spruce
#

no actually, i need to update my editor

#

wait

#

what's FTS

boreal anvil
#

Unity 2019 is now in long term support, FTS is their final versions of release.

#

very little will be done to 2019 except bug fixes from now on. No more extra development so its now FTS

#

LTS, not FTS.. sorry, confused with the releases with my company.. Long Term Supprt

shy spruce
#

ok yeah lol

#

no im not on the latest LTS version

boreal anvil
#

I honestly have very little experience with URP / I've been trying to break HDRP lol.. What particle pack did you download? Ill go check it out and see if i have the same issue

#

(if its a feebie)

shy spruce
#

its free yeah

#

uhm im actually gonna stop working on this for the day, i've got this other ML project that i need to do some work on

#

ill try updating the LTS on my editor tomorrow and see if that helps

#

thanks for all the help @boreal anvil

boreal anvil
#

It probably wont.. Ill send you a side if I come across the same thing if you want

shy spruce
#

what do you mean?

boreal anvil
#

Ill send you a direct message, will check this out and get back to you if you want

#

Im stuck on my project for now, so its worth a little look into urp for me.

shy spruce
#

alright that'd be great

#

thanks again

boreal anvil
shy spruce
#

that's what i did as well, but it didn't work once i pressed play

boreal anvil
#

And I see nothing in game view.. same issue

shy spruce
#

yea

#

i played around with some of the shaders, for example on the fire stream one i changed the shader to URP->lit i believe and changed the emmision, and that worked

#

but only for that one prefab

boreal anvil
#

might just be best to rebuild it in urp, doesnt look like the asset says it supports urp

#

seems like its working, just very odd.. If I get in the middle of one of the fire particle effects

humble fox
#

anyone know what to do with shadergraph the current render pipeline is not compatiable with this master node

boreal anvil
#

@shy spruce You will need to play around with soft particles selection, flipbook blending, and blending mode in the shader setting to get them to work how you want.

humble fox
#

yeah there was no option to creater rendering @boreal anvil

#

is it something to do with how i created the project?

#

also a butload of errors

#

all mostly no suitable method found to override

boreal anvil
#

the errors could be causing subsequent errors that mean nothing

#

good ole programming fun, whats the top error? direct message me if you want lol

humble fox
#

im gonna create a new project and try again just to see. Just using shaders to test atm

#

thanks for the help though il let know if its still broke

boreal anvil
#

np. I dont mind helping since my roadblock seems to be permanent right now lol

humble fox
#

rip, i saw ur screenshots, game looks cool

boreal anvil
#

the problem is it doesnt look cool rofl

humble fox
#

well cooler then anything i can do atm

#

im going for a tron type look in my game. Shaders would be best for that right?

boreal anvil
#

ShaderGraph is your best friend there.. But you could get by with the default SRP shaders.. they are actually pretty good..

humble fox
#

ok

#

if i make the models in blender can i then apply unity shaders to parts of the models?

boreal anvil
#

for example,. in my pic, the emission is just a mask to an emissive layer, nothing special

#

Im also doing it all with probuilder for prototyping

#

I recommend probuilder to prototype, you can then export to an object and fix up in blender

humble fox
#

so with your lines on the wall is that two objects, 1 with the emission shader and another over the top?

boreal anvil
#

nope, 1 object, 1 shader with different textures

#

the emission mask takes care of the lighting

humble fox
#

but how do you have it so its just a strip?

#

is that the mask?

boreal anvil
#

yup, just a line across the texture pretty much

#

sec

humble fox
#

oh cool

boreal anvil
#

super simple

#

Honestly, I own C4D, and all my prototyping is still done with probuilder, just because its easier to build with all your game assets around you. If I want to get more complicated, ill export and revise after..

humble fox
#

is there a way to have a shader graph play by code then stop

boreal anvil
#

You would have to work around the Time node, and maybe a bool input to start/stop

#

toggle the bool on the material to stop etc..

#

ie: multiply Time by bool / if bool = 1 time moves if 0 no..

#

exactly what i use to pulse these lights ๐Ÿ™‚

#

Time x 0 will basically stop time in the shader

humble fox
#

so what should i plug the bool into multiply

#

because i cant plug it into anything

boreal anvil
#

damn you have me digging again..

#

lol

#

this is basic math. wtf is it not in unity lol

humble fox
#

i cant plug this anywhere into time?

boreal anvil
#

ie: sine wave runs as long as bool is true - in this case its multiplied by one. if negative/false, the sine is multiplied by 0 to stop the movement

#

@humble fox Hope that helps? Any other question? ๐Ÿ™‚

humble fox
#

no thanks for the help

boreal anvil
humble fox
#

@boreal anvil

#

it works but it would be good if there was a way to make it stop once the remap reaches one rather then do it with a bool

sharp tendon
#

Hey I need some help. I'm trying to find this Shadergraph shader I made through a youtube tutorial into Amplify, and I seem to have it working, but I can't get multiple lights to work.

#

That's the shader^

#

This is the function that does all of the lighting, fresnel, and gloss for the shader. (It's by default an unlit shader.)

#

I can get up-close SSes if needed, but I'm just confused because the initial shader required an external script since shadergraph can't get a lot of the lighting data the shader needed. (It's a toon shader)

#

So I'm trying to avoid that since Amplify does get that information.

boreal anvil
#

@humble fox I just dropped some random stuff in to show the connections, do what you wish with it.

hearty sage
#

Hello, I am very new to Unity Shader

boreal anvil
#

Whats up Mitchell?

hearty sage
#

I just completed a tutorial completely but on the game my shader is completely black

#

But on the scene it works fine

boreal anvil
#

Was it a recent tutorial that aligns with recent render pipelines?

#

ahh,,, i shouldnt be helping, i am a noob.. but i love to fix things

hearty sage
#

I did notice a slight difference in the Sprite Lit Master

#

So I guess I am using a newer render version

boreal anvil
#

Standard / URP or HDRP?

#

and what tutorial?

hearty sage
#

Sorry, I have no idea if it's standard, /URP or HDRP.

#

This is my first encounter with the Rendering/Shader system.

boreal anvil
#

Whats your version doing?

#

Standard / URP or HDRP are the options you use to create a new project

hearty sage
#

Oh, it's a 2d standard

#

I am using unity 2019.3.14f1

thick fulcrum
#

@boreal anvil your lighting problem, could it be related to mip maps perhaps. try enabling / disabling on the imported texture to see what difference it makes.

dim sequoia
#

with the scripting api of unity, you can take the mesh out from a meshfilter or skinned mesh renderer, read the normals array and change the normal direction, then assign it back to the mesh and assign that mesh back to the meshfilter/skinned mesh renderer,
there is sometimes an important distinction to make between mesh and sharedMesh, because if you edit a sharedMesh, that means all the instances that access that some mesh asset have the changes applied too

#

That is all the information I have though, related to a problem like this

meager pelican
#

@boreal anvil sorry, my post was to videep and Peaj's conversation.

#

Just a thought: Did you check anisotropic filtering settings and such?

#

Emission will impact pixel color. Your problem seems to be more about where pixels are drawn...incorrectly, if I view it properly. That implies either bad sampling of your color textures or even mesh issues. If you highlight the mesh with wireframe you should see where the triangles are, that might give you an indication of what the heck is going on...color vs geometry.

dim sequoia
#

ah yes, but shouldn't you only have to do it once? when importing the model?
I don't really know how to store the edited meshes back in the asset though,

otherwise you could maybe have a custom shader that calculates lighting differently than to depend on the mesh normal directions?

meager pelican
#

ah yes, but shouldn't you only have to do it once? when importing the model?
I don't really know how to store the edited meshes back in the asset though,

otherwise you could maybe have a custom shader that calculates lighting differently than to depend on the mesh normal directions?
@dim sequoia

2 cents: https://forum.unity.com/threads/using-derivative-normals-on-curved-surfaces.594733/

#

And such

#

@upbeat basin

low lichen
meager pelican
dim sequoia
#

good inputs! but like I said I can't really contribute more ^^
an alternative to the automated RecalculateNormals I have seen someone else posting:

public void HarshNormals()
    {
        Mesh m = GetComponent<MeshFilter>().sharedMesh;
        Vector3[] normals = m.normals;
        Vector3 normal, v1, v2, v3;
        for (int i = 0; i < m.triangles.Length; i += 3)
        {
            v1 = m.vertices[m.triangles[i]];
            v2 = m.vertices[m.triangles[i + 1]];
            v3 = m.vertices[m.triangles[i + 2]];
            normal = Vector3.Cross(v1 - v2, v1 - v3);
            normals[m.triangles[i]] = normal;
            normals[m.triangles[i + 1]] = normal;
            normals[m.triangles[i + 2]] = normal;
        }
        m.normals = normals;
    }

    public void SmoothNormals()
    {
        Mesh m = GetComponent<MeshFilter>().sharedMesh;
        m.RecalculateNormals();
    }
meager pelican
#

@upbeat basin Yeah, IDK, assming that's applied in a shader, then the shader would have to recalc the normals (possibly with derivative technique, or other). If applied in script to the actual mesh, then the api call MIGHT work.

All sound like a PITA.

low lichen
#

I think if Unity's skinning doesn't support this, you'll have to implement your own skinning. Unity's skinning is not extensible.

meager pelican
#

Allegedly fixed in 2019.2, unless "corrective blendshapes" are other than this.
@upbeat basin

urban pendant
#

Hey, is there a way to use a replacement shader but keep all the properties of the original shader?

#

my replacement shader is just a vertex displacement one

low lichen
#

@urban pendant Yes, that is how replacement shaders work

#

You'd have to do something with those properties in the replacement shader, though

dim sequoia
#

if you worked with a compute shader, might not be too expensive,
well maybe it is still, depending on how many meshes you need to operate on

#

and the skinned mesh baking would still have to occur on the cpu afaik?

so you can bake the current pose of the skinned mesh renderer into a mesh, assign the normals of it to a compute shader buffer, calculate them depending on the algorithm you select, and read them into the mesh after the calculation again,
is that sounds too expensive you could also work with a certain delay, like a 1 frame delay: starting the nromal calculation in the current frame, but taking the results in the next frame, then scheduling the new calculation etc

urban pendant
#

@low lichen nice name 1st of all, secondly how do I apply aforementioned properties in the replacement shader?

#

I'm using the standard shader for the materials rn

low lichen
#

If your replacement shader has properties with the same name and type as the original material, the original values of those properties will be passed to your replacement shader

urban pendant
#

do I need to recalculate all the stuff Unity does for me ? :/

low lichen
#

Replacement shaders are not meant for extending shaders

#

It's for replacing them

urban pendant
#

hmm I can't blame them the name is quite clear

#

Do you know of a solution to extend shaders at run time

low lichen
#

That just isn't a thing in shaders unfortunately. It sounds like you want to be able to deform the vertices of everything in your scene, but still let the original shaders do whatever they were doing?

urban pendant
#

yes

#

I might look into C# scripts that do that instead then

low lichen
#

To modify the meshes at runtime? That's not going to run very smoothly

#

How many meshes?

urban pendant
#

its worth a shot

#

The entire scene, which is why I was looking into replacement shaders

low lichen
#

Is this for something like a world curvature effect?

urban pendant
#

Which rn is not a lot of meshes actually, around 30 low poly models

#

Yes its like the subway surfer effect

#

I'll actually look into rewriting some of the standard shader properties into the curved shader 1st

low lichen
#

You might as well be using a custom shader in the scene at that point

urban pendant
#

true

#

Thank you for the help btw ๐Ÿ˜„

#

if anything it helped with my mental stability haha

meager pelican
#

@upbeat basin Fine.
I'm guessing here, admittedly, but it would seem that since you can get the worldspace pos of every pixel, and you know the derivatives, you'd have 3 points to calc a resulting worldspace normal in the frag. ?Then magically convert to tangent space? But yet, PITA. And IDK about "the rim".

steel fog
#

hello, i search a workaround for the detail shader in HDRP

#

does somebody has an way to use this shader please ?

dawn hill
#

Using Shader Graph, how can I have my grass mesh "disappear" or flatten when an object/collider is placed on top of it?
It doesn't need to be any realistic displacement, necessarily (although that'd be cool) just looking for a way for grass to get hidden by prefabs I place down

#

@steel fog There's really no good workaround for it. After trying many different things for the past two weeks, I moved to URP instead.

steel fog
#

there is the realtime global illumination on URP ?

#

@dawn hill

low lichen
#

@dawn hill When any object/collider is placed on top of it? You have to somehow get the data of what objects are on the grass to the shader in some format. The absolute simplest and the most limited solution would be to just support one sphere collider, where you just pass the position and radius of that sphere to the shader and that shader checks if the current vertex is within that sphere and do something.

#

You could also pass in an array of sphere colliders which the shader loops through

#

Having it react to any shape and just not spheres would be more work

#

For you, and the GPU

thick fulcrum
#

If using unity grass spawning, you can paint it out when the prefab is spawned as well depends on needs ๐Ÿ˜‰

steel fog
#

If using unity grass spawning, you can paint it out when the prefab is spawned as well depends on needs ๐Ÿ˜‰
@thick fulcrum
but how do you use the Unity grass spawning with HDRP ?

thick fulcrum
#

I'm not using HDRP but I assume, same way as normal. The only problem I'm aware of is the grass shader issue. Which can be worked around / use a solution from asset store.

dawn hill
#

@steel fog No, but you have to consider what's more important for your project.

steel fog
#

I'm not using HDRP but I assume, same way as normal. The only problem I'm aware of is the grass shader issue. Which can be worked around / use a solution from asset store.
@thick fulcrum
there is only one workaround

#

use meshes as grass

#

and it's too laggy

thick fulcrum
#

there was some re-written shaders for earlier versions, do they not work?

steel fog
#

re-written for detail grass ?

thick fulcrum
#

yup, just google they come up

steel fog
#

only this

#

but it not longer work

dawn hill
#

@low lichen So you're saying to have exactly one instance of a collider? Sort of how people usually implement grass bending by the player walking through it?
So there isn't a way to just have it react to colliders in general, then. ๐Ÿ˜ฆ

#

@thick fulcrum I gave a bunch of workarounds and fixes a shot. Unity is dead-set on breaking any custom made solutions people have come up with for the grass detail shader

thick fulcrum
dawn hill
#

I tried several "working" HDRP grass detail shader speople have used and released on reddit and github, and couldn't find any that actually work for 2019.4 and HDRP 7.4

low lichen
#

@dawn hill A shader is run completely separate from everything else. The only information it has is the information you or Unity give it, like properties

#

So if you want it to know about all the colliders in the scene, you have to pass that information somehow

steel fog
#

@thick fulcrum you have send me exactly the same -_-

thick fulcrum
#

different git... not looked at code though

steel fog
#

it's a fork

#

the date is the same, the size is the same
the desc is the same and the screen

dawn hill
#

@low lichen What if the determination is done by the gameobject with the collider? Is it possible for it to read that the grass is there and flatten it?

#

Or is that something that would just cause the grass everywhere to react to the change

low lichen
#

That depends if the grass is drawn separately or all together

dawn hill
#

It's terrain grass, I assume it's drawn together

low lichen
#

I assume you're not drawing each blade of grass separately, but maybe a few blades in a bunch?

#

Usually, grass is drawn as a bunch of intersecting quads with a grass texture on it

dawn hill
#

Oh yeah, I mean it's a prefab with an FBX that uses the grass texture

#

That's what it is. It's the "fake 3d" I guess ๐Ÿ˜‚

low lichen
#

And you're using Unity's terrain tool to paint the grass on as opposed to manually placing them as game objects?

dawn hill
#

Correct, they're placed using the brush

low lichen
#

It's possible to do something like you described, where the collider checks if it's on top of some grass and "tells" the grass to flatten itself

#

I don't know how difficult it would be to detect if you're on top of grass, though

meager pelican
#

I'd keep a list of collider-spheres with radius in alpha, and then make custom grass shaders that responded to the closest one. Calc in the vertex stage.

#

float4 array

#

But IDK that you can billboard it and pull it off

dawn hill
#

Oh, could I stick a trigger collider on the grass prefab with a script to flatten itself? Or is that stripped away when the terrain spawns it

meager pelican
#

You could wind-sway for all the same with some variation, but....circular nah.

#

If you want circular grass to fall away, you can't billboard it on a quad like that. Not that I know of.

low lichen
#

I think the terrain draws the grass manually. They aren't actual game objects with mesh renderers

dawn hill
#

I gotcha. Sorry, I know that's really leaving shaders behind ๐Ÿ˜…

#

I just started barely messing with shaders (thanks to shader graph) so still pretty clueless on what's possible and not. And what's not worth it due to a huge performance hit for a small effect lol

jagged path
#

so I am kinda stuck with making shaders with shader graph.

#

I'm trying to make an effect for the walls only.

#

how can I check if the face is a wall?

steel fog
#

So nobody has an alternative for detail/grass shader for HDRP ?

grand jolt
#

i'm really novice at shaders, can i put a shader into an UI?

grand jolt
#

and can i have it like a filter in my screen?

spiral agate
#

what do these do? unity_SHAr, unity_SHAb, unity_SHAg

soft harness
#

Can you exclude a material from ambient occlusion?

outer cloak
#

I'm trying to get a PBR Graph onto a cylinder but no mater what it is black. Outside of PBR I can add a lit or unlit material. My universal render seems fine. But if I create a simple PBR that emits red, I cannot apply it to the cylinder. When I drag it onto a material it is dark. Alpha changes the look of the material but it has zero color. Any ideas?

meager pelican
#

How can it change the look if it has zero color?

Someone else mentioned a similar thing and they had skybox problems. Make sure your skybox is working so you don't get NaN's or something that f's up the lighting calcs.

#

@outer cloak

#

@soft harness Can you draw it AFTER the post-processing pass somehow? Otherwise if you're doing screen-space AO, I don't know if it honors a mask/stencil or not, otherwise I don't see how you'd do that. I suppose you could clone their shader and add that feature if you really really feel in the mood. ๐Ÿ˜‰

soft harness
#

It's the grass

grand jolt
#

2D sprites dont have emission right?

#

just color?

meager pelican
#

It's the grass
@soft harness

So is it baked AO or PP AO?

soft harness
#

PP ao

meager pelican
#

Id try either a higher render queue to get "above" the PP AO and/or a camera stack. But IDK if you can isolate the grass or not. Terrain?

soft harness
#

nah mesh

meager pelican
#

That might be good! So you can have meshes and stuffis have AO (rocks, etc) and move the grass to a higher queue or camera stack.

Just spitballing.

soft harness
#

uh

#

wut

meager pelican
#

Do you know what camera stacking is and what render queues are? Or no?

soft harness
#

Not really

meager pelican
#

Google around a bit. Basically they let you control the order things are done in. So draw the grass AFTER the AO effect is applied to everything else. ๐Ÿ™‚

soft harness
#

what about baked AO?

meager pelican
#

That's the one IDK about at all. It's faster, of course, and it's baked into the lightmapping. But the thing is, IDK how to exclude the grass from the bake. Maybe you can, but I just haven't done it. :/

soft harness
#

Don't you mark things as static to bake AO?

meager pelican
#

That's a good point. There's "lightmap static" that would allow it to be baked...or not. But IDK what the rest of your lighting will look like, you'll have to do some combo of realtime and baked. I think. There's precomputed realtime, There's a "contribute GI" flag too, I guess they renamed the "lightmap static".

outer cloak
#

@meager pelican I don't think it is the sky box. the t2 shader graph is applied to the materials as plain grey rather than voronoi.

#

hmm I think I got it. The shader has to be an Unlit Graph. thanks.

sharp tendon
#

So the issue is SRP Additional Light essentially just grabs all lights outside of the main light. (Point lights, spot lights, area lights, and any additional directional lights.)

#

But I'm trying to make it be stepped (like all of the other lighting is; since it's a toon shader), BUT if I do that; the light has no color. (To do this; I plug it into the UV along with all of the other lighting information.)

#

So if I plug it in after the texture so that I have color; I lose the lighting calculations (Since it needs to be in the UV slot to cause the stepping that occurs between light bands.) Any ideas as to how I could have both the color of the light, and the toon shading?

slow bear
#

I'm writing a custom shader for my UI, but I'm missing something; how does one properly retrieve the UV for a world-space UI object? I am using the vertex position, but it seems like the vertex position is locked to the root Canvas object

#

and if I use the UV coords is fine as long as the image is set to simple, but I'd like to find a general solution that takes into account also the "sliced" setting

winter hamlet
#

Hey I thought of learning coding shaders. Does anyone know any relative fast pace resources you would recommend?

warped moth
#

Is it possible to write to the stencil from 3D world, and read from it in UI? I want to cut a hole for a 3D object in UI.

grand jolt
#

theyre needed for distant textures, but close up theyre beyond awful

prime timber
#

When calculating normals isn't it correct that the viewing angle of the viewer doesn't have an effect on the brightness but only the angle between the normal and the lightsource?

meager pelican
#

Depends on if you want specular or not.

But for basic N dot L, it's the surface normal and the light vector.

prime timber
#

Because I am doing a Udemy course on shaders and there is a part where it says
"The more a normal faces the viewer the stronger the brightness at that point on the surface."

#

Which confuses me because it comes right after:
"This brightness in the Lambert lighting model is determined by the angle between the normal and the light source."

meager pelican
#

I took a few discounted ones for fun, enjoyed them.

But it depends on the lighting model, like I was saying. For normal Lambert, you're right, it doesn't need view direction. But go Blinn-phong and yeah, you need that vector too.

prime timber
#

Good to know! Thanks a lot!

normal shuttle
#

How can one transform a point from a barycentric coordinate system into a local coord system?

meager pelican
#

Why not just interpolate the object-space location?

#

(I assume that's what you mean by local coord)

stray wraith
#

I want it to keep its normally material but still fade

#

What am I doing wrong?

knotty juniper
#

your new shader does only inculde one color property for the color value of the shader need to use the the same color property name and texture property name as the shader that was used before to be able to simply switch over

stray wraith
#

@knotty juniper I am new to URP and Shader Graph. The normal shader it is using is the basic URP Lit one with the material the object comes with

#

What do i need to add to that shader and where do i need to plug it into to make it work.

knotty juniper
#

if you select the material that uses the URP/Lit Shader
you can right click on top of the material and click select shader
that will select the shader file and give you a list of all the shader propertys the lit shder has

#

from that you can start to create the propertys for your shader

#

For example
for the color
you probably like to have the Properties
_BaseColor
_BaseMap

create thouse in your shader and multibly them , then you cann pip them into the color value of your shader

#

repeat that for all the stuff you use in the URP / Lit shader

#

@stray wraith

stray wraith
#

@knotty juniper that's what it looks like before i added the shader i made too it..

knotty juniper
#

so the color and color Texture propertys
Metailic
and Smoothnes

stray wraith
#

So i would need a BaseMap, Matallic and Smoothness?

knotty juniper
#

yes

stray wraith
#

Can i make those things within shader graph?

#

again sorry for sounding stupid.. new to this aspect ๐Ÿ˜„

#

This is the 2nd shader i have made, lol

#

I know how to do the multiple.. but not sure how i would make a Base Map within Shader Grapg

knotty juniper
#

you know how to add shader properties in the shader graph

stray wraith
#

yes

knotty juniper
#

For maps use a propety of type Texture2D

stray wraith
#

ok

#

I think i tried that already.. i probably just didn't have it hooked up right

#

so multiple the Texture and then plug into the color and then into the albedo?

knotty juniper
#

hope this helps

stray wraith
#

@knotty juniper You rock!

#

that solved it!

#

Thank you so much!

#

I knew i was close to it, lol

knotty juniper
#

everyday is a day for learnig ๐Ÿ™‚

stray wraith
#

Agreed, I upgraded my project to URP and it was a headache for a bit switching out all the stuff but once i did.. I am loving the shader graph and URP and learning each day about it ๐Ÿ˜„

sharp tendon
#

Anyone ever have an issue where attenuation gives you shadows as though your model's flat shaded? Not sure what's going on...

knotty juniper
#

check your normals

waxen pike
#

is there anyone making volumetric lighting in Universal Render Pipeline?

wooden vortex
#

curious. Does anyone know if it possible to create some sort of shader to indicate overlapping vertices. I want to indicate on object A all the vertcies that are inside object B and color them red. (not really a unity question)

meager pelican
#

Both objects would have to be aware of it (maybe replacement shaders) and use a stencil.

But that's probably not quite what you're after.

#

???

loud canyon
#

Does anyone know the best way to partially update data sent to a shader without needing to resend everything? I need to change a few hundred bytes each frame, but they're buried amidst gigabits of unchanged stuff I'd rather not resend ๐Ÿ™‚ (It's a sparse voxel oct-tree, so it doesn't much matter what format it's coming in as, it'll need to be manipulated anyways)

meager pelican
#

Well, you could use compute shaders, and only update portions of buffers.
There's also API calls in c# that take offsets, like for float arrays IIRC

loud canyon
#

Thanks! Is that performant for single byte changes? I thought the only way using compute buffers was with GetNativeBufferPtr, which I think means unsafe code and a lot of other ill-advised hassle.

meager pelican
#

Nah, just make a buffer with source-updates, and process it into the destination. So you'd set that filling it with whatever you need to update, maybe with indexes, and then just call a kernel that updates the main "real" RWbuffer.

void bobcat
#

How would one express this line in Shadergraph?

fixed noise = tex2D (_NoiseTex, frac(textureCoordinate * _NoiseScale));
regal stag
#

UV node, Multiply by _NoiseScale property, into Fraction node then into the UV input on the Sample Texture 2D.

void bobcat
#

Alright, thanks ๐Ÿ™‚

#

Another question:
float2 textureCoordinate = IN.screenPos.xy / IN.screenPos.w;

Is this correctly translated to Shadergraph?

regal stag
#

You might want to use Default rather than Tiled, but the division by the W component will already be handled for you, only in the Raw mode would you do it manually.

void bobcat
#

According to the shader I'm trying to convert it says its to divide perspective

#

So as a texture coordinate, do I just use XY?

regal stag
#

Yeah

void bobcat
#

Okay

#

I'll try that

#

As an aside; Is there a way to set an unexposed Property of a graph?

regal stag
#

There's an "Exposed" option in the blackboard for each property

void bobcat
#

Like lets say that I want to make that X/Y as a Vector 2 and then store it as a property for easier usage and to maintain readability. Would I need to like, sub-graph that?

#

I don't want to expose this one. I just want to set it in my graph so I have a reference point back to it

regal stag
#

Ah, that's not something that's possible currently.

void bobcat
#

bummer

regal stag
#

You can use a subgraph to organise things better, but if you use that subgraph multiple times it will still do those calculations multiple times.

void bobcat
#

Welp, that's not..good

regal stag
#

At least that's what it does as far as I'm aware, I don't really use subgraphs all that much

void bobcat
#

So if you can't set a Shaders property when its unexposed, is there really much point to them as unexposed?

regal stag
#

You can set a property from C# code even if it's unexposed. The exposed option just means it won't show in the material inspector.

void bobcat
#

Yeah okay, but then it's just more cumbersome and all. But okay, I hope that'll come in a later version, then

regal stag
#

Yeah, I know the Amplify shader editor has a Register/Get Local Shader Variable thing. Would be nice if shadergraph had something like that too, I imagine others have already mentioned it, though I don't see anything on the roadmap.

void bobcat
#

Is a Shadergraph asset transferable to others?

#

Yeah seems like it

waxen pike
#

Could you show us your graph? Maybe we could see how we could help.

#

Yes it is totally transferable, if there isnโ€™t any solution, maybe we need to build our own graph node for that.

sharp tendon
#

Hey I have a kinda complicated, possibly stupid question.

I'm making a skybox, and the stars in the skybox I'm trying to make move. To create them; I'm using Voronoi noise; so I figured I could just change the angle offset slowly over time using the time node.

#

When I do that though; I'm realizing it starts the voronoi noise off at close to 0 since I'm multiplying the time by .0x (That way the starts aren't more like fireflies lol)

#

Is there a way to set the angle offset to a number higher (Lets say 10) before beginning to increase it with time?

#

Oh nvm!! My initial attempt worked, but I had just messed up when plugging my nodes in. This was the solution!

umbral cargo
#

is there a way for me to adjust this property in ShaderGraph from an exposed property?

#

or would is it a limitation of how this particular Master Node is coded?

#

meaning, they purposefully made it so I couldn't alter this property like I can Color, Alpha, Position, etc.

indigo cloud
#

Having an issue with a texture in hdrp, can't figure out why in shader graph the texture is corrupt. Looks fine in the inspector. Grateful if anyone knows what I'm doing wrong!

vocal narwhal
#

that's how colour channels will be filled without the alpha

#

it's showing you the real information in RGB (and not showing you A)

#

Please do not cross-post

#

one channel at a time

indigo cloud
#

ah so expected behaviour? sorry for cross post, will delete

vocal narwhal
#

(already have)

#

but yeah, expected behaviour

indigo cloud
#

ok so thats not the issue then

umbral cargo
#

I think the answer to my question is I can't manipulate Sorting Priority in ShaderGraph with an exposed property and it was coded that way on purpose.

worldly drift
#

Does anybody have a clue how Image Effects on Cameras with target texture work? It seems like the camera renders into a temporary render texture to put that through the image effects and the last image effect is the one really rendering into the target texture.

meager comet
#

Hey is there anybody who can help me with 2D light masking ?

steel fog
#

hi

#

i have a little issue

#

how can i use screen space reflection with transparent lit ?

amber saffron
#

expected : transparent objects don't write in the depth (to resolve SS reflection)

#

But you can enable the transparent depth pre pass to make it work

steel fog
#

i enable it but that change nothing @amber saffron

#

i have try with and without theses cases independently

amber saffron
#

I was maybe ahead of time here, it might not be implemented in the latest 7.x version.
In 10.x (not released, but available on the public github), you have this in the HDRP asset :

steel fog
#

i will try the 10.x so

amber saffron
#

So, you need to enable :

  • "Transparent Screen Space Reflection" in the HDRP asset
  • "Recieve SSR Transparent" on the material
  • "Transparent Screen Space Reflection" in the HDRP Default Settings
#

@steel fog

steel fog
#

thanks

#

i guess it's only in the 10.x ?

wary horizon
#

Can anyone help me? my shader graph is using the screen Pos and screen colour to apply a "heat" effect. like you see on racetracks when its hot, but its not working? its just grey...

stray wraith
#

Is the Stencil override not saving when i set it a known bug with the new URP ?

amber saffron
wary horizon
amber saffron
#

I suspect that you have conflicts in your packages versions.
Don't import the SRP packages separately. Remove all from package manager except universal render pipeline (remove core and shadergraph)

#

They will automatically be imported as dependencies of URP

wary horizon
#

do i go into package manager and remove like that? never done this before etc, dont wanna break my project

#

i have backed it up just now though

amber saffron
#

yes you can remove them using package manager

wary horizon
amber saffron
#

from what I see in the error, I suspect that you have imported individually RP.core

wary horizon
#

i just installed visual effect graph, i restarted unity saince my shader didnt work, tried to reload and got this error

#

By the looks of it, i assume i just need to upgrade my Urp package?

amber saffron
#

Ok I see. Update URP to 7.1.6 then

#

Explanation : shadergraph is a dependency of vfx-graph, so it tries to import it at the same version.
But SRP.core is at the same time a dependency of shadergraph and URP, so you have a version conflict

wary horizon
#

So, what do i do to fix it? since the tutorial for the heat shader said i needed to install visual effect shader?

#

is it this i enable @amber saffron? on each of my Urp settings pipeline? Low / Medium / High

amber saffron
#

only if you want the effect in all of them ๐Ÿ™‚

#

To fix : update URP to 7.1.6 to be in sync with VFX graph

#

Note that with latest versions of 2019.3 and 2019.4, you could have URP&VFX 7.4.1

wary horizon
#

Oh ok, it looks to be working, i enabled opaque texture and the shader dissapeared, which should happen, let me finish the shader for the 4th time and ill let you know ๐Ÿ˜…

stiff flower
#

anyone have a way they like to use to get noise in shadergraph with a 3D position?

#

Gradient Noise just takes a vector 2... looking to drive my noise from 3D world position

wary horizon
#

How hard would it be to do a lightening strike with ShaderGraphs? Or is there a better way

meager comet
#

Hey is there anybody who can help me with 2D light masking ?

fair sleet
#

How would you implement a blur shader in URP?
The only method I found is using a Grab Pass witch isn't supported in URP :(

meager pelican
#

Scene Color node is like a grab pass. Enable it in settings. It happens after opaque, so do your blur after that.

dreamy sonnet
#

Any way to make a shader that colors the absence of light?

#

A global light of some sort.. but

#

I'm not too sure

dawn hill
#

I'm using the Stylized Grass Shader by Staggart Creations, combined with Nature Renderer by Visual Design Cafe. NR added a "procedural instancing" feature that requires adding a 2-3 lines of code to the shader. I followed their guide but I must be doing something wrong. Can someone better versed in shaders help me out?

green abyss
#

Hullo! I'm working on a pixel art shader in shadergraph and I was wondering if there's an easy way I'm missing for getting the size of one pixel from an input texture

#

NVM found it! If anyone else is wondering this plz feel free to @ me

devout quarry
#

@dawn hill contact the publishers

soft harness
#

it seems it's the normal map fixed3 bump = UnpackNormal(tex2D(_Bump, IN.uv_MainTex)); bump.xyz *= _NormalIntensity; o.Normal = bump;

viscid knoll
#

@soft harness the normalmap is not unpacked

#

look at the texture file to si if its tag as a normal?

soft harness
#

It's tagged as a normal map

#

also it is unpacked

viscid knoll
#

in URP it look like this UnpackNormalScale( tex2D( _Bump, uv_Bump ), 1.0f );

#

if it can help you

#

ah non you are multipling the z value of the normalmap

#

don't touch at the z value ^^

#

to get normal intensity just multiply .xy value

#

then add the non modified z value to the vector3 .z channel

blazing siren
#

Hello, is there a way to calculate in shader, distance to the center? but in normalized units?

amber saffron
#

@blazing siren Like distance(positionA, positionB); ?

blazing siren
#

I kinda don't know how to call this

#

but as you see i am trying to created a multiplied cone of sight shader

amber saffron
#

If you want world space distance, you need to convert the positions to world space.

blazing siren
#

I've introduced those two shader properties

#

FIllDistance and ViewDistance

#

now I want to be able to pass viewDistance = 20 and shader should be able to fill out entire 20 diameter distance with this bleak red color

#

let me try to paste some of the shader code

soft harness
#

in URP it look like this UnpackNormalScale( tex2D( _Bump, uv_Bump ), 1.0f );
@viscid knoll

blazing siren
#
{
    i.ray = i.ray * (_ProjectionParams.z / i.ray.z);  // farPlane / rayZ

    // 3D point reconstruction from depth texture
    float depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, i.screenUV);
    depth = Linear01Depth(depth);
    float4 vpos = float4(i.ray * depth, 1);
    float4 wpos = mul(unity_CameraToWorld, vpos);

    // Discard point if is a vertical surface
    clip((dot(normalize(ddy(wpos)), float3(0, 1, 0)) > 0.45) ? -1 : 1);

    float3 opos = mul(unity_WorldToObject, wpos);
    opos.y = 0;

    // Discard hit point if it is outside the box
    clip(float3(0.5, 0.5, 0.5) - abs(opos.xyz));

    // Alpha calculation
    float2 pos2D = opos.xz;
    float distFromCenter = length(pos2D);
    float obstacleAlpha = getObstacleAlpha(wpos); // 0 if occluded, 1 if not
    // Obviously dividing by 60 is not the answer
    float alpha = (distFromCenter <= _ViewDistance / 60 ? _Color.a : 0) * getAngleAlpha(pos2D);
    alpha = (distFromCenter <= _FillDistance / 60 ? _NonVisibleColor.a : alpha) * getAngleAlpha(pos2D);

    float4 col = distFromCenter <= _FillDistance / 60 ? _NonVisibleColor : _Color;
    return saturate(float4(col.rgb, alpha));
}```
amber saffron
#

Oh, it's a post process ?

#

@blazing siren

soft harness
blazing siren
#

I'll be honest

#

Its the first time i've been doing something with shaders

#

so i don't really know

amber saffron
#

Is it applied on a material, on an object (and what kind of object), or in a post process effect ?

blazing siren
#

I found a piece of shader somewhere, and made my own modifications based on trial and error

#

its a projector

#

no wait

#

its a mesh

soft harness
#

I fixed it. It was the tangents.

blazing siren
amber saffron
#

I don't know what is the final look that you want, but from the image I saw, you could achieve the same visual by using a plan mesh and a very simple shader that draws the arcs

blazing siren
#

well in short i need animated AOE indicator on ground

amber saffron
#

@soft harness to change the strengh of a normal map, you can look at the code of the normal strength node of shadergraph :
Out = float3( In.rg * Strength, lerp( 1, In.b, saturate(Strength)));

blazing siren
#

something like this, preferably a cone with customizable angle, distance

#

square can come later

amber saffron
#

Ok, if it need to stick on the ground, yes, it a bit more complicated. A projector shader could be the way to go.

blazing siren
#

isn't this a projector shader? i mean it is on mesh

#

but it sure projects on ground

#

and it does it very well

amber saffron
#

Ok

waxen canopy
#

hi, how can i modify the default shader of terrain on URP 7.4.1?

blazing siren
#

this is entire code

amber saffron
#

Well, for the distance calculation, I think your issues is here float2 pos2D = opos.xz;

#

opos is the reconstruced position in the object local space

#

Did you scale the object ?

blazing siren
#

yes

amber saffron
#

So the position is also scaled

blazing siren
#

so i need something like

#

float realDistFromCenter = length(wpos.xz);

#

?

amber saffron
#

You could do it like this :

float distFromCenter = length( (wpos - pivotpos).xz);
blazing siren
#

hmm

#

im only changing it on big cone so far

amber saffron
#

The mesh pivot is at the handle right, it's not the center of bounds ?

blazing siren
#

at center

#

in the end i need to be able to do full circle

#

basically any angle 1-360

#

this is vpos

amber saffron
#

Let me do so tries locally

blazing siren
#

ohh i see now

#

wpos is world position based

amber saffron
#

exact

blazing siren
#

but why opos is wrong tho?

#

float3 opos = mul(unity_WorldToObject, wpos);

#

is it because its scaled?

amber saffron
#

It can be correct, but it is in the object space. Meaning that if your mesh is a smal one unit quad that is stretched, the positions will only got from -0.5 to 0.5

blazing siren
#

its scaled by 60

#

the more i try to tacke this the less I know

amber saffron
#

Ok, found my error

#

This is the fix you need : float3 pivotpos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xyz; float2 pos2D = (pivotpos - wpos).xz; float distFromCenter = length(pos2D);

#

And remove all your /60

blazing siren
#

yep dayum

#

it works

#

thank you very much

#

i will probably also need to figure out how to make edges more visible

#

by the way is this possible to make edges lower transparency?

soft harness
amber saffron
#

Everything is possible, it's up to how you do your alpha calculation ๐Ÿ™‚

soft harness
#

It's localized around the monster, and fades out at a distance

amber saffron
#

@soft harness Looks like a point light cookie to me

blazing siren
#

well the only remaining functions are

#
float getAngleAlpha(float2 pos)
{
    const float PI = 3.14159;
    float sightAngleRadians = _ViewAngle / 2 * PI / 180;
    float2 npos = normalize(pos);
    float fwdDotPos = max(dot(float2(0, 1), npos), 0);
    float angle = acos(fwdDotPos);
    float angleF = angle / sightAngleRadians;
    return max(1.0 - pow(angleF, _AngleStrength), 0);
}```
#

and this makes right/left edges of cone less or more transparent based on _AngleStrength

#

while i would like to invert that effect

soft harness
#

Also the wall in the original gets shiny when he's around

blazing siren
soft harness
#

I'm thinking maybe lerp between the MainTex and MainTex*Wallpattern by 1/thedistance to the monster

blazing siren
#

this is with _AngleStrength = 10

amber saffron
#

@soft harness The look of the patern projected from the light totally depends on the geomtry around and how it is placed.

#

@blazing siren And, what would you want to see with that number ?

soft harness
#

Dumb it down a bit?

blazing siren
#

to put it simply

amber saffron
soft harness
#

but how do i pass in the monster's position?

amber saffron
#

my last phrase was for @blazing siren

soft harness
#

Ah, but my question still stands

amber saffron
#

@soft harness From my point of view, of what I saw in the image, placing a point light with a texture cookie at the monster position would do the trick

soft harness
#

That's what i did, and the result isn't good

#

there's stretching in the texture, and it's lighting up the scene

amber saffron
#

Compared the your reference screenshot, the monster is in a way wider space, and the light range is seems bigger.
Yes it is lighting up the scene, because that's what a light does.

soft harness
#

But I don't want it to light up the scene. I want it to be like snaking shadows

#

But without the light source to produce those shadows

blazing siren
#

this looks like the one i need

amber saffron
#

yep

blazing siren
#

so wait a second

soft harness
#

I'll try and find a video of the monster

amber saffron
#

Once you have the distance from the SDF, you can easilly draw lines

blazing siren
#

i could literally replace entire function with just that?

amber saffron
#

Haha, almost yes :p

blazing siren
#

basiclly i need this

#
{
    p.x = abs(p.x);
    float l = length(p) - r;
    float m = length(p - c*clamp(dot(p,c),0.0,r) );
    return max(l,m*sign(c.y*p.x-c.x*p.y));
}```
amber saffron
#

input the position, radius and angle to this function, it return the distance to the "pie".
discard all pixels with positive values, do a step to the lines, and fill the rest with the color you want

#

Add a small distance to origin check for the in/out sections, with the additional line, and you have it

soft harness
blazing siren
#

allright i will check out that in evening

soft harness
#

37:48

amber saffron
soft harness
#

yeah

amber saffron
#

Basically looks like decals.

#

Need to leave

#

good luck

soft harness
#

Bye!

#

(btw, you can see it on the other side of the wall, so it wouldn't be a decal, i don't think)

#

Can you pass an objects position into a material it doesn't have?

soft harness
#

How do i get the vertex position in world space in the surf struct?

soft harness
#

not really

#

My current trouble is converting _InkDemonPos to world Space

regal stag
#

_InkDemonPos is probably already in world space. But the vertPos / v.vertex is in object space. I believe you can just add float3 worldPos to the Input struct to get the worldspace position in a surface shader.

soft harness
#

_InkDemonPos is Vector, and I use float inkdist = (1/distance(IN.vertPos, _InkDemonPos.xyz))-_InkInfluence; and for some reason, if the vector is 0,0,0, then it's the distance from the center, and if it's, say, 1,0,0, it's the distance from the center + 1,0,0

#
                float inkdist = (1/distance(IN.vertPos, worldinkpos))-_InkInfluence;```
radiant osprey
#

Hi Everyone! I'm new to Shader Graph (and Shaders) and I'm trying to understand what the Simple Noise node's UV input does. I wrote a short question about it in the Unity Forums for future generation's sake, it would be awesome if someone could take a look and help me (and others) out:
https://forum.unity.com/threads/help-in-understanding-simple-noise-node-uv-input-in-shader-graph.917993/

soft harness
regal stag
#

Yeah, with no input it uses the UV0 channel, which is the texture coordinates for the mesh. Those coordinates don't have to be next to eachother for each triangle so can cause seams.

radiant osprey
#

@regal stag awesome, that explains the issue well, thanks!

soft harness
#

you're welcome ๐Ÿ˜ฆ

radiant osprey
#

hey @soft harness , thanks as well for the video ๐Ÿ™‚ although it doesn't really answer my question... I didn't ask what a UV map is, but how different inputs to a Simple Noise's UV input affect the generated noise

regal stag
#

If used to sample a seamless-texture (as in, the sides of the texture can tile), those seams won't really show. But for the generated noise, it's continuous beyond the 0-1 range and is not seamless.

#

Also to be clear, when using the Position, it's a Vector3 but the UV input is a Vector2, so it will only take the XY/RG components. The resulting noise is stretched through the z axis.

radiant osprey
#

@regal stag wow, thanks so much for the detailed answer, now I also understand the meaning of the colourful preview windows next to each node. I'm going to play around with it in Shader Graph now ๐Ÿ™‚

dawn hill
#

Do shader inputs only read from their respective channel? For instance, will the Occlusion Map texture only read from the Green channel? Would having info in the Blue channel affect it adversely?

low lichen
#

It probably depends on the input and if the shader reads those different channels or not

#

If the shader ignores those channels when it samples that texture, then no, it won't have any effect.

dawn hill
#

I gotcha. I have assets that are sometimes missing a dedicated file for metallic, or occlusion, etc but they include a "Mask Map" and I think that's supposed to sort of include everything in one file. I didn't know if it would be wrong to just drop that same "Mask Map" into all the inputs for Metallic, AO, etc on something like the URP/Lit shader

night current
#

hello..

#

can i know why i got an error?

jovial onyx
dawn hill
#

Is it possible for Unity to use an old/cached/alternate version of a shader in Play mode, compared to Edit Mode/Scene View? I seem to have something like that happening

jovial onyx
#

@dawn hill Happened a me a lot with URP shaders with enum options

dawn hill
#

@jovial onyx Any resolution for it? I tried re-importing, reloading scene, Generating Shader Includes again, if that even matters ๐Ÿ˜…

#

I'm using URP as well

jovial onyx
#

For me was a pain as hell, never found a way to manually update it, i ended up sending a bug with an extensive description of the problem, and not using the features that made that

dawn hill
#

Ah. I'd really like to get this working. It's moving the shader to the GPU and it's a massive performance gain ๐Ÿ˜…

jovial onyx
#

If you don't mind and you're learning, i reccomend you to switch to a beta unity version with the latest urp, they fixed a lot of bugs over 7.x

dawn hill
#

Really? Have you tried any of the betas/do you know if this "shader caching" thing was fixed?

jovial onyx
#

Specifically shader chaching on the enums its not fixed, but a lot of small problems on the graph were resolved

#

Don't know if it is the same bug

blazing siren
#

I've tried to implement that Pie into a shader

#

however i do not know how to discard pixels that don't fit into a pie itself

#

the inner result looks pretty okayish (except for alpha and colors)

#

This is the shader code

night current
#

@jovial onyx ah.. ok nice to know.

amber saffron
#

@blazing siren easy : after line 115 where you get the distance to the SDF pie, add this : if (len > 0) discard;

blazing siren
#

that is only for forward direction

#

but also need to clip anything outside of pie

amber saffron
blazing siren
#

daminit i need to understand it

#

because so far im going blind

#

now how to make center more transparent?

amber saffron
#

To make the center transparent, just us the length of the "pos2D" vector as an alpha source

#

@blazing siren

blazing siren
#

OHHH boy

#

but for some reason its not aligned with view

#

but rotated 90 deg

amber saffron
#

Oh, you wanted it to rotate with the object ?

blazing siren
#

well technically it should just be pointing where object looks at

#

like you know its suppose to be indication that mob does cone attack

#

i know i can rotate mesh

#

and that would do the trick

amber saffron
#

The code right now only takes thepos2D world position to draw the shape, totally ignoring the mesh transform

blazing siren
#

hmm

#

well it can ignore all mesh except for rotation

#

only rotation is important

amber saffron
#

so either you manually rotate the position, or do a fancy matrix transform to have "unscaled object space"

blazing siren
#

scale etc doesn't matter

#

by the way what do you mean "just us the length of the "pos2D" vector as an alpha source" ?

amber saffron
#

the length value of "pos2D" is the horizontal distance from the point of view of the character

#

you can use this, perhaps through a smoothstep function, as source of the alpha value of the final frag output

blazing siren
#

lineMask is essentially alpha?

amber saffron
#

it's a [0-1] mask used for the lerp operations, but you can do whatefer you want with it

blazing siren
#

lineMask = max(lineMask, smoothstep( 0.0052, 0.005, length(pos2D) ) );

#

like this?

#

doesn't seem to work

amber saffron
#

This code adds separation line to the border ones

blazing siren
#

oh wait

#

i can just

#
float4(0, 1, 0, 0.2), // innder color```
#

and it does seem to work

#
                            float4(1, 0, 0, 0.2), // outer color
                            float4(1, 0, 0, 0.5), // inner color```
#

thats almost exactly what i need

#

i don't really want to make any gradients there tbh, plain color is fine

amber saffron
#

well, you have it now

blazing siren
#

now last thing is making lines thicker

#

so that is clearly visible at this distance

#

NOICE thank you very muchj

amber saffron
#

Last step now is the rotation

#

For sake of me, I can't figure out how to remove the scale from the world to object matrix :/

blazing siren
#

what do you mean?

amber saffron
#

Like I said before, you don't want the scale of the object to affect the distances set up on the material.

#

That what I did the shape calculation using world space

#

but by doing this, you loose the rotation information and the cone is always pointing in the same direction.

blazing siren
#

yep, rotating mesh doesnt do anything

#

if you can't figure out how to do this then I doubt I can ๐Ÿ˜ฆ

amber saffron
#

Whoohou, got it

blazing siren
#

how?

amber saffron
#

Let me tiddy this up

#

Replace the pos2D with this ```// Take WorldToObject matrix and remove the scale information
float4x4 mat = unity_WorldToObject;
for (int i = 0; i < 3; i++)
{
mat[i].w /= length(mat[i].xyz);
mat[i].xyz = normalize(mat[i].xyz);
}

                // 2D pos in object space, but with world units
                float2 pos2D = mul(mat, wpos).xz;```
blazing siren
#

yep works thanks

#

if I understand correctly I will have to manually create materials on the fly right?

amber saffron
#

Each time that you want to display it with different values, yes.

blazing siren
#

well it will have to be animated so

fervent tinsel
#

I always wondered about both of these

#

especially the precision thing can confuse people

#

altho so can "single"

#

I dunno if "full" would have worked better since there's no double precision math coming for these shaders any time soon

devout quarry
#

half-single-double is logical to me

#

but I do agree that 'full' might represent the idea of precision better

#

in this context

meager pelican
#

"Vector" is the problem, although it comes from interface issues I'd guess, due to C#'s vector classes.

But float2 vs half2 (which you can't declare because no interface I guess) but if it's not exposed..... Vector isn't a type, it's a dimension. Type/dimension. float3, half4...

topaz nova
#

Hey guys so I'm not sure the issue I'm thinking it's the shaders though...I used the HD pipeline....in unity my main character looks a little bit see through....you can see outlines through him....but when exporting him he looks destroyed as in you can completely see through his body....you can see his eyes behind his head...any help is appreciated.

strong lotus
#

How would I mimic a real-world projector inside HDRP? Tried using a decal projector, but it projects on every surface in the box of influence, which is not what I want. It should only project on surfaces directly visible from the projection "lens"

#

I also would preferably be able to use a custom material shader for the projection, but if it's not possible, I'll settle for just a texture projection.

#

Really not sure where to start on this one, if it's even possible. I'm pretty new to building custom shaders and it's limited to just shader graph stuff

small hinge
#

I'm using a simple dither node setup to dither out a material's alpha and alphaClipThreshold values in shader graph. It successfully masks out the material, but it also gets rid of the shadows casted by the mesh. is there a way i can mask out the material but still keep the casted shadows?

strong lotus
#

If anyone else is interested in the question I asked, I ended up rolling my own solution. Basically creating a custom mesh renderer that dynamically places/morphs geometry in a cone from a single origin point. To make this 3d, I can just straight extrude the entire geometry. Since it's rendered on a plane, I can use a custom shader directly on the surface, using the normal tangents to project a texture on a single side of it (the projecting side) https://twitter.com/garetmckinley/status/1276022564087828481

Okay, last tweet on my custom mesh renderer, I swear. Here's a better video demonstrating the fluidity with a slower interpolation

#gamedev #unity3d #indiedev https://t.co/G1KQPZTFSF

โ–ถ Play video
thick fulcrum
#

@topaz nova if you imported from Blender, check the material... maybe even assign a new one. Check the opacity on the color and ensure material is set to opaque where appropriate.

umbral cargo
#

hey all, you know how colors are in the 0-1 range in shader code, right? I'm trying to figure out the best way to convert that to 0-255, but I'm not sure what to google to find out.

#

I think I just multiply by 255 and truncate the remainder by shoving it into an int

solemn granite
#

hey i dont know where to ask this so sorry if its the wrong place

#

i dont understand why my scene is different in my build compared to the scene in unity editor

#

the height seems to be okay, but width gets messed up

strong lotus
#

@umbral cargo yup, multiplying by 255 will do the trick, to truncate use ceil

#

Basically Mathf.Ceil(color * 255);

#

Ceil rounds the decimal up

#

You can also use Mathf.Floor() if you'd rather round down

slow bear
#

I'd like to add a hole in a ceiling from which some pieces are going to be dropped from; I've tried using the depth Mask / Hole Effect shader, but there's still the issue where every piece that's supposed to fall through from the chute must have its material set to at least Geometry+3

#

is there a similar solution that doesn't need to shift every material further away in the queue?

low lichen
#

@slow bear So what render queue do you have set on the mask and the hole mesh?

slow bear
#

mask and hole are on Geometry+1 and +2 respectively

#

all items on Geometry+0 get holed if they happen to find themselves along the path from the hole to the camera

#

now, the only solution would be to sandwich the mask, by doing something like:

  • Geometry+0: static meshes and level geometry
  • Geometry+A: hole mask
  • Geometry+B: hole mesh
  • Geometry+C: dynamic objects

With A < B < C

#

seems like the best way to do this without actually modifying the mesh, but then there's the case where meshes belonging in the "Level geometry" group might overlap and screw the holes

#

otherwise I'll reserve Geometry+0 for all "hole-able" meshes and all Geometry+C meshes for the "non hole-able" ones

meager pelican
#

@small hinge Well, in the standard pipeline, you can write your own shadowmask pass. Then in that pass, don't dither it.

But in SG, IDK that you can. You could always use SG to generate the code, copy it off and then edit it from there, but you'll have to re-copy and reapply the edits if you change the SG.

IDK if you can detect the pass type in SG and apply the dither conditionally...not that I know of. Unless MAYBE you can do that dither operation in a custom node!!! That might be the ticket. So if you dither in a custom node you could check what shader pass is active.

low lichen
#

@slow bear Yeah, that's the simplest solution. Another solution would be to draw the "hole-able" meshes with a stencil write to mark those pixels as "hole-able". Then you could draw all geometry before and draw the mask after, where it will only replace the stencil value with the mask value if the pixel is marked as "hole-able" with whatever stencil value you pick

#

The downside with this approach is that you'd need to have a custom shader on the hole-able geometry to write that stencil value

#

SRPs allow for more control over setting global stencil states so you don't have to define a Stencil block in each shader

grand jolt
#

Hi guys, i'm following a Brackeys tutorial on 2D glow, but trying to get it working in HDRP, I started a new unlit graph and followed the tutorial, the problem is some of my code modifies the color of sprites, and as this shader isnt like a standard sprite shader there is no _Color property, and adding one results in the screenshot below.

Does anyone know how I would get around this? I'm trying to get secondary _Emission texture maps working with 2D sprites..

meager pelican
#

IIRC they use "_BaseColor" instead of _Color

grand jolt
#

isnt BaseColor for mesh renderers?

meager pelican
#

IDK, you're saying not for sprites?

regal stag
#

I think the sprite renderer colour uses vertex colours?

low lichen
#

Are you making a sprite shader in Shader Graph?

meager pelican
#

I'd have to look at generated code

grand jolt
#

yeah, trying to get emissive maps working on sprites

low lichen
#

So you have a working Shader Graph sprite shader without emission map support and you're trying to add that support?

grand jolt
#

yeah

regal stag
#

You'll probably need to multiply the sprite texture's alpha with the emission

grand jolt
#

well I just duplicated the standard sprite shader

#

but as far as i'm aware theres no way to modify that?

meager pelican
#

No, but you can see (or copy) the code

low lichen
#

Emission is just adding the emission color to the final albedo/opaque color. For transparent objects, you'd have to do what Cyan said, multiply the emission color by the alpha before adding it to the final color

#

Otherwise you get what you have now, the emission revealing the sprite mesh

meager pelican
#

It might effect the lightmap stuff though, because it's emissive.

#

But you might not care about that.

low lichen
#

I'm sure the lightmappers ignore SpriteRenderers

grand jolt
regal stag
#

Oh right, it's unlit anyway. Then yeah just multiply the emission with the A from the main texture sample.

#

Before adding it

low lichen
#

And if you want your shader to support the color property in SpriteRenderer, you should multiply the vertex color in there somewhere

grand jolt
#

erm yeah my code modifies that, so i'll need to, very new to this shader graph stuff though so just trying to get Cyans thing sorted one min

regal stag
#

Wait actually, you need to connect the main texture sample A output to the alpha on the master node.

grand jolt
#

that worked!, whiteness is gone!

#

doh....

Ok, need support for that _Color now, any idea how I would do that @low lichen

low lichen
#

SpriteRenderer doesn't set the _Color property

#

It modifies the mesh to add vertex colors

grand jolt
#

mySpriteRenderer.material.SetColor("_Color", mySpriteBulgeColor);

I'm using that (if it matters)

low lichen
#

You could be doing mySpriteRenderer.color = mySpriteBulgeColor; if you use the vertex color in your shader instead of the _Color property.

grand jolt
#

so just change the code eh? i'll give it a shot and remove the _Color from the graph

low lichen
#

You'll also have to add a Multiply node right at the end that connects to the Color output and multiplies the result of the main texture and emission addition with the output of the Vertex Color node

grand jolt
#

giving it a shot now, one sec

low lichen
#

Yes, except the alpha output should be whatever the alpha is of that last Multiply node

#

Or no

#

Then it would become invisible if the color is black

#

Which is probably not what you want

grand jolt
#

aye ๐Ÿ˜›

#

i'll change that code and test

low lichen
#

Did you remove the part where you multiply the emission with the texture alpha before adding it?

#

I'm not seeing that in your last screenshot

grand jolt
#

dont think I had it to begin with, rofl

#

wait one second

low lichen
#

What emission texture are you using?

grand jolt
#

black and white one

low lichen
#

You still have to plug the texture alpha into the Alpha output

#

Not sure why you stopped doing that

grand jolt
#

sorry I assumed it had to be routed before outputting, you mean like this? this gives me white again

low lichen
#

What if you set the emission color to black?

grand jolt
low lichen
#

Are you sure you've saved the graph? It doesn't look like it has applied the alpha fix you made.

#

Is your shader set to transparent?

grand jolt
low lichen
#

Your shader is set to Opaque

#

That's not transparent

#

Change Surface to Transparent

grand jolt
#

@low lichen ooooh almost, no whiteness, but the _Emission isnt showing, also, I have an idle animation that animates the sprite every 5 seconds and I get the whiteness when the texture changes

I'm guessing I might be able to get around it if I try putting all the textures in a spritemap, at the moment they are all singular

#

that still doesnt explain why the emission isnt showing on the one with the map though

grand jolt
#

solved the texture change issue, just the emission not showing now...

low lichen
#

@grand jolt What does your graph look like now?

grand jolt
#

should look like the frog on the left:

low lichen
#

I think the issue is that you're just taking the red channel of the emission texture

#

Emission maps aren't always grayscale

grand jolt
#

take em all?

low lichen
#

Try it

#

Everything except the alpha, though

#

Though, the worst you could get is alpha greater than 1, unless your emission texture somehow has negative alpha

grand jolt
#

no change

#

same result

low lichen
#

I guess it doesn't actually matter, because the alpha is ignored anyway

regal stag
#

What colour is the EmissiveColor set to?

grand jolt
#

currently default is black, i've got code to lerp it

regal stag
#

If it's black, nothing will show because it's multiplying by 0

low lichen
#

Is the frog supposed to have that pink overlay on it or is that unintentional?

regal stag
#

That tends to be how emission works though, you just need it to be set to white if you want the emission to appear

grand jolt
#

yeah thats intentional, it's in the middle of a color lerp

#

no change unfortunately, set it to white default

regal stag
#

Not just default, but the colour on the material inspector itself needs changing too

low lichen
#

So you have an emission texture that has just the eyes as white, everything else as black and you have your emission color set to white?

#

A screenshot of the material would be good

grand jolt
regal stag
#

Well there isn't a emission texture set

grand jolt
#

it's set to the _Emission secondary texture of the sprite

#

it fetches it

#

which is the emission map

regal stag
#

I had no idea sprites had the ability to have multiple textures like that, that's really cool

grand jolt
#

๐Ÿ™‚ i thought so too ๐Ÿ˜›

#

you can do it with tilesets and stuff

#

this just happens to be a single sprite

regal stag
#

So, your emission map has black pixels though rather than white

grand jolt
#

yeah with meshes white is emission, black is non, so followed the same rules

regal stag
#

Oh right, only glowing eyes

grand jolt
#

yeah, the sprite is too small to have an outline, it looks bulky and naff, will do outlines with better red images

#

res*

regal stag
#

I can't really see anything wrong. Are the eyes on the emission map white, or just transparent?

grand jolt
#

white

regal stag
#

Perhaps it would be a good idea for the shader to output the emission map texture sample colour & alpha, just to make sure it's being set correctly

grand jolt
#

how would that go? any ideas?

regal stag
#

I mean taking the RGBA output on the emission sample, into color on the master node, and the A output into the alpha. Just temporarily, to see if the sprite texture is actually being set.

grand jolt
#

oh my bad, one sec i'll try

#

looks like the map is ok

regal stag
#

Okay, going back to what MentallyStable mentioned, the pink overlay - you mentioned a colour lerp but I don't see that in the graph, unless you mean that's on the C# side and set via the sprite renderer colour / vertex colours?

grand jolt
#

yeah it's all in script

regal stag
#

Right, so you don't want that to affect the emission colour?

grand jolt
#

yeah I do, thats why I named the actual color picker _EmissiveColor, that way the script works on these spritestoo

#

mySpriteRenderer.material.SetColor("_EmissiveColor", mySpriteEColor);

regal stag
#

Is the _EmissiveColor what is colouring it pink though?

#

Or is that just set via spriteRenderer.color or whatever it is

grand jolt
#

oh sorry, thats the lerp array:

mySpriteRenderer.color = Color.Lerp(mySpriteRenderer.color, discoColors[discoColorsIndex], t);

regal stag
#

Right. So the way you have the graph set up currently, you are multiplying by the vertex colours after applying the emission, so everything turns pink. I think you might just want to tint the _MainTex and not affect the _Emission/eyes?

grand jolt
#

pink is intentional, it's lerping through a disco-colors array on .Color, it's also doing the same using the same array for _EmissiveColor

#

i can grab some footage if it helps, itll be a minute

#

unless thats unrelated, and it's still turning pink without me realizing

regal stag
#

What I'm trying to get at is I think the emission is there, it's just not very bright and if mySpriteEColor is also being lerped with your discoColors, you are applying that tint twice - since it is multiplied by the _EmissiveColor and vertex colour later on.

grand jolt
#

it's not lerped, the first one is a single momentary-change, it's changed back almost immediately, the discoColors one is lerping through the array, so i'm not sure if mySpriteEColor not lerping changes anything

regal stag
#

What is mySpriteEColor set to then?

grand jolt
#

depends on the object, if it's a frog it's green

#

it's set in inspector

regal stag
#

Okay... so it should have green glowing eyes?

grand jolt
#

yeah, when I trigger the method which I tied to a right-click, nothing happens

#

the emission lerp happpens on left click, nothing happens

regal stag
#

Should the green also be tinted by the spriteRenderer.color?

#

Or keep those colours separate

grand jolt
#

erm, well it takes a snapshot of the color on the material, then changes it to mySpriteEColor for a moment then goes back to the snapshot color

    public IEnumerator EmissionSpriteBulge()
    {
        var mySpriteEColor = mySpriteRenderer.material.GetColor("_EmissiveColor");

        Color colorConvertBulgeEmission = mySpriteBulgeEColor;
        
        mySpriteRenderer.material.SetColor("_EmissiveColor", colorConvertBulgeEmission * 0.1f);
        yield return new WaitForSeconds(0.2f);
        mySpriteRenderer.material.SetColor("_EmissiveColor", mySpriteEColor);
        yield return new WaitForSeconds(0.2f);
    }
    public IEnumerator ColorSpriteBulge()
    {
        var mySpriteColor = mySpriteRenderer.color;

        mySpriteRenderer.color = mySpriteBulgeColor;
        yield return new WaitForSeconds(0.2f);
        mySpriteRenderer.color = mySpriteColor;
        yield return new WaitForSeconds(0.2f);                
    }
#

same deal with .color

regal stag
#

This is getting more complicated, I think you should just set the spriteRenderer.color and _EmissiveColor to a single colour in the Start() method, just to test the shader is working the way you want.

#

It's hard to tell if the shader is the problem or whether the code is

grand jolt
#

i'll pre-cache the emissive color

#

[HideInInspector] public Color32 mySpriteStartingEColor;
mySpriteStartingEColor = this.gameObject.GetComponent<SpriteRenderer>().material.GetColor("_EmissiveColor");

    public IEnumerator EmissionSpriteBulge()
    {
        //var mySpriteEColor = mySpriteRenderer.material.GetColor("_EmissiveColor");

        Color colorConvertBulgeEmission = mySpriteBulgeEColor;
        
        mySpriteRenderer.material.SetColor("_EmissiveColor", colorConvertBulgeEmission * 0.1f);
        yield return new WaitForSeconds(0.2f);
        mySpriteRenderer.material.SetColor("_EmissiveColor", mySpriteStartingEColor);
        yield return new WaitForSeconds(0.2f);
    }

Looks ok @regal stag ?

#

it's fetching white

#

on start()

regal stag
#

That's not really what I meant. I mean just ignore the code side of things for now. Do something like :

mySpriteRenderer.material.SetColor("_EmissiveColor", Color.green);```
Then check if the shader itself is the result you want. There's no point of setting the colours if the shader itself isn't doing what you need it to. I get the feeling that the multiply with the Vertex Color should be with the _MainTex only, before the Add node, rather than after - but it depends on whether you want the emission colour to also be affected by the spriteRenderer.color.
I've gotta go do some things, so good luck, maybe someone else can take over.
grand jolt
#

thanks

#

and no i dont want the color to affect the emissive color ๐Ÿ˜›

#

so i take it the current setup is fine

regal stag
#

Then you need the vertex colour to be multiplied with the _MainTex output only, before the add, not after

#

I'd also look into swapping out the emission map texture for something with more white pixels.
Perhaps also change the _EmissiveColor to HDR mode so it has an intensity that can be increased (which will probably work better with bloom post processing if you have that in the scene).

grand jolt
#

ALMOST!

#

I CAN SEE IT FAINTLY! lol

#

gonna increase the white pixels on the maps

exotic urchin
#

Does Unity handle meshes and particle meshes differently?

Back one is a particle system using the vertex color, alpha over life which is what's used in the particle system.
Front mesh is using the Animation Control material property that is set to be a slider that I am moving back and forth.....Does something look off?

thick glen
#

Noob question... I'm using the code below on the two objects in the gif. Why is the tile only slightly changing in tone but the entire cube is lighting up in a very pronounced way? The cube is a default unity cube but the tile is an imported asset.

    rend.material.color = Color.green;
meager pelican
#

@thick glen I haven't see your shader.

But ....as a general rule, the material (or sharedMaterial) .color is multiplied by whatever else sets the color...so it's a tint. Which is why the side of your tile is being tinted green. So your texture map is being skewed to the green channel. (0,1, 0) RGB. But it's mostly green anyway, except the sides.

thick glen
#

@meager pelican ty for your help. What value in the renderer (if not color) should I use for a more prominent, visible change? I'm thinking something like an outline... guess I just need to do some more research.