#archived-shaders

1 messages · Page 179 of 1

tranquil fern
#

That's good to know. I just changed it, made a build and noticed nothing different except (expected) my custom shaders not working

#

I found instructions on fixing those, but they're not for shader graph

low lichen
#

Shader Graph should automatically be adding single pass support

tranquil fern
#

Maybe I should re-save or something?

low lichen
#

Maybe

#

How broke are your custom shaders?

#

Magenta, like they're missing or weird in the right eye?

tranquil fern
#

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 😄

honest bison
#

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.

honest bison
#

alright, I got it working

median gull
#

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```
median gull
#

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.

umbral patio
#

heyall. quite new to shaders here. how would i get the depth buffer value of a given screen space coord?

real topaz
#

@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?

thick fulcrum
#

@real topaz you probably just need to swap the order, working bottom to top. Base texture first I think

low lichen
#

@umbral patio You mean in a written shader? And what render pipeline are you using?

real topaz
#

which texture is base texture? @thick fulcrum

#

every texture are in order(like i need)

#

and thanks for helping btw

thick fulcrum
#

if it was terrain for example, might be a typical example, Sand-> grass -> rock -> snow

real topaz
#

ohh, but that shouldn't make any difference imo for testing

thick fulcrum
#

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

low lichen
#

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

thick fulcrum
#

ah good spot ^^

real topaz
#

b is a vector1 for controlling height

low lichen
#

What is the value of the variable you have plugged into the last Lerp?

real topaz
#

its a vector 1

low lichen
#

Yes, I got that part. But what is its value?

#

0? 1? 0.5?

real topaz
#

0.6

thick fulcrum
#

you appear to be ignoring the height position so it's potentially overwriting everything

real topaz
#

sorry i just started shader graph yesterday, so guide me towards the right direction, plz

low lichen
real topaz
#

hold on

thick fulcrum
#

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

real topaz
#

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

thick fulcrum
#

just checking, are you using world position or object?

real topaz
#

world

#

i think

thick fulcrum
#

so if you scale up the y axis / move the object does it appear?

real topaz
#

hold on, lemme see

#

well the texture kinda stays there when moving on y, and when scaling on y, the texture stretches

thick fulcrum
#

do you just want it based on the objects height?

real topaz
#

well, kinda. i have a procedural terrain and i want to texture it based on height

thick fulcrum
#

you can still use world space UV for the texture, but you might be better off using object space for the height calculation

real topaz
#

would that solve the overlapping issue

thick fulcrum
#

you may also need to divide / multiply by object scale to avoid stretching.. but it's early for me so I'm brainslow 😄

real topaz
#

nah stretching isnt a problem as im mapping uv in script

thick fulcrum
#

I think it should remedy the overlapping issue

real topaz
#

ok,

thick fulcrum
#

@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

real topaz
#

should i divide the object space y to see the texture more distinctly as they are now blending more aggresively

thick fulcrum
#

might be more multiply by a strength value

real topaz
#

to the G of split?

#

or to overall clamped value?

thick fulcrum
#

before the clamp but after the add

#

damn computer just blue screened opening Unity 😦

real topaz
#

must be the shaders lol

thick fulcrum
#

you might not be wrong 😆

real topaz
#

although theres some unintentional deep frying lol

#

but thank you sooo much

thick fulcrum
#

no problem, it's a start in right direction at least 😉

real topaz
#

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

deep brook
#

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.

low lichen
#

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.

deep brook
#

@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).

low lichen
#

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.

deep brook
#

@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.

low lichen
#

There's just no way for the shader to know if it's close to the edge of the mesh

deep brook
#

Hmm. maybe something using particle FX would be a better approach that still remains straightforward?

devout quarry
#

@deep brook for the image you showed, something like this is used probably

deep brook
#

@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.

devout quarry
#

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

deep brook
#

@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.

devout quarry
#

But as you'll see in the article, you still need to configure culling manually, but it's doable with shader graph

sage ingot
#

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;
         }
     }
 }```
deep brook
#

@devout quarry awesome! thanks for that.

eager venture
#

Any idea on why my alpha sorting is seeing through things?

eager venture
runic wyvern
#

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.

tranquil fern
#

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.

tranquil fern
#

But the trees are still pink 😄 I'm on fire today

meager pelican
#

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.

runic wyvern
#

Can someone PLEASE tell me how to view a sphere from the inside, that isn’t turning on ‘two-sided’ in the settings?!

