#archived-shaders

1 messages ยท Page 7 of 1

shadow locust
#

yes

grand jolt
#

oh i thought it was a hash value

pine lily
#

fml I'm done trying to use shader graph in unity, tut is not even a year old and can't follow it either

#

shader graph is a mess to work with

keen cloud
grand jolt
# shadow locust yes

can you explain how this line works? every VAT demo I see does not convert to UV coordinates, just straight out casts a uint into a float. shouldn't vertCoords be in the range of 0...1 if i want to use it for texture sampling?

            struct appdata
            {
                uint vertexId : SV_VertexID;
                float4 vertex : POSITION;
                uint inst : SV_InstanceID;
            };

            v2f vert (appdata v)
            {
                float vertCoords = v.vertexId; // THIS
                ...
            }
regal stag
grand jolt
shadow locust
#

unless I'm just completely misreading what you're tying to do here

grand jolt
#

i'm trying to bake animations into textures. x axis is the individual vertices of a rig, and y axis is the frame count for the animation

#

but i think i messed up my texture baking process as well, i fix that first and see if my shader improves

shadow locust
#

ok I missed that this was a shader animation

shadow locust
#

you probably need to know the width/height of the texture either way to map your 0-1 or 0-vertexcount number to an x/y in the texture, right?

grand jolt
#

i'm super confused because every example I find on github treats the first argument as uid (vertexId) but the second seem to be a normalized coordinate for texture sampling. am i trippin?

shadow locust
#

Can you link one of these examples

shadow locust
#

which makes sense

#

so you're going from a vertex id (uint) to a normalized value (0-1) which indicates the x coordinate of the pixel on the texture
I'm assuming the y coordinate will come from the time factor

#

so each row in the texture is a frame in the animation

grand jolt
#

so float vertCoords = v.vertexId; is just a typo i guess

shadow locust
#

maybe

#

where are you seeing that

grand jolt
#

first paragraph, without the bilinear filtering

#

my shader looks like this, so i do divide by tex size

            
            float4 vertex_sample(sampler2D tex, float4 texelSize, uint id)  
            {
                float vertexCoords = id;
                float animCoords = _Time.y * _Speed / texelSize.y % texelSize.w;
                float4 texCoords = float4(float2(vertexCoords, animCoords) * texelSize.xy, 0, 1);
                
                // @TODO: offset

                return tex2Dlod(tex, texCoords);
            }
shadow locust
#

I'm wondering if they're somehow doing the texture sampling in "pixel coordinates" instead of "normalized" coordinates somehow in that example

#

something like what Cyan was mentioning earlier

#

like what does tex2Dlod(); expect

#

normalized or pixel coords?

#

or it's just a typo and they forgot to normalized it ๐Ÿ˜†

#

not sure

grand jolt
#

at least now it's not a big blob but an almost correct set of vertices ๐Ÿ˜„

#

i inverse LERPed my vertices on the CPU side and convert back in GPU side

#

could this be that I have no normals? ๐Ÿ˜ฎ

tight phoenix
#

gamma question ๐Ÿค” if I highpass filter a texture in photoshop and then use the Overlay blend mode, the middle range greys should not change much/at all.
Bringing that same texture into Shadergraph, I would expect the same behaviour, but instead Overlay severely darkens it
If I multiply by 1/2.2 (gamma removal) it works as expected.

How do I save out my files/work gamma-less in photoshop? I dont want to be constantly gamma correcting within shader itself

#

is there anything I can do about this on the Unity's side?

#

my setting is to linear but im still getting gamma problems? because the source file's gamma is wrong? But in photoshop there's no gamma option on save out

#

same problem again - even though there is a wide range of colors, the lerp doesnt see that because gamma is fucking up its sampling

#

maybe I should ask in artasset workflow ๐Ÿค”

tight phoenix
#

Hmm it looks like unchecking sRGB in the texture import settings is enough to move it back to the linear space even though it was exported from photoshop in 2.2 gamma ๐Ÿค”

#

I guess that also explains why it always seems like the one-minus range has way more lights than darks even though I know both of those ranges are 'linear'

#

ill keep this in mind in case I ever want to do any falloffs in gamma space? ๐Ÿค”

white pivot
#

how to project image to a plan object in unity ? can it done in unity?

shadow locust
white pivot
#

im stil confused in main preview my effect its well and its look like a like. but in my viewport its even no get rendered?

#

its in hdrp

amber saffron
# white pivot im stil confused in main preview my effect its well and its look like a like. bu...

