#archived-shaders
1 messages ยท Page 160 of 1
not there, into the UV slot on the SampleTexture2D ๐
yup yup
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
Does anybody know how to write depth in a post process effect (OnRenderImage). Cant get it to work
which render pipeline are you using? I only have a solution for one of those though D:
I am using the default render pipeline
then I don't know how to help, sorry x.x
does your solution work with urp or hdrp?
URP
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
Alexander Ameye goes through how to add a depthnormals pass to URP in this tutorial, but hopefully you should be able to figure out how to just do a depth pass if you don't need the normal information, or just use the red channel: https://alexanderameye.github.io/outlineshader.html
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 ๐
@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
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
That should be quite straightforward
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.
@meager pelican depth normals are to be used I guess
I am using the depthbuffer to determine how far an object penetrates the snow surface
@worldly drift so you are not able to access depth buffer ?
For example a sphere will press down the snow in the middle deeper than at the edges
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.
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)
Does the depth buffer contain values for clipped or occluded verts ?
but now I want snow fall so I need to write into the rendertexture depthbuffer
From the camera's perspective. And not quite the distance, but the z-depth
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 ?
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
Oh, so you're using a camera to generate your height field.
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
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?
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.
Ohh, multiple cameras
@quaint coyote yes but the main camera that captures the scene doesnt really matter here
@worldly drift so are you applying a command buffer to the other camera ? And it's rendering out depth properly?
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
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.
in the post process shader?
Yes, you're wanting to write to the dept buffer, right?
GTG, later.
even with ZWrite on it does not do anything
it just seems like the postprocess does not work at all
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?
@quaint coyote sure.
- Snow camera renders to Render Texture with DEPTH_AUTO
- PostFX attached to the snow camera should apply snow fall shader to change depth in render texture (refill)
- 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 ๐ค
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
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.
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
havent tried to use command buffers in this case yet
Also you are rendering depth after everything, and post-processing is also after everything
currently I am just using a rendertexture asset becaused the felt to be the easiest workflow
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
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
Are you using the depth from snow cam in the post process of the snow cam or main cam?
post of the snow cam
Ohh sorry, got confused here that's why :(
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
Then your flow is perfect... How are you manipulating the depth tex? In a postfx ?
And then you do a blit again?
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
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
yeah that would work I guess, but I would unnessecarily render a color texture and I still cant write to depth in postfx
That's true
but it seems like I have read depth and write it into color in order to actually use and write it
You would be reading depth, copying to another color tex and then modifying the value
I thought I was clever by avoiding it but now it is just giving me a headache
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
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
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 :)
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
I guess post is better, with replacement it's like an additional pass on objects...
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
from the docs I would think it will just render with replacement shaders instead of usual once: https://docs.unity3d.com/ScriptReference/Camera.SetReplacementShader.html
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)
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).
in game
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.
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.
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
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.
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
@shy spruce - URP asset should be assigned under Project Settings > Graphics > SRP Settings.. Plus might need to upgrade materails?
very top
also i did upgrade my materials
Scriptable Render Pipeline Settings
oh lol
well i have something assigned
does that have to do with the particle system tho?
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?
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
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)
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
It probably wont.. Ill send you a side if I come across the same thing if you want
what do you mean?
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 - downloaded the package - upgraded materials
that's what i did as well, but it didn't work once i pressed play
And I see nothing in game view.. same issue
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
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
anyone know what to do with shadergraph the current render pipeline is not compatiable with this master node
@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 - HAve you checked https://answers.unity.com/questions/1535235/shader-graph-error-the-current-render-pipeline-is.html
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
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
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
np. I dont mind helping since my roadblock seems to be permanent right now lol
rip, i saw ur screenshots, game looks cool
the problem is it doesnt look cool rofl
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?
ShaderGraph is your best friend there.. But you could get by with the default SRP shaders.. they are actually pretty good..
ok
if i make the models in blender can i then apply unity shaders to parts of the models?
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
so with your lines on the wall is that two objects, 1 with the emission shader and another over the top?
nope, 1 object, 1 shader with different textures
the emission mask takes care of the lighting
oh cool
diffuse vs emission
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..
Since my post is now also buried, anyone have any ideas to clean up the quality on these emissive textures? https://discordapp.com/channels/489222168727519232/497874081329184799/723357615546957936
is there a way to have a shader graph play by code then stop
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
damn you have me digging again..
lol
this is basic math. wtf is it not in unity lol
This would pulse (sine cycle) and be off on negative:
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? ๐
no thanks for the help
@humble fox little better for ya
this is what i did
@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
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.
@humble fox I just dropped some random stuff in to show the connections, do what you wish with it.
Hello, I am very new to Unity Shader
Whats up Mitchell?
I just completed a tutorial completely but on the game my shader is completely black
But on the scene it works fine
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
I did notice a slight difference in the Sprite Lit Master
So I guess I am using a newer render version
โ
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=93jnsgD-8Wo
Let's make a cool Sprite Tint using Shader Graph. This is excellent for Heal and Damage effects.
Check out the entire Shader Graph Tutorials Playlist
https://www.youtube.com/playlist?...
Sorry, I have no idea if it's standard, /URP or HDRP.
This is my first encounter with the Rendering/Shader system.
Whats your version doing?
Standard / URP or HDRP are the options you use to create a new project
@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.
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
@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.
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?
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
@upbeat basin Unity's GPU skinning compute shader is available here
https://github.com/cheeseburgames/unity-builtin_shaders/blob/master/Shaders/DefaultResources/Internal-Skinning.compute
https://docs.unity3d.com/ScriptReference/Mesh.RecalculateNormals.html
I would think the mesh animations would recac them. But there's an api call.
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();
}
@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.
I think if Unity's skinning doesn't support this, you'll have to implement your own skinning. Unity's skinning is not extensible.
How to reproduce: 1. Open attached "oldie.zip" project 2. Observe the model Expected result: BlendShapes normals are imported correc...
Allegedly fixed in 2019.2, unless "corrective blendshapes" are other than this.
@upbeat basin
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
@urban pendant Yes, that is how replacement shaders work
You'd have to do something with those properties in the replacement shader, though
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
@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
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
do I need to recalculate all the stuff Unity does for me ? :/
hmm I can't blame them the name is quite clear
Do you know of a solution to extend shaders at run time
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?
To modify the meshes at runtime? That's not going to run very smoothly
How many meshes?
its worth a shot
The entire scene, which is why I was looking into replacement shaders
Is this for something like a world curvature effect?
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
You might as well be using a custom shader in the scene at that point
true
Thank you for the help btw ๐
if anything it helped with my mental stability haha
@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".
hello, i search a workaround for the detail shader in HDRP
does somebody has an way to use this shader please ?
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.
@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
If using unity grass spawning, you can paint it out when the prefab is spawned as well depends on needs ๐
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 ?
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.
@steel fog No, but you have to consider what's more important for your project.
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
there was some re-written shaders for earlier versions, do they not work?
re-written for detail grass ?
yup, just google they come up
only this
but it not longer work
@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
@steel fog could try https://github.com/flamacore/UnityHDRPTerrainDetailGrass
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
@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
@thick fulcrum you have send me exactly the same -_-
different git... not looked at code though
it's a fork
the date is the same, the size is the same
the desc is the same and the screen
@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
That depends if the grass is drawn separately or all together
It's terrain grass, I assume it's drawn together
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
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 ๐
And you're using Unity's terrain tool to paint the grass on as opposed to manually placing them as game objects?
Correct, they're placed using the brush
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
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
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
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.
I think the terrain draws the grass manually. They aren't actual game objects with mesh renderers
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
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?
So nobody has an alternative for detail/grass shader for HDRP ?
i'm really novice at shaders, can i put a shader into an UI?
and can i have it like a filter in my screen?
what do these do? unity_SHAr, unity_SHAb, unity_SHAg
Can you exclude a material from ambient occlusion?
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?
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. ๐
It's the grass
It's the grass
@soft harness
So is it baked AO or PP AO?
PP ao
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?
nah mesh
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.
Do you know what camera stacking is and what render queues are? Or no?
Not really
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. ๐
what about baked AO?
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. :/
Don't you mark things as static to bake AO?
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".
@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.
S.O.S.
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?
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
Hey I thought of learning coding shaders. Does anyone know any relative fast pace resources you would recommend?
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.
why the mip map textures look next level awful?
theyre needed for distant textures, but close up theyre beyond awful
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?
Depends on if you want specular or not.
But for basic N dot L, it's the surface normal and the light vector.
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."
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.
Good to know! Thanks a lot!
How can one transform a point from a barycentric coordinate system into a local coord system?
Why not just interpolate the object-space location?
(I assume that's what you mean by local coord)
I need help, I'm trying to make the object fade out when the cam is too close. This is what it looks like before the shader is applied to the material.
When I apply the shader
I want it to keep its normally material but still fade
Here is the shader
What am I doing wrong?
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
@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.
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
@knotty juniper that's what it looks like before i added the shader i made too it..
so the color and color Texture propertys
Metailic
and Smoothnes
So i would need a BaseMap, Matallic and Smoothness?
yes
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
you know how to add shader properties in the shader graph
yes
For maps use a propety of type Texture2D
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 You rock!
that solved it!
Thank you so much!
I knew i was close to it, lol
everyday is a day for learnig ๐
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 ๐
Anyone ever have an issue where attenuation gives you shadows as though your model's flat shaded? Not sure what's going on...
check your normals
is there anyone making volumetric lighting in Universal Render Pipeline?
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)
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.
???
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)
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
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.
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.
How would one express this line in Shadergraph?
fixed noise = tex2D (_NoiseTex, frac(textureCoordinate * _NoiseScale));
UV node, Multiply by _NoiseScale property, into Fraction node then into the UV input on the Sample Texture 2D.
Alright, thanks ๐
Another question:
float2 textureCoordinate = IN.screenPos.xy / IN.screenPos.w;
Is this correctly translated to Shadergraph?
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.
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?
Yeah
Okay
I'll try that
As an aside; Is there a way to set an unexposed Property of a graph?
There's an "Exposed" option in the blackboard for each property
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
Ah, that's not something that's possible currently.
bummer
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.
Welp, that's not..good
At least that's what it does as far as I'm aware, I don't really use subgraphs all that much
So if you can't set a Shaders property when its unexposed, is there really much point to them as unexposed?
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.
Yeah okay, but then it's just more cumbersome and all. But okay, I hope that'll come in a later version, then
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.
So I tried to make this shader as a graph:
http://smoothslerp.com/diffused-posterization/
But I didn't get the same result so I probably fucked up somewhere.
Shader Tutorials and (possibly) more
Is a Shadergraph asset transferable to others?
Yeah seems like it
Looks like this:
But mine looks like this
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.
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!
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.
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!
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
ah so expected behaviour? sorry for cross post, will delete
ok so thats not the issue then
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.
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.
Hey is there anybody who can help me with 2D light masking ?
hi
i have a little issue
how can i use screen space reflection with transparent lit ?
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
i enable it but that change nothing @amber saffron
i have try with and without theses cases independently
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 :
i will try the 10.x so
I had to figure where all the settings were, but I enabled it :
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
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...
Is the Stencil override not saving when i set it a known bug with the new URP ?
@wary horizon - Enable "opaque texture" in the URP asset : https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@8.1/manual/universalrp-asset.html
- The master node must be set to transparent
thank you @amber saffron just need to sort this out first ahaha
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
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
yes you can remove them using package manager
these are ones ive got
from what I see in the error, I suspect that you have imported individually RP.core
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?
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
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
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
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 ๐
@amber saffron, Thank you โค๏ธ
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
How hard would it be to do a lightening strike with ShaderGraphs? Or is there a better way
Hey is there anybody who can help me with 2D light masking ?
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 :(
Scene Color node is like a grab pass. Enable it in settings. It happens after opaque, so do your blur after that.
Any way to make a shader that colors the absence of light?
A global light of some sort.. but
I'm not too sure
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?
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
@dawn hill contact the publishers
What is wrong with my shader?
it seems it's the normal map fixed3 bump = UnpackNormal(tex2D(_Bump, IN.uv_MainTex)); bump.xyz *= _NormalIntensity; o.Normal = bump;
@soft harness the normalmap is not unpacked
look at the texture file to si if its tag as a normal?
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
Hello, is there a way to calculate in shader, distance to the center? but in normalized units?
@blazing siren Like distance(positionA, positionB); ?
I kinda don't know how to call this
but as you see i am trying to created a multiplied cone of sight shader
If you want world space distance, you need to convert the positions to world space.
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
in URP it look like this UnpackNormalScale( tex2D( _Bump, uv_Bump ), 1.0f );
@viscid knoll
{
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));
}```
So like
I'll be honest
Its the first time i've been doing something with shaders
so i don't really know
Is it applied on a material, on an object (and what kind of object), or in a post process effect ?
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
I fixed it. It was the tangents.
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
well in short i need animated AOE indicator on ground
@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)));
something like this, preferably a cone with customizable angle, distance
square can come later
Ok, if it need to stick on the ground, yes, it a bit more complicated. A projector shader could be the way to go.
isn't this a projector shader? i mean it is on mesh
but it sure projects on ground
and it does it very well
Ok
hi, how can i modify the default shader of terrain on URP 7.4.1?
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 ?
yes
So the position is also scaled
You could do it like this :
float distFromCenter = length( (wpos - pivotpos).xz);
The mesh pivot is at the handle right, it's not the center of bounds ?
at center
in the end i need to be able to do full circle
basically any angle 1-360
this is vpos
Let me do so tries locally
exact
but why opos is wrong tho?
float3 opos = mul(unity_WorldToObject, wpos);
is it because its scaled?
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
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
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?
Can you do the effect on the walls in this picture with shaders?
Everything is possible, it's up to how you do your alpha calculation ๐
It's localized around the monster, and fades out at a distance
@soft harness Looks like a point light cookie to me
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
I'm thinking maybe lerp between the MainTex and MainTex*Wallpattern by 1/thedistance to the monster
this is with _AngleStrength = 10
@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 ?
Dumb it down a bit?
You might want to learn a bit about signed distance field. In particular the "Pie" from here : https://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm ๐
Tutorials and articles of Inigo Quilez on computer graphics, fractals, demoscene, shaders and more.
but how do i pass in the monster's position?
my last phrase was for @blazing siren
Ah, but my question still stands
@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
That's what i did, and the result isn't good
there's stretching in the texture, and it's lighting up the scene
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.
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
yep
so wait a second
I'll try and find a video of the monster
Once you have the distance from the SDF, you can easilly draw lines
i could literally replace entire function with just that?
Haha, almost yes :p
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));
}```
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
@amber saffron This video @ 37:48 https://www.youtube.com/watch?v=UYxXXf9ovjs
Bendy and the Ink Machine Chapter 3 NO COMMENTARY
BATIM PLAYLIST: https://youtu.be/vMrERo_8jX4
FOLLOW US ON TWITTER:
ROCKIT:https://twitter.com/RockitGamingRec
VINNY NOOSE: https://twitter.com/VinnyNooseRG
allright i will check out that in evening
37:48
This ?
yeah
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?
How do i get the vertex position in world space in the surf struct?
So what i've got rn is this: https://hatebin.com/iidcvjvcce, which kinda works
not really
My current trouble is converting _InkDemonPos to world Space
_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.
_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;```
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/
It's a UV map. https://www.youtube.com/watch?v=iIvTUDgaXik
This tutorial covers the basics of texture unwrapping, otherwise known as UV mapping, the process of wrapping a 2d texture image onto a 3d object.
Presenter: Robby Frank
This video is a high quality training video from The Guerrilla CG Project a non for profit organisation ...
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.
@regal stag awesome, that explains the issue well, thanks!
you're welcome ๐ฆ
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
You can output the UV as colour to better see the coordinates & possible seams.
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.
@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 ๐
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?
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.
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
hello..
can i know why i got an error?
im following these https://www.youtube.com/watch?v=FbTAbOnhRcI
Hello and welcome to, like, the 10 millionth water tutorial Iโve done. In this weekโs video weโre looking at some more in-depth Unity Shader Graph features to make water, or an ocean, with shoreline/edge foam, depth, and waves.
Shader is compatible with HDRP., Edit: it used...
@night current youre not setting the HDRP or URP pipeline, check this for URP https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@8.1/manual/InstallURPIntoAProject.html
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
@dawn hill Happened a me a lot with URP shaders with enum options
@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
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
Ah. I'd really like to get this working. It's moving the shader to the GPU and it's a massive performance gain ๐
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
Really? Have you tried any of the betas/do you know if this "shader caching" thing was fixed?
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
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
@jovial onyx ah.. ok nice to know.
@blazing siren easy : after line 115 where you get the distance to the SDF pie, add this : if (len > 0) discard;
That's exactly what it does for me :
daminit i need to understand it
because so far im going blind
now how to make center more transparent?
Here, I made a small sample of how you could use it : https://hastebin.com/ogaqecobud.cs
Looks like this :
To make the center transparent, just us the length of the "pos2D" vector as an alpha source
@blazing siren
Oh, you wanted it to rotate with the object ?
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
The code right now only takes thepos2D world position to draw the shape, totally ignoring the mesh transform
so either you manually rotate the position, or do a fancy matrix transform to have "unscaled object space"
scale etc doesn't matter
by the way what do you mean "just us the length of the "pos2D" vector as an alpha source" ?
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
lineMask is essentially alpha?
it's a [0-1] mask used for the lerp operations, but you can do whatefer you want with it
lineMask = max(lineMask, smoothstep( 0.0052, 0.005, length(pos2D) ) );
like this?
doesn't seem to work
This code adds separation line to the border ones
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
well, you have it now
now last thing is making lines thicker
so that is clearly visible at this distance
NOICE thank you very muchj
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 :/
what do you mean?
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.
yep, rotating mesh doesnt do anything
if you can't figure out how to do this then I doubt I can ๐ฆ
Whoohou, got it
how?
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;```
yep works thanks
if I understand correctly I will have to manually create materials on the fly right?
Each time that you want to display it with different values, yes.
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
half-single-double is logical to me
but I do agree that 'full' might represent the idea of precision better
in this context
"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...
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.
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
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?
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
@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.
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
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
@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
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?
@slow bear So what render queue do you have set on the mask and the hole mesh?
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
@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.
@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
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..
IIRC they use "_BaseColor" instead of _Color
isnt BaseColor for mesh renderers?
IDK, you're saying not for sprites?
I think the sprite renderer colour uses vertex colours?
Are you making a sprite shader in Shader Graph?
I'd have to look at generated code
yeah, trying to get emissive maps working on sprites
So you have a working Shader Graph sprite shader without emission map support and you're trying to add that support?
yeah
You'll probably need to multiply the sprite texture's alpha with the emission
well I just duplicated the standard sprite shader
but as far as i'm aware theres no way to modify that?
No, but you can see (or copy) the code
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
It might effect the lightmap stuff though, because it's emissive.
But you might not care about that.
I'm sure the lightmappers ignore SpriteRenderers
currently my graph looks like:
Oh right, it's unlit anyway. Then yeah just multiply the emission with the A from the main texture sample.
Before adding it
And if you want your shader to support the color property in SpriteRenderer, you should multiply the vertex color in there somewhere
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
Wait actually, you need to connect the main texture sample A output to the alpha on the master node.
that worked!, whiteness is gone!
doh....
Ok, need support for that _Color now, any idea how I would do that @low lichen
SpriteRenderer doesn't set the _Color property
It modifies the mesh to add vertex colors
mySpriteRenderer.material.SetColor("_Color", mySpriteBulgeColor);
I'm using that (if it matters)
You could be doing mySpriteRenderer.color = mySpriteBulgeColor; if you use the vertex color in your shader instead of the _Color property.
so just change the code eh? i'll give it a shot and remove the _Color from the graph
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
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
aye ๐
i'll change that code and test
it's gone white again @low lichen , is that the alpha thing?
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
dont think I had it to begin with, rofl
erm, gives a weird result @low lichen :P
wait one second
What emission texture are you using?
black and white one
You still have to plug the texture alpha into the Alpha output
Not sure why you stopped doing that
sorry I assumed it had to be routed before outputting, you mean like this? this gives me white again
What if you set the emission color to black?
Default set to black:
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?
@low lichen It's not the alpha clip threshold or something is it?
@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
solved the texture change issue, just the emission not showing now...
@grand jolt What does your graph look like now?
I think the issue is that you're just taking the red channel of the emission texture
Emission maps aren't always grayscale
take em all?
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
I guess it doesn't actually matter, because the alpha is ignored anyway
What colour is the EmissiveColor set to?
currently default is black, i've got code to lerp it
If it's black, nothing will show because it's multiplying by 0
Is the frog supposed to have that pink overlay on it or is that unintentional?
That tends to be how emission works though, you just need it to be set to white if you want the emission to appear
yeah thats intentional, it's in the middle of a color lerp
no change unfortunately, set it to white default
Not just default, but the colour on the material inspector itself needs changing too
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
Changed the color in the inspector to white, no change:
Material screenshot:
Well there isn't a emission texture set
it's set to the _Emission secondary texture of the sprite
it fetches it
which is the emission map
I had no idea sprites had the ability to have multiple textures like that, that's really cool
๐ i thought so too ๐
you can do it with tilesets and stuff
this just happens to be a single sprite
So, your emission map has black pixels though rather than white
yeah with meshes white is emission, black is non, so followed the same rules
Oh right, only glowing eyes
yeah, the sprite is too small to have an outline, it looks bulky and naff, will do outlines with better red images
res*
I can't really see anything wrong. Are the eyes on the emission map white, or just transparent?
white
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
how would that go? any ideas?
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.
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?
yeah it's all in script
Right, so you don't want that to affect the emission colour?
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);
Is the _EmissiveColor what is colouring it pink though?
Or is that just set via spriteRenderer.color or whatever it is
oh sorry, thats the lerp array:
mySpriteRenderer.color = Color.Lerp(mySpriteRenderer.color, discoColors[discoColorsIndex], t);
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?
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
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.
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
What is mySpriteEColor set to then?
Okay... so it should have green glowing eyes?
yeah, when I trigger the method which I tied to a right-click, nothing happens
the emission lerp happpens on left click, nothing happens
Should the green also be tinted by the spriteRenderer.color?
Or keep those colours separate
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
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
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()
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.
thanks
and no i dont want the color to affect the emissive color ๐
so i take it the current setup is fine
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).
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?
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;
@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.
@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.