thick fulcrum
#

@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.

warm wasp
#

Does anyone know a guide on how to include refraction with a thickness map to a shader?

sharp basin
#

@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.

cinder chasm
#

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

low lichen
#

I assume this isn't a texture but something you are generating in the shader?

cinder chasm
#

Yes

low lichen
#

Can you show how it's generated?

cinder chasm
#

Ooft sure can, bit messy though

low lichen
#

Because the softening would have to be incorporated into that

#

It can't be done afterwards

cinder chasm
#

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

sharp basin
#

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.

granite solstice
#

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.

cinder chasm
#

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!

ancient silo
#

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?

granite solstice
#

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

grand jolt
fast skiff
#

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

low lichen
#

@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.

frozen mason
#

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

low lichen
#

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.

frozen mason
#

Which metod would be more performant ?

low lichen
#

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

frozen mason
#

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

low lichen
#

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.

tranquil fern
#

Is there a way for me to detect intersection with another object in my graph? I'm currently solving it by:

  1. Setting a Vector3 with the position of the object I'm interested in
  2. 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
  3. 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.

thick fulcrum
#

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 😉

tranquil fern
#

😄

#

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

thick fulcrum
#

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.

tranquil fern
#

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

fast skiff
#

@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)?

thick fulcrum
#

@tranquil fern you need some sort of volume effect, was it yourself who did a back hole effect or someone else on here?

tranquil fern
#

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

thick fulcrum
#

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) 😆

tranquil fern
#

I am using URP 😄

#

I think I got something, but it requires me to set the anchor properly

eager gate
#

hello guys, how can i remove these black things on my object? I think that these are shadows, but i don't want them

tranquil fern
#

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?

low lichen
#

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

eager gate
low lichen
#

@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

thick fulcrum
#

@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

low lichen
#

@eager gate Window > Rendering > Lighting Settings > Environment Lighting > Change from Skybox to Color or Gradient.

tranquil fern
#

Hm yeah, I could take the size into account to change the position. Good point

eager gate
#

@eager gate Window > Rendering > Lighting Settings > Environment Lighting > Change from Skybox to Color or Gradient.
@low lichen nothing change

low lichen
#

Are you using URP or HDRP or neither?

tranquil fern
#

@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?

eager gate
#

URP

low lichen
#

@eager gate What shader are you using for the terrain? Universal Render Pipeline/Lit?

tranquil fern
#

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.

thick fulcrum
#

@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
#

@eager gate What shader are you using for the terrain? Universal Render Pipeline/Lit?
@low lichen yes

tranquil fern
#

@thick fulcrum Yeah

#

I'll just mess around with these depth, color, position and camera nodes and see what I can accomplish with them

fast skiff
#

@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 🙁

low lichen
#

Because the Standard shader isn't a surface shader

#

So you're making a surface shader?

eager gate
#

i've tried different shaders but nothing change

fast skiff
#

will it be easy to create a texture splatting shader with shader graph?

dapper kraken
#

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;
}

fast skiff
#

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:

#

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?

worldly drift
#

is it possible to set culling in shader graph?

thick fulcrum
#

@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?

tranquil fern
#

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.

fast skiff
#

@thick fulcrum can't I use RGB(A) values of vertices for splatmap in combination with URP instead of a splatmap?

thick fulcrum
#

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?

tranquil fern
#

@thick fulcrum No I want the effect as seen on the capsule to work the same on the character.

thick fulcrum
#

is it safe to assume this is a seperate shader?

tranquil fern
#

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

thick fulcrum
#

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?

tranquil fern
#

What options do you mean?

#

Tiling and offset?

thick fulcrum
#

"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

tranquil fern
#

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

fast skiff
#

@thick fulcrum ok thx, I will give it a try, as I don't really know where to start learning to create shader code

thick fulcrum
#

@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?

tranquil fern
#

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

thick fulcrum
#

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 😉

tranquil fern
#

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

tranquil fern
#

This looks pretty good right? I'm thinking I'll add some warping/distortion to the plane

fast rose
#

@tranquil fern hey that looks great! I've been thinking about something similar; how did you get t to 'not draw' behind the wall?

tranquil fern
#

It's sending in the position to the shader.

fast skiff
#

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?

tranquil fern
#

I just got told that I need to add a shader keyword to a build... I don't know where/how to do that.