The image is very blurry to read the node names, but I think you are pluging the swirl into the emission ?
HDRP is using physically based lighting with physically based light intensity value, making the direct and ambiant light VERY high intensity (look at the directional light intensity, it's about 100k).
What you see is correct, it's just that the emission is totally washed out by the scene lighting : raise the emission intensity by multiplying it with a constant, or use the emission node to control it more easilly

gray harness
#

how do i send zero length compute buffer to gpu?

white pivot
#

yeah thnks

#

the switl

amber saffron
white pivot
#

haha my grammarly is off sometimes in discord.

white pivot
#

im ask again sorry for to much ask, its hologram animate up and down but i want it to consistent up and down in any angle not like the first picture but like in central angle like in second picture.

karmic hatch
mental quest
#

alpha is black when URP Sprite Lit shader is used with image. Any possible solutions

stable pollen
#

I am trying to create a shader in a URP project that displays a grid pattern on the surface of an object, where the grid remains a static size regardless of the scale of the object (no stretching).

Right now I change the parameters of the material via script as the object is resized, however the Z axis does not work correctly and I'm not sure what to do. I considered there must be something I can do with normal information, but I don't know how to use it.

Any ideas are appreciated.

#

This is me extending a sample I found and not knowing what I'm doing

#

I feel like this would work fine if it was the actual mesh changing and not the scale of the object.

shadow locust
regal stag
#

Each side is also masked here using normal vector, similar to a triplanar shader as Praetor mentioned

stable pollen
#

Ok, at least I had the right thought trying to do some sort of normal mask...

#

I think I understand what is in that flow

regal stag
grand jolt
#

this is how my animation baking looks like. It resembles when Dr Manhattan was reincarnated from thin air more like an actual human

#

do you guys think adding normals would help this?

#

because to me it rather looks like the vertex order is messed up big time

#

i'll ask again: are we 100% sure that SV_VertexID is the vertex ID going from 0 to Nvertices, in order? The same order that UnityEngine.Mesh.vertices goes?

#

this is when I use the original vertex coordinates (static mesh with MeshRenderer), but output the baked anim texture to the fragment shader color

#

seems right to me as only the limbs change color

#

i'm guessing it has to be the shader that's wrong

white pivot
#

Thanks ๐Ÿ™

ashen shale
#

can anyone tell me what the type for a property assigned with CommandBuffer::SetComputeVectorArray should be on the gpu side?The docs don't say (that I could find), so I'd assumed it might be Texture1D, but that doesn't work. I've tried a handful of different types I could find in the hlsl docs that might be applicable and haven't found one that doesn't cause an error, so I'm obviously missing something.

#

nvm, float a[size] seems to not throw an error, thinking too much in C# brain

amber saffron
#

@grand jolt Yes, the order should be the same.
I would greatly suggest to also add a half pixel offset to the sampling coordinates, to be sure you're not getting the value from the neighbour pixel, or some interpolation

grand jolt
#
float3 vertex_sample(sampler2D tex, float4 texelSize, uint id)  
{
    float vertexCoords = id;
    float animCoords = _Time.y * _Speed / texelSize.y % texelSize.w;
    float4 texCoords = float4(float2(vertexCoords, animCoords) * texelSize.xy + 0.5f, 0, 1);
    
    // @TODO: offset

    return tex2Dlod(tex, texCoords).xyz;// * _VATScale + _VATOffset;
}
#

so like this? i just added the +0.5f

amber saffron
#

If you do this, you're offseting the sample by half the texture ๐Ÿ™‚
You want to do +0.5f * texelSize.xy

grand jolt
#

float4 texCoords = float4((float2(vertexCoords, animCoords) + 0.5f) * texelSize.xy, 0, 1);

#

OMG IT WORKS

#

JUST LIKE BLACK MAGIC

amber saffron
#

yep, should work

grand jolt
#

okay i'll remember this

#

it's like when something doesn't work flip a sign

amber saffron
#

Is the texture set to use linear filtering ?

#

And tile or clamp ?

grand jolt
#

yeah and no compression

#

i even downloaded import settings from others' VAT githubs just to be sure

#

also I was using renderer.BakeMesh on the renderer's sharedMesh and that didn't seem to modify the mesh. that was the other bug from yesterday

amber saffron
grand jolt
#

i'm making a vertex anim texture, to render a bunch of people without heavy CPU calls

#

now i shall see if calls are actually reduced in a minute

amber saffron
#

Ah yeah, had to reread and think twice : so applying a skinnedmesh.BakeMesh to a meshrenderer+meshfilter

grand jolt
#

exactly, yeah

#

thank you so much for the help!

steel notch
#

Can you get a Render Texture from a Overlay Camera?
I want to save explicitly what an Overlay Camera is seeing.

tight phoenix
#

is there an easy way to remove this weird black pixel line that polar coordinates is generating?

#

its not even happening at the "end" of the texture because the texture gradient starts and stops at black, that yellow/green is the 50% mark

#

if I add 0.5 to offset it so that the black part overlaps that line... the line becomes yellow ๐Ÿ˜

#

pretty sure it has something to do with texture compression ๐Ÿค” but imt not sure why its occuring at the 50% mark instead of at the ends

#

the gradient starts and stops with black, not yellow

amber saffron
tight phoenix
#

hm wait is it because its trying to lerp between the two ends, and 50% of the way between the two ends is the yellow

#

because its trying to blend across

amber saffron
#

I don't get your issue...
I seed the gradient texture, I see the preview of the sample node, it seems correct to me

amber saffron
#

AHHH this !
No, it's not because of lerp

#

It's texture mips : where the uv.x goes brutally from 0 to 1, the sampler will force a very hight mip value, sampling the highest mip of the texture, that is probably yellow-ish

tight phoenix
#

mips you say ๐Ÿ‘€ ๐Ÿค”

amber saffron
#

If you don't need mip maps on the texture and anisotropic filering, disable mipmap generation on the texture asset

#

That's the easy fix

amber saffron
tight phoenix
#

its a very small teture

#

you are right the red doesnt go fully black though ๐Ÿ‘€ ill fix that

amber saffron
#

Mips are not only about texture size, but help to reduce rendering artifacts when displaying a texture from far of the camera

tight phoenix
#

Ahh

amber saffron
#

It really depends on the texture.
See the moire effect here : https://en.wikipedia.org/wiki/Mipmap#Overview

In computer graphics, mipmaps (also MIP maps) or pyramids are pre-calculated, optimized sequences of images, each of which is a progressively lower resolution representation of the previous. The height and width of each image, or level, in the mipmap is a factor of two smaller than the previous level. Mipmaps do not have to be square. They are i...

#

Anyway, problem fixed now ๐Ÿ™‚

tight phoenix
#

Ahh yeah that checkerboard looks pretty awful without mips

grand jolt
#

i get the same batches as if i spawned the same number of objects with SkinnedMeshRenderer

#

my FPS is much better as it was 37 before

#

did I screw up something? do I have hidden calls from CPU still? :S

grizzled bolt
#

All the rest will be handled by SRP batching which you can examine more closer in the frame debugger

grand jolt
#

do you think assigning the same material with color Material Properties would help?

#

one way to find out

dull igloo
#

Hey guys, i'm having trouble with shaders in unity. Trying to make this custom platform for beat saber but everytime I make an asset and put it in it takes or a black-like colour or a white/blueish light colour. I tried making a material and it automaticly takes the other shaders or something... Anyone who knows how I caan fix this?

#

It also doesn't matter what shader I choose, I always get the same two colours, black or blueish white

grand jolt
#

If I have N objects, each with the same mesh and M materials (that refer to the same material, with property blocks), then I can expect N x M draw calls?

If I modify my shader to use GPU instancing, that will reduce the N x M significantly, right?

#

I'm asking because now my shader has no instancing enabled, and I get 10K draw calls with the exact same params, and I'm wondering how I could optimize this

grizzled bolt
#

@grand jolt Assuming that you are on URP from what you asked previously, it's worth looking into what SRP batching does and how to work with it

#

It seems more effective than instancing or dynamic batching in many situations

grand jolt
#

i'm trying to understand normal instancing first. I see that having M materials per Renderer makes it M calls, but I can live with that if i can get 1000 objects to have 10 calls

grizzled bolt
grand jolt
#

okay then i'll try with SRP batching

grizzled bolt
#

You can try all the options, just be mindful of what's happening under the hood
Hard to test instancing if SRP batching disables it, or causes almost exact same performance savings

grand jolt
grizzled bolt
#

It only seems to display draw calls reduced by static and dynamic batching specifically

grand jolt
#

the turorial talks about the stats window so i'm assuming it'll reduce ๐Ÿ˜„

grizzled bolt
#

Which tutorial?

#

Probably the most important note about SRP batching is that it doesn't reduce draw calls, it reduces their cost

grand jolt
#

i really don't get this, and i do want to reduce draw calls

faint socket
#

anyone knows how to check if you're using URP or HDRP, im trying to find the exposure node but i dont see it, even tho I think im on hdrp

grizzled bolt
# grand jolt i really don't get this, and i do want to reduce draw calls

You don't have to reduce drawcalls to improve performance, and SRP batching often beats the traditional draw call optimization techniques for much less work
If you do want to practice those techniques I would recommend you use built-in RP for it to keep things simple (especially so if your tutorial uses built-in RP)

grand jolt
#

i'll first understand how normal GPU instancing works

tight phoenix
#

Shader language translation question - what are the equivalents of "sin_thetaL" "sin_thetaV" in a unity shader's code/language?

#

or maybe my mistake is something else entirely

#

okay fixed the = and the truncation, but that first question remains

#

hmm I didnt fix the truncation

#

I see why its happening but im not sure what it should be instead

#

oh wait its not a vec3 it was just a float all along

#

okay fixed it for real

#

but still no idea what sin_thetaL and sin_thetaV are or how to replace them with real things

#

I assume its sine, and theta, of whatever L and V are??

#

oh wait thats from the next step I didnt read enough

#

so nevermind everything Im dumb for not reading ahead
(it was the dot product)

tight phoenix
#

im following this tutorial but im not getting the expected result

#

the result is white and I dont know how to debug whats wrong with it

#

he defines d = _Distance

#

but no where does he declare or show what that is

#

he has a variable for distance in and unrelated earlier step, which he sets to 1600

#

and using that value here just makes it white

#

I dont understand why its not working I copied it exactly every single step

#

going into mental health crisis now because im too fucking stupid to see where i made a mistake in copying someone

#

cant do a single fucking thing right on my own ,cant even fucking plagarize without fucking it up too

dull igloo
karmic hatch
# tight phoenix

Does using the absolute thing to sample a rainbow gradient look OK?

exotic kraken
#

How is the depth value in the depth buffer calculated?

lone vine
#

Would anyone happen to know why my sprite and shader is making the hair semi-transparent?

lone vine
#

Had my wires crossed!

vital smelt
#

So, I'm trying to make a portal using the Render Pipeline.

#

I need to find a way to get the screen space coords to make the portals actually look like portals instead of just a render texture plastered on

knotty juniper
# vital smelt I need to find a way to get the screen space coords to make the portals actually...

Portal is one of the most celebrated videogames ever, and its core mechanic certainly got people talking when it first released. In this video, I go over some of the core concepts you'll need for making your own portals in Unity! This project uses quite a lot of C# scripting and a couple of HLSL shaders, but I try and go over the core bits in de...

โ–ถ Play video
vital smelt
#

Yeah, that's URP not Render Pipeline

#

Uh, I meant Shader Graph

#

Sorry, I'm trying to do it with Shader Graph

#

Sometimes English is hard, my bad

knotty juniper
#

you should be ablte to transfer that shader code to nodes line by line

vital smelt
#

Hmmm, okay, thanks

#

I'm still not entirely sure what nodes would do what...

#

Like, this is what happens. It doesn't seem to do much.

karmic hatch
white pivot
white pivot
karmic hatch
#

I would guess you have to decide what to put in Strength

#

Perhaps some property multiplied by cosine(frequency*time)

white pivot
karmic hatch
#

Cosine goes between -1 and 1 at regular intervals

white pivot
#

its work

vital smelt
#

Yeah, I'm still unable how to convert that Shader into a Shader Graph

#

I have no experience with Shaders, only Shader Graph so I'm not sure what corresponds to what

kind juniper
vital smelt
#

I've tried that. Some of the functions don't have similar nodes

kind juniper
vital smelt
#

I don't wanna do that. I don't want to use shader code at all.

kind juniper
#

We can't help you if you don't provide any specifics...

vital smelt
#

I was talking to Tach.

wraith inlet
vital smelt
#

Well, I've been messing around with the code and found that for some reason, using Render Textures isn't working when I have URP enabled.

#

Like, without the Forward Rendering Pipeline, the default Unity one shows the render texture correctly from the cameras point of view

#

But when I have the FRP on it just shows a section of the skybox

kind juniper
#

Aaand we went into a different issue entirely... I thought you were trying to convert a shader to shader graph?

vital smelt
#

Yeah but while I was trying to do that, I realised it wasn't working because the _MainTex was just giving me a sky box chunk

#

So I changed the material to a regular Unlit Texture one to see if my shader was doing that and nah, it's the render texture just being given a sky box.

kind juniper
#

Again, it's very difficult for us to reply if you don't share more info, like screenshots or code snippets... Render texture works the same way, wether it's birp, urp, regular shader or shader graph, so the issue must be somewhere else.

vital smelt
#

If I remove the FRP, the Render Texture works perfectly fine, displaying the camera feed.

#

If I put it back into the settings, it just shows a sky box section

vital smelt
kind juniper
#

That's not enough info. We don't even know what you render into that render texture. Share details of your setup. Just rendering to a render texture from a camera doesn't even involve shaders. And certainly rendering path wouldn't affect it.

vital smelt
#

...

#

The render texture is rendering the camera feed from a secondary camera. Without the Forward Rendering Pipeline, it shows the feed correctly on the material of the Quad that shows the feed in game.

#

When I take the FRP out of my graphics settings, the Render Texture no longer displays the camera feed, but rather a section of the skybox.

#

Red area camera displays onto the Blue area white screen

#

Blue area camera displays onto the Red area white screen

#

If I press Delete on this, so it's back to the default Unity settings, the cameras work

#

If I put it back, it breaks

#

My end goal is a cutout shader to snip the section of the render texture that I need to display on the canvas to get a Portal effect

kind juniper
#
  1. That setting in Graphics determines what RENDER PIPELINE you're using. Removing the URP asset switches to BIRP.
  2. Birp shaders are incompatible with URP, so your shaders stop working entirely. Everything turning pink is an indicator of that.
  3. To confirm that the render texture is rendered properly on both render pipelines, look at the actual render texture preview instead of relying on whatever happens to it in the shader.
vital smelt
#
  1. I know this
  2. I know this, the floor textures are URP that's why they turn pink. This isn't about those, this is about the white screen.
  3. This isn't the issue I'm having
#

I appreciate your help, but I don't think I can repeat the issue for a 4th time.

kind juniper
#

Okay, so can you confirm that the render texture renders properly regardless of the render pipeline?

#

And if it does, then we're back to the conversation half an hour ago: provide the shader code that you have an issue to convert to shader graph as well as what you have in your shader graph currently.

kind juniper
vital smelt
#

The render texture displays incorrectly when the URP Pipeline is being used

#

Where there should be a recursive blue archway, there is instead, a section of the skybox.

vital smelt
vital smelt
#

I can't progress with the first issue because a new one has come up that has been the entire reason I've struggled to solve the first one.

#

I was only able to identify this "big boss issue" because I switched back to the BIRP

#

BIRP shows this

kind juniper
vital smelt
#

These are game screenshots.

#

From the game view.

kind juniper
kind juniper
vital smelt
#

How?

kind juniper
#

Because it has to be rendered through a shader.l to be displayed in the scene view...

vital smelt
#

This is URP

kind juniper
#

This is the material preview

#

Not the texture preview

vital smelt
kind juniper
#

This is not a texture preview

#

This is rendered via shader

vital smelt
#

There is no Render Texture preview because it's dynamically created with code.

kind juniper
#

You can still reference it and view it in the inspector.

vital smelt
kind juniper
#

Finally!

#

And the urp one?

vital smelt
kind juniper
#

Okay.

#

It seems like the objects are not rendered on the birp one. Is it because of layers setup?

vital smelt
#

I dunno, that's why I'm here asking.

#

They're all on Default Layer

kind juniper
#

Didn't you watch the tutorial? It should be covered.

vital smelt
#

What tutorial?

kind juniper
#

Wherever you got that shader from

vital smelt
#

ITS NOT THE SHADER

#

Oh my god dude

#

How are we still stuck on that

kind juniper
#

It's not the shader in this particular case, no. But the whole thing is relevant.

#

Did you or did you not get it from a tutorial?

vital smelt
#

I haven't implemented a single shader, because switching over to URP causes the Render Textures to fuck up

#

No, I haven't done anything from a tutorial

kind juniper
#

So you created that portal system entirely on your own?

vital smelt
#

Yes

#

I've been using Unity for 5 years.

#

I just don't use Shaders.

kind juniper
#

Then how so that you can't answer my simple question?

#

"Why are the objects not visible on the render texture?"

vital smelt
#

Which question is it that I supposedly can't answer?

#

Because I don't use render textures that often either.

kind juniper
#

It's irrelevant.

#

Let me simplify: why are the objects not rendered by the camera that renders the render texture

vital smelt
#

I have no clue dude

#

The culling mask doesn't change

kind juniper
#

So you didn't create that system..?

vital smelt
#

I don't work for Unity, so no I did not program the camera system in Unity

kind juniper
#

I mean the little portal setup that you have ๐Ÿ˜…

vital smelt
#

My code doesn't do anything to any of the objects in the game, there is no reason for them to be invisible

#

Nothing is toggling their mesh, disabling/enabling them or changing their layers

kind juniper
#

So you don't know how your portals work in BIRP despite you being the one who made them?

vital smelt
#

I can't tell if you're a troll or just misunderstanding me

kind juniper
#

I'm asking you simple things: to explain how your system works(when it actually works). And you can't seem to do it.

vital smelt
#

The code for the portals isn't doing anything that would disable the blue and red objects abilities to be rendered by the cameras onto the render texture.

kind juniper
#

It doesn't have to be the code. It could be the setup in the scene

vital smelt
#

The code simply moves around the cameras in relation to the main camera's distance from itself

#

The setup of the scene is irrelevant when the matrixes are all converted to local space in the calculations.

#

the cameras all move accordingly and there is no reason for it to not function in URP

kind juniper
#

The setup is relevant precisely because there are ways to make these objects not render by the camera.

#

Let's leave out URP for a moment and try to figure out how your portals work in the first place

vital smelt
#

If they are able to render while set up in BIRP, then their setup is irrelevant in URP.

kind juniper
#

There could be camera settings that are different in BIRP. Anyways we can't know it unless we know how it works in BIRP.

vital smelt
#

There are 3 cameras.

#

Main, R and B

#

Main moves with WASD

#

R moves relative to it's own portal based on the offest of Main from B

#

B moves relative to it's own portal based on the offset of Main from R

#

In R, the R Screen is invisible and in B, the B Screen is invisible

#

so each can see the other side of their own portal, which will (eventually, when I get the Cutout Shader Graph figured out) show the other side only of the alternate portal

kind juniper
#

Okay, so you agree with me, that normally R and B cameras should be rendering the box and the portal frame that appear in their frustum?

vital smelt
#

If there was a green sphere behind the blue portal, within the shaded blue box under the blue camera, then the main camera (black) would be able to see that green sphere on the red portal's render material.

#

But at the moment, in BIRP, the cutout doesn't work because I haven't made it because I want to use URP. But in URP, the cutout doesn't work because the only thing being given to the render material is skybox

#

Previewing the camera feed through the Unity editor shows the correct image

#

and yet, on the red portal

#

We don't see that same image reflected.

#

What we should see

kind juniper
#

Ugh... Okay. I think I got myself confused somewhere along the way.
So this is the BIRP RT, correct?

#

And this is the URP one?

vital smelt
#

Yes

kind juniper
#

So, the whole "objects are not rendered in BIRP" thing was incorrect. They are actually rendered in BIRP.

#

They don't render in URP though

vital smelt
#

They are rendered in BIRP, but not in URP

#

However the camera can still see them

kind juniper
#

Can compare the render textures now that you have materials properly rendering?

vital smelt
#

The render textures are the same.

#

The pink was because I didn't switch the red and blue back to BIRP materials.

kind juniper
#

So the URP one is still like that?

vital smelt
#

I kept them as URP when switching back to BIRP

#

Yes

kind juniper
#

Ah, okay.

#

Then There must be some settings in the camera

vital smelt
#

When I had them as BIRP materials, back before switching to URP, they showed up as red and blue on the render texture

#

The camera can still see the objects, as shown in the camera preview

#

But it's not rendering them to the texture

kind juniper
#

Take a screenshot of your camera inspector...

vital smelt
#

There's also a Universal Additional Camera Data down the bottom.

kind juniper
#

Is that the wrong camera? I don't see render texture setup as the output. Or if it's not at runtime, then play the game and take a screenshot again

vital smelt
#

Some interesting findings while I was messing around:

#

If I change the Background Type from Skybox, the camera works properly

#

As in, if I change it to Solid Colour...

#

Something wrong with the skybox?

kind juniper
#

Why is the camera disabled though?

vital smelt
#

Because it's being controlled by code

#

I call .Render() manually

kind juniper
#

I'm not sure if that bypasses something in the render pipeline(specifically related to render textures)

vital smelt
#

Let me try turning it on a sec

#

Nope, the camera being on or off doesn't make a difference

#

the only thing that does is the Background Type of the environment, so far

#

Yeah, setting the Background Type to Solid Color or Uninitialised works

kind juniper
#

Can you share the whole script? We keep on discovering things that you never mentioned, so I wonder if there's more to it...

vital smelt
#

The script for what?

#

The only thing the script does is moves the cameras, and then manually calls the Render

kind juniper
#

Hmmm

vital smelt
#

Seems like I'm not the only one who has had an issue like this

kind juniper
#

The skybox doesn't seem to work in my project either...๐Ÿค”

vital smelt
#

So the skybox is making your render textures weird as well?

kind juniper
#

Ah, nvm. I didn't have skybox material set up.

vital smelt
#

Hm

#

Maybe I don't have my skybox material set up correctly either

#

How do I create a URP Skybox?

kind juniper
kind juniper
vital smelt
#

Yeah, I did have it set up correctly. Still doesn't work. Weird...

kind juniper
#

For starters, I'd avoid calling Render manually.

vital smelt
#

We've already established that it's not causing an issue though.

kind juniper
#

We don't know that for sure. It might be a combination of factors.

#

Is there any reason you need to call it anyway?

vital smelt
#

I'm calling it manually so I can control when the render texture is being updated and controlled so it isn't using too much processing power

#

I'll switch it back to auto rendering and see what happens

kind juniper
#

Keep the camera enabled at least until the issue is resolved

vital smelt
#

Going back to manual rendering doesn't fix it

#

Only changing from Skybox to Solid Background Color works

kind juniper
#

Can you check that camera with the frame debugger?

#

Could it be that skybox is rendering after your object?

vital smelt
#

It's possible. But the camera still sees the objects in the preview window.

#

With the background set to a solid colour, sometimes the legs of the frames disappear behind the base. Strange

#

At least the portal works now lmao

#

Still, need to figure out that skybox thing...

kind juniper
#

Check The frame debugger. I feel like it has something to do with depth.

vital smelt
#

How do I open the frame debugger again?

kind juniper
#

with the skybox enabled

#

Window -

vital smelt
kind juniper
#

Might want to look at your game tab in parallel. It displays the render target at the currently selected stage.

vital smelt
#

Yeah, that's what I've got

#

Not really sure what I'm looking for

#

The first one is the skybox in the background

kind juniper
#

And the last section?

#

The skybox rendering

vital smelt
#

That adds the skybox onto the background

#

But you can see the second SRP Batch puts the skybox onto the render texture

kind juniper
#

Ugh.. Wait. That's the wrong camera.

vital smelt
#

Oh

#

My bad, one second

kind juniper
#

The custom renderer one is the one that we need to look at

vital smelt
#

So B Camera?

kind juniper
#

Yes

vital smelt
#

How do I get to that one?

#

It keeps taking me back to the Main camera when I click enable

kind juniper
#

They should both be rendering. I think it's this one

vital smelt
#

Yeah it's plastering the skybox over everything else

kind juniper
#

Can you take a screenshot with details visible

vital smelt
#

First image is before it paints skybox. Second is after.

#

So how do I fix the depth issue?

kind juniper
#

hmm

vital smelt
#

i'd have to change it's RenderQueue position, right?

#

But that wouldn't fix the strange issues with the portal frame legs :/

kind juniper
#

did it fix the issue with the skybox?

vital smelt
#

I haven't figured out how to change the RenderQueue yet

kind juniper
#

In your render texture settings, can you set the depth buffer to something else?

vital smelt
#

That fixed the leg issue

kind juniper
#

but not the skybox overwriting?

vital smelt
#

Nope

#

That one is still being stubborn

kind juniper
#

What unity/urp version are you using?

vital smelt
#

Wait, I fixed it

kind juniper
#

How?

vital smelt
#

Well, after you told me to change the buffer, I looked at what other options could be used when making the render texture

kind juniper
#

And? What option was it?

vital smelt
#

I just changed the RenderTextureFormat

#

And it works now. No idea why.

#

Maybe my GPU?

#

I know that some GPUs have issues with certain formats.

kind juniper
#

What format was it before/is it now?

vital smelt
#

I don't know what it was before.

#

Wait, I think I changed the GraphicsFormat not the RenderTextureFormat

#

R8G8B8A8_UNORM was what it was before. I changed it to R16G16B16A16_UNORM and it works now

kind juniper
#

Hmm

#

It works for me with your initial format

vital smelt
#

I'm not gonna question it. I'm just gonna take the W and continue with my project.

kind juniper
#

Guess there's a possibility it's hardware issue

vital smelt
#

Again, might be my GPU.

#

Yeah, I think it's my GPU.

#

Only thing I can think of.

kind juniper
#

Or it could be a bug in your URP/Unity version. I did notice some differences(especially in the frame debugger) when comparing to mine.

vital smelt
#

It could be. I'm not 100% sure. I haven't updated it in a long long time though.

marble anchor
#

How to change object colour based on colours of other objects using shader with blend modes?

grizzled bolt
marble anchor
grizzled bolt
mental bone
#

I would wager a guess that they were written for BiRP and aimply dont support HDRP

vague ginkgo
#

can anyone help me fix a lit billboard shader graph?

#

the quad on the left is just a normal quad, and the one on the right is using the billboard shader

#

it does everything I want it to, but the shadows are wrong as well as casting a shadow on itself

regal stag
# vague ginkgo

Rather than using the "Inverse View" Transformation Matrix node , you could use a Custom Function node with Out = unity_CameraToWorld;. That version of the matrix is still the actual camera when rendering shadow passes.

vague ginkgo
#

alright, I've never used the custom function node so I'll do some research

#

thanks!

vague ginkgo
#

that's actually exactly what I ended up with lol

#

awesome you're a lifesaver!

tight phoenix
#

https://www.alanzucconi.com/2017/07/15/cd-rom-shader-2/
I'm trying to follow this tutorial. To the best of my knowledge I've done everything as written, and I have a result that is similar but not exactly what his produces. Attached is a gif of the effect - from certain angles it gets very very bright and I am unsure is this is the intended expected result or not.

#

Following these same steps, my result differs:

#

The above is the expected but mine seems to be the reverse of what is expected? What differs?

#

Is the tangent vector being calculated correctly?
In his code, there is no concept of the 'space' its in, tangent, world, view, object, etc. so I have no way of knowing if ive set those values to the correct "space"

#

using WorldTangent (is tangent vector set to world space equivalent?) I get a very blown out result compared to his example of what should be the same result:

#

I have a custom node that is all the parts of his code that had to be done in node

regal stag
#

It might also help if you test with a similar cd / flat circular mesh rather than a cube

tight phoenix
tight phoenix
regal stag
#

I'm referring to the View Direction here

tight phoenix
regal stag
tight phoenix
#

there must still be flaws since mine still looks weird

tight phoenix
#

scene is currently behaving identically to preview

tight phoenix
#

I did all the same mathematical steps to the same input in the same order, but the result is not the same

#

which is confusing and frustrating

#

math should be math so why isnt it working

#

I get furiously frustrated and my mental heal plummits because it feels like im being gaslit by the universe, the same steps should produce the same result, not a different result, this is not how real life functions

#

UV in, mult 2, subtract 1. Done
Normalize, done.
Make a vector 3 that is the negative of UV.y, zero, and UV.x, done
Transform that to world space (I guess I dont know what space that original set of steps is based in??????????)
normalize, done

#

Trying every space

#

none of them produce the correct result

#

its not possible that it doesnt produce the correct result but its staring me in the @#$@^ing face producing the wrong result which isnt possible and Im sceaming in agony on the inside

#

I have to go now because im now deeply in mental health crisis because nothing ever fucking works the way its supposed to work when -I- do it because the only common denominator in everything I do is that I'M the one doing it, im the stupid fuck up every time, its never anyone elses fault, the tutorial is never wrong, im always the stupid fucking piece of shit idiot fuck who cant do a single fucking thing right

meager pelican
# tight phoenix its not possible that it doesnt produce the correct result but its staring me in...

Sure it's possible, because Surface Shaders do "automatic lighting", and Mr. Zucconi is using a feature called a custom lighting model that is plugged into it (calling their default lighting function, and then doing an ADDITIVE lighting on top of that to get the diffraction grating). And he's got a conditional on that where if cosThetaL and cosThetaV are the same (diff is 0) he returns just the original color from the standard lighting calc.

In shader graph, AFAIK, you can't just call the standard lighting calc, like a built-in node, and get the result and then add to it (additive blending). But @regal stag may know if it is possible, maybe with an unlit graph and adding your own lighting calc sub-graph. He has tuts to that effect. Then you could add your diffraction result on top of that.

Outside of that, you won't duplicate Mr. Zucconi's results.

tight phoenix
tight phoenix
#

I am not seeing how the differences in regard to being added over top of existing lighting would result in the bad results I have

#

maybe I dont understand the default shading models?

meager pelican
#

I haven't verified your code....I'm loading unity though, might take me the day to screw with things (doing several things today). But I can try to SG some diffraction and see what I get.

I did notice that you weren't using the tangent node (it wasn't hooked up to anything) in one of your posts.

