#archived-shaders
1 messages · Page 179 of 1
Shader Graph should automatically be adding single pass support
Maybe I should re-save or something?
Maybe
How broke are your custom shaders?
Magenta, like they're missing or weird in the right eye?
Not showing up at all
I can see the shadow (on the ground)
But where there was once a wobbly ball of doom, is now nothing.
Okay I changed something random just so I could save it again and now it works
And it's so frickin cool to see it
When I fire off two of them it's like watching two stars collide
Dancing around each other before consuming 😄
I'm stuck writing the specular term for my skin shader. Can anyone help me out?
My Phong is fine.
I can't get Blinn-Phong to look the same.
alright, I got it working
Just a check, does assigning float4.xy = float2 work?
I'm reading through the assembly and it looks like it works:
34: lt r0.z, l(0.000000), r0.z
35: movc r1.xy, r0.zzzz, l(0,0,0,0), r0.xyxx
36: store_structured u0.xyzw, vThreadID.x, l(0), r1.xyzw```
Also, does int value = uint - int result in a proper negative number? Ex: uint(0) - int(1) = int(-1)?
Nvm, I'll just explicitly cast the uint to int before subtraction.
heyall. quite new to shaders here. how would i get the depth buffer value of a given screen space coord?
@real topaz lerp them in order of importance, the output of one lerp feeds into next with the proceeding texture etc.
@thick fulcrum thanks, it's working fine for 3 textures but the fourth texture is overlapping everything, any help?
this is what i am doing
@real topaz you probably just need to swap the order, working bottom to top. Base texture first I think
@umbral patio You mean in a written shader? And what render pipeline are you using?
which texture is base texture? @thick fulcrum
every texture are in order(like i need)
and thanks for helping btw
if it was terrain for example, might be a typical example, Sand-> grass -> rock -> snow
ohh, but that shouldn't make any difference imo for testing
but depends on your height map setup, basically as you have found the last one covers the rest so it needs to have smallest mask / coverage
The last lerp is using a T value that is almost entirely white. That means it will mostly contain whatever you plug into B
Or actually, you're not using these nodes
ah good spot ^^
b is a vector1 for controlling height
its a vector 1
0.6
you appear to be ignoring the height position so it's potentially overwriting everything
sorry i just started shader graph yesterday, so guide me towards the right direction, plz
I can still pretty clearly see the original grass texture at the bottom there. What is the issue here?
using a single vector it will just be a fade across everything based on that value, if you use the value from the second add node it's probably correct.. but I'm a noob also 😉 MentallyStable is better guy to help tbh
the fourth one overwrites
using a single vector it will just be a fade across everything based on that value, if you use the value from the second add node it's probably correct.. but I'm a noob also 😉 MentallyStable is better guy to help tbh
@thick fulcrum haha, but still wouldn't have done it without your help
my sand is gone using the second add nod, this is soo confusing for my one dimensional brain
just checking, are you using world position or object?
so if you scale up the y axis / move the object does it appear?
hold on, lemme see
well the texture kinda stays there when moving on y, and when scaling on y, the texture stretches
do you just want it based on the objects height?
well, kinda. i have a procedural terrain and i want to texture it based on height
you can still use world space UV for the texture, but you might be better off using object space for the height calculation
would that solve the overlapping issue
you may also need to divide / multiply by object scale to avoid stretching.. but it's early for me so I'm brainslow 😄
nah stretching isnt a problem as im mapping uv in script
I think it should remedy the overlapping issue
ok,
@low lichen might correct me, but object space will work 0 to 1 while world space will be in literal world values -infinity to + infinity
so this maybe why it's not showing because it's outside of your objects position. but I'm just guessing at moment :D
So as your wanting to mask in the 0 to 1 range this should be better
should i divide the object space y to see the texture more distinctly as they are now blending more aggresively
might be more multiply by a strength value
before the clamp but after the add
damn computer just blue screened opening Unity 😦
must be the shaders lol
you might not be wrong 😆
yooo, you are an angel
although theres some unintentional deep frying lol
but thank you sooo much
no problem, it's a start in right direction at least 😉
this was the last most difficult part in this project
no problem, it's a start in right direction at least 😉
@thick fulcrum yeah, gotta not-be-afraid of shaders now
What nodes can I use to simulate this green highlight effect in the image? I tried fresnel but it highlights inside the object as opposed to outside the object.
There is no node that can do that. The first obvious reason being you can't draw pixels outside the mesh you're drawing
The space the mesh takes up on screen determines what pixels end up running your shader.
@low lichen Is there a straightforward approach you can think of to get this effect?
Someone online mentioned using a slightly bigger model to enable this and overlay it somehow (though I'm not sure how to even do this).
It's unfortunately a problem that doesn't have a simple solution. That screenshot looks like it's rendering the character twice, once fully green and one normally. The fully green version is drawn into a separate render texture and then blurred so that it bleeds outwards. Then the two versions are combined together in some way.
@low lichen Do you see a way of getting something close to the effect, while respecting the limit of drawing within the mesh?
I tried using fresnel, but the green is inconsistent along the edges. The green amount seems to depend on the viewing angle.
There's just no way for the shader to know if it's close to the edge of the mesh
Hmm. maybe something using particle FX would be a better approach that still remains straightforward?
@devout quarry That's a cool article, thanks for that. Seems to be the way to go for the outline effect. That'll require more time than I'm willing to budget on this effect at the moment though.
I see, well fresnel is the absolute easiest effect you can use then, but as you experienced, low visual fidelity. One step higher, would be 'vertex extrusion' where you extrude vertices along their normal.
in shader this looks as simple as this
v.positionOS.xyz += v.normalOS * _OutlineWidth;
// output
o.positionCS = TransformObjectToHClip(v.positionOS.xyz);```
but as you can see, it can produce issues as well
you could also just scale up the object
here's a resource for you
@devout quarry Do you know if there's a node in shader graph that does vertex extrusion? I haven't gotten into writing my own shaders yet.
Right, then this should be of use. https://www.codinblack.com/outline-effect-using-shader-graph-in-unity3d/
But as you'll see in the article, you still need to configure culling manually, but it's doable with shader graph
I can't keyframe gradient script's colors for animation
Must something be added into script so that keyframing was possible?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
[AddComponentMenu("UI/Effects/Gradient")]
public class Gradient2 : BaseMeshEffect {
[SerializeField]
private Color32 topColor = Color.white;
[SerializeField]
private Color32 bottomColor = Color.black;
public override void ModifyMesh(VertexHelper vh){
if (!this.IsActive())
return;
List<UIVertex> vertexList = new List<UIVertex>();
vh.GetUIVertexStream(vertexList);
ModifyVertices(vertexList);
vh.Clear();
vh.AddUIVertexTriangleStream(vertexList);
}
public void ModifyVertices(List<UIVertex> vertexList) {
int count = vertexList.Count;
float bottomY = vertexList[0].position.y;
float topY = vertexList[0].position.y;
for (int i = 1; i < count; i++) {
float y = vertexList[i].position.y;
if (y > topY) {
topY = y;
} else if (y < bottomY) {
bottomY = y;
}
}
float uiElementHeight = topY - bottomY;
for (int i = 0; i < count; i++) {
UIVertex uiVertex = vertexList[i];
uiVertex.color = Color32.Lerp(bottomColor, topColor, (uiVertex.position.y - bottomY) / uiElementHeight);
vertexList[i] = uiVertex;
}
}
}```
Gradient in question
@devout quarry awesome! thanks for that.
Is there a way to displace vertex based on the camera position?
I’m trying to distort a sphere inwards so if a camera goes into the sphere, we can still see the shader.
I'm looking for a guide to help me fix a custom shader to work in URP (the well known everything being pink issue). Any pointers? It's a relatively small shader, I got it from an asset I bought and upgrading doesn't work. I just used my newly acquired shader graph skills to recreate it.
But the trees are still pink 😄 I'm on fire today
Any idea on why my alpha sorting is seeing through things?
@eager venture
Looks like depth testing is getting in your way. Try not writing to the depth buffer. That, however, has it's own implications, using the transparent queue.
What's happening is that opaque objects that write to the depth buffer (they usually do) are "in front" of the other pixels. So things "behind" them are skipped, like the planter.
The other option is to make sure you do a discard and throw away the pixel if it is transparent, but that can suck on low end mobile devices. <=== try that first if you're not discarding already.
Can someone PLEASE tell me how to view a sphere from the inside, that isn’t turning on ‘two-sided’ in the settings?!
@runic wyvern a sphere is empty there is no inside data, it's not a voxel. it's a mesh, there are things you could do like trigger a post processing / screen effect when in the sphere though. Depends what you actually want to visualize when inside the mesh.
Does anyone know a guide on how to include refraction with a thickness map to a shader?
@grand jolt, I'm not really sure. The normal issues in the preview kind of went away when I ran the base material through a multiplier (changing the input to a vector 3 instead of the vector 4), but it stayed that when I changed it back so it might have been a weird Unity glitch, I don't know but it is very disconcerting.
@regal stag Yeah, I eventually got rid of the unpack nodes. The object space one was intentional for detail normals and it was on a branch so I was testing with it off by default anyway.
Like I said, the normals issues were resolved to some degree by means that I'm unsure. That said, I was still getting weird reflectivity issues using this shader in transparent mode and having any amount of smoothness on. It would reflect the world like a mirror even on low values. I was able to fix this by swapping the Lit Master node with a PBR Master node, but it means I don't have access to the HDRP shader features.
Anyone know how I could take a texture like this and soften the edges of each 'island'?
I've tried the color mask node, but for some reason the 'fuzziness' value just seems to make the entire material white
I assume this isn't a texture but something you are generating in the shader?
Yes
Can you show how it's generated?
Ooft sure can, bit messy though
Because the softening would have to be incorporated into that
It can't be done afterwards
Rough annotation
Afterwards it samples a gradient and they're blended together. The issue is, I can't find a good source of Opacity for the blend
If I use the branch node, it has no feathering
If I use a multiplied node, the alpha is too far under 1, and it's a transparent desert
So an update on my nodes, I think it just came down to issues I caused. The invert color node didn't work as I expected and the oneminus node which I used at first didn't quite work, but more importantly I think it was because I didn't set the textures to be bump at first. Either that or I was getting some weird anomalies with Unity. Either way, it is now working and I got the DirectX normals working with a multiply by -! node switch for the G channel.
https://puu.sh/GLICQ/26e9e13a22.png
@cinder chasm you can use a another clamp node to get a contour around your islands with an small delta. then use a remap node to manage how much difference is between the islands and the mask you're making. Then i thing that you can smothstep the result with that mask. Its like a dissolve effect but in reverse.
I'm gonna have a shower but that sounds promising, I'll have a go at it later on. For clarification, how do I get the contour with the clamp node? That's the only step that doesn't immediately come to me
Thanks Attelo!
I'm trying to bake an emission in a room but the intensity of the light I want is confined to directly under the light. How do I spread it out?
well essentially your doing a clamp with your comparison if you put another comparison with a little delta, its like another clamp.
so you may use a value like 0.6 and then clamp to 0.5
to get the gradient
How can i get a lighting like this? Is there any asset on the store for that?
Hi, if i need to calculate vertex colors with lerp and have values between 0 and 1, should I convert them to byte and use Color32, or is it better then to use Color in that case?
because manual says: For performance reasons, consider using colors32 instead. This will avoid byte-to-float conversions in colors, and use less temporary memory.
I started to learn to code my own shaders (again) - just very simple. In some cases I prefer the simple look of the mobile shaders better (mainly as I can't good values for grass that is not glossy), but one important thing is missing then:
I added a point-light to the player (like a torch) and it casts shadows when a edge is near - but does cast the shadow with mobile shader. why?
receive and cast shadows is on
need some kind of Texture Splatting, but don't want to lose the extra shadow casted by the point-light
@fast skiff GPUs have been optimized to work with floats, and on mobile you have half which is the same as float but with half the precision and faster to calculate with.
How hard or easy would be making a shader like this one??? Would it be doable just in shader graph?? I just would like to be able to get one side (wall/part) as shader not all 4. The cubes construction is what interests me
To create geometry like that, you would probably need a geometry shader. Or have the mesh start with a bunch of cubes arranged somehow and the vertex shader randomly positioning them all.
But I would probably just draw a bunch of cubes with an instanced draw call
Then I could specify the positions in script.
Which metod would be more performant ?
With an instanced call, you would be offloading the random position logic off the GPU to the CPU, so I would think that would be more performant.
Random scale as well it looks like
That specific screenshot is repeating though, might have been hand placed 😬
Yeah, sounds good. making it by script would be much easier for me coz im ass with shaders😝
Cool thank you @low lichen for suggestion. Gonna try that ! Cheers
And if you are finding that generating all the random positions is taking too much time on the CPU, you can try to speed it up with the Job system and Burst. It's a perfect match.
Is there a way for me to detect intersection with another object in my graph? I'm currently solving it by:
- Setting a Vector3 with the position of the object I'm interested in
- Creating a new Vector3 in the graph with the x and z from the provided position and the y of the vertex/fragment (not sure) position in world space
- Using the distance between that new position and the vertex/fragment position to smoothstep between 0 and some max "thickness" distance I've specified
I'm trying to make an effect for characters walking through a portal. I want to only alter a certain distance from the portal, and use the distance as the intensity.
I do think my current approach might be dumb, or at the very least overly complicated... But I'm not sure if that's just a feeling or if that's correct.
assuming before they interact with portal surface, I'd probably use a second object which is transparent and then use the scenecolor node to apply a distortion to. the trick would be if you only want it affecting the characters. would need to provide a color mask perhaps which means more work sadly.
But there maybe easier methods, I'm probably overthinking it 😉
😄
Can shaders be applied in layers?
I'm thinking that maybe I could have a transparent "effect" area and do something when the color changes. Then I can tell it to only do that to objects on the character layer or something
Also I'm not sure what scene color does
scene color just grabs everything behind the transparent object, so you can do glass distortions for example
being able to apply to just certain layers would be a great asset, but I'm not sure how to go about it.
I like the idea of using a different object a lot because then I don't have to put different materials on my characters
But I'll still have the same problem: How do I apply the effect in a gradient
I think it would need to feed its (the portal intersection object) rotation to the shader
Is that what Shader.SetGlobalFloat is for? I saw it in a tutorial earlier
@low lichen thx, but that does not explain why the shadow from point light does not show up with a simpler shader. what setting could activate that (except of Cast/Receive Shadows, which is of course on)?
@tranquil fern you need some sort of volume effect, was it yourself who did a back hole effect or someone else on here?
Yeah
I can do the volume effect, that part I understand. It's the gradient. But I think I have it.
But to then apply it only on the characters stepping through is going to be harder. I don't think it's going to be possible to get away with only having a shader on the volume
If your using URP, I'm sure it could be done with a custom render feature. but I'm not sure how to go about it yet!
it's on my list of things to look into (hoping someone else comes up with solution and shares in meantime) 😆
I am using URP 😄
I think I got something, but it requires me to set the anchor properly
Which gives me this:
hello guys, how can i remove these black things on my object? I think that these are shadows, but i don't want them
Because the object position is at the center (z axis). So if I manage to move that it's a step forward 🤔
@eager gate Make it unlit?
If there was no shading, it would all be the same color and you wouldn't be able to see that the ground is uneven
if i make it unlit is like that
@fast skiff You need to add shadow support to your shader.
You probably just want a lighter shadow color
It's completely black because you don't have any ambient light in your scene
@tranquil fern you should be able to specify your own position a vector 3 in object space 0 and 1 is each extremities while 0.5 is middle ofc
@eager gate Window > Rendering > Lighting Settings > Environment Lighting > Change from Skybox to Color or Gradient.
Hm yeah, I could take the size into account to change the position. Good point
@eager gate Window > Rendering > Lighting Settings > Environment Lighting > Change from Skybox to Color or Gradient.
@low lichen nothing change
Are you using URP or HDRP or neither?
@thick fulcrum Earlier when I said I know volumetric, I think I was wrong 😄 Is there a way to affect only what's inside of the object?
URP
@eager gate What shader are you using for the terrain? Universal Render Pipeline/Lit?
I found something with far plane and scene depth... I'm currently trying to find a good course/tutorial that'll help me understand those. I don't want to use them and not understand why it's working.
@tranquil fern this is why I mentioned the color node but it's not going to work for this now my brain engages.
The only proper way is to probably have a shader on the character to do the effect, you could use a gameobject collider to trigger passing of data to the shader (specifically where the portal is and switch on effect)
scene depth allows you to recreate object positions in shader space for the current frame, but you wont be able to distinguish which is portal and where is middle (at least not easily)
how did your black hole effect work, was it a shader per object to be affected?
@eager gate What shader are you using for the terrain? Universal Render Pipeline/Lit?
@low lichen yes
@thick fulcrum Yeah
I'll just mess around with these depth, color, position and camera nodes and see what I can accomplish with them
@low lichen How to add shadow support in a shader? It is not completely black, but shows only the shadow of the directional light. with standard shader it shows also the shadow of the players spot light
need to have some kind of texture splatting, but the standard shader seems to be really complicated
can not even find the surf method within a copy of Standard shader 🙁
Because the Standard shader isn't a surface shader
So you're making a surface shader?
i've tried different shaders but nothing change
will it be easy to create a texture splatting shader with shader graph?
Hello. I'm writing hlsl for custom function. ScreenRotate gets corrupted based on screen ratio. Could you help?
float2 ScreenRotate(float2 UV, float2 Center, float Rotation) {
UV -= Center;
float s = sin(Rotation);
float c = cos(Rotation);
float2x2 rMatrix = float2x2(c, -s, s, c);
rMatrix *= 0.5;
rMatrix += 0.5;
rMatrix = rMatrix * 2 - 1;
UV.xy = mul(UV.xy, rMatrix);
UV += Center;
return UV;
}
I made a screenshot, all the same texture, but different shader - on the right side (washed out grass color) it shows the shadow of the point light on the custom shader it does not show the shadow.
The regular shadows from the directional light work with both shaders:
so i.e. a shadow casted from a hill from the "sunlight" with custom shader:
and the same with Standard Shader - there also appears the shadow from the point light:
with mobile shaders it is the same as with the upper picture. just one shadow. What would I need to add to the shader code to get mutiple shadows?
beside the "shadow-issue" I like the non-washed out colors of the simple shaders more than the standard shaders washed out colors
What I need: some kind of texture splatting, i.e. using RGB(A) values as input - so I can set weights at vertices, textures should include Albedo Map + Color and a Normal Map. Also it should be able to receive multiple shadows (like with Standard shader)
For now 3-4 textures will be enough, in the end it would be perfect to somehow have the possibility to have up to 8 textures (but not important now).
Also I would like to combine texture splatting with Triplanar mapping as the next step.
Anyone has any ideas how to start?! Where can I find tutorials or other useful resources? Or may it better for my needs to switch to URP and Shader Graph?
is it possible to set culling in shader graph?
@fast skiff there are some examples of setting up custom model with splat maps for URP shader graph search (URP terrain model replacement shader). The problem with this is that you will need to use a 3rd party program to create your splat maps, probably model editor which you create the mesh in.
Equally there are still resources to do this out there for standard pipeline shaders.
I'm assuming this is not for terrain otherwise why not use the built in shader and tools?
I'm using an asset from synthy. It's pretty cool, but the texture used is one image of which it picks bits and pieces in the mesh renderer. This, too, is fine... Except my custom shader seems to gets applied on the texture, which is the whole thing. Which means that the result looks strange because it only has an effect when the color I am using is being processed by the shader.
Is there something I can do about this?
I'm sometimes bad at explaining so I thought I'd add a video that shows what I mean
The capsule holds the entire texture, so that works great. The character uses parts of it (yellow and dark brown) so only gets affected when those pixels on the texture get changed.
I don't know what this shader is doing precisely, but based on the behaviour I'm seeing I think this is exactly what's happening.
@thick fulcrum can't I use RGB(A) values of vertices for splatmap in combination with URP instead of a splatmap?
I believe one could do that as there is
but I've not done any work with it myself so can't say if you will have problems
@fast skiff simplest thing is probably to setup a separate project and test creating a URP shader in shader graph to see if you can manage it before messing up your project 😉
@tranquil fern you want the affect just to happen on the one model and not affect all others?
@thick fulcrum No I want the effect as seen on the capsule to work the same on the character.
is it safe to assume this is a seperate shader?
It's in the video 😄
I included the top part to show it's a shader. It's from an asset I got
"Advanced dissolve" which does precisely what I want. It just doesn't play nice with the way synthy sets up textures
I'm probably wrong, but I think it's assuming a flat UV which is causing issues on the model due to scale of the UV's involved (atlased texture?). Have you fiddled with the mapping options etc on the dissolve shader?
"mask: type" and "Cutout: mapping"
I suspect you need to "mask" it to that part of the texture atlas and "scale" the effect, but you would probably end up having to write your own
The mask type is to indicate if it's reacting to other objects or if it's reacting to a float
The cutout mapping doesn't have a lot of options, but I can set it to triplanar which is slightly better but still makes everything green at once
@thick fulcrum ok thx, I will give it a try, as I don't really know where to start learning to create shader code
@fast skiff shader graph is a bit more intuative and you can get visual feedback as you create your masterpiece. Although it can still take a while to debug as the graph grows into a monster 😉
@tranquil fern using the triplanar mode, if you increase / decrease the tiling does it improve it any?
Not really. But I'll play with it some more. I'll also try replacing the textures
Because it works fine with my custom models
I suspect Synthy are using atlased textures to save on drive space and performance for mobile platforms, if your not targeting mobile you could spare the space and performance I think 😉
It's for VR, specifically the Quest, so it's mobile 😦
But I think I got it...
It's how I'll be spawning enemies
This looks pretty good right? I'm thinking I'll add some warping/distortion to the plane
@tranquil fern hey that looks great! I've been thinking about something similar; how did you get t to 'not draw' behind the wall?
It's sending in the position to the shader.
i have another question: what would a neutral normal-map look like? I work on a simple texture-splatting surface shader (using RGB(A) values as input) want to use normal maps and wonder what to use if one if them has no normal map?
I just got told that I need to add a shader keyword to a build... I don't know where/how to do that.
nwm, neutral normal map seems to be about the RGB-value 128/128/255 …
guys, how can I scroll between more than one texture sequentially using shaders?
I mean this piece of code can do it for a single texture
Hi, i'm making a boat game and built the waves with shader graph but i'm having trouble getting the player's Y axis to match the wave Hight.
if anyone has any suggestions for this, please let me know
the standard way is to recreate the wave calculation on the cpu, then you sample a few points to make the object "float"
i try doing that on the GPU to put calculations else where away for the CPU
i'm trying to get the wave Hight by compiling the graph into scripts
to make it a little easier you can use the mathematics package, then add using static Unity.Mathematics.math; to your c# file. this then allows you to use functions and syntax which matches with shader language.
you won't be re-creating the whole mesh, just sampling a few points per floating object, this will be hardly noticeable on CPU
if your still concerned about performance, you can use the unity.jobs package to multithread the code OR use a compute shader to run the calculation but you still need to pass it back to the CPU
funnily enough has been my task today to tackle making my water height sampling more accurate, so I pushed it to a compute shader which then immediately lost 80 fps but it was very accurate 😆
to reduce this issue I've added in an update frequency delay, I'm currently batching up height point queries before passing them to the compute shader.
Is this typical behaviour or should I be looking at my compute shader to see if I messed something up?
i'll try that. i'll let you know if i ran into walls
whenever I edit a shader script in visual studio the program crashes
So I'm trying to make a sprite mask that fades in instead of appearing
In this video, I modify the default sprite shader in Unity to create a Sprite Mask Shader.
Link to the Default Sprite Shader: https://github.com/nubick/unity-utils/blob/master/sources/Assets/Scripts/Shaders/Sprites-Default.shader
Use the art I used in this video:
https://ope...
I'm trying to follow this video but it isn't working
is the shader code outdated?
he doesn't explain how the mask works with game objects in the scene
I feel like I'm missing something
They aren't using a Sprite Mask component. That can't do partial transparency so wouldn't be possible to fade. Instead, they have edited the shader that sprites use to send in some float properties (X position, Y position and radius, could be converted to a single Vector property tbh). Then the edited shader is calculating the alpha based on those values.
Anyone here knowledgeable about HDRP Custom Passes?
I want to try and utilize a custom pass to recreate PS1 style texture distortions.
ok I think I fixed some errors but the effect is very unnoticable
if u look in the game view u see a bit of the sprite in the middle
I'd appreciate any help
Anyone see where the error could be?
here's what I copied
would this be better to do in shadergraph?
I have these dot which are prefabs of 2D sprites. These are placed on transparent object, when i add material, they turn invisible. Any idea why?
@tranquil fern Hey could I borrow that shader? I'm new to Unity and am not in the skill range of making my own yet.
I think I'm going to just do the mask on shadergraph
how do I remove the square part?
any way to stop unity from compiling shaders and/or warming them up?
oof, had to ask before figuring it out: turn off scene shading with that combo box in the top left 👍
Can someone help me make a shader?
I tried following a dissolve shader tut but I want to change something
every tut uses simple noise
But it doesn't work with pixel art
is there a technique I can use to change noise to pixel art?
Does anyone know how I might go about taking the provided vetex object position, convert it to the world position, and then convert it back to the object position?
That's my major snag right now.
@rapid willow if your in shader graph, there is the "Transform" node, for code there are some built in variables to help with this. see following list https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
OK, I seemed to have figured it out using TransformObjectToWorld(input.positionOS)
Hey, that's pretty gray
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Here's the code
If you also want something that is pretty gray.
Unfortunately, the effect I wanted to achieve was PS1 styled texture distortion.
So, you know, not really ideal.
So, any suggestions to fix that would be appreciated.
Thanks. I'm sorry it's not the effect you're looking for. But slap a hologram effect on this bad boy and you have one of those maps from the space movies
Ey, guess there's a bright side after all.
What are you working on? a new Petscop?
RE1 styled sci-fi horror game called Biospace.
Also when I read "PS1" I thought of something. Lemme dig through my stored links real quick
That was a lot easier than I thought 😄
I had a shader working in the regular pipeline. But I wanted some of that nice HDRP lighting.
So I decided, hell with it, i'll upgrade and deal with it.
Here's the before
Yeah... I started on URP but I still find loads of things that simply work better on built-in.
This might be a dumb suggestion, but can't you just lower the quality by a lot?
The biggest difference was fewer vertices and lower resolutions
That would give you a closer effect and as a bonus give you a performance boost
In a way, that looks really cool.
But the PS1 couldn't adjust textures to fix the camera's perspective, which gave it a really iconic look I want to try to recreate.
Thanks by the way.
Sorry if I'm wasting your time by the way. I just really like this stuff but I'm not very good at it yet.
No worries. I like talking about it.
I just really want to figure out a way to get the nice lighting and fog from HDRP as well as the PS1 styled artifacting.
I know it's possible. All the elements seem to be there. But getting everything working is, well, tricky.
Especially since the HDRP scripting stuff isn't very well documented.
Looking at the differences, it mainly looks brighter
It definitely is a bit brighter, but the fog and lighting are also a lot nicer and more ATMOSPHERIC.
This shows it off a bit better
Ps1 is A+. Love the console.
That, right there, is very rudimentary ps1 styles vertex snapping, happening within the HDRP pipeline.
I worked on figuring out just that over the span of around 7 hours.
I'm trying to change the property on a material's shader for multiple objects in my scene.
The thing is, I want every object to have their own "instance", right now I'm setting the float property on 1 gameobject, and the material changes for every gamobject that uses it.
I find online that if I want that behaviour (which I don't) I should use the "sharedMaterial" property, but I'm not using that, I'm just using the material property.
Anyway, how do I detach my gameObjects from this shared material so they do it individually?
right now I'm getting the material via the RawImage ".material" property, and just changing a value via the Material's ".setFloat" method
😮 they added grid snapping to shader graph <3, works so well now
@dusk hatch Unlike normal renderers, RawImage doesn't seem to have a .sharedMaterial vs .material thing. If you want a new instance you probably need to clone the material manually. I think you can do something like rawImage.material = new Material(rawImage.material);. You would also be responsible for destroying that material instance, e.g. in OnDestroy.
thanks man, I'll try that out!
😮 they added grid snapping to shader graph <3, works so well now
@devout quarry
Grid Snapping is the easy thing to get working in HDRP.
Next up i need to figure out how I'm gonna manage to do affine texture mapping.
Which... whew. Will not be a fun time.
That's the the grid snapping he was talking about I think, but, shaping nodes in shadergraph editor 😉
Wait, can affline texture mapping be done in shadergraph?
I thought it didn't have access to the uv maps
Yeah I meant that nodes now snap to the grid lines in the shadergraph editor, before they didn't
may be this is what you want, i'm also working on this but so far stuck at the Material Override script
Does anyone have experience of unity Hybrid Renderer?Every time I try to change values in Material Override my cube just go totally transparent
and if I disable gpu instancing it become normal, the problem is I use this because I want the instancing
OK nevermind,I just upgrade to HYBRID_RENDERER_V2 and it solve the problem,turns out the v1 just won't work
Is this kind of stripe shader easy to do ? (only the stripe)
What i mean is, i need to know how to set the color of my stripe to transparent
Never mind i did it
@regal stag Thanks! your suggestion worked perfectly
Hi, i'm beginner with shaders
and I'm following VR Game tutorial where youtuber creates sprite unlit graph (experimental) shader and it works for him, but for me it's all transparent (I tried sttep-by-step 3 times).
I created then normal unlit shader which works perfectly (dashed line with time offset) but it does not change colour. His version changes colour. Also built-in mobile/particle/alpha-blended shader changes the colour, but there's no way to animate its offset.
Any idea what's wrong?
@fair glacier Not familiar with that component but it's possible that it uses vertex colours? Maybe try the Vertex Colour node.
Works! yeah thanks 😄 @regal stag
can someone help me i cant seem to get the urp to let me turn transpancy on
Hello there!
I've been working on a tool to convert the tiles used from the Tilemap Package in Unity to be managed as entities instead.
I've been using some of the code from https://github.com/fabriziospadaro/SpriteSheetRenderer and rewritten and added some code slightly.
It renders all the sprites with the same Mesh with 1 setPass (drawcall) using the DrawInstancedMeshIndirect Method, and it works fine!
But now that I've ran into trying to implement some lighting system I've kind of hit a roadblock. I've looked at plenty of different sources regarding
how I could calculate the light inside the shader: https://pastebin.com/aGK4KxVV
So with the current method, all the instances being rendered have the same Mesh and Material, but different UVs of the texture is used when rendering each instance (using ComputeBuffers and/or StructuredBuffer for multiple instance rendering)
But whenever I try to apply the light effect (Using formula: diffuse = Kd x lightColor x max(N · L, 0)) I get this as result:
A powerful Unity ECS system to render massive numbers of animated sprites. - fabriziospadaro/SpriteSheetRenderer
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'm open for all kinds of suggestions in how I could solve this. The lighting doesn't even have to be dynamic either and could be prepared and bake beforehand too, but I'm not sure how I would do that!
When I edit values inside the shader graph the preview image changes
but nothing changes when I go to scene view and change the values with a slider in a material
Anyone here managed to manipulate the bounding box of a mesh from the GPU? I managed to manipulate the vertices of a mesh straight from compute shader to shader program but had no idea how to change the bounding box of the mesh. This is crucial as the camera will not render the mesh if it is out of it's bounding box...
Have you tried rendering it using a separate camera?
can anyone tell my why my shader brightens my texture?
is it because I'm adding two white values?
what should I do instead
nvm had to clamp
Have you tried rendering it using a separate camera?
@rapid willow no, how does it work?
You basically just have two cameras, and one of them is always pointing at the object that needs to be rendered so it's not culled.
Does anyone know a suitable replacement for "UNITY_LIGHTMODEL_AMBIENT.a" in hDRP?
anyone know how to make an outline shader?
I have a toon shader for my game and I think adding an outline would make it look really nice
I heard post processing is better for outlines
How can I reference/input Material properties in shader graph?
For example, the built-in shader graph shader URP/2D/Sprite-Lit-Default will use the diffuse texture assigned to mesh renderer's material. How do I do the same with a custom shader graph?
how can I combine the pixelate uv and screenspace UV?
You basically just have two cameras, and one of them is always pointing at the object that needs to be rendered so it's not culled.
@rapid willow oh, thanks alot! but will it affect performance?
Any thoughts on how i can get rid of all these shader errors/warnings?
This server build runs fine but the errors are concerning
anyone know how to make an outline shader?
@finite stirrup Unity has tutorial on how to make an outline shader in URP.
it's a post processing effect.
How can I reference/input Material properties in shader graph?
For example, the built-in shader graph shader URP/2D/Sprite-Lit-Default will use the diffuse texture assigned to mesh renderer's material. How do I do the same with a custom shader graph?
@vast geode Just create properties and select the type of property accordingly.
Any thoughts on how i can get rid of all these shader errors/warnings?
This server build runs fine but the errors are concerning
@solid geyser I think you need to remove#pragma only_renderers
You basically just have two cameras, and one of them is always pointing at the object that needs to be rendered so it's not culled.
@rapid willow I tried but it doesn't work, do you mind pointing me to some articles or talking it in more detail?
The Unity Manual helps you learn and use the Unity engine. With the Unity engine you can create 2D and 3D games, apps and experiences.
These resources should help
anyone know how I can combine pixelated noise to screenspace?
thanks, but it is talking about rendering a camera on top of another render camera, the original camera still does cull the object when it is out of it's original bounding box.
anyone know how I can combine pixelated noise to screenspace?
use the screenspace UV coordinate i guess
There's also documentation there about culling.
oh
I tried and it didn't work
where would I input the screenspace uv?
simple noise is already receiving pixelated uv
if I add the pixelated uv to screenspace it doesn't give the right thing
I want the effect when it's zoomed out to be the same as when zoomed in
anyone know what I should do?
how do I combine pixel noise with screenspace?
what do I do with the UV coordinates?
anyone have any suggestions?
Dude just give it some time.
@simple violet bro, this is object space not screen space
I see that you are using the right UV, which is object space, did you use screen space UV node somewhere?
I need to see more of the shader graph
I use screen pos to keep the alpha of the rectangle on the screen
Here's the entire shader
at the square are there, don't use screen position
Basically I just want the pixelated static to appear on screen position
Why not screen position?
use object position
bcs screen position depends on where your camera is
there is the grp called "Square Area"
The square area gives the effect that I want tho
ya, the screen position node swap to object position
I want there to be an opening where my camear is
oh i see
yeah, you should use object position too in that case
how would that help?
it will make the rectangle stay in place no matter where you camera is
and then change the position of the rectangle based on some offset value
what offset value?
XY offset value to offset the rectangle
ya i think sth like this, you can also multiply it with a value to scale it down
so what do I do with it?
i think that's basically how you do it, save it and see if it works
hmm, not sure about this, but can you use another position node, the one with a sphere preview
no, i meant the position node has a sphere like preview
which position node?
oh
set the space to object
wait, the rectangle need UV, why not we just use UV instead lol XD
what?
this will work, but I think a better solution is to use UV node instead of position node
yes
if you want world space it is also possible, then we cannot use UV, we need to use position node and set the space to absolute world, but I think that is not necessary.
they are pretty much the same
I would not same exactly same but alot of similarity i guess
and @simple violet we have a simpler solution, just use a tiling and offset node.
a lot of carry over right?
yeah
? try moving the camera, I think it will stay in place
what do you mean
we didn't use camera space
u said use object space not camera space
yea
so it is working
you can scale the UV however you want, it's up to you to change how the effect will look like
what do I change?
I want the effect when it's zoomed out to be the same as when zoomed in
@simple violet I solved this problem only
give me a demo?
I want it to do the same thing as 0:08 when zoomed in
u see the pixels are bigger when zoomed in
and the pixels are smaller when zoomed out
the dissolve pixels
is this a post processing effect?
ya is the shader a post processing effect?
why is it using screen position again?
because I want to level to be revealed when I move from level to level
that's why it is not solved, we use object space not screen space
what?
I thought I called you to change it to tiling and offset node?
I changed it and it did the same thing as before
hmm, can i have a screen shot of the most recent shader?
oh, erm sorry, try using the tiling and offset node
where?
replace the position node
I'm pretty sure the problem is in the simple noise node
not in the position node
I want the UV that goes into the simple noise to affect only where the camera is looking
and also pixelate
are you able to send me the shader graph to me and let me see what I can do. It's hard to fix it like this XD
let's do it through DM
I'm going to head to bed soon
ok
as we are now kind of spamming the Unity server
solved it in DM 🙂
had to put screen space into pixelate UV
had nothing to do with object position
😂
https://gyazo.com/6817d8f5ebe100e9857fdf8517024ce2
I managed to get the texture snapping working, but I'm not sure why it's being offset so much from where it's supposed to be (It should be a table sitting in the room directly below and to the left of where it currently is)
Like all of the coordinates seem to be working relative to the other coordinates on the object. It seems to have the correct perspective as well. It's just in the wrong place.
Here's the relevant code:
https://pastebin.com/EZbkjAr0
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Hello!
how can I scale a Uv using the (0.5, 0.5) as center?
please @fluid lance me!
@fluid lance subtract 0.5, scale with multiply, add 0.5
thanks ^^
I think I might have localized the issue.
Something happening in the space conversions.
mul(UNITY_MATRIX_VP, mul(UNITY_MATRIX_M, float4(GetAbsolutePositionWS(TransformObjectToWorld(input.positionOS)), 1)));
That is some really hacked together code right there.
And I'm pretty sure that's where the issues are happening.
I think you might be converting from object to world twice, with the UNITY_MATRIX_M and TransformObjectToWorld
Well I tried removing the TransformObjectToWorld, and it still doesn't work, but it's now not working in a different way.
So that's progress.
For context, the code above is an approximation of the UnityObjectToViewPos code.
In itself, that's just the equivalent of mul(UNITY_MATRIX_MV, float4(pos, 1.0))
But HDRP doesn't seem to have access to Matrix_MV, so I had to create that using the weird mul
Yeah, this is also including the projection matrix though, so would be going to clip space not view.
I think it's a bit weird that you end up in clip space, but then convert back to object with input.positionOS = GetCameraRelativePositionWS(TransformWorldToObject(vertex));, assuming world space again
How would I get from clip space back into object space?
I think using UNITY_MATRIX_I_VP would get you back to world? (would be the inverse of what the UNITY_MATRIX_VP one)
So i'd use something like GetCameraRelativePositionWS(mul(UNITY_MATRIX_I_VP, float4(vertex, 1.0)))?
If HDRP doesn't have a _MV one you might just be able to convert from object to world with UNITY_MATRIX_M and world to view with UNITY_MATRIX_V though. Idk if you need projection space with what you are doing or not.
Lemme check real quick
Well it's not throwing an error with GetCameraRelativePositionWS(mul(UNITY_MATRIX_I_VP,vertex))
So it seems like it does have UNITY_MATRIX_I_VP
But I can't see any of the object's geometry either
oh god
Maybe try this?
float4 snapToPixel = mul(UNITY_MATRIX_VP, float4(TransformObjectToWorld(input.positionOS)), 1.0);
...
input.positionOS = TransformWorldToObject(mul(UNITY_MATRIX_I_VP, vertex));
Not sure if you need the transform back to positionOS anyway though. The output of the vertex shader is in clip space so I imagine later you're just converting it back again later. Could maybe remove that and just output the clip space one, assuming you don't need the snapped position in object space for something else.
It's... definitely something.
Hold on, lemme send you the full code so you have the context for what I'm trying to perform.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
A lot of it is commented out right now, since it's holdover code from the script I'm trying to convert.
which is this script:
Right now I think the shader I'm working with is set to unlit, so I'll need to figure that out too.
Oh, also, for the image I posted above, the only object that has the material I'm looking for is the selected object, which I still can't see.
Well I'd probably change vertex.xyz *= -snapToPixel.w; to not be negative, as the psx-vertexlit one above doesn't do that
Eyyyy, that's getting there.
Everything seems to be correctly aligned now. It's just all... big.
Wait I think I figured that out.
It... kinda works.
I had to add in a vertex.xyz = vertex.xyz*1.01 in order for it to show up. When it's not present, this is what I get:
Do you still have the vertex.xyz = vertex.xyz*2; and vertex.z = vertex.z + _WorldSpaceCameraPos.z; lines in there? I'd probably remove those too
Those are gone.
Right, thought so, just checking
I replaced vertex.xyz = vertex.xyz*2 with vertex.xyz = vertex.xyz*1.01
Just so I can see something.
Do I need to apply the shader to everything in order for them to render properly?
Usually you'd have the shader/material applied to the mesh, but I'm not really familiar with HDRP and this CustomPass stuff.
I prefer URP. It's a bit simpler 😄
I'm basically taking HDRP, stripping out most of the features, and just having the nice fog.
Because I'm a fool.
A fool with a DREAM.
WAIT!
I THINK IT WORKS
I had to change around the render settings some, but there we go.
Now, time to figure out how to make this into a lit shader 😓
question about stencil masks and ui. Can you use a stencil mask to cut out of a raw image or something similar. At the moment i have this where the object is being cut out of it in the scene view but nothing in the camera view. is there a way to get this working or should i look elsewhere
please @midnight minnow ty
How would I make standard shader completely unaffected by all post-processing? Including lighting
@grand jolt Don't cross post. And you need to render it with a camera that doesn't have post processing.
Apologies, and that's not an option as I don't have access to the camera object itself.
I mean with another camera. Post processing is a camera after effect, you can only use another camera to mix something without it.
With things like bloom you can somewhat avoid the effect by lowering brightness lower than bloom threshold on the object.
@desert orbit sorry for pinging you if you have already seen it but do you know anything about using a stencil to cut out of ui
if you could point me in the right direction it would be greatly appreciated
Not familiar enough with it. A good question to ask here though.
ok ty
Creating animated weapon skins like it, should I use local space or screen space to cover these skins on the weapon?
Also they have some masks, so the skin covers specific parts
Both the game camera and the scene cameras render the texture in differing quality based on depth. Where do I access the setting that modifies how to render a texture based on depth(basically to render everything of the same quality, regardless of depth)?
Trying desperately to find a shader for transparency on terrains. (picture is showing a "Nature/Terrain/Transparency" shader on top of a ground mesh) Couldn't find one yet that works properly.
@alpine karma I suggest you google MIP maps and study up a bit.
But you can sample any level of a texture with text2DLOD.
There's problems if you sample too detailed of a texture too, produces artifacts.
The GPU normally selects the texture MIP that most closely relates to the resolution that it's at for that position on the screen. This is what the "Generate MIP Maps" option is about on the texture importer.
But with that texture, it might work out.
Or you can turn off MIP Mapping for that texture.
2 cents.
Does anyone know how to make a custom pass lit shader?
Right now I'm using the default unlit one mentioned in the documentation.
There are a bunch of choices here, both unlit ShaderGraph and unlit HDRP shader works and additionally there is a custom unlit shader that you can create using Create/Shader/HDRP/Custom Renderers Pass.
Is there someone experimented in ShaderGraph that could help me figure out two issues that I have (I think they are related) I stated the issues in the video description and reproduced the issue for you to understand, thanks for your time
So my issues are the following :
#Issue 1
When the player look at the sun, if the atmosphere's mesh is on the way, the sun won't display the bloom effect (From the volume script provided by URP), this can be countered if I decrease the transparency of my shader which is not...
Also Outlander, if I understand correctly, a shader pass allows you to render certain items with a specified shader? like a mask? (sorry I'm new to shaders) Because if that's the case then my issue is related to your post
Anyone successfully managed to rotate a Cubemap in shadergraph ?
I have a sphere with a custom shader that I use to make an animated skybox, with an HDRI cubemap as a the maintexture.
But applying "Rotate ArboutAxis" to the ViewDirection you feed to SampleCubemap lead to some very trippy deformations, not cleanly rotating the skybox like you can do the HDRIsky inside a volume.
Any idea why the maths are wrong ?
Code? Graph? Set Up?
although i'm new to shaders, I think rotating to the view direction is a bad idea, if I'm not mistaking the view direction is the camera direction
Here is the concerned setup.
And yeah I guess it's wrong, but there is barely any doc about cubemap stuff and that's the only setup I found to be working (for a rotation value of 0).
... not sure what you mean.
CubeMap in the diagram is my HDRI skybox, the output from SampleCubemap goes pretty much directly to color, to an unlit node that's isn't fed anything else.
That shader is applied on a double-sided Unity sphere, intended to be seen from the inside.
oh okay
still try the position node
AFAIK it still get the cubemap position, allowing you to rotate to a given axis from the center of the CubeMap
Also looked at your video. #2 is expected, once you clip inside the mesh it can't be rendered. You could try some volumetric stuff although I don't know how it work in URP (I only work in HDRP). I would try with VFXgraph and a ton of small transparent particles, might give the same effect without being too costly.
Volumetrics aren't supported in URP if I'm not bullshitting
It's absurdly costly performance-wise anyway, you aren't losing much.
Ah ah ikr? I've already tried a project using HDRP, didn't end well
VFXGraph? can you tell me more about it?
I still want to have the exact same effect as shown in the video
It's the new particle system basically.
Run on the GPU so you can make clouds, grass and co out of it without murdering your performances.
Also I still don't see what you want to do with the position node ? SampleCubemap doesn't care about that info anyway ?
I'm trying to make something that feels like it should be simple but has me a little stumped. I have background buildings in my 2D endless runner being made out of a set of randomly stacked parts up to a random quantity. I assumed it was better to compress those all into one texture since that's a lot of draw calls for what is effectively the same object. Trying to make a shader for it though you apparently can't set to tex2darray, so I have no idea how to do it. Any advice?
I would have tried replacing the ViewDirection node with the position node, so instead of trying to rotate accordingly to your game's view, it just base itself off of the cubemap pos
but that's just a suggestion
what do you mean you can't set to tex2dArray?
you mean assigning the textures?
Tested it. It does ... something. And it sorta rotate correctly. However it has some baseline wrapping. Eh.
Guess I will keep trying feeding the Sample something else than Viewdirection, maybe some random combo will work.
Video of the issue?
Ye. Looking in the forums there's no way to set them at runtime.
Because I need to give the material the parts of building to use.
tex2D Array are arrays of textures rught?
Yes
then why don't you add all your buildings inside the tex2DArray and make a random that will select the buildings??
seems like overkill to feed continuously an [ARRAY] not a list, an array, at runtime
even more with textures
Because there are times I need to speicify certain types of blocks. So if there's something on that building block there can't be a block with a window behind it for example.
This is being instanced. It's not always the same array length.
branch node?
?
Because there are times I need to speicify certain types of blocks. So if there's something on that building block there can't be a block with a window behind it for example.
@vestal stream Branch node is an if statement in ShaderGraph basically, it takes a predicate (bool) that you can use to control your workflow
so you also want to create a predicate that fill your condition
Ok, but that means I now need to give the shader every single building block it could use and all the information about which buildings they belong to and which ones can and cannot have stuff on them and so on.
uh yeah?
better than trying to set it dynamically imo
when you mean every single building block, you basically mean every TYPES of blocks right?
I'm still going to have to set a lot dynamically just so it knows what to use, so I don't know how much better.
I'm still going to have to set a lot dynamically just so it knows what to use, so I don't know how much better.
@vestal stream Dude, branch node
so it knows what to use = bool parameter in your shader
which is going to be filled from a script I guess
Lets say I have 5 different looks for buildings each with 10 blocks for it. I would need it to have all 50 of those and be dynamically told which ones to use. Because the shader cannot and should not decide when a block needs to be able to have stuff on it.
a better way for me to understand would be for you to provide images and schemas
Give me a min for it then
sure
Let's say this is a building. It is only using the green block sets. Only that middle block is able to have something put on it because there's no windows or anything in the way. I need to be able to specify using blocks like that at certain points because the things put on them effect gameplay.
yeah so what's the issue with what I told you?.
just create a predicate that is a bool (hasWindow) or some shit, and provide a script that fills this condition?
and let's say you have 10000 of those buildings, you are not going to fill a tex2DArray of 50000 of length are you?
So for every block of this building with an UNKNOWN quantity of blocks I need to tell each of them if they can or cannot have windows, then have the shader look through all of its blocks and the matching array of if those blocks have windows or not and keep picking at random until it finds ones without windows. Does this not seem a little off?
tbh I don't even understand why you want a shader for it? what is your purpose exactly? can you provide an example of what you are trying to achieve,
what seems off is that you want a shader to do it
It's an endless 2D runner, you're going through a city with a lot of verticality, so random buildings in the background.
You want me to pool many copies of every single building block?
That's how you do endless stuff.
At least that's how everyone I know does it.
store as many as you need and upon the block leaving the game view you disable it
Hnnngh. Trying to access the lighting data in this HDRP custom shader, but Im not sure where to get it.
kind of like an occlusion culling for 2D but with animated shit
I assumed rather than having a huge amount of objects I just mix parts of a single texture. I am amazed how aparently just putting textures by each other into one big one is apparently more expensive than having an object for every single building block
That's how you do endless stuff.
At least that's how everyone I know does it.
@polar relic you are referring to object pooling? or shaders?
yeah but your object is composed of tiny objects aka blocks
Object pooling yeah.
Not sure if shaders even can be used for dynamic map generation like that. At least not without a script somewhere feeding the shader each elements it need to display.
so no differences and that's what object pulling is for
you recycle the objects that you previously used, without destroying anything, so no garbage collection
yeah feeding the shader is what I was proposing but now I understand what he wants, not appropriate to use a shader
Next time you want to describe what you wanna achieve instead of stating the issue, maybe there is an alternative you didn't see
and so do I actually
Ok, well would it be better to only pool the blocks you'd see on screen and change out the sprite on them instead of the maximum amount possible of every single block? I've had someone say otherwise but I honestly can't believe that.
whaaaaat
I suggest you look into an object pooling tutorial?
I'll do a drawing for you
I know what object pooling is. Just holding what you want in memory and bringing in old unused ones instead of making new ones.
I know about this stuff, just not what's optimal. I only didn't know branch nodes because you were talking about shader graph, which in saying about tex2darray made clear I'm not using.
Well I did the drawing anyway
feeding a shader [WITH AN ARRAY OF TEXTURE2D] is the opposite of optimal
so yeah what you want is object pooling
Ok, well about the thing I asked before you made the drawing. You said yes to pooling the max amount of every single block that can be used. Surely it's better to pool the max amount of blocks and change the sprite of that block as needed. Right?
but why do you wanna change the sprite?
dude, you just pool let's say 2000 wood blocks, 100 windows etcc etcc and look for available block of your choice?
you don't even need to script the prefabs and stuff
you just need to instantiate an amount you know won't be too less
Let's say for the sake of example there are a max of 50 blocks on screen at once, and 20 blocks to chose from.
You are saying it's better to pool 1000 blocks instead of 50 and change what those 50 are. Right?
if for example you know you display only 5 buildings at a time, and that at maximum those building will contain 10 blocks, you just instantiate about 50
I don't know if it's better to pool more than what you need rather than changing the texture directly
but I think my way is better
that's something you wanna test and report here tho
and if you are going to display, let's say more than 10000 blocks at a time, object pooling won't cut it, I would hardly recommend start using ECS in that case
I don't understand how storing an extra 950 objects can be better than just changing some sprites. So far this stuff sounds crazy to me.
Oh no that's the thing. It's not displaying 1000 at a time. Just having them just in case. Only 50 at a time, but that's a random 50, so technically they could be 50 of the same sprite everywhere.
you don't need a big ass amount, just enough to be sure your pooling system will still have blocks available
So what I said in that example
you have 1000 blocks of different type?
Reread the scenario again. I'll draw what I mean
Pooling doesn't need to have a fixed size. You can add more object to your pool if the one you need right now isn't already in here. And you clean that when switching levels.
your scenario doesn't answer my question
so again, how many TYPES of blocks do you have
and yeah what Unnamed said is right, and if your blocks are based on level, you can just update the pooling system with the set of blocks you want to display
althou altering the pool itself is costy (is it?)
Let's say this is the screen view. There are 17 blocks on screen. Let's say that maxes at 20 blocks visible at once. There's a bunch of block types visible at once, some repeated. There's nothing stopping every visible block being the same block type. If I am pooling everything I need instead of changing sprites of a smaller pool, I need 20 of each type of block stored just in case.
try that then 🤷♂️
By the by, Unnamed, with VFX Graph, can I still have the same "Fog/Volume" effect I made with my shader? if you look closely when I rotate the planet, the mountains that are far away, are kind of grayed out by the atmosphere, can I still get this effect?
oh and could you sort your issue out?
GetBuiltinData(input, V, posInput, surfaceData, alpha, bentNormalWS, depthOffset, builtinData); Does anyone know how to access this?
I'm trying to get the built-in lighting data and apply it through a custom pass in HDRP, but there's like no documentation on this.
I'm pretty sure it's an hlsl script
an hlsl script is used for shaders, more specifically, it is a file that can be appended to the custom function node in shader graph
I'm hard coding this, not using Shader Graph
it doesn't mean it is shadergraph exclusive
Hmm...
I tried to #include the files I think it's referencing.
But they keep throwing up errors in the .hlsl files.
Lemme compile and send you a screenshot.
sure
I'll also put the full code up on pastebin
ok
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I guess BuiltInUtilities.hlsl is what is throwing errors right?
ah that's okay
so apparently you are missing dependencies
by any chance do you use an RP?
HDRP, yeah.
hmmm
I'm running this through a custom pass to create a vertex snapping effect.
Problem is, the default built shader is unlit.
too complicated
I literally started shader 2 days ago
what is a vertex snapping effect?
It's already done, just isn't lit.
I'm trying to retrieve the builtin lighting data.
GetMainLight function?
I'm not sure if I have access to that.
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl"
however it is LWRP
I should just be able to pull the existing lighting build data that's already stored, but the way it's setup by default overwrites it using ZERO_INITIALIZE(BuiltinData, builtinData);
so you want to check if you can get a file named Lighting.hlsl or something from the ShaderLibrary in the HDRP
once you could include that file you should be able to use your GetMainLight function
I don't have LWRP installed, since I'm not using that pipeline.
There might be something in ShaderVariables.hlsl
I'm still combing through the code
you want to try this maybe
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
that's what I use to "convert" unlit shader to lit shaders using the light
Worth a shot.
just a little hlsl file that you can include and get the liight value from the float returned by the func CalculateMainLight
the light value is a float right? not a color or float4?
Tell me how it went then
It's a Vector 3 that is says it needs
the light value
@grand jolt
show your code
What it seems like here is that there's existing builtin light data that the code is attempting to retrieve from the fragimput. Some of that data is then overwritten by this script.
So, I should be able to just take the existing light data that is already generated and pass it through.
and in english, how does it looks like?
What do you mean?
that means I couldn't comprehend what you just said, but I get it now
So, I should be able to just take the existing light data that is already generated and pass it through.
@rapid willow and you are stuck there is that right?
Yes. Every time I try and take the existing BuiltinData and utilize it beneath the point where it's reset, it says that the data hasn't been fully initialized.
That's what I did.
you might wanna create a var that would hold the light datas and then use that variable for your use case
nvm it won't work
can you show your code?
I get this error.
It should already be in the pastebin from earlier.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Here's just the relevant code.
dude, I think an out value can't be set
maybe take this GetBuiltinData(input, V, posInput, surfaceData, alpha, bentNormalWS, depthOffset, builtinData);
and pass a new builtInData with the values you set
maybe something like this
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
cooking dinner right now, but i'll try it when I get done
sure
are shader graphs compatible with the standard render pipeline now?
and for that matter, vfx graphs?
Not that I know of
are shader graphs compatible with the standard render pipeline now?
@cold sentinel I'm using URP with ShaderGraph, no issues on my end
i meant the built in pipeline, sorry, not the scriptable ones
ah can you tell me the difference with the built in pipeline? I don't see the issue
built in is the one that is default rp that you have when you dont have any of the other ones installed
so for example
the default 3d project
this one will by default have the builtin
aaaaaaah
well you could still use ShaderGraph, but it will include the Core RP Library
however you can still use it has it is, so I say you can using the default built in pipeline, yes
The error seems pretty clear seth, you are trying to pass a frac param in your function while it expect something else
Or vice versa
At the first line of your code btw
hlsl uses actually nvmfract
it's actually this inside the F macro
k.xyw *= float3x3(-2,-1,2, 3,-2,1, 1,2,2)
HLSL doesn't have a * operator for matrix multiplication
that is k.xyw = mul(float3x3(-2,-1,2, 3,-2,1, 1,2,2), k.xyw);
New problem : how do you extract full HDRI info ?
I'm still working on my enhanced skybox shader, but I can't match exactly Unity's Volume-HDRISky coloring. I tried playing with tint, adding emission, exposure, etc ... nothing match Unity's result.
It look like the original HDRI texture has some additional data to make the clouds whiter than their actual RGB color, without impacting the empty blue parts as much.
Any idea ? I'm using SampleCubemap to extract the color from the texture, but obviously I'm missing something.
I'd start with Unity's shader source for the HDRI cubemap. You can get their sources on their download site, just change the drop-down to built-in shaders.
I'm assuming you're using the same texture for both versions, so it's already marked as HDR 24 bit format.
There seem to be a function "DecodeHDR" that's probably responsible for what I want.
Will see if I can call it from shadergraph's custom nodes.
Shader wizards i need help:
I have huge ocean plane and i want ships to drive over the ocean so the question is how can i hide the waves inside the ship?
My idea was to have a nother object which hides the plane at the contact points how can i do that?
Pls help
Stencils! Write some stencil value on the pixels inside the boat, draw the boat first, then have the water not draw pixels where that stencil value is.
Sorry i dont know anything about shaders how do i do that?
And thanks for helping me
Is your water using a custom shader? Is your boat using a custom shader?
The boat is a normal shader the water is a custom shader
Normal shader being the Standard shader?
Yes
That complicates things because Unity requires custom shaders to override the stencil state.
But if performance isn't critical, like on mobile, there's a hack you could do
You're sure Crest doesn't already have this feature?
That would be a pretty big oversight for such a popular ocean asset
No it hasnt
@slim steppe what about this?
UV space? What do you mean by "animated weapon skins"? Like if you change the tiling/offset dynamically in the shader? That's messing with UVs.
The base UV would be set in the modeling program.
Then you animate it.
And honor the masks.
I'm watching some old shader graph effect tutorials and a few of them use custom functions to get lighting data, is this what the ambient light node was created for? to replace the need for that?
@grand jolt You still need custom functions to obtain light information from main or additional lights. (e.g. https://github.com/Cyanilux/URP_ShaderGraphCustomLighting). That ambient node only gets the ambient colour values (aka the Environmental Lighting colours under the Lighting window).
Though while you can use those colours, I don't think it's technically the correct way to apply ambient lighting - I think that's what the SampleSH functions in the URP/Lighting.hlsl is for (also used for light probes?). Using the Baked GI node also handles that for you, or samples baked lightmaps.
@regal stag ah ok, well i'm trying to replicate this in HDRP:
https://www.youtube.com/watch?v=YrATLRhOExk
@ 1:51 he uses the custom function to I -think- drive the offset and position of the halftone, which is what I was hoping that node would allow me to circumvent the need for as i'm trying to stay away from custom functions ATM. But i'll look into it, wasnt sure if theres any other way to achieve a similar effect.
What do you think about the Halftone Effect? Did you know that?
In this video, we create on Unity the shader that applies the Kirby's halftone effect to 3D models.
Model: https://sketchfab.com/3d-models/fan-model-kirby-159e9a80a0e04ab49ea227fa04ca775d
Custom Node articles by...
Not sure you can get light info in HDRP from custom functions. You could pass the light's direction in using a global shader property though.
global shader property? any docs or tutorials for that anywhere?
Using a C# to set it that is. Shader.SetGlobalVector https://docs.unity3d.com/ScriptReference/Shader.SetGlobalVector.html
ah ok, cheers
hey hey - this has probably been answered 800 times in the past, but does anyone know how to solve the "vertex position offset doesnt work nicely with the z buffer" problem?
I assume this is because you have a post processing shader that relies on the depth texture. That depth texture isn't generated from the same shader pass that draws the mesh. There's a specific shader pass that is depth only and you will need to do the vertex offset in that shader pass too.
ahh got it
im hoping that Amplify will let me do that, so i dont have to start hacking code into shaders right off the bat
thanks dude
Are you using a Fallback shader?
not that im aware of; its been a while since i used ASE so im not sure
oh ok i think i solved it
erm does GetMainLight() apply to point lights etc?, or is it specifically for directionals?
in terms of adding it as a custom function in Shader Graph
GetMainLight would be the directional one. GetAdditionalLight would be for point/spotlights.
Those functions are only in URP though, they aren't available in HDRP.
ah I see, was researching HDRP alternatives and found this:
https://forum.unity.com/threads/hdrp-getmainlight.745943/
which I suspected only worked with directionals
and as I dont really have directionals, it's all point lights, i'm betting thats useless XD
@toxic flume I suppose you could use a flipbook animation and just change frames to animate.
I'm trying to get a sprite to cast shadows in URP using this shader, but it only receives them
what would be a good alternative?
as it seemed to have worked for people in this thread, though my unity version is 2019.4.13f1 and I'd be surprised if that was broken between that and 2019.3 https://forum.unity.com/threads/srites-do-not-receive-any-shadows-from-3d-objects-in-the-universal-render-pipeline-urp.803517/
When I made a shader for an object, how am I able to activate it only at a specific event?
you can define a variable for example int (0 or 1) and set it in specific time
material.SetInt("_ActiveFlag",1)
Also you can switch between different materials, one is default and the other is a custom material
ok thanks
how do i make a refractive water shader in unity hdrp?
in a shader graph, I made a basic colour property for my elements, which I applied to the albedo btw, when I first set the colour value it works, the colour applies to the objects that have a material affected by the shader, however second time I change the colour and save the shader it doesn't change in the game review on the object, or in a scene builder, it stays the same, that is, until I change the 'reference' value into some random string and save the shader again, and to be completely honest I'm just a beginner and have no clue what the reference value is, I tried looking it up in unity manual but I couldn't find any documentation related to reference under colour shader property, so, can anybody explain this to me?
When you define shader propertys that are exposed publicly unity will publish them on the meterial.
On the first time it will take the default value from the sader and saves it as the value it should have.
if you change the default value in the shader again unity wount override the allredy existing materials.
Else you wold proabbly lose all the settings saved in a material every time you change the shader.
i hope that explains it.
@languid bane
oh
so, properties are just default values?
is there a way to change the values in realtime, like, just to get a preview of how it would work?
The properties should be exposed on the material. You can set them there
hi im completely new to shaders, so i have question. how do i make a reflective/refractive water shater in HDRP?
this is a nice tutoreal for a water shader
its for URP but should work for the most part in HDRP too
https://www.youtube.com/watch?v=gRq-IdShxpU
In this video, we'll take a look at how we can use the Shader Graph feature in Universal Render Pipeline, or URP for short, with Unity to create a water shader! The water shader can be simple or complex, and include the features you desire. Let your imagination get wild in thi...
or do you have somting different in mind?
nevermind, I kinda got what I wanted, I figured colour node doesn't have any other modes except default and hdr, so I used hue instead, modulating it using a vector 1, which has a slider node, which is pretty close to what I was looking for
hmm didnt seem to work very well, the entire plane was just purple and the only thing that worked was the displacement
This is a tutorial on creating a refractive shader by using the color scene node which gets the camera texture, this method is good for things like rivers because you don't need to put lots of reflection probes for it to work.
This material is part of the LWRP Material Pack V...
might not work, as it seems to be used in srp
however if theres a way to make 2 normal maps move on a standard hdrp material, then my issue should be solved
is there anyway to do that?
is there any good way to display shadows from sprites in Unity URP?
@spring fox You can use a normal blend node to do that.
The HDRP code is such a rat's nest.
@spring fox for the basics of water in shader graph HDRP, moving normals adding color and refraction should be the same as URP. Where it differers is Reflection, in hdrp you have different reflection probes you can access which are potentially better than what we have access to in URP.
I'd suggest starting with the basics and look at reflections once you are happy with the rest.
@toxic flume You must have deleted the post, but no, I'm not sure about that. I don't have their source code. Nor did you show me a decent video of the animation (not being snotty, just saying IDK exactly what effect you want).
There's animation skinning, whereby you animate a mesh like with mechanim, and then skin it, adjusting for things like creases. Then there's texture animation, whereby you change what you draw over time (or over travel distance or whatever variable). I'm guessing you're talking about the latter, since the image shows things like "stars" or "dots" or whatever that I assume "move" on the flat surface of a weapon, say that rifle.
It would help if you dig up or record a specific video of the effect.
I admit I'm guessing and working a bit blind, but you didn't get any other answers so I was trying to help. Show exactly, or closely as possible, what you want and everyone can help you kick around the options.
I could need some help with my shader. It's a shader which dissolves an object, but I want it to start it when its called. Right know it runs continuously
over and over again
but I want it to start dissolving when I need it to
I made already 2 materials 1 with the shader and 1 without, but when I activate the other material the shader already runs all the time in the backround
@dusky mountain you could put a branch on your effect and only have it run when bool condition = true
is this in shader graph or code?
A branch would kinda work, but it might suddenly switch to half-dissolved or something, assuming the dissolve effect is based on time (as in Time node, or _Time in code, perhaps put through a Fraction node to repeat it).
You could swap that out for a Float/Vector1 property instead, with the reference set to "_Dissolve" though, then you can have free control over when it dissolves using C#. For example, GetComponent<Renderer>().material.SetFloat("_Dissolve", value);. "value" likely being 0 or 1 for fully visible/invisible depending on how the shader is set up. Using .material will mean it creates a new material instance instead of sharing with others. You need to destroy that material instance too at some point though, e.g. in OnDestroy function). And for animating, maybe look into putting that into a loop in a coroutine or setting via Update method.
or, if your dealing with a LOT of objects, you can use MaterialPropertyBlocks, that wouldn't require destroying the instance I believe
important to note using .material may be more performant, MPB's are only more performant with a large number
Depends if you are working in URP/HDRP or built-in. MaterialPropertyBlocks don't play well with the SRP Batcher
yeah thats a bummer, it does completely break SRPB :(, I use GPU-I instead personally
hmm, trying to follow that water shader tutorial. I downloaded boatattack demo project, but disabled the existing water plane and created a new one, following along.
Seems to work fine (with some fiddling since apparently my Unity version has a different shadergraph concept), until I add the Alpha channel. Then suddenly my plane gets a water texture thats even animated (and behaving a bit oddly)? Despite not having made anything in the shader for that
you might want to try in a clean scene, maybe some other items besides the water plane I can't recall at moment.
It's just weird, because when I disable my plane, nothing's there at all 😄
But yeah, guess I'll try an empty scene, just figured it's nicer with the isalnd props already placed down
Oh, you're right
There is something there, just hard to see without a backdrop
Ah, it's a shader or something added to the renderer itself
now you can test in island scene at least 🙂
Yeah, thanks ^^
Hello guys, i have images that has Aplha chanel. I can get this alpha if i choose some mobile shaders that exist in Unity. But, because of bending world i had to use custom PBR graph. So, can i add alpha color to my images in PBR?
@spring fox for the basics of water in shader graph HDRP, moving normals adding color and refraction should be the same as URP. Where it differers is Reflection, in hdrp you have different reflection probes you can access which are potentially better than what we have access to in URP.
I'd suggest starting with the basics and look at reflections once you are happy with the rest.
@thick fulcrum i got the basic water to work with moving normals and a planar reflection probe, but i have no refraction so ho do i do that?
this is my shader so far
@spring fox there's a few ways to approach this, but essentially it's scene color node and warp the UV based on the wave normals. There's an example for refracted glass around which is what I used initially. if your struggling / can't find I can dig out an example 😉
looking pretty good so far
anywhere you like, but I'd probable add it in before the reflections. It's basically grabs a texture of the scene below the water, like a depth grab but in color.
well do i put in albedo? like where does it end up in the main node?
yes into the albedo eventually, but you need to distort the image. if you look up some refracted glass effects it should make more sense than I can describe 😄
ok, i'll look for a tutorial on it, thanks for all your help!
one more question, this tutorial requires a 'movement' node and i cant find that node, has it been removed or does it have a different name?
I've never heard of a "movement" node, perhaps it's some custom code in a "custom" node. but for basic water there's no need for custom nodes, even vertex displacement could be done in graph
hmm ok
or perhaps someone knows better than this noob
if it works don't knock how simple it is, simple is good 😉
none of the tutorials seem to work
@spring fox this is what I use, but replace the "Normal Vector" node with the result of your combined normal maps. I just used it as a placeholder because my graph is a monster 😆
does this require 'depth texture'?
refraction amount is a vector1, I think lower value the more it distorts