fast skiff
#

nwm, neutral normal map seems to be about the RGB-value 128/128/255 …

stoic bear
#

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

cyan hare
#

if anyone has any suggestions for this, please let me know

thick fulcrum
#

the standard way is to recreate the wave calculation on the cpu, then you sample a few points to make the object "float"

cyan hare
#

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

thick fulcrum
#

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

thick fulcrum
#

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?

cyan hare
#

i'll try that. i'll let you know if i ran into walls

simple violet
#

whenever I edit a shader script in visual studio the program crashes

simple violet
#

So I'm trying to make a sprite mask that fades in instead of appearing

#

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

regal stag
#

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.

simple violet
#

I know

#

I copied the video scripts

#

but it's not doing anything

rapid willow
#

Anyone here knowledgeable about HDRP Custom Passes?

#

I want to try and utilize a custom pass to recreate PS1 style texture distortions.

simple violet
#

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?

fair gulch
#

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?

wary sand
#

@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.

simple violet
#

how do I remove the square part?

rotund solar
#

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 👍

simple violet
#

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?

rapid willow
#

oh god the shader is angry

#

i assume I did something horribly wrong

rapid willow
#

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.

thick fulcrum
rapid willow
#

I'm hard coding it.

#

Using Custom Passes

rapid willow
#

OK, I seemed to have figured it out using TransformObjectToWorld(input.positionOS)

rapid willow
#

Here's the code:

tranquil fern
#

Hey, that's pretty gray

rapid willow
#

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.

tranquil fern
#

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

rapid willow
#

Ey, guess there's a bright side after all.

tranquil fern
#

What are you working on? a new Petscop?

rapid willow
#

RE1 styled sci-fi horror game called Biospace.

tranquil fern
#

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 😄

rapid willow
#

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

tranquil fern
#

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

rapid willow
#

And after.

#

I already have that setup using a render texture.

tranquil fern
#

In a way, that looks really cool.

rapid willow
#

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.

tranquil fern
#

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.

rapid willow
#

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.

tranquil fern
#

Looking at the differences, it mainly looks brighter

rapid willow
#

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

tranquil fern
#

Oh that's nice

#

Makes me want to get the ps1 from the attic and play some

rapid willow
#

Ps1 is A+. Love the console.

rapid willow
#

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.

dusk hatch
#

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

devout quarry
#

😮 they added grid snapping to shader graph <3, works so well now

regal stag
#

@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.

dusk hatch
#

thanks man, I'll try that out!

rapid willow
#

😮 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.

amber saffron
#

That's the the grid snapping he was talking about I think, but, shaping nodes in shadergraph editor 😉

rapid willow
#

Wait, can affline texture mapping be done in shadergraph?

#

I thought it didn't have access to the uv maps

devout quarry
#

Yeah I meant that nodes now snap to the grid lines in the shadergraph editor, before they didn't

rapid willow
#

Ohhhhhh ok.

#

Sorry, I'm just a bit thick lol

west eagle
#

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

drowsy dove
drowsy dove
#

What i mean is, i need to know how to set the color of my stripe to transparent

drowsy dove
#

Never mind i did it

dusk hatch
#

@regal stag Thanks! your suggestion worked perfectly

fair glacier
#

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?

regal stag
#

@fair glacier Not familiar with that component but it's possible that it uses vertex colours? Maybe try the Vertex Colour node.

fair glacier
#

Works! yeah thanks 😄 @regal stag

rapid willow
#

Does anyone know why the object is being offset so much?

stark harbor
#

can someone help me i cant seem to get the urp to let me turn transpancy on

scenic meadow
#

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:

GitHub

A powerful Unity ECS system to render massive numbers of animated sprites. - fabriziospadaro/SpriteSheetRenderer

#

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!

simple violet
#

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

waxen pike
#

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...

rapid willow
#

Have you tried rendering it using a separate camera?

simple violet
#

is it because I'm adding two white values?

#

what should I do instead

#

nvm had to clamp

waxen pike
#

Have you tried rendering it using a separate camera?
@rapid willow no, how does it work?

rapid willow
#

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.

simple violet
#

I want my pixelated noise to affect only screen space

#

How would I do that?

rapid willow
#

Does anyone know a suitable replacement for "UNITY_LIGHTMODEL_AMBIENT.a" in hDRP?

finite stirrup
#

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

simple violet
#