Your first results looked pretty cool, and they had circular diffraction, so you're on the right general track somehow. ๐Ÿ™‚
He has that conditional though...

regal stag
tight phoenix
tight phoenix
#

so maybe his curve values are no good since they're not based on linear space?

#

I changed my output tangent vector to resemble his to illiminate that possbility as well

regal stag
#

As Carpe mentioned there is also that conditional in the tutorial

if (u == 0)
        return pbr;

Could try handling this with a Comparison and Branch node.
"u" being the output of "Calculate Tangent Vector" group.
But rather than return pbr, maybe just use... 0? Whatever the Base Color is? Not sure.

tight phoenix
#

Oh hmm, I did see that but I figured it would be okay if I was using an unlit with black texture to simply skip that step, but I guess it does serve a purpose, if the value is exactly zero is aborts?

regal stag
#

Seems like it. I'm not sure how much it will affect the result though

tight phoenix
#

using the above adjusted tangent vector, the result is closer to his, the ultra burn out only occurs on the up/down axis

#

Ill try adding that back in as a test, I wasnt going to because conditionals in shaders are bad to have (to my awareness)

regal stag
#

Conditionals are fine. Branching sometimes isn't, but they are different things.

#

Branch node uses a ternary (bool ? x : y) behind the scenes which never actually produces a real branch. Both sides are always calculated.

tight phoenix
#

Oh, interesting ๐Ÿค” I didnt know that

#

Will this work in place of returning PBR? Since I have no PBR to return in shade graph, will break make it exit?

regal stag
#

I don't think you can break in a function. (It's usually used to exit from a loop)

tight phoenix
#

with brackets in case that matters

#

Oh ๐Ÿค”

#

Like this then maybe?

meager pelican
#

That, in his code, is the result of a standard lighting calc. If you look at his example pics, you'll see CD-ROMS with environmental reflections on them.

But if you want to bag all that, and just do some flat color, maybe with an N-dot-L calc for lighting, you could return that instead. Or a texture lookup with an N-dot-L.

regal stag
tight phoenix
#

The only thing I am studying right now is the anisotropy itself, reflections and base colors and stuff I have no current interest in

meager pelican
#

So return black.

tight phoenix
#

like that?

regal stag
#

Yeah

tight phoenix
#

No change in the output at all

#

so I guess it wasnt neccessary to break, that or im doing something else wrong that is negating the change

meager pelican
#

The conditional I was talking about was the Cos_TheaL - Cos_TheaV == 0

tight phoenix
tight phoenix
#

for me I named it "viewTangent" because I didnt know what u was supposed to represent

meager pelican
#

OK

#

He's got a saturate function in there too. Might reduce the blowout.