I heard post processing is better for outlines

vast geode
#

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?

simple violet
#

how can I combine the pixelate uv and screenspace UV?

waxen pike
#

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?

solid geyser
#

Any thoughts on how i can get rid of all these shader errors/warnings?
This server build runs fine but the errors are concerning

waxen pike
#

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

waxen pike
#

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?

rapid willow
#

These resources should help

simple violet
#

anyone know how I can combine pixelated noise to screenspace?

waxen pike
#

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

rapid willow
#

There's also documentation there about culling.

waxen pike
#

oh

simple violet
#

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?

rapid willow
#

Dude just give it some time.

waxen pike
#

@simple violet bro, this is object space not screen space

simple violet
#

?

#

I'm new to shaders could u give more details pls

#

@waxen pike

waxen pike
#

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

simple violet
#

I use screen pos to keep the alpha of the rectangle on the screen

#

Here's the entire shader

waxen pike
#

at the square are there, don't use screen position

simple violet
#

Basically I just want the pixelated static to appear on screen position

#

Why not screen position?

waxen pike
#

use object position

simple violet
#

k I'll try it

#

which square?

waxen pike
#

bcs screen position depends on where your camera is

#

there is the grp called "Square Area"

simple violet
#

The square area gives the effect that I want tho

waxen pike
#

ya, the screen position node swap to object position

simple violet
#

I want there to be an opening where my camear is

waxen pike
#

oh i see

simple violet
#

basically it's a big tiled sprite

#

and I go around it level to level

waxen pike
#

yeah, you should use object position too in that case

simple violet
#

how would that help?

waxen pike
#

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

simple violet
#

what offset value?

waxen pike
#

XY offset value to offset the rectangle

simple violet
#

like this?

waxen pike
#

ya i think sth like this, you can also multiply it with a value to scale it down

simple violet
#

so what do I do with it?

waxen pike
#

i think that's basically how you do it, save it and see if it works

simple violet
#

nothing happened

#

@waxen pike

#

did I do it right?

waxen pike
#

hmm, not sure about this, but can you use another position node, the one with a sphere preview

simple violet
#

sphere preview?

waxen pike
#

no, i meant the position node has a sphere like preview

simple violet
#

which position node?

waxen pike
simple violet
#

oh

waxen pike
#

set the space to object

simple violet
#

alright

waxen pike
#

wait, the rectangle need UV, why not we just use UV instead lol XD

simple violet
#

what?

waxen pike
#

this will work, but I think a better solution is to use UV node instead of position node

simple violet
#

k

#

so will this make the pixel noise relative to object space?

waxen pike
#

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

simple violet
#

still getting the same thing as before

waxen pike
#

? try moving the camera, I think it will stay in place

simple violet
#

what do you mean

#

we didn't use camera space

#

u said use object space not camera space

waxen pike
#

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

simple violet
#

what do I change?

waxen pike
#

I want the effect when it's zoomed out to be the same as when zoomed in
@simple violet I solved this problem only

simple violet
#

u didn't

#

it's the same as before

waxen pike
#

give me a demo?

simple violet
#

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

waxen pike
#

is this a post processing effect?

simple violet
#

it's the shader I just showed u

waxen pike
#

ya is the shader a post processing effect?

simple violet
#

no

#

it's a material

waxen pike
#

why is it using screen position again?

simple violet
#

because I want to level to be revealed when I move from level to level

waxen pike
#

that's why it is not solved, we use object space not screen space

simple violet
#

what?

waxen pike
#

I thought I called you to change it to tiling and offset node?

simple violet
#

I changed it and it did the same thing as before

waxen pike
#

hmm, can i have a screen shot of the most recent shader?

simple violet
waxen pike
#

oh, erm sorry, try using the tiling and offset node

simple violet
#

where?

waxen pike
#

replace the position node

simple violet
#

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

waxen pike
#

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

simple violet
#

I'm going to head to bed soon

waxen pike
#

well, we continue this tmr then XD

#

in DM

simple violet
#

ok

waxen pike
#

as we are now kind of spamming the Unity server

simple violet
#

I want the shader to do this

#

but with pixelated noise

waxen pike
#

solved it in DM 🙂

simple violet
#

had to put screen space into pixelate UV

#

had nothing to do with object position

#

😂

rapid willow
#

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.

fluid lance
#

Hello!

#

how can I scale a Uv using the (0.5, 0.5) as center?