tight phoenix
#

cyan pointed that out as well, I am also saturating the result

#

I moved anything that could be done in nodes outside of the code

#

this is the only point I can difinitively say is definitely 100% wrong

#

to my understanding its -exactly- his code word for word function by function

#

but the result is completely different

#

I "fixed it" but it only looks fixed

#

it shouldnt need "fixing" if it wasnt fucked

meager pelican
#

I thought you could "just" use a worldspace tangent node.

tight phoenix
#

so most likely it just looks fixed and is still fucked

meager pelican
#

but I can't see the left side

tight phoenix
tight phoenix
tight phoenix
#

so the mistake must be occuring within or before the custom node

meager pelican
#

The input into the "fix tangent" for you is UVs, but for him he's using Unity's tangent.

tight phoenix
meager pelican
#

I may not be reading you right. I mean I hate graphs! ๐Ÿ˜‰

tight phoenix
#

there must be a mistake in this above since it produces that gif

meager pelican
#

Hang on

tight phoenix
#

and it doesnt happen later since you can see it if I open the preview

meager pelican
#

Never mind, you have a worldspace tangent node plugged in.

regal stag
#

Maybe the viewDir is negated in graph vs surface shader?

tight phoenix
tight phoenix
#

the 'white' here is assume is extremely high values?

#

he didnt do anything to this step after the absolute

#

but maybe I need to do something?

regal stag
#

Could try a Saturate to clamp them to 1

tight phoenix
#

does that not say: the absolute of the two dot products, THEN .. multipled by D which im not doing ๐Ÿค”

#

I looked at that dozens of times

#

now to recall what d even was

#

oh wait no

#

im not dumb

#

that step is inside of the loop

#

oh hm

#

that step is inside the loop

#

I dont think I can precalculate it outside and pass it in maybe?

#

viewTangent is u, inDistance is d

meager pelican
#

For that , you can do most of it outside the loop (and should). N is the loop counter though.

tight phoenix
#

yeah that part of the function is within the loop so I guess I was wrong in that I was doing that part correctly and its not the problem

regal stag
#

It should be fine to move it out the loop as nothing inside the abs is based on n

tight phoenix
#

in his code, 'steps' was the magic number 8

#

so I just replaced it with steps and defined steps as 8

regal stag
#

Out of curiosity, what happens if you use 8 rather than steps.

tight phoenix
#

No change in output after replacing steps with 8 hardcoded

regal stag
#

Am running out of ideas ๐Ÿ˜ฆ

tight phoenix
#

I feel very strongly that the problem is in here somewhere

meager pelican
#

blink blink
he's counting from 1 to 8 and calcing a new wavelength each time. So it's based on that within the loop. Then calling his special function. The other parts could be passed in though, and calced outside the loop.

tight phoenix
#

in some capacity this does not match that above code

tight phoenix
#

maybe GI Light Dir is different than the main light direction?

regal stag
#

What version are you in btw?

tight phoenix
#

2020.3.13f1

regal stag
#

Try a Normalize node on the View Direction output

#

It's not normalised by default in versions prior to 2021.2

tight phoenix
#

that seems to have fixed it ๐Ÿ‘€ ๐Ÿค”

regal stag
#

In v12+ they've now got View Direction (normalised) and View Vector nodes which makes this clearer

tight phoenix
#

I didnt know how I was wrong, but I knew the problem was going to be some invisible difference between his and mine, and low and behold the invisible difference was view distance was not normalized ๐Ÿค”

regal stag
#

Yeah. It's just one of those differences between surface shader inputs and shader graph. :\

tight phoenix
#

hokay anisotropy GET

#

now to learn about thin-film iridescence and every other aspect of anisotropy

tight phoenix
tight phoenix
hardy socket
#

how do i have like a texture / albedo like in the base materials where i can have a variable than can be color and texture at the same time in shader graph ?

#

like this :

regal stag
vital smelt
#

Does anyone know how to get the equivalent of "Cull Off" in a Shader Graph?

regal stag
vital smelt
#

I put Two Sided on but it still doesn't work. I still see through the "screen cube" if i stand in it

regal stag
#

Well, Cull Off and Two Sided are equivalent. It might be that you need to do something else to fix the issue though.

vital smelt
#

It just isn't drawing on the inside of the cube

regal stag
#

Are you saving the graph after changing the settings?

vital smelt
#

Yes

meager pelican
vital smelt
#

I have it set to 24 on the render texture i think

vital smelt
#

When I enter half way into the portal, I see out the other side of the frame instead of the image being rendered still

#

First image is before entering, second image is if the player stops on the boundary of the portal

meager pelican
vital smelt
#

If I move 1 more pixel forward, I transition

meager pelican
#

Near plane clipping of the object?

vital smelt
#

But I don't get why this one pixel exists, as it makes the portal flicker if i run through it

vital smelt
meager pelican
#

It's a camera attribute

#

defines the view frustum

vital smelt
#

I have it set to 0.01

meager pelican
#

well, try 0.001, or move the transition point to something that works for ya. 2-cents.

vital smelt
#

I don't think I can go lower than 0.01

kind juniper
#

If my loop length depends on a property, does it mean that it can't be unrolled? just how much more ineffective would that make it? ๐Ÿค”

#
[unroll]
 (int i = 0; i < LayersCount; i++)
mellow wind
#

hey, iโ€™m just putting this here because i think itโ€™s an issue pertaining to materials or textures, but iโ€™m having issues with a model iโ€™ve imported from blender

kind juniper
#

You can either use a shader that renders both faces of a polygon in unity or invert the affected face's normals in blender.

eager folio
#

Fixing it in blender is a much better solution for most such situations, to clarify.

mellow wind
#

yโ€™all are absolute blessings, iโ€™m grateful to you

meager pelican
# kind juniper If my loop length depends on a property, does it mean that it can't be unrolled?...

The compiler has to know how many versions of the loop contents to insert at compile time OR wrap it in conditionals. So for constants it can unroll it directly by simulating the loop. But for a variable, it has no way to know how many lines to plan for, UNLESS YOU TELL IT.

So if you know the max iterations, say 16, you can use
[unroll(16)] as an attribute. I haven't tried it, but it is supposed to check if the actual value of the variable exceeds the condition specified in the for-loop on each iteration. That's a lot of ifs.

The plus side is that it can optimize memory access better when the loop is unrolled. It is linear flow strait down the line, no increments or "goto"s in a loop except for the terminating check.
https://en.wikipedia.org/wiki/Loop_unrolling

Loop unrolling, also known as loop unwinding, is a loop transformation technique that attempts to optimize a program's execution speed at the expense of its binary size, which is an approach known as spaceโ€“time tradeoff. The transformation can be undertaken manually by the programmer or by an optimizing compiler. On modern processors, loop unro...

kind juniper
#

The compiler wouldn't compile otherwise actually.๐Ÿค”

meager pelican
#

Right, because it can't, otherwise. ๐Ÿ˜‰

kind juniper
#

I mean even without the unroll. Or I'm mixing up things. Hahah.

meager pelican
#

Yeah, I guess sometimes you must either specific [loop] or give it a count, as it has a hard time guessing what optimization to use, or not.

#

Weird

kind juniper
#

I see. That makes sense

rancid shuttle
#

anyone know why this is happening? i copied cel shading from daniel ilett

unique kettle
#

When my model is in blender the hair looks perfectly fine but when I import the model to unity and then add transparency on the hair material some of the hairs don't show but the culling is off , can somebody please help

regal stag
unique kettle
#

When I use alpha clip it works perfectly fine but it doesn't have a sudden realistic transparency

unique kettle
# unique kettle

On the tip of the hair and I really don't know why it does this when I select transparency

regal stag
rancid shuttle
unique kettle
#

If u look u can see the grid lines just go through it on only some parts i don't know why it does that I wanted to ask if u knew

kind juniper
#

Perhaps just an issue with the depth texture?

regal stag
unique kettle
#

Oh ok sorry

#

Do u know how I can fix it then

#

I'm kinda new

regal stag
#

I would use alpha clipping rather than transparency

unique kettle
#

Ok I'll do that but do I still not have a option to go with transparency and still have the whole models hair show up correctlyy??

#

Is there no option to fixing that โ€ขฬ โ€ฟ ,โ€ขฬ€

kind juniper
#

Perhaps change the rendering order?

unique kettle
#

Okk

kind juniper
#

Or is it called sorting order/sorting queue?
It's in the material settings usually at the very bottom

unique kettle
#

Alr

grizzled bolt
kind juniper
#

I think they were referring more to the unity grid rendering on top of the hair.

rancid shuttle
#

any ideas why its not doing the outline correctly

rancid shuttle
regal stag
#

It looks like the outline pass is not using ZWrite On

rancid shuttle
#

i really don't understand shaders, i just copy and paste them

#

oh ok, i changed zwrite off to zwrite on

#

and it works thanks

pale python
#

hey,

I have few walls that are URP based, they look fine on the editor even in playmode.
However, once I make an android build it and enter the game, those walls just disappears.

what could be the cause of that?

hexed surge
#

hey guys
In a compute shader, how do I access global variables from another file ? I have textures and samplers in the main shader file and need to sample them in functions defined in separate files

and I can't just sample them in the main and then just pass the values, because some functions need to sample areas around each pixel of the output

#

can I just pass the reference to the texture along with uvs ?

pale python
#

how to activate those blocks ??

meager pelican
meager pelican
pale python
meager pelican
pale python
#

why ??

meager pelican
#

Probably settings.

pale python
#

im doing this for android

meager pelican
#

IDK, shouldn't matter.
But maybe it's like...if you're using tangent space normal, you won't need world space normal.

hexed surge
meager pelican
#

@pale pythonAnd the specular color probably only applies to specular workflow.

pale python
pale python
#

i have basic stuff and they are greyed out

meager pelican
#

So what's the problem? You don't need worldspace normal active in the block.

#

You don't need specular color either.

#

So no problem.

meager pelican
#

make sure to include them at the point where you would type them in, not just at the top of the file.

pale python
#

any thing i add to the default, doesnt work, all greyed out

meager pelican
#

Is it a lit graph?

hexed surge
pale python
#

i'm using the shader graph editor for it

meager pelican
meager pelican
#

You have to set them on each file/shader/material from c#.
Each shader is independent of the others, there are no "externs" for that type of thing, you must set the references in c# for the invocation, or the engine will do it for you for many things like with materials.

meager pelican
# pale python

It's an unlit graph, so you don't have those PBR calcs available.

pale python
tame topaz
#

@pale python In the future, don't crosspost your questions

pale python
#

sorry i forgot to delete the other one

hexed surge
tight phoenix
#

ignore that its a mess, is this too many noise nodes to get the above look?

grizzled bolt
regal stag
#

Assuming you don't need this to scroll over time or something, you could also bake the current result of the shader to a texture.
That way you could use another shader graph with just a single texture sample to basically produce the same result.

ocean bough
#

I've made quite a simple 2D sprite URP shader that offsets horizontal, vertical and diagonal copies of the maintex to create a fake blur for my foreground and background layers.
A problem I have is that I can only increase the offset ever so slightly until you can start telling apart the "sampling".
Does anyone know if there's some nice way to blur more accurately and increase the samples, like a gaussian blur or something? I'd rather try and avoid playing around with the render pass stuff as it's a bit complex for me but any suggestion is welcome.

#

I can't resort to using DOF or anything like that as I can't use that as a post process layer on my foreground (it blurs everything on the screen, not only the foreground)

karmic hatch
ocean bough
karmic hatch
#

On your sprite you want to be blurry

#

Low res and then bicubic looks roughly gaussian

#

though ig at that point you could just use a texture and actually gaussian blur it

ocean bough
#

yeah the problem is I have a loooooooooot of textures and manually blurring the actual texture would more than quadruple the game size

#

they're all scattered around on sheets

karmic hatch
#

if they're at different distances there's probably a depth of field post processing option

ocean bough
#

it would also benefit to have it automatically blur a certain strength just directly in the scene

#

yep. I tried that before and like I said it doesn't work for the foreground unfortunately. It does work well with the background though. But the foreground is just as important

#

the problem is the post processing pass applies the dof on the whole screen so it blurs my middle-ground layer too

#

after having searched around forever I just ended up going back to my older solution which was this shader but trying to improve it and make it a little better, although I get stuck here at the sampling as I can't figure out a way to make it look better

karmic hatch
#

Use your eyes and the framerate to average it rather than lots of layers

meager pelican
#

@ocean boughWould Unity's motion blur help you? You could use a separate camera for the background if you don't want that blurred, and composite them.

ocean bough
#

It's a very basic 2D foreground, middleground, background layout. Middle is sharp, everything else blurred (statically blurred)

#

preferably in a gausian sampling

#

ori a great example. background further away blurs. More the further away. Foreground is very "close" so appears very blurry

meager pelican
#

OK, so layers or camera stacks, with blur on top of them. Does Unity's blur post process not work for your use-case? Just curious. You CAN of course write your own blur shaders, but it ends up likely being a post processing pass with layers anyway.

ocean bough
# meager pelican OK, so layers or camera stacks, with blur on top of them. Does Unity's blur pos...

Exactly. And here is where I've gotten stuck. It sounds pretty straight forward - but the problem comes when ever the post processing layer is applied on the foreground layer (either as a camera, or just a layer), because the post process pass doesn't produce an "alpha" that can read what part of that layer has content in it - it simply applies the full effect all over the screen, thus blurring everything behind it (even the sharp middle ground).

#

I'm not so skilled in how render passes/features work, but the ideal gold moment for me here would be if there is someone knowledgeable enough on how to make one custom render feature that can produce post processing dof on the foreground without it being applied "backwards" all over the screen

#

i've been struggling for a long time with this. It seems like a very very common thing in 2D games but it seems almost impossible to recreate it in URP 2D. Seen lots of threads without any proper solution

meager pelican
#

Hmmm.
I'm not a 2D expert.
But...
Seems to me you could put a post processing pass on the foreground camera, and then AFTER that, draw the mid-ground. There would be some "extra work" doing that, since it would draw over stuff it didn't otherwise need to draw, but if the blur happens before you draw the sharp layer, problem solved?????

ocean bough
#

yeah exactly if it was drawn first it would of course not be applied on the next coming layers in the queue. but how would you go about rendering the next layer (in this case, the sharp middle ground) without it overlapping? as if its sorted correctly

lean lotus
#

How do I extract the scale from a float4x4 in HLSL?

meager pelican
#

It would still be depth clipped.

ocean bough
#

Ok, how would you about doing this? A camera with priority numbers?

#

I don't know how to sort around the render queues in an order like this

meager pelican
# lean lotus How do I extract the scale from a float4x4 in HLSL?
lean lotus
#

thx

meager pelican
# ocean bough I don't know how to sort around the render queues in an order like this

I'm talking off the top of my head here, so grain of salt.
But...
You'd assign objects to layers, foreground, middle, background.
Then you'd have a camera, or cameras, to render say the foreground + background layers, but not the middle.
You'd then have a post process of blur or DOF or whatever.
Then you'd have another camera with "don't clear" on it, and render only the middle layers.

I think. But I don't do 2D

#

I'd make a very simple test-case scene and test stuff out

ocean bough
#

Hmm, ok. And priority number on the said cameras to decide the render order yeah?

#

The cameras dont have Don't clear in this pipeline though

meager pelican
#

I guess, or just the order in the object list. You'll play with that and get it. It's been a long time for me since I've messed with that and it could have changed.

meager pelican
#

Second. Please stand by.

#

you mean in URP?

ocean bough
#

There are Depth Texture settings and stuff in urp

#

Yeah

#

I use the 2D stuff in URP though but the camera rendering should be the same (throughout URP).

meager pelican
#

OK, so you want an overly camera, right?

ocean bough
#

That would work.

#

makes sense right? i think

meager pelican
#

It gets the depth buffer and the color buffer from the previous camera

#

per that docs page

ocean bough
#

Hm ok

#

Seems interesting, I'll follow what you said tomorrow and see if I can get something out of it. I need to head to bed. I'll keep you posted. Thanks so much

meager pelican
#