#

please @fluid lance me!

vocal narwhal
#

@fluid lance subtract 0.5, scale with multiply, add 0.5

fluid lance
#

thanks ^^

rapid willow
#

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.

regal stag
#

I think you might be converting from object to world twice, with the UNITY_MATRIX_M and TransformObjectToWorld

rapid willow
#

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

regal stag
#

Yeah, this is also including the projection matrix though, so would be going to clip space not view.

rapid willow
#

Hmm...

#

Could it be the HDRP camera-based rendering causing it?

regal stag
#

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

rapid willow
#

How would I get from clip space back into object space?

regal stag
#

I think using UNITY_MATRIX_I_VP would get you back to world? (would be the inverse of what the UNITY_MATRIX_VP one)

rapid willow
#

So i'd use something like GetCameraRelativePositionWS(mul(UNITY_MATRIX_I_VP, float4(vertex, 1.0)))?

regal stag
#

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.

rapid willow
#

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

regal stag
#

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.

rapid willow
#

It's... definitely something.

#

Hold on, lemme send you the full code so you have the context for what I'm trying to perform.

#

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.

regal stag
#

Well I'd probably change vertex.xyz *= -snapToPixel.w; to not be negative, as the psx-vertexlit one above doesn't do that

rapid willow
#

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:

regal stag
#

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

rapid willow
#

Those are gone.

regal stag
#

Right, thought so, just checking

rapid willow
#

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?

regal stag
#

Usually you'd have the shader/material applied to the mesh, but I'm not really familiar with HDRP and this CustomPass stuff.

rapid willow
#

HDRP is... funky.

#

To say the least.

regal stag
#

I prefer URP. It's a bit simpler 😄

rapid willow
#

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 😓

midnight minnow
#

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

grand jolt
#

How would I make standard shader completely unaffected by all post-processing? Including lighting

desert orbit
#

@grand jolt Don't cross post. And you need to render it with a camera that doesn't have post processing.

grand jolt
#

Apologies, and that's not an option as I don't have access to the camera object itself.

desert orbit
#

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.

midnight minnow
#

@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

desert orbit
#

Not familiar enough with it. A good question to ask here though.

midnight minnow
#

ok ty

toxic flume
#

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

alpine karma
#

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)?

magic meteor
#

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.

meager pelican
#

@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.

rapid willow
#

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.

grand jolt
#

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

#

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

polar relic
#

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 ?

grand jolt
#

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

polar relic
#

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).

grand jolt
#

how about the position node

#

you apply your shader to the material CubeMap right?

polar relic
#

... 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.

grand jolt
#

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

polar relic
#

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.

grand jolt
#

Volumetrics aren't supported in URP if I'm not bullshitting

polar relic
#

It's absurdly costly performance-wise anyway, you aren't losing much.

grand jolt
#

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

polar relic
#

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.

grand jolt
#

oooh

#

interesting

#

give me updates if you still can't figure out for the CubeMap

polar relic
#

Also I still don't see what you want to do with the position node ? SampleCubemap doesn't care about that info anyway ?

vestal stream
#

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?

grand jolt
#

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?

polar relic
#

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.

grand jolt
#

Video of the issue?

vestal stream
#

Ye. Looking in the forums there's no way to set them at runtime.

grand jolt
#

???

#

why do you wanna set it at run time

vestal stream
#

Because I need to give the material the parts of building to use.

grand jolt
#

tex2D Array are arrays of textures rught?

vestal stream
#

Yes

grand jolt
#

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

vestal stream
#

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.

grand jolt
#

branch node?

vestal stream
#

?

grand jolt
#

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

vestal stream
#

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.

grand jolt
#

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?

vestal stream
#

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.

grand jolt
#

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

vestal stream
#

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.

grand jolt
#

a better way for me to understand would be for you to provide images and schemas

vestal stream
#

Give me a min for it then

grand jolt
#

sure

vestal stream
#

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.

grand jolt
#

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?

vestal stream
#

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?

grand jolt
#

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

vestal stream
#

It's an endless 2D runner, you're going through a city with a lot of verticality, so random buildings in the background.

grand jolt
#

yeah so?

#

object pooling?

vestal stream
#

You want me to pool many copies of every single building block?

grand jolt
#

???????????

#

ah actually yes

polar relic
#

That's how you do endless stuff.
At least that's how everyone I know does it.

grand jolt
#

store as many as you need and upon the block leaving the game view you disable it

rapid willow
#

Hnnngh. Trying to access the lighting data in this HDRP custom shader, but Im not sure where to get it.

grand jolt
#

kind of like an occlusion culling for 2D but with animated shit

vestal stream
#

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

grand jolt
#

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

polar relic
#

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.

grand jolt
#

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

vestal stream
#

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.

grand jolt
#

whaaaaat

#

I suggest you look into an object pooling tutorial?

#

I'll do a drawing for you

vestal stream
#

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.

grand jolt
#

feeding a shader [WITH AN ARRAY OF TEXTURE2D] is the opposite of optimal

#

so yeah what you want is object pooling

vestal stream
#

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?

grand jolt
#

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

vestal stream
#

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?

grand jolt
#

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

vestal stream
#

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.

grand jolt
#

you don't need a big ass amount, just enough to be sure your pooling system will still have blocks available

vestal stream
#

So what I said in that example

grand jolt
#

you have 1000 blocks of different type?

vestal stream
#

Reread the scenario again. I'll draw what I mean

polar relic
#

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.

grand jolt
#

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?)

vestal stream
#

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.

grand jolt
#

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?

rapid willow
#

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.

grand jolt
#

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

rapid willow
#

I'm hard coding this, not using Shader Graph

grand jolt
#

it doesn't mean it is shadergraph exclusive

rapid willow
#

Hmm...

#

I tried to #include the files I think it's referencing.

#

But they keep throwing up errors in the .hlsl files.

grand jolt
#

like?

#

you know I can't help if I can't see

rapid willow
#

Lemme compile and send you a screenshot.

grand jolt
#

sure

rapid willow
#

I'll also put the full code up on pastebin

grand jolt
#

ok

rapid willow
grand jolt
#

I guess BuiltInUtilities.hlsl is what is throwing errors right?

rapid willow
#

It says BuiltinGIUtilities?

grand jolt
#

there are both files included

#

oh you are referring to the error

#

my bad

rapid willow
#

np

#

just glad to have another pair of eyes on this issue

grand jolt
#

ah that's okay

#

so apparently you are missing dependencies

#

by any chance do you use an RP?

rapid willow
#

HDRP, yeah.

grand jolt
#

hmmm

rapid willow
#

I'm running this through a custom pass to create a vertex snapping effect.

#

Problem is, the default built shader is unlit.

grand jolt
#

too complicated

#

I literally started shader 2 days ago

#

what is a vertex snapping effect?

rapid willow
#

It's already done, just isn't lit.

#

I'm trying to retrieve the builtin lighting data.

grand jolt
#

GetMainLight function?

rapid willow
#

I'm not sure if I have access to that.

grand jolt
#

#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl"

#

however it is LWRP

rapid willow
#

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);

grand jolt
#

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

rapid willow
#

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

grand jolt
#

you want to try this maybe

#

that's what I use to "convert" unlit shader to lit shaders using the light

rapid willow
#

Worth a shot.

grand jolt
#

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

rapid willow
#

It's a Vector 3 that is says it needs

grand jolt
#

what is "it"

#

without context can't help

rapid willow
#

the light value
@grand jolt

grand jolt
#

show your code

grand jolt
#

aaaah

#

the Vector3 is the normal Vector*

#

wait bullshit, it's a position

rapid willow
#

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.

grand jolt
#

and in english, how does it looks like?

rapid willow
#

What do you mean?

grand jolt
#

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?

rapid willow
#

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.

grand jolt
#

because it.... resets

#

why don't you take it before it reset the lighting?

rapid willow
#

That's what I did.

grand jolt
#

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?

rapid willow
#

I get this error.

#

It should already be in the pastebin from earlier.

#

Here's just the relevant code.

grand jolt
#

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

rapid willow
#

cooking dinner right now, but i'll try it when I get done

grand jolt
#

sure

rapid willow
cold sentinel
#

are shader graphs compatible with the standard render pipeline now?

#

and for that matter, vfx graphs?

vocal narwhal
#

Not that I know of

cold sentinel
#

oh

#

okay

grand jolt
#

are shader graphs compatible with the standard render pipeline now?
@cold sentinel I'm using URP with ShaderGraph, no issues on my end

cold sentinel
#

i meant the built in pipeline, sorry, not the scriptable ones

grand jolt
#

ah can you tell me the difference with the built in pipeline? I don't see the issue