Welcome.
I'm just guessing though, but worth some experimentation.

somber chasm
#

Anyone know how to get the height of the mesh at a point using a surface shader?

#

Afaik theres only worldPos and worldNormal nothing for the actual surface

#

I generate the mesh in code using a float[] heightmap, how could I pass this to my shader if theres no built in way to do it through shader only?

somber chasm
#

nvm figured it out, unity_WorldToObject and it's inverse

#
float3 objectPos = mul(unity_WorldToObject, float4(IN.worldPos.xyz, 1)).xyz;
meager pelican
somber chasm
meager pelican
#

I wouldn't have said "check the generated code" if it wasn't a surface shader.

#

There's still a vertex stage, you just have to check the code.

somber chasm
#

Ah ok, im not that great with shaders - I only know enough to be dangerous

#

Didn't know you can check the output

meager pelican
#

Yeah, it's ugly since there's a lot of variants.

#

Sec, let me check something.

somber chasm
#
struct Input {
    float3 worldPos;
    float2 uv_MainTex;
    float2 uv_MainNorm;
    float2 uv_SecondTex;
    float2 uv_SecondNorm;
    float3 worldNormal;
    INTERNAL_DATA               // Required to set o.normal and read worldNormal
};

I'm just reading straight from this struct

#

And converting worldPos and worldNormal to object space

meager pelican
#

appdata_full has a value called "vertex".
See that struct for how to include it in your "Input" values.
They have an example here: https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html
That extrudes the model along the normals and makes a "fat soldier" (towards the bottom of the examples, about 2/3rds down the page)

      Tags { "RenderType" = "Opaque" }
      CGPROGRAM
      #pragma surface surf Lambert vertex:vert
      struct Input {
          float2 uv_MainTex;
      };
      float _Amount;
      void vert (inout appdata_full v) {
          v.vertex.xyz += v.normal * _Amount;
      }
      sampler2D _MainTex;
      void surf (Input IN, inout SurfaceOutput o) {
          o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
      }
      ENDCG
    } ```  
They use a custom vert function in the surface shader.
#

The point is that v.vertex is what you want already, you don't have to "uncovert" it.

somber chasm
#

I see, I guess the only problem then would be if i'm drawing stuff based on the height of the vertice and normal in the surf method, how would I do that using the vert method?

#

Thats a big help though thanks

#

This is what I wanted, so that the model can be rotated and translated without changing

meager pelican
#

I'm low on time, I have to get ready for work.
Uhm, I thought you generated the mesh in C#.
But if you're doing vertex height mapping in the shader, you can expect those values to be interpolated in the v2f data.

somber chasm
#

Ah gotcha, thanks man. Enjoy work when

meager pelican
#

ha

#

So it depends on if you need a custom vert() function or not, I guess. Just make sure you have a v.vertex and an IN.vertex and that you set the IN.Vertex to the value of v.vertex. You'll have to check the code and makes sure that unity doesn't translate that vertex value before you assign it.

#

You can check the generated mess in the inspector, there's a button for that.

somber chasm
#

Ohhh yeah that makes sense, I got it now. Thanks a lot!!

meager pelican
#

๐Ÿ™‚

molten trellis
#

Hey guys !
I am a real unity newbie.
I am currently developing a 2D game, and I want to make my enemy projectiles more visible to the player, but adding a shadow/outline behind the sprite (like white shadow on this drawing).
How should I do that ? Is it with Shaders, or another graphic tool ?

wicked niche
#

This is how I draw a smooth circle in a black background, but how can I draw a rectangle?

#

How to create rectangle mask?

vocal narwhal
#

These functions are distances to a shape, so you can use that distance as a mask if you do some basic remapping (and saturating the result to avoid non 0->1).

frozen fulcrum
#

Hi! I have a question, maybe someone had same issue like me. On the left - game view, on the right - scene view, for a GOLDEN text shader. I think it's something with Additive mode, because it should work as intended just like on the scene view

long bramble
#

you might also not have post processing enabled on your camera

rotund tundra
#

trying to figure out this ink shader im using, mostly how it uses colour, it has a float4 channelMask
depending on the values it changes colour,
x at 1 = yellow
y at 1 = red
z at 1 = green
w at 1 = blue
it always uses the last value eg x will be ignored if y is 1
removing the channel mask makes it default to blue

frozen fulcrum
hardy rampart
#

I found this glass shader online

#

It seems to have a tiling option on the inspector but changing its value does nothing, how should I change the script to make tiling work?

regal stag
#

(Though that may assume the texCoord in the vertexOutput is a float2 (not float3)... It doesn't seem like the z axis is used so could change it)

hardy rampart
#

Worked like a charm had to add #include "UnityCG.cginc", though but still it's perfect. Thanks!

molten jasper
#

Are standard URP shaders now used for vertex displacement?

wary horizon
#

im using cyans blit for a screen effect, though i now have a minimap thats using a second camera, the blit is being applied to that too, is there a way to only do the effect for one specific camera?

regal stag
regal stag
wary horizon
#

I have these 3 now

#

I, don't have one of those? O.o

regal stag
#

You must do, it's what tells Unity to use URP ๐Ÿ˜…
It'll be what is assigned under the Project Settings -> Graphics

wary horizon
#

oh, on each of my quality settings?

regal stag
#

Yeah or there, would probably need to add them on all if you have multiple assets for each quality setting

wary horizon
#

ah ok ok! i didn't know you could do this!

hearty obsidian
#

For the ball above, I got the look with scene color + some fresnel. My goal is to check off the opaque texture, I was wondering if there's a cheap way I can get something that looks like it w/o the scene color? The ball rotates

regal stag
hearty obsidian
#

@regal stag Oh wow, I'll see myself out

#

thanks

grand jolt
#

Hello, I am new to Unity. Was wondering if someone might be able to offer me some assistance with a texture problem I am having

tight phoenix
#

Is there a formula or method to deform a 2D square UV into a hexagonal UV? (until is still booting up but ill picture my use case here in a sec)

#

by deform into a hexagon I know the UV will still be square ultimately, but I am trying to correct a bit of distortion that comes from a shortcut I am using

#

as a cheap alternative to 3D noise, I am projecting my 2D noise textures at my cube from a 45 degree angle to make a texture that is unique on 3 faces and tiles on all sides
The downside with this method is that it produces a degree of stretching that sorta 'points' at the vertex im projecting at

#

I want to try to correct the stretch, I know there will be some stretch no matter what with this method, but I am thinking that if I can somehow deform the UVs in these three directions away from the center, that it will look slightly less stretched

strange frigate
#

Hello there, fellow unity enjoyers! I have a minor question to ask - does Render Texture utilize object's UV islands or it just uses whole UV space?

shadow locust
#

not different from any other texture in terms of how it gets sampled

tight phoenix
strange frigate
#

Damn, now I feel stupid... Is there a way to get UV vertices position, using URP shader graph?

tight phoenix
#

sorta but not quite ๐Ÿค”

#

almost?? ๐Ÿค”

#

hm I think maybe the problem is that I need the triangle to be rotated to point at the lines instead of the faces?

#

you can see it not working here

#

almost kinda works ๐Ÿ‘€

#

I think the gradient curve just needs to be changed

#

sorta works except you can kind of see a decreased cell density the closer to that corner

#

maybe the problem is that I need a hexagon instead of a triangle ๐Ÿค”

molten jasper
#

@dim yoke to answer your question mark reaction (which you would have been better tagging me for). There are some old tutorials on Unity's site that refer to displacing vertices in shaders on hdrp/urp. However the option for PBR shaders (which the tutorials use) in the context menu is missing.

tight phoenix
#

hexagon is proving troubling to use ๐Ÿค”

trim pewter
#

apologies for the newb question but is there a reason why when using a texture with a transparent background as a Base Map produces black as the background color? is there any way to change this?

tight phoenix
#

its easy to make it worse, maybe my problem is that I should be doing this from the opposite corner, or in reverse to what I am doing ๐Ÿค”

molten jasper
#

I figured it out, thank you anyway

tight phoenix
#

everything I try just makes it worse, not better

#

getting frustrated

#

this shouldnt be this hard to fix, its just geometry

#

great now that I achknowledged that im frustrated, the feelings are now overwhelming

#

stupid worthless piece of shit doesnt do what I wnat because im too stupid to make it do what I want because I cant even describe what I want it to do

#

maybe the problem is that im trying to fix a 2D problem with a 1D sollution????????????????????????

#

I just want to unfuck the shitty stretching worthless look my own stupid worthless hack is generating

#

why is it so hard not to hate myself for being a worthless failure at everything i ever try to do or touch

#

time to go somewhere else

#

i can NEVER seal the fucking deal, I can only make these shitty worthless half ass attempts, and then im forced to wait for people who are better than me to fix it because im too stupid to fix it myself :/

#

i hate myself for being so weak and stupid that im forced to rely on others. all the people I idolize arent forced to rely on others, the people with actual skill and talent just -DO- it

#

im just a fucking worthless parasite

tight phoenix
#

the sollution has to be that i need to write math that will stetch the UVs along the black axis, along the green lines, towards the yellow points

#

stretching it this will way remove the warped appearance

#

what vector math will fill these quadrants with negative values, and the others with positive values, ramping away from the lines?

grand jolt
#

Where do you connect the multiply node?

tight phoenix
#

i tried to brute force it because thats the only thing im capable of doing, but even that doesnt work

#

the gradient is pointing in the wrong direction

#

stretches in completely the wrong directions, another worthless failure produced by the worthless failure

#

I stupidly thought I could redeem myself by at least proving that it can be done

#

I hate that I know it CAN be done
but only by someone better than I am
i will never be that better person, im just a stupid worthless POS who can do nothing but dream, I cant achieve a single thing with my own two worthless hands
ideas are worthless
when someone better than me solves this problem for me, IF that happens, it will be THEIR achievement
I will have contributed nothing
infact I contribute less than ntohing, I actively TOOK AWAY that better person's time, which could have been spent achieving something even greater than my worthless hack ideas

tight phoenix
#

I tried to do it -manually- by -drawing it- in -photoshop-

#

but im STILL too fucking stupid to do it right

#

it still doesnt @#$@%^@^&ing work and I dont know why because im too fucking stupid to do do anything on my own

#

they all stretch in the wrong @#$@^@ing direction

#

I wish I wasnt so stupid

#

a smart person could solve this easily

#

I wish I felt like I was a smart person, I wish ididnt call myself stupid just like how my parents, my siblings, my teachers, and everyone else ive ever met called me stupid growing up

#

i give up, im too stupid to do anything useful

#

i just have to settle for my original shitty hack job

#

the one that any talented person could easily fix all the flaws in

#

but I have to compromise, settle for something objectively worthless, objectively worse in every regard

#

just like every single thing I do and touch, settle for less, settle for worthless, always compromise compromise compromise, never do a single fucking thing or achievement or note, never live up to any expectations, never HAVE any expectations of to be anything but a worthless waste of space to begin with

#

i wish so goddamn fucking desperately to BE SOMEONE

#

but im just too fucking worthless, ill never be the people idolize

#

they're younger than i am, smarter than i am , faster than i am

#

every trait i have, they have in greater exccess

#

the ONLY thing I can ever hope to achieve, is to be the big fish in a VERY small fucking pond

#

because if people have the option for something with real skill, real talent, and myself, they will never, EVER 'compromise' the way I have to fucking compromise and take me over someone with real skill

subtle mica
#

I have a problem with this shader, on the x sides the material is 90 degrees turned
Code:

Shader "Custom/WorldSpaceShader"
{
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB)", 2D) = "white" {}
    _Scale("Texture Scale", Float) = 1.0
}
SubShader {
    Tags { "RenderType"="Opaque" }
    LOD 200

CGPROGRAM
#pragma surface surf Lambert

sampler2D _MainTex;
fixed4 _Color;
float _Scale;

struct Input {
    float3 worldNormal;
    float3 worldPos;
};

 void surf (Input IN, inout SurfaceOutput o)
 {
      float2 UV = abs(IN.worldNormal.x) > 0.5 ? IN.worldPos.yz : abs(IN.worldNormal.z) > 0.5 ? IN.worldPos.xy : IN.worldPos.xz;
      o.Albedo = tex2D(_MainTex, UV * _Scale).rgb;
 }

ENDCG
}
    FallBack "Diffuse"
}

subtle mica
#

How can I rotate this side 90ยฐ

karmic hatch
# tight phoenix i can NEVER seal the fucking deal, I can only make these shitty worthless half a...

probably worth practicing using vectors in geometry problems, and often you might need to break out the pen and paper if you can't guess at the form of the answer. Then for me at least there's a lot of trial and error with signs and coefficients, and often messing around with some vague idea of the geometry/physical problem you're trying to solve, but more trying to make it look reasonable at the end, will get you something that works.

karmic hatch
#

For something that's positive on one corner and negative on the other, you could do:

float DiagonalSlice(vec3 normal, vec3 position) // Both are in object space
{
  vec3 one = vec3(1.) - normal;
  vec3 posOnFace = position - normal;
  return dot(one, posOnFace);
}
#

So all faces will be sliced along the vector in the plane of the face, closest to (1, 1, 1)

#

and then for the scaling, you could have the input be something like:

float AlongDiagonal(vec3 normal, vec3 position) // this gives us the coordinate that DiagonalSlice misses
{
  vec3 one = vec3(1.) - normal;
  vec3 posOnFace = position - normal; // unnecessary given the next step (all components parallel to normal return zero) but whatever
  posOnFace = cross(posOnFace, normal); // normal is always length 1 and points outwards so this gives us a perpendicular vector
  return dot(one, posOnFace);
}

float OutputValue(vec3 normal, vec3 position, float stretching) // this function gives the stretched voronoi noise
{
  vec2 faceCoordinates = vec2(DiagonalSlice(normal, position), AlongDiagonal(normal, position));
  faceCoordinates.r = stretching * faceCoordinates.r / (stretching + abs(faceCoordinates.r)); // this function can really be whatever you want 
                                                                                              // but it determines how one coordinate is stretched 
                                                                                              // with respect to the other.
  return Voronoi(faceCoordinates);
}

@tight phoenix

karmic hatch
flint adder
#

Hey all I am running into an issue where SRP batcher will not work with multiple shaders ?
How can I make all of my game effects inside fit into one shader? Is that a suggested method for optimization?

kind juniper
scarlet crater
#

is there a method of creating full screen effects without using any sort of scripting?

#

I'm attempting to create a custom asset for a game but one of the limitations is user generated scripts do not get included within the asset

#

only shaders and such

#

my only idea was to slap a grab pass shader onto a quad or something and then transform the vertices to the screen, somehow

#

wondering if theres a better way

flint adder
#

because of different shaders are used

white pivot
#

hey guys its possible to make this effect from shader graph? i can doing the affter effect but idk how to import it to unity
https://www.youtube.com/watch?v=peb7DQtSieQ

vocal narwhal
swift flame
#

how do i use this?

#

i googled it but nothing came up.

kind juniper
#

Plug things in, plug things out.

swift flame
#

Never mind it working. i thought it wasn't.

#

just cleared all my settings when i saved.

white pivot
vocal narwhal
# white pivot i will try second , the alternative i know to bulid trails and the VFX graph (ci...

I think the complexity with VFX graph would be not overlapping the lines. If you didn't care about that you could pick some random times when new particles split off, or take a 45deg turn from their starting angle. With my experience it would be hard to tell what would work without a bunch of experimentation
It's a complex effect! Another option that might be easiest might be to use the spline package (https://docs.unity3d.com/Packages/com.unity.splines@latest), they have some examples for extruding meshes along splines, and it also lends itself to placing the circles on the ends too.

radiant jacinth
#

Is there a reason of how when you import a 3d file, some shaders are shown on the editor but then some others don't?

lunar depot
#

I have a pretty specific question, I think.

#

So I have a shader for a UI image material. And it has a variable I am controlling from a script. However when the image is masked, it does not work anymore.

#

I've done some research and it's because the mask mucks with the materials. I can get it to work if I use "materialForRendering" instead of material, but the problem is I'm not just getting the material, I'm also setting it so each instance of the material in the scene is its own thing. If I don't, the variable is obviously the same for all instances of the material, which I want to avoid.

#

So what I am currently doing is: get the material that's on the image, make a new instance of it, and then put that back into image.material. However when the image is masked, this doesn't work, because materialForRendering is read only, obv.

neat hamlet
#

You can set it to be a mask in script by messing with the stencil

#

so avoid the mask component

lunar depot
#

Is there another way, because that doesn't seem feasible for whhat I'm trying to do. I want it to use the mask component if needed.

#

is there any way to access that material?

neat hamlet
#

no, the mask component locks the material

lunar depot
#

Is there a way to do this before the mask locks the material?

neat hamlet
#

dont think so

lunar depot
#

like instantiate my version of the material, put it on the image and then when the mask comes in it grabs that one?

neat hamlet
#

maybe if you add the mask component in script?

lunar depot
#

So just so I understand it: what's the mask doing, specifically?

#

Like when the mask is turned on (maskable on the image, frex), it grabs the material that's on there and then?

#

It instantiates that somehow? Because I can't seem to get to it anymore at that point, right?

neat hamlet
#

I think the flag there is the issue

lunar depot
#

Ah.

neat hamlet
#

I made my own masking script to avoid it

lunar depot
#

Yeah, unfortunately that's not an option here. damn

#

alright, further testing: If I enable masking after the material has been instantiated I can actually access the variables in there.

#

So: make an instance of the material, assign it to the image, then enable masking (mask makes its own copy) and then use materialForRendering.SetFloat to access that version of the material.

#

However if masking is on when the material is enabled it probably comes down to order of script execution, and even with mine being early in the script execution thing, I can't do my copy thing before the mask does its copy thing. So something doesn't work

#

update: sometimes it works, sometimes it doesn't, even with the mask enabled?

tacit parcel
lunar depot
neat hamlet
#

the stencil buffer is different

white pivot