cold sentinel
#

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

grand jolt
#

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

cold sentinel
#

okay

#

thank you

grand jolt
#

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

last robin
#

hlsl uses fract actually nvm

#

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);

polar relic
#

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.

meager pelican
#

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.

polar relic
#

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.

slim steppe
#

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

low lichen
#

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.

slim steppe
#

Sorry i dont know anything about shaders how do i do that?

#

And thanks for helping me

low lichen
#

Is your water using a custom shader? Is your boat using a custom shader?

slim steppe
#

The boat is a normal shader the water is a custom shader

low lichen
#

Normal shader being the Standard shader?

slim steppe
#

Yes

low lichen
#

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

slim steppe
#

Its on pc

#

Iam using crest

low lichen
#

You're sure Crest doesn't already have this feature?

#

That would be a pretty big oversight for such a popular ocean asset

slim steppe
#

No it hasnt

low lichen
kind juniper
meager pelican
#

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.

grand jolt
#

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?

regal stag
#

@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.

grand jolt
#

@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...

▶ Play video
regal stag
#

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.

grand jolt
#

global shader property? any docs or tutorials for that anywhere?

regal stag
grand jolt
#

ah ok, cheers

rain haven
#

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?

low lichen
#

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.

rain haven
#

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

low lichen
#

Are you using a Fallback shader?

rain haven
#

not that im aware of; its been a while since i used ASE so im not sure

#

oh ok i think i solved it

grand jolt
#

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

regal stag
#

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.

grand jolt
#

and as I dont really have directionals, it's all point lights, i'm betting thats useless XD

meager pelican
#

@toxic flume I suppose you could use a flipbook animation and just change frames to animate.

upbeat topaz
#

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/

dusky mountain
#

When I made a shader for an object, how am I able to activate it only at a specific event?

toxic flume
#

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

dusky mountain
#

ok thanks

spring fox
#

how do i make a refractive water shader in unity hdrp?

languid bane
#

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?

knotty juniper
#

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

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?

regal stag
#

The properties should be exposed on the material. You can set them there

spring fox
#

hi im completely new to shaders, so i have question. how do i make a reflective/refractive water shater in HDRP?

knotty juniper
#

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...

▶ Play video
#

or do you have somting different in mind?

spring fox
#

that should probably work

#

i'll check it out

languid bane
#

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

spring fox
#

hmm didnt seem to work very well, the entire plane was just purple and the only thing that worked was the displacement

upbeat topaz
spring fox
#

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?

upbeat topaz
#

is there any good way to display shadows from sprites in Unity URP?

grand jolt
#

@spring fox You can use a normal blend node to do that.

rapid willow
#

The HDRP code is such a rat's nest.

thick fulcrum
#

@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.

meager pelican
#

@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.

dusky mountain
#

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

thick fulcrum
#

@dusky mountain you could put a branch on your effect and only have it run when bool condition = true

dusky mountain
#

a branch?

#

how

thick fulcrum
#

is this in shader graph or code?

regal stag
#

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.

grand jolt
#

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

regal stag
#

Depends if you are working in URP/HDRP or built-in. MaterialPropertyBlocks don't play well with the SRP Batcher

grand jolt
#

yeah thats a bummer, it does completely break SRPB :(, I use GPU-I instead personally

vague pike
#

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

thick fulcrum
#

you might want to try in a clean scene, maybe some other items besides the water plane I can't recall at moment.

vague pike
#

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

thick fulcrum
#

now you can test in island scene at least 🙂

vague pike
#

Yeah, thanks ^^

shadow matrix
#

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
#

@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?

spring fox
thick fulcrum
#

@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

spring fox
#

alright, i'll try that, thanks!

#

where do i put the scene color node?

thick fulcrum
#

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.

spring fox
#

well do i put in albedo? like where does it end up in the main node?

thick fulcrum
#

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 😄

spring fox
#

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?

thick fulcrum
#

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

spring fox
#

hmm ok

thick fulcrum
#

or perhaps someone knows better than this noob

spring fox
#

i mean my node thing is very basic

thick fulcrum
#

if it works don't knock how simple it is, simple is good 😉

spring fox
#

none of the tutorials seem to work

thick fulcrum
#

@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 😆

spring fox
#

does this require 'depth texture'?

thick fulcrum
#

refraction amount is a vector1, I think lower value the more it distorts