#archived-shaders

1 messages · Page 36 of 1

tight phoenix
#

does this look like what you'd expect specular to look like on the deformed and recalculated normals?

grizzled bolt
#

The simplest way is probably to compare to a "ground truth" mesh

tight phoenix
#

Trying to google it but only finding confusing unclear results

grizzled bolt
tight phoenix
#

I tried recalculating the normals without deforming the mesh and when its completely flat it looks correct but the version that thinks its deformed without being deformed, the secularity takes on a very polygonal look

grizzled bolt
#

Blender for example lets you do the same kind of deformation and normal recalculation on the mesh, using their math which I'd trust

tight phoenix
tight phoenix
#

I am seeing the deformation modifiers, Ill google that, ah okay Displace modifier

grizzled bolt
tight phoenix
#

I cant move forward and debug my shader until I have this but I cant figure out how to have this

#

for some reason it wont show me any parameters for the displacement

grizzled bolt
tight phoenix
#

I only know how to use 3dsmax but max wont deform on a texture as far as Im aware

#

I will keep googling

grizzled bolt
grizzled bolt
#

After it's been applied you'd right click the mesh and "shade smooth" to automatically calculate the normals
I expect you'll want to use UV coordinates instead of local for the displacement, makes it easier to line up the texture in case the transform scales or spaces get wonky upon export

tight phoenix
tight phoenix
grizzled bolt
tight phoenix
#

I dont know if that means its already exactly the size of local

grizzled bolt
#

That's probably the case

tight phoenix
#

the deformation also doesnt appear to match the texture at all

autumn sigil
#

Hey, helpppppp

tight phoenix
#

Ill just move forward for now and hope it works in unity

autumn sigil
#

How do I do a blur in SG the best?

#

a blur of a texture

tight phoenix
#

so there's no possible way I can use this to act as a baseline comparison

#

XY back to square one, how do I get a baseline to compare it to 🤔

#

Getting frustrated that I just wasted all that time in blender only to ultimately get nothing from it, that method cannot produce a base line to compare against

#

looking at this again, is this what specular should look like on recalculated normals?

#

it seems wrong to me

#

if this was a normal map it would be 100% wrong

tight phoenix
#

how/why is it making hexagons where there are none

tight phoenix
tight phoenix
tight phoenix
#

when I replace the procedural noise with a texture sample, the recalculation no longer works

#

all I did was delete the procedural noise and replace it with the texture identical in every way

#

but clearly not identical in any way because it no longer works

#

this was the old method

#

I ripped out everything and replaced it with the texture sample

tranquil wolf
#

anyone know what the object vertex position node is in URP lit shader graph?

tight phoenix
#

the expected result

#

now its turned purple for no reason after I moved the code into a subgraph

#

why does debugging shaders have to be so extremely frustrating and painful

#

why/how does anyone rely purely on interpreting color values to debug

#

this is masochism

#

is there really no better way?

thorn tapir
#

hey not entirely sure where this question belong, but how hard would it be to selectivley apply a pixelation shader to things in my scene?
Is it as simple as two cameras, one capturing only the things I want pixelated, another capturing everything but that... apply shader, and somehow mix the results back together for the output?

tight phoenix
#

there are no differences so why is it magenta

#

I do not understand

#

its not magenta inside the graph

#

Do I need to pass in the texture ??? that makes no sense but I can see nothing eles to try

#

nope doesnt work

grizzled bolt
tight phoenix
#

its not magenta inside the graph

#

but it is outside of the graph

#

this is that magenta node

#

identical in every way

#

except that cannot be possible

#

my understanding is wrong

#

I am wrong

#

but I cannot understand how or where I am wrong to fix it

#

im too frustrated for this

#

I just want to deform a mesh and then recalculate normals of the deformed mesh

#

but this is proving to be impossible

#

I am using these nodes from this person to recalculate the normals

#

he says this is the only way, it is correct, it is flawless, it must work

#

the problem must be with my work, his work is not flawed

#

I copied his identically in every way so if it worked for him it should work for me but it doesnt work for me

#

so I am wrong

#

but knowing that doesnt help me become right

#

im starting to have an ocd melt down so im just going to close everything and give up, thats all something someone like me can do

#

someone please show me where I am going wrong because I am not capable of progressing until I know where is going wrong and I am not capable of fixing it myself, I need help

grizzled bolt
#

I have not made that kind of system or much anything of that complexity so I can't be of more help

tight phoenix
#

all my assets

tranquil wolf
tight phoenix
#

when in blender if I set it to UV instead of local, it didnt change, so I assumed uv and local were identical

#

but that is not the case

civic lantern
tight phoenix
#

to put it lightly

#

okay I think I got them to line up

#

now to try to recalculate the normals again

#

its definitely not the same

#

this guy's recalculate normals after mesh deformation is complete nonsense, its not even remotely recalculated

#

so now my XY is going even further back because literally all my work is built upon a useless incorrect lie :/

#

all of this is wrong nonsense bluffing to be correct it seems

#

I dont understand why someone would go to all that effort just to make something that isnt even remotely aproximal

#

his is stupidly based around animating over time so maybe the mistake is that I just adapted it wrong somewhere

#

he is doing all this worthless extra shit that completely occludes any possible understanding of what is important and ciritcal and what is worthless wasted computations

#

so frustrating when people release tutorials and assets that are bunded with all this bloat

#

when you google recalculating normals in shader this is the only result

#

it makes me feel better to blame him but I know in my heart that ultimately I am the one too unskilled to make sense of his work

grizzled bolt
tranquil wolf
#

so I have this shader for my leaves, but instead of looking like they are blowing in the wind I am getting a weird psychedelic effect. Any ideas?

grizzled bolt
#

I assume that's what you mean by psychedelic effect

#

I think wind animations usually are done only on vertices

tranquil wolf
#

I did distort with noise

#

🙃

grizzled bolt
#

Probably no need to do it on both verts and texture

opaque mist
#

Is there a way to reference the ambience colour in the shadergraph?

tranquil wolf
#

Even if I get rid of the noise on the texture, it still doesnt look right. Sure, the weird effect is gone, but it still doesnt look like it is blowing in the wind so much as "jittering"

regal ivy
#

the bottom bar is "bugged" because Render Mode is set to Overlay and not Camera. The material is used in a Image component. Is there another way to tackle this besides changing Render Mode of the Canvas component? I want to avoid having to go back and change a few scripts.

plain bluff
#

Hey guys I require some assistance

#

I am trying to get a dissolve shader to come out of this object

#

But it makes it look like this

#

Supposed to look like that

#

Ive got this going on in the graph view

#

It still says its missing _MainTex

#

I am probably missing something super obvious so any help is appreciated

#

Thanks

opaque mist
#

How do I fix this issue? I feel like it can be fixed through the shader graph, but I'm not too sure how

tacit parcel
# tight phoenix when you google recalculating normals in shader this is the only result

bashing the article writer wont do you any good, just saying...
try this, it's written in shader code but I think it can be converted to shadergraph
https://www.ronja-tutorials.com/post/015-wobble-displacement/
what you might need is this vert shader code from the article, again, I think shadergraph has all the nodes needed to remake it in shadergraph

    float4 modifiedPos = data.vertex;
    modifiedPos.y += sin(data.vertex.x * _Frequency) * _Amplitude;
    
    float3 posPlusTangent = data.vertex + data.tangent * 0.01;
    posPlusTangent.y += sin(posPlusTangent.x * _Frequency) * _Amplitude;

    float3 bitangent = cross(data.normal, data.tangent);
    float3 posPlusBitangent = data.vertex + bitangent * 0.01;
    posPlusBitangent.y += sin(posPlusBitangent.x * _Frequency) * _Amplitude;

    float3 modifiedTangent = posPlusTangent - modifiedPos;
    float3 modifiedBitangent = posPlusBitangent - modifiedPos;

    float3 modifiedNormal = cross(modifiedTangent, modifiedBitangent);
    data.normal = normalize(modifiedNormal);
    data.vertex = modifiedPos;
}```
the basic seems similar with the article you've posted (predicting the neighboring texel to calculate normal), but I think it's easier to understand (at least for me)
tight phoenix
# tacit parcel bashing the article writer wont do you any good, just saying... try this, it's w...

You are right. I called myself out shortly after - it made me feel better in the short term but ultimately the root of the problem was my own lack of ability, not their tutorial.
I will try out your code. I was trying to get access to the full data like vertexes in shadergraph but wasn't having much success in figuring out the syntax; I kept getting undeclared identifiers
Ill take a look at this tomorrow morning first this, its midnight atm for me

onyx cargo
#

i have a simple stencil shader with a stencil int parameter, but when i change it via script at runtime it doesn't work

#

mat.SetInt("Stencil", 1) doesn't throw any errors or anything but when i look at the object in the scene/inspector its still showing 0 for Stencil

neat hamlet
#

how does the stencil block look?

tacit parcel
neat hamlet
floral fox
#
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
            RenderTextureDescriptor descriptor = new RenderTextureDescriptor(source.width, source.height, source.format);

            RenderTexture normalDepthRT = RenderTexture.GetTemporary(descriptor);

            outlineCam.targetTexture = normalDepthRT;

            outlineCam.Render();

            Graphics.Blit(normalDepthRT, destination);

            RenderTexture.ReleaseTemporary(normalDepthRT);
    }

heres the code

opaque mist
opaque mist
#

I've made a toon shader using NedMakesGames' tutorial as a base (unlit shader), but discovered that objects, rather than casting a shadow on the object with the shader, acts as a light source and brightens up the object rather than casts a shadow. Is there a way to make objects using the same shader cast shadows onto each other?

onyx cargo
#

_StencilMask("Stencil", Int) = 0

#
Stencil {
 Ref [_StencilMask]
}
#

oh wait

neat hamlet
#

just to be sure, youre called SetInt on _StencilMask right

onyx cargo
#

i might be a dipshit

neat hamlet
#

not "stencil"

onyx cargo
#

yep 😅

#

thank you rubber ducky!

neat hamlet
#

😛

wraith wing
#

any idea how to create triangle checker on shader graph?, thank you

tight phoenix
#

In Shadergraph how can I access data.vertex like in a normal HLSL written shader?

#

Im tyrying to adapt hlsl code into a custom function node but I don't know how to send in all the things it needs, and google is not yielding answers

amber saffron
tight phoenix
wraith wing
#

already try using checker but the problem is I can't adjust the "gradient" for normal

regal ivy
#

It's easier if you manipulate UVs

#

imo

#

hold on

onyx cargo
#

so i'm using a stencil mask and stenciled shaders to make some impossible overlapping room

#

how can i make it so the blue cube 2 is occluded by the mask itself?

#

but i should still be able to see blue cube 1

#

bc its "in front" of the mask

tight phoenix
#

based on this it looks like frequency and amplitude is for their sine wave stuff

#

but I am not trying to do sine wave stuff

#

Luckily the tangent are already saved in the model data, so we can just use them. The bitangent isn’t, but we can calculate it easily by taking the cross product of the normal and the tangent (taking the cross product of two vectors returns a vector that’s orthogonal to both).

After we obtain the bitangent we create two new points that are almost at the vertex position, but slightly changed, and give them the same treatment we gave the original position.

With those positions we can now calculate the new normal of the surface. For that we calculate a new tangent and bitangent from the positions by subtracting the modified base surface position from the modified surface positions where we added the tangent/bitangent previously. And after obtaining the new tangent and bitangent, we can take their cross product to get the new normal which we then use.```
#

there description is saying how it works but my comprehension is not strong enough to make sense of it

regal ivy
tight phoenix
#

doing this the mesh just vanishes entirely 🤔

#

no values ive tried in freq or amp do anything visible

#

noise in either slot does nothing

#

the answer is right here in my hands but I'm not skilled enough to grasp it

#

I dont know what i am doing wrong or how to learn how to learn

sacred stratus
tight phoenix
#

hm reading the code they're doing SIN and I dont need sines so maybe I can edit that line

#

    float4 modifiedPos = position;
    //modifiedPos.y += sin(position.x * _Frequency) * _Amplitude;
    modifiedPos.y += noise;
    
    float3 posPlusTangent = position + tangent * 0.01;
    //posPlusTangent.y += sin(posPlusTangent.x * _Frequency) * _Amplitude;
    posPlusTangent.y += noise;

    float3 bitangent = cross(normal, tangent);
    float3 posPlusBitangent = position + bitangent * 0.01;
    //posPlusBitangent.y += sin(posPlusBitangent.x * _Frequency) * _Amplitude;
    posPlusBitangent.y += noise;

    float3 modifiedTangent = posPlusTangent - modifiedPos;
    float3 modifiedBitangent = posPlusBitangent - modifiedPos;

    float3 modifiedNormal = cross(modifiedTangent, modifiedBitangent);
    outNormal = normalize(modifiedNormal);
    outPosition = modifiedPos;```
#

in this code block, why might the meshes vanish?

#

I assume they vanished because they have been offset someplace very far away or shrunk extremely small or something

#

but I can't see why the code would be doing that

#

if I dont edit the vertex positions the mesh does not vanish but the normals look very wrong

amber saffron
tight phoenix
amber saffron
#

Then you have to re-think how you approach this.
The key point of the normal calculation method is to apply the same deformation to position, pos+tan, pos+bitan, and calculate the deformed normal from those.

tight phoenix
#

I am also starting to feel like at the end of this I am going to have the exact same nonfunctional version I had before, its starting to look more and more exactly like that set up and I've already seen that that set up doesnt work, which is concerning

#

this did not work and its looking exactly like this

amber saffron
#

Should work 🤷‍♂️
I've used it in the past and can confirm it works

tight phoenix
#

is the answer that its just not possible to deform vertex and recalculate the normals? because thats the dead end I keep being lead into

tight phoenix
#

the results I get are unusuable and unpredictable and do not match any of the examples

#

Ill try again from scratch but I am not optimistic

#

I will try to pass out the 3 modified values, and then use them on noises, and then pass that back into a new custom function to finish the output

tight phoenix
#

I split the code before and after the triangulated three positions to do the noise inbetween the making and the using

amber saffron
#

You should use Tangent + tangent cross normal (bitangent)

tight phoenix
# amber saffron Why are you using normal vector in tangent and object space ?

I have no idea, I was trying to interpret their code and no one told me I was wrong.

void vert(inout appdata_full data){
    float4 modifiedPos = data.vertex;
    modifiedPos.y += sin(data.vertex.x * _Frequency) * _Amplitude;
    
    float3 posPlusTangent = data.vertex + data.tangent * 0.01;
    posPlusTangent.y += sin(posPlusTangent.x * _Frequency) * _Amplitude;

    float3 bitangent = cross(data.normal, data.tangent);
    float3 posPlusBitangent = data.vertex + bitangent * 0.01;
    posPlusBitangent.y += sin(posPlusBitangent.x * _Frequency) * _Amplitude;

    float3 modifiedTangent = posPlusTangent - modifiedPos;
    float3 modifiedBitangent = posPlusBitangent - modifiedPos;

    float3 modifiedNormal = cross(modifiedTangent, modifiedBitangent);
    data.normal = normalize(modifiedNormal);
    data.vertex = modifiedPos;
}```

they appear to be using tangent and bitangent, is this not correct?
#

What should I be using if I should not be using tangent and bitangent?

amber saffron
tight phoenix
amber saffron
#

But this, is not a tangent

tight phoenix
#

I am trying to aproximate this and I dont know what data.vertex or data.normal is in shadergraph

amber saffron
#

There is a dedicated tangent vector node

tight phoenix
#

what is data.normal if not the normal vector in tangent space???

#

someone told me that data.vertex was object space position in shadergraph, what then is data.normal?

amber saffron
tight phoenix
#

making that change completely broke the normals, it looked correct before, are you sure?

amber saffron
#

I'm talking of the equivalent of data.tangent is **tangent **vector node

tight phoenix
tight phoenix
#

so its just conicidence that it looks right?

amber saffron
tight phoenix
#

another reason why debugging shaders is so painful, the only way to debug is to look at its appearance and its appearance can lie

tight phoenix
#

This is correct then?

amber saffron
#

yes 🙂

tight phoenix
#

This looks correct, is there a way I can determine if it is correct, beyond just looking at it with my eyes?

#

this being deformation of the vertexes and recalculation of the normals from the deformed positions

amber saffron
tight phoenix
#

debugging shaders is tough

dim yoke
# tight phoenix

Actually I just came up with one relatively easy way that could work. You can do normalize(cross(ddx(vertexPos), ddy(vertexY))) to find the normals calculated from the adjacent pixel position. By comparing those and the normals calculated by you, you can see whether you got it right. Because that way of using partial derivatives makes the normals flat shaded, you would be better to switch to a lot more subdivided mesh so it doesnt mess up the test

wraith wing
hallow socket
#

Hello, I have an issue where after the scene reloads, the shader/lighting is all screwed up. The only code I have for this is

{ UnityEngine.SceneManagement.SceneManager.LoadScene("Level 1"); }``` on the trigger object that the ball hits when it falls off the platform.
I'm an absolute beginner and am following a book on how to code this, and it doesn't say anything about this issue appearing/how to fix it.
https://gyazo.com/6f73f10709ed2b745c6c31788bc7052a
regal ivy
#

with fraction node, it keeps it always between 0 and 1 (each coordinate)

#

If I haven't tiled the fraction UV output, the preview results on the right would be all black

wraith wing
regal ivy
#

If you have difficulties with this, you can always watch BLENDER tutorials about Node Shaders. It's the same principle, different program and quite a few different nodes

#

they are very popular

wraith wing
wraith wing
worldly crater
#

Iam looking for some kind of shader to turn white graphics into blured edges and preferably in rectangle shape

I have this but i cant seem to find what iam looking for, tried googling but dont really know how to call it

#

i want to achieve glow behind this portrait, where green sprite is

#

something like this

late terrace
# worldly crater something like this

🌍 Bundle MASSIVE Discount 98% OFF! https://cmonkey.co/humblebundle
✅ Get FREE Assets https://assetstore.unity.com/?on_sale=true&aid=1101l96nj&pubref=unityglow
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games https://unitycodemonkey.com/gamebundl...

▶ Play video
worldly crater
regal ivy
regal ivy
late terrace
#

Anyone know how i can create a Unlit Graph?

#

It is not in the create option, i'm new to shaders so i don't really know where to look, but the tutorial showed it in the create menu

neat orchid
#

Why does my fresnel cover the entirety of the object even though it covers only the edges in the preview?

#

increasing or reducing power doesn't seem to do anything in that regard

regal ivy
#

Are you using normals correctly?

neat orchid
#

hm

#

I connected the normal map to the normal output 😄

#

I figured that was it

plain bluff
regal ivy
#

The reason it looks cloudy is because you are setting the transparent area not transparent anymore.

#

Also, MAYBE (I haven't tested it) you should also change the scale of the simple noise so it fits the pixel resolution or your sprite's resolution is too big for the texture.

royal hollow
#

Is it possible to affect point lights from inside of a shader graph? I'm trying to add a clamp to avoid oversaturation when players/enemies with point light effects stand near each other.

plain bluff
onyx cargo
#

selected is a portal mask with the stencil write shader with the mask set to 1... the red cube uses the stencil read shader with the mask set to 1, blue objects use the stencil read shader with the mask set to 0

#

how can i make the stencil mask portal show only stuff with the mask set to 1, but still show the floating blue cube where it overlaps, because it is in front of it?

gloomy gust
#

all my shaders seem to have been destroyed for some reason after switching to 2021.3.19f from 2021.3.18f

#

a shadergraph i had working in the last version didnt seem to work

#

how can I fix this isssue?

gloomy gust
#

fixed it , turns out it disabled my render pipeline asset so i added it again

leaden radish
#

is it possible to add 2 materials to one object?

#

like how to stack 2-3 effects on asset

regal ivy
leaden radish
#

I got like 2-3 shader graphs that create different effects

#

how about 2D sprites?

#

like if i want to make it glow and pixelate at same time

#

glow is one shader graph another is another graph

#

oh well i don't like drawing pixel so i just add a pixel shader to it lol and say to those pixel lovers here is ur pixel art

regal ivy
late terrace
#

still can't find the Unlit graph

desert orbit
#

@late terrace If you are following their tutorial, make sure you have the same Unity version and pipeline installed to see the same features.

#

!ban 718852952684625959 Scam

echo moatBOT
#

dynoSuccess REDHOOD#1627 was banned

late terrace
#

But does that mean they removed the Unlit Graph?

#

I'm sorry for all the question, i'm very new to shaders

desert orbit
#

For example, this is how 2022 looks like.

#

Make sure you have URP installed

late terrace
#

oh

#

I was only told to install shader graph package, ty : )))

desert orbit
#

And shadergraph support for built-in pipeline is only on latest versions.

late terrace
gloomy gust
#

why does sprite default not get affected by shadows, but my one does?

desert orbit
#

If you want it to be unaffected by shadows and light use unlit shader

south acorn
#

Is there an equivalent to mathf.pinpong in the shadergraph? Trying to make something like the flashing of a gmod error

gloomy gust
desert orbit
#

In unlit shader you correct brightness yourself. So apply darker tint to match

gloomy gust
desert orbit
#

If it's a completely custom shader you have to introduce another color and mix it in. Lookup how to tint colors in shadergraph.

#

or use default unlit and use its tint

desert orbit
south acorn
#

I did try Sin but its not exactly what I'm looking for

desert orbit
#

You'll have to be more specific then

gloomy gust
desert orbit
#

You still need a tint color for the non-outline part

#

You just multiply color property and it will be a tint color

gloomy gust
#

i do need the door to be affected by shadows, but i want the outline to be unaffeeced

desert orbit
#

Should have started with that then

gloomy gust
#

sorry 😅

desert orbit
#

Don't think it's possible. You might push very bright or dark color on your outline to overwhelm any shadow or light. Apart from that use separate unlit material on top as an outline

desert orbit
#

well yes, draw outline material on top. Depending on how you have things setup. position in the world of make it priority layer or render order.

keen kraken
#

sooooooooo I have a shadergraph a buddy made for me (I have no idea how shaders do the thing) anyway, How can i use it in the project, I importet it, tried creating different shaders but i didnt see that i can put it in somewhere or how

desert orbit
#

consider other objects interaction if they also have own outline materials so they won't conflics

gloomy gust
desert orbit
keen kraken
#

cant

#

just shows me the nono symbol

#

its still in this shape

desert orbit
#

You need shadergraph and appropriate pipeline installed

keen kraken
#

. . . okay then, gonna look that up, thanks

#

as data i only have this and the meta

desert orbit
snow forge
#

Hi all,

I'm having a bit of a brain issue.

I have this graph and everything is working great (dissolve shader), what I'm trying to do now is 'overlay' a colour 'on top' of the base rock texture (to make it look like the rock has ore). Using a colour at the moment but will eventually use a texture.

I'm a bit stuck on what node(s) to use to mix the two, I've tried multiplying/adding/blending but none seem to work (the base rock texture gets covered up by the black)

keen kraken
#

I made it grow up, graph is still empty

regal stag
regal stag
keen kraken
#

installed all of them

#

from what i saw in packages

#

lightweight made it big, that was it

snow forge
#

@regal stag Ah thanks. I always seem to have a weird blind spot with the lerp node. lol.

onyx cargo
#

is there a way to make a stencil mask doesn't always render "in front"?

keen kraken
#

the solution was: the unity versions didnt match up

#

the shader was too new

maiden leaf
#

What do I need to change to make the black background transparent? The png for this sprite has a transparent background, not sure why it's black in this Shader Graph. This is a Shader Graph -> URP -> Sprite Unlit Shader Graph

grizzled bolt
dark forge
#

So I have two custom functions, which both work independently

#

it basically does the same thing but with different math

#

when I try and attach both to any node

#

it spits out an error

#

I just want to use an enum to switch between them, the add node is just there for demonstration

#

I can't seem to figure out why

#

I doubt anyone can give me an answer since there isn't a lot of information, but can anyone give me some hints on where to start looking?

thin bear
#

I'm new to GPU syntax. This should be a simple question;
For a line such as
o.uv = v.uv;
How do I mess with just the u component and leave the v component untouched. Eg.
o.uv = (0.5, v.v);
That's what I assumed would work, but it doesn't like "v.v".

thin bear
#

Finally figured it out.
o.uv[0] = 0.5

simple violet
#

does making shader graph shaders cause long build times?

#

whenever i make a build i see a compiling shader variants and it can take hours

#

my project isn't even very big

#

i only have 6 shader graph shaders

prime shale
#

o.uv.y

#

to mess with a specific component you just use xyz

#

o.uv.x = 0; //modifying the u component

#

@thin bear

thin bear
#

I see how it's supposed to go now

#

In "o.uv.x", UV is the whole uv structure, and .x is one component of it

karmic hatch
#

(which you choose is up to you, it's a matter of preference)

thin bear
opaque mist
snow forge
#

So very nearly done with this shader and getting it to do exactly what I need it to do but I was wondering if anyone had any suggestions on how to make it look better. ie, a better way to blend/integrate the 'ore' texture onto the base asteroid rock texture without it looking like it's just painted differently. Having a bit of a brain block on ideas.

lunar valley
snow forge
#

@lunar valley Aaw shucks. lol. Thanks. 🙂 I am quite happy with it, but the harsh edges on the ore bother me. lol.

meager pelican
snow forge
#

@meager pelican Single Material. HDRP.

#

1 sec......going to record a vid of it 'working'

meager pelican
#

OK, maybe check into DDXY. Track the change in color and MAYBE you can figure something.

Two textures? (I'm not up to speed here, and have to bail out soon, but somehow you need to track the changes).

#

Because that's what you want to change. You don't want an abrupt change of color.

#

GTG, have fun (looks good!)

snow forge
#

There ya go, test vid of what I'm trying to do. 🙂

#

There is a weird transparency thing going on when it's supposed to be fully opaque which I need to fix, but I think I know what that is.

lunar valley
snow forge
#

Yeah one shader.

#

one sec, let me stitch a few screen grabs together.

#

It's a little messy tbh, but top half deals with the actual texturing side of things, and the bottom half is the dissolve stuff.

lunar valley
# snow forge

The quality is really bad so I am guessing what all of the nodes are but If you wouldn't be pluging the noise into the step function you would a have a lot smoother fallof

snow forge
#

Quality's bad? How so? Looks fine here full size.

bold citrus
#

not really sure where this would go, but in unity this is happening to my sprites

#

they appear to have blue on some of the pixels

lunar valley
snow forge
#

@lunar valley Open in Browser and zoom in?

lunar valley
#

im on phone, and when I zoom its very pixelated so I can't read it but as I said its whatever

snow forge
#

aah okay.

#

But yeah with the step node, if I don't do that it kinda covers the whole asteroid with the ore colour 😕

#

sokay, I'll live with it for now. It works, that's all that matters. lol. Plenty more to do on other things 🙂

lunar valley
grizzled bolt
white cypress
lunar valley
#

I thought this worked like in whatsapp where the pictures are automatically decompressed and downloaded

potent ice
#

Hello people. So, I have 3 images I want to use as a background / skybox. A pretty nebula, without stars, an image with a transparent background and lots of small stars and an image with a transparent background and a few large stars.
I want to have the nebula at the back, with the small and big stars layered on top, and offset the star images by different values to simulate parallax. Now, my game is like a 2D game with 3D rendering. Top down view, movement constrained to a plane, etc.
The camera is not orthographic because there will still be movement on the Z axis, mostly rotations, and some environment objects might still move "front and back" as a sort of puzzle mechanic.
I'm using HDRP.
My images are square, they tile, but they aren't skewed for a regular cubemap.
I can imagine two ways to do it.
Either making a custom shader (maybe as a graph ?) to render the nebula and stars and have the stars offset depending on a parameter, OR
simply have a large plane that's far away enough that it doesn't clip with anything else (or give it a shader with an order of -1 to render it before anything else ?) and parent it to the camera.
Which approach would be the best ? If there's a 3rd option that's better, please mention it.
Depending on the choosen approach, could you help me set it up ? (All of that is highly theoretical and I'm not sure how to implement things like custom shaders)

lunar valley
potent ice
#

Yeah, that was my plan, to use a script to move the stars. I'm not sure if I should try and setup a shader graph and a cubemap for the skybox or just create 3 basic planes and move the transform.position of the stars...

regal stag
snow forge
#

@regal stag aaah, interesting. Will give that a go, thank you 🙂 ((Still learning all the nodes. lol.))

lunar valley
snow forge
#

@lunar valley lol. Sometimes my brain turns to mush and I turn into a turnip. Especially today (dealing with Fluid Dynamics for work) lol.

frank sonnet
#
Shader "Custom/Shader_Skybox" {
   
    #include "UnityCG.cginc"
    
    Properties{
        _InvProjMatrix("Inverse Projection Matrix", Matrix4x4) = "unity_CameraInvProjection"
        _WorldSpaceCameraPos("Camera Position", Vector) = "unity_CameraWorldPos"
        _Cube("Skybox Cube Texture", Cube) = "" {}
    }

        // Eingabevariablen
    float4 screenPos;

    // Berechnet den View Ray für ein gegebenes Pixel im Bildschirmkoordinatensystem 
    float3 ComputeViewRay(float4 screenPos)
    {
        float4 ndcPos = float4(screenPos.xy * 2.0 - 1.0, 1.0, 1.0);
        float4 worldPos = mul(_InvProjMatrix, ndcPos);
        worldPos /= worldPos.w;
        float3 viewDir = normalize(worldPos.xyz - _WorldSpaceCameraPos);
        return viewDir;
    }

    // Ausgabevariablen
    fixed4 frag(v2f i) : SV_Target
    {
        // View Ray berechnen
        float3 viewDir = ComputeViewRay(screenPos);

        // Farbwert des Pixels aus der Skybox-Textur auslesen
        fixed4 color = texCUBE(_Cube, viewDir);
        return color;
    }
}

can someone tell me what my problem her is? because i just include a header there. its standard lib for unity right?

regal stag
frank sonnet
#

thank you

muted pond
#

How can I allow backface culling? I heard I need to create a new shader (best to copy from Standard) and apply it via code. However I have no real idea how to do that quickly

tight phoenix
#

I have nodes that make a hex grid and nodes that return a random color based on the object's position, but I would like to combine them so that every hex cell has a random color

#

I know that what I need is for every cell to be exactly one value across the entire cell, but I am not sure how to get that from what I have

#

if there is any variance in value then the randomize will randomize the color for every individual pixel which is not what I want

#

this is the end result I am trying to get - this person however every single hexagon is an individual game object, in my use case its one single flat plane

#

its easy to do if it were individual game objects like that, but since I have a flat plane I need to adapt it for that but am not sure how 🤔

#

I do have the SDF of one single hexagon but I am not sure if that approach solves what my current grid can't do 🤔

snow forge
#

@tight phoenix How are you generating the colours currently? Can we see the far left nodes fully (the ones that feed into the Hex Lines Group)

tight phoenix
#

short version: UV coordinates are spun and fractioned and other maths to shape them into hexes

snow forge
#

Okay, well bare in mind that I'm still learning this stuff myself, so I may be way off. But I think in the 'BGR Repeating Grid' is where the colours are getting defined, I'm not entire sure how to go about it, but I would think that you need some sort of randomisation of colours maybe after the last Power node in that Group would be needed before feeding into the Initial Grid group?

#

Looking at it, I'm not really sure how to get rid of the repeating pattern though. 😕

tight phoenix
#

If it were game objects I would pump the game object's position into a randomizing function and return that to adjust its color

#

but since its a texture not objects, I would need every hex cell to be filled with a single value to do the same

#

but I can't figure out the math to procedurally build a hexagonal tiling pattern filled with all a single value

#

in the circled step here it will have made a tiling pattern of rhombuses that are filled with a solid value of 0, 1, 2, etc as it moves off into the UV distance

#

but I am not sure how to then turn that into hexagons while retaining its behaviour 🤔

#

thinking visually, I need to map the U and V gradients into hexagons somehow and then combine them as the input into the random color node I have

#

but like, do it right and with math, thats just an example sketch drawn badly

dim yoke
tight phoenix
frosty cedar
#

guys can anyone explain me something, i wanted to make this leaves of the tree fade out the transparency when the tree comes close to the camera, what is a good way of achieving this effect?

fresh osprey
#

Is there a way to completely turn the environment black and just turn one mesh white

#

Much like this

#

I kinda wanna add this effect when i slash some enemy

fresh osprey
#

Can you help me out a bit

#

i am kinda new to shaders

tacit parcel
#

some way I can think of
A. using camera replacement shader to override the person shader (to white) and the rest to black (easier in built-in pipeline, gives headache in urp)
B. using camera culling layer to exclude the background from the player, then shade the character white
C. using stencil, again, it will be more elaborate if you are using urp

the easiest way to shade the character white is using emission channel

fresh osprey
#

alr

#

Thx

sacred stratus
#

Properties
{
_MainTex ("Texture", 2D) = "white" {}
_MyFloatArray ("My Float Array", Float[]) = 1 2 3 4 5
}
//

uniform float _MyFloatArray[];

Can somoene help me find the correct syntax for this, I'm inside a unlit shader, so I can't use computebuffers.

vocal narwhal
sacred stratus
#

I don't want to predeclare it, I want an array that I can set trough the material

vocal narwhal
#

You don't need to put it in the Properties section

#

the properties block is for the inspector

sacred stratus
#

oh

vocal narwhal
#

and you won't be able to use the inspector, you will have to use code

sacred stratus
#

so just this will work?
uniform float _MyFloatArray[];

vocal narwhal
#

I'm pretty sure you have to declare the length:
float _MyFloatArray[5]

sacred stratus
#

can the length be a variable?

vocal narwhal
#

The length is fixed

#

but you could choose to make it a max amount and only use part of it based on a variable

sacred stratus
#
Property (VectorGraphicMaterial) exceeds previous array size (206 vs 4). Cap to previous size. Restart Unity to recreate the arrays.
UnityEngine.Material:SetFloatArray (string,System.Collections.Generic.List`1<single>)

This means that I have to predefine the size?

meager pelican
sacred stratus
#

oh you can use a compute buffer on unlit shader?

meager pelican
#

Yes. It's just a buffer, nothing to do with lighting.

vocal narwhal
#

You can declare buffers in any shader, it's a tool like anything else

meager pelican
#

Unless you code it to impact lighting, that is.

vocal narwhal
#

The only thing is whether or not you have a compute compatible platform, which excludes low-end mobile

#

The workaround for that is generally to just use a texture

sacred stratus
#

yes I did that before, but it's kind of a pain in the ass using a texture for storing data

meager pelican
sacred stratus
#

seems as not even my onboard graphics card supports it

#

so using a texture as a stroage is gonna be my best choice?

shadow kraken
#

I have a very basic shader in BIRP that is used as a sort of always on top shader. When applied by default it just renders unlit white. When I transfer it to URP, it doesn't give any errors, but objects render fully transparent. Would anyone have an idea if some of this isn't supported in URP?

SubShader
    {
        Pass
        {
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite Off
            ZTest Always
            Cull Off
            Fog { Mode Off }
            
            BindChannels 
            {
                Bind "vertex", vertex
                Bind "color", color
            }
        }
    }
#

The Bind syntax I'm not familiar with so that might be it

#

Alternatively help me decode this. Is the shader just using some shortcuts to set up a vert shader pulling the vertex color and applying it directly?

#

Actually it does render but only when there's another object overlapping with it 🤔

shadow kraken
#

If I remove ZWrite Off then it behaves like in BIRP... So I guess this behaviour is different in URP

regal stag
# shadow kraken Actually it *does* render but only when there's another object overlapping with ...

Not sure why it acts differently in built-in but to clarify, what's probably happening here is the skybox is rendered after the opaque queue, and because the sphere doesn't write to the depth buffer the skybox renders over it.
So would need ZWrite to be On, or specify Tags{"Queue"="Transparent"} so it's rendered after the skybox. (I imagine it would also need to be in the transparent queue to make Blend work correctly)

shadow kraken
#

That makes a lot of sense. Setting it to transparent queue fixed it. Thank you so much for explaining

swift loom
#

Are there any differences between Vulkan and DX11 when it comes to either structured compute buffer access or SampleLevel in compute shaders?? I have an issue where my shader will either have something written to it incorrectly or it reads something incorrectly and I can't quite figure out what. It works perfectly in Vulkan but it's broken in DX11.
The only thing that I could even think of was whether there's some difference between how either handles clamped samplers. I typically have to do -0.01 on the texture size division as I sample a texture or it will return an incorrect value.

#

second half is DX11

#

or maybe the async write is causing data loss?? but would that matter for a compute shader? maybe i should switch to another buffer write mode

swift loom
#

also has BeginBufferWrite been removed? It's listed as an option for dynamic buffers but it doesn't seem to exist

#

It works in DX12 it seems but not DX11.

frank sonnet
#

how do i create a skybox in unity trough rastarization do i have to program something in shader?

grizzled bolt
frank sonnet
#

i hope thats clear what i mean

grizzled bolt
#

Rays?

frank sonnet
#

like light rays

frank sonnet
#
Shader "Custom/Skybox6" {
    Properties{
        _FrontTex("Front Texture", Cube) = "white" {}
        _BackTex("Back Texture", Cube) = "white" {}
        _LeftTex("Left Texture", Cube) = "white" {}
        _RightTex("Right Texture", Cube) = "white" {}
        _UpTex("Up Texture", Cube) = "white" {}
        _DownTex("Down Texture", Cube) = "white" {}
    }

        SubShader{
            Tags { "RenderType" = "Opaque" }
            CGPROGRAM
            #pragma surface surf Lambert

            samplerCUBE _FrontTex;
            samplerCUBE _BackTex;
            samplerCUBE _LeftTex;
            samplerCUBE _RightTex;
            samplerCUBE _UpTex;
            samplerCUBE _DownTex;

            struct Input {
                float3 worldPos;
            };

            void surf(Input IN, inout SurfaceOutput o) {
                float4 frontColor = texCUBE(_FrontTex, IN.worldPos);
                float4 backColor = texCUBE(_BackTex, IN.worldPos);
                float4 leftColor = texCUBE(_LeftTex, IN.worldPos);
                float4 rightColor = texCUBE(_RightTex, IN.worldPos);
                float4 upColor = texCUBE(_UpTex, IN.worldPos);
                float4 downColor = texCUBE(_DownTex, IN.worldPos);
                float4 finalColor = (frontColor + backColor + leftColor + rightColor + upColor + downColor) / 6.0;
                o.Albedo = finalColor.rgb;
                o.Alpha = finalColor.a;
            }
            ENDCG
    }

        FallBack "Skybox/Cubemap"
}

do someone know what i have done wrong? because i dont get any errors and i cant put any pictures in the inspector window

amber saffron
frank sonnet
amber saffron
frank sonnet
#

ok i changed it to 2D thx

royal hollow
#

Howdy folks. I've been learning the ShaderGraph to make fun effects for my 2D game, but haven't discovered if there is a way to modify the impact of how URP point lights interact with the materials. Specifically I'd like to put a clamp on how much they combine, to prevent oversaturation during events when multiple lights overlap in the scene. Just wondering if anyone has a moment to help me understand if what I want to do is feasible?

frigid anchor
#

since updating to 2022 unity render target handle is now switched to rtHandle but my friend getting errors in
Blit(commandBuffer, source, tempRenderTargetHandle.Identifier(), material);

the "tempRenderTargetHandle" no longer have an .Identifier() to it

what is the switch to make it work

regal stag
swift loom
#

Why can't I manage to write data to a dynamic compute buffer with .SetData when BeginWrite works just fine with a SubUpdate buffer? Is SetData more finnicky about "blittable types"? I have a struct with 3 uints in it which works fine with BeginWrite.

I tried both a normal type array and a native array but neither works.

frigid anchor
#

in the shader "source" is a RenderTargetIdentifier

swift loom
regal stag
dire ravine
#

Is it possible to add a shader to a light 2D?

tropic crow
#

Hello!
I am trying to make some portal stuff using URP, Render Features and Stencil buffer, and I have a question:
On image 1, the portal is functioning correctly, displaying the blue cylinder correctly, since it is after the portal.
On image 2, the cylinder is between the camera and the portal, and yet, with the cylinder being rendered after the stencil, it still shown within the portal.
Do you have any Idea what I could try? Thanks!

#

(Image 2 but without the stencil effect for more clarity)

swift loom
#

So it has to be Immutable I guess??

#

why doesn't dynamic work??

amber hollow
regal stag
# tropic crow Hello! I am trying to make some portal stuff using URP, Render Features and Sten...

^ to somewhat add to the above. If I understand the problem correctly using a render texture would have the same problem.

But one advantage of that method is that you can edit the projection matrix of that second camera to be oblique, meaning it's near clip plane can be at the portal plane and any objects infront of the portal are clipped. If you don't want to use a second camera, might still be able to edit the projection matrix in a custom renderer feature (and reset it after rendering the portal objects).

An alternative could be writing a shader that adds a clipping plane. e.g. https://www.ronja-tutorials.com/post/021-plane-clipping/ (will need to translate to URP / shader graph). But means every object needs to use that.

tropic crow
lunar valley
dire ravine
#

I'm talking about a SpriteLight2D

#

like, apply a shader to that lights sprite

cobalt totem
#

I'm thinking there may be a way to optimise my shader code: I'm rendering a tornado funnel (essentially a curved cone) and using a 3D noise texture to vary the density and shape of the cone. I'm thinking a 3D texture may be overkill, and there may be a way to combine multiple 2D textures?

float3 samplePos1 = float3(samplePos.x, samplePos.y, 0);
float3 samplePos2 = float3(samplePos.z, samplePos.y, 0.5);
float3 samplePos3 = float3(samplePos.x, samplePos.z, 0.9);

float4 rawSample1 = _shapeTex.Sample(sampler_shapeTex, samplePos1);
float4 rawSample2 = _shapeTex.Sample(sampler_shapeTex, samplePos2);
float4 rawSample3 = _shapeTex.Sample(sampler_shapeTex, samplePos3);

float4 rawSample = rawSample1 * 0.333 + rawSample2 * 0.333 + rawSample3 * 0.333;
float shapeOffset = dot(float3(rawSample.x, rawSample.y, rawSample.z), float3(shapeCoefs.x, shapeCoefs.y, shapeCoefs.z));              
#

This sort of works but at certain angles you can see the repetition in the pattern

edgy glen
#

Hello dear ShaderMakers, i'm a total noob in this matter !
I have a flying enemy with wings that render fine with the standard double sided shader.
For rendering and optimizing purpose, I have a custom shader that is based on the standard shader and the cutout effect works fine. Except i needed it to be like the standart double sided, because only one side of the wings is rendered. Can you help me ?

grizzled bolt
dire ravine
#

Is it possible to apply a shader to the texture of a SpriteLight2D?

worldly karma
#

noob question: how do i stop background sprites from being rendered in front of foreground sprites

#

i'm not using sprite renderer. i'm using mesh renderer

worldly karma
#

Pls help

#

I'm crying

worldly karma
#

I'm dying

worldly karma
#

nvm i figured it out. hell yeah

#

i enabled material overrides in the shader and set the surface type to opaque in the surface options. then i disabled alpha clipping

ember scaffold
#

So I'm trying to make a tree and followed a tutorial

#

Multiplying the alpha input with a float doesn't make it transparent and completely ruins the whole thing, how would I fix this?

meager pelican
# ember scaffold Multiplying the alpha input with a float doesn't make it transparent and complet...

You're not "multiplying the alpha input with a float", you're outputting alpha directly to the alpha value at the fragment stage. And it looks like you're using alpha clipping with a threshold of 0.5, a good thing. If your alpha values in your texture are correct, the black areas will be clipped.
And from the image you've shown, it looks like they ARE clipped.

So I don't understand. That's a nice looking tree so far, BTW.

#

There's some slight black around the edges. Might be due to how you're sampling the texture, or some blurring/anti-aliasing going on somewhere.

ember scaffold
#

What I need is for the entire leaf section to appear more transparent than it already is, while keeping everything else intact including the clipping, color shade, and whatnot.

meager pelican
# ember scaffold What I need is for the entire leaf section to appear more transparent than it al...

ENTIRE leaf transparent? Like cellophane leaves?
OK, well, that's different. Alpha clipped shaders are generally done in the opaque queue, and I suspect that's what's going on here.

Try moving to the transparent queue.
But if you do that, you may have to do a discard/clip operation in your shader if there's nodes for it. Testing the value of the alpha against some threshold. Or do a conditional that sets alpha to zero for the pixels you're excluding.

ember scaffold
meager pelican
#

Well, you might be talking about an entirely different effect...distance-to-player screen space dithering.
you want to know what is between the camera and the player, and dither it/fade-it out somehow, depending on how you want it to look.

meager pelican
# ember scaffold You know, so you can see through the leaves when the player walks beneath them

A follow up to the previous tutorial, I show you how to use dithering in Shader Graph to fade out meshes when they are close to the camera.

Previous Tutorial
https://youtu.be/iTlSwQ4b-uM

(づ ̄ ³ ̄)づ ~(˘▾˘~)

TWITCH ( ͡° ͜ʖ ͡°)
https://www.twitch.tv/PabloMakes

TWITTER (ಥ﹏ಥ)
https://twitter.com/PabloMakes

₪ ₪ Time Stamps ₪ ₪
00:00 - Int...

▶ Play video
sacred stratus
#

I created this texture.

Texture2D myDataTexture = new Texture2D(count,1,TextureFormat.RGFloat,false);

When I upload it to a shader, it seems to have negative values when being read in following manner

//Inside the shader
float2 pointA = tex2D(Points_t, index2).xy*32768;

Does someone have a clue, why this is happening?

toxic ore
#

I have used a shader to make this card design. Initially I put it on a Sprite Renderer and it worked fine but now I switched to an Image because I want to keep the cards as canvas elements. However, instead of being transparent on the sides, it is showing as black. What can I do to make it transparent?

#

What type of material do canvas elements use? Currently the shader for the card is set to Sprite Custom Lit

#

Or does this not have to do with the shader but with the canvas settings?

thin crater
#

Hi! After a lot of time I created a toon shader based on many tutorials and articles online. The shader perform as expected on everything, but it doesn't work correctly mixing the main light and additional lights. Here's what happens:

#

When I turn on the light (as in this campfire) the light changes the color of the objects too much, and it also sets them black if the intensity is low.

#

As you can see from a very low intensity light, the color almost turns black.

#

I figured out that there had to me some multiplication between the lights in the shader, and I found it:

#

But turning that multiplication into an "Add" function doesn't fix the black light. It fixes the color (the orange light only adds a bit of orange to the objects) but when light intensity is low, the light is still black.

#

Any clue on how to fix it? The shader is also pretty big and I don't know if sharing it all can be helpful.

thin crater
sacred stratus
#
Pass
{
StructuredBuffer<float2> Points_b : register(t0);



}
C#
{
        ComputeBuffer buffer = new ComputeBuffer(count,sizeof(float)*2);
        buffer.SetData(data);
        
        VectorGraphicMaterial.SetBuffer(name+"_b",buffer);

}
//Does someone see why all the values in the shader are then equal to (0,0)
ember scaffold
meager pelican
lyric vortex
#

Hello I'm trying to use this https://github.com/fuqunaga/MirrorReflection to create a plane acting as a mirror. But it is not compatible with URP so I'm trying to use the same script that builds a reflexion texture, and create my own shader graph that renders this texture to my plane.
It doesn't work, nothing is rendered. I supposed that the built texture is available from the shader graph from a _ReflectionTex variable but maybe it is wrong. Could you please tell me what is the problem ? Here is my shader graph:

meager pelican
#

I meant C# debugger.
But yes, shader debuggers exist. Research PIX (DX12) and Visual Studio (DX11) and also see the options for vendor-specific debugging tools for your particular make/model of GPU. The vendor tools are the most painful to get set up and use, but also the most powerful for analysis/debugging.
See also: https://docs.unity3d.com/Manual/SL-DebuggingD3D11ShadersWithVS.html

south granite
#

Hey, I have problem when building the game. It throws error about Nature Renderer Shader?
How can I solve this? what can be the problem.

#

It worked perfectly fine, but now I cannot build the game

#

When I click on the error message on console:

prime tusk
#

Hey, I have some code that uses graphics.drawneshnow and a lot of GL.Vertex etc. I’m using the unlit color shader and setting the color property and calling setpass to change the color. I think setpass is causing a little extra overhead but I can’t figure out how to use gl.color instead. What does the shader need to look like for gl.color to work?

prime tusk
#

Hmm, I’ve used BindChannels in my shader and it works when drawing lines directly, but not with Graohics.DrawMeshNow

tulip heath
#

Hi! I'm trying to make a shader to pixelize my 3D player, but not the environment, because that's already pixel art. How would I do this with shader graph? Everything I've seen keeps applying to the whole screen or it just isn't viable.. I'm relatively new to shaders so please enlighten me! :D thank you!

dim yoke
tulip heath
#

how would i do that, keep the alpha of the background, and then place it exactly where the player is supposed to be on screen?

#

I tried something like that but it kept the background instead of having transparency, and I also couldn't figure out how to make the pixelized version appear where the player is normally on screen.

dim yoke
tulip heath
#

Alright.. But how would I get the camera to output the render texture with a transparent BG?

#

Currently it is just black

#

aha! apparently post processing makes it keep the background for some reason!

#

Thank you!

hazy sage
#

Hey everyone! I was wondering if anyone knew how I could make an outline for sprites with bones in 2D, I searched online but can only find something that would work with a sprite changing shape

#

Bonus point if you know how I could make it pixel perfect

tulip heath
#

Theres some good shaders on the asset store @hazy sage

#

Ive seen some good free ones before

hazy sage
#

What do I have to search for exactly?

tulip heath
#

pixel outline is what i would try

hazy sage
#

None are free, only one is an actual outline, and it only works with "fixed" sprites

tame topaz
#

The All-In-One sprite shader on the store has outline support, among a ton of other useful sprite effects.

shy onyx
#

If I wanted to create this type of effect where the wall disappears between the player and the character. Is a shader the right way to do this?

fallow plume
#

Is there a Texture Format which has 3 channels which can store floats?
I'm looking through this list, https://docs.unity3d.com/ScriptReference/TextureFormat.html
and there's 'RFloat' , 'RGFloat' , 'RGBAFloat' but no RGBFloat
There is a RGB9e5Float, but I am not sure it's what I want (I'm new to shaders)
Is there such a format available?

prime tusk
regal stag
regal stag
shy onyx
# regal stag In this specific case, as the walls are very jagged I'd say probably not. They'r...

Thanks. I'll see what I can do with that. In my head I thought it would be easy to make that effect were I could have a wall and then have a shape that would "cut out" the wall almost like a boolean effect in blender as I rotated the camera around the room. But its turned into a few days of trial and error with not much progress. I looked at stencil buffers and a couple "transparent shader" tutorials but nothing has really giving me this effect. I should just make the whole scene with a static camera and just have a cut out like in the game.

spring niche
#

Hey artists,
Is there a way to make a shader that apply a overlay texture on top of everything it collide with, I want to make some kind of growing moisture for my game but I searched for hours and don't seems to find something

Thank you !

dusky trellis
#

Guys

#

i need help , im porting a bunch of shaders to unity from shadertoy

#

there's this one, that when i do this

#

i want to make it show , regardless of what distance is

#

or increase the distance

dim yoke
dusky trellis
#

this is the shader

#

i want to navigate thru with VR

#

but to do that, i have to fix this render issue that it hides when you go high

#

i found where the flaw is, render , but removing it bugs everything lol

#

@dim yoke
i can send my conversion so far in dms so you can check it out

grizzled bolt
dusky trellis
#

yeah, im a newbie with this stuff

#

sorry

#

i also got a few shaders that i want to be able to walk around, and not get a static animated shader

dusky trellis
#

can somebody teach me how to fix these shaders?

grizzled bolt
barren fox
#

hey, could anyone help me with changing the color of the texture? im trying to combine the color property with the sample texture 2d but it doesnt work because it reverts to white in the add node. How do I change the color of the sample texture 2d or fix this in general? Please have patience with me as Im very new to shaders

prime shale
#

Im assuming perhaps mabye you want to modify the texture by "multiplying" it by a color instead of adding a color like you currently are doing?

#

and in that case, just swap that add node for a multiply one

barren fox
#

works! thank you very much

quiet silo
#

anyone know why there isnt a consume buffer type?

#

am I missing something

plucky flare
plucky flare
edgy glen
grizzled bolt
edgy glen
regal stag
quiet silo
#

yeah also just found that

#

ty

tight phoenix
#

I am doing vertex deformation and then normal recalculation and I am experiencing an issue that I am not 100% sure what the cause or sollution is

#

as pictured, object surface vector is black on that side edge, but green on the deformed height bit

#

as far as I am aware that back part should be the same color yeah?

#

visualizing it from other angles, it feels like too much of the original flat surface color is being used maybe?

#

but I am not sure 100% where the problem occurs or how to fix it because this normal recalculation is a massive ammount of code and nodes to achieve, all of which I was given rather than coded myself

edgy glen
tight phoenix
#

yeah its not just the lighting

#

HM when the noise is a smaller scale, its only happening at the edges

#

the inner parts are dark as should be expected

#

so I must be doing something wrong with how I tried to naievely not use this effect at the edges

#

the mask I am using to only deform the verts I want (lightened to show verts)

#

I am just lerping between the calculated bit and what it normally was, but that clearly isnt doing what I think it should do or what I want it to do

edgy glen
# tight phoenix

Seeing this i see no bug, colors repartition match the normals i see. I have a problem (because of english maybe) to understand what do you want to achieve here : you want the edges t be what color ?

tight phoenix
#

the inner part looks right but compare the inner part to the outer edge, the specular is all janked up

#

thats what im trying to fix, and to fix that I must fix the normals, and the normals are what I was visualizing in color

regal stag
tight phoenix
#

I need the outer area to smoothly transition to flat so that it doesnt create a ram-rod straight edge vert wall

#

the more we discuss it the more I think I am using my mask wrong in some way

regal stag
#

I'm not sure if it's "wrong" using the lerp, but you could try multiplying the mask with the amount of displacement instead (I guess noise1, noise2 and noise3 in this case)

tight phoenix
#

no mask showcases the problem I am trying to solve

#

besides that it also affects the outer polygons, but it also creates openings, and I don't want vertical walls anyways so its not just a matter of fillling the gap

tight phoenix
#

what is pictured above is doing that, that was the first sollution I tried, getting rid of the Lerp and multiplying the noise by the mask

regal stag
#

That's odd, because it looks like it's still being displaced there

tight phoenix
regal stag
#

The vertex positions I mean. Displacement is usually something along the lines of vertexPos + float3(0, height, 0)
If the mask contains values of 0 on the outer edges, then height * mask would produce 0 for those edges and there shouldn't be any displacement

tight phoenix
#

if you are refering to this image, this was the image with no mask

#

I don't think I am communicating what I mean or understanding what you mean well

#

here is the mask applied Step not Smoothstep

#

the back part should be black but its not black because its recalculating the noise at that spot as if the noise is continuing and not clamped off like I am doing 🤔

#

and me lerping with the 'actual' normal is the flat upper face green normal 🤔

#

and not the black normal that it should be recalculated into

#

I think im starting to see why its wrong but I am not seeing how to fix it

#

the mask must come much earlier, but where

#

doing the mask immediatlely after the noise pattern should be the answer???? but that didnt work, it made no difference

regal stag
# tight phoenix

The mask currently is going into these Hex Terrain Noise Calculation subgraphs. Is it being used there?

tight phoenix
#

not currently because I took it out to debug why it wasnt working, I will re-add it to where it was, which was multiplying the noise

tight phoenix
#

the mask was multiplied after the last step before going into the calculator

#

Mask being multiplied into immediately after the noise

#

I fear I am just too stupid to play telephone like this, you are so skilled that if I just link you the graph you could find what I am doing wrong in 10 seconds flat 🔥

#

but that doesnt help me grow and learn and not make the mistake in the future

regal stag
#

I'm not so sure, I'm a bit stumped too 😅

tight phoenix
#

the answer is going to be that im a stupid idiot who assumed something somewhere, assumed wrong, and ruined it

#

Sorry getting frustrated, will keep my language neutral

#

the shader as is is currently hacked to piece because im desperately trying to debug it

#

this is not the X or the Y or the Z this is like 15 steps removed from what im ACTUALLY trying to fix and do

#

but I cannot get to any of the things I ACTUALLY want to be doing because every single fundamental thing is completely #$@#^@ broken because I don't know what I am doing

#

yeah im not able to remain unemotional, closing discord

#

mark my words the problem is that I made a stupid mistake because I'm #$@#^ stupid, its NEVEr unity thats wrong, its always me who is wrong

meager pelican
#

Old video using shader forge, but using partial derivation might work for you.

#

You might get away with using ddx ddy functions (ddxy) to track WSposition changes, and do:

  float3 posddy = ddy(IN.worldPos.xyz);
  float3 normalWS = normalize(cross(posddx, posddy));
dim yoke
#

partial derivative solution may not be what you want to use for the final result but as I said earlier, they could be good way to debug your normals to see whether they are correct or not

meager pelican
#

@dim yokeSorry if I duplicated, I probably missed something in the posts above. I skimmed.

#

Also one thing to check is if you're needing and getting worlds-space normals vs tangent-space normals.

neat orchid
#

Guys, I'm a total noob at shaders. What can I do to make the sphere around the ammo more interesting? Or should I leave it as is?

dim yoke
neat orchid
#

I mean should I just remove the circle and leave the outline

tight phoenix
regal stag
#

@tight phoenix Okay... I think I've figured it out. I compared it to other methods and they were also quite green actually. It's really not far off so was difficult to debug. But I'll try to explain what I think the problem is :

The way this normal reconstruct technique works is simulating the displacement from three points, the vertex position and two nearby points, offset in the tangent and bitangent directions. To get the correct result, it's important that any displacement calculation is replicated for each point separately and must use that point as the input. (That's why you use a subgraph, generating the noise multiple times with each point as the input)

But currently when you calculate the mask, you're using the Position node. That's only correct for that first point. You would need to duplicate the mask calculation with "outTangent" and "outBiTangent" as inputs. The output of those would go into the corresponding Mask input on the Hex Terrain Noise Calc subgraph.

(Or like, move the mask calculation into that subgraph and use the Position Vector property as it's input. Probably easier)

Also inside that subgraph, move the mask multiply to the end (after multiplying by height)

ebon basin
# neat orchid https://streamable.com/qixtfb

Looks fine and really all I would suggest outside of what you got is adding continuous rotation so it looks more interactable. As far as shader improvements, maybe some outlines for the pickups to further increase the visibility.

neat orchid
#

look fine with or without the circle? Also, I added rotation (of the individual meshes) but it literally cannot be seen. I also tried rotating the entire groups but I think it kinda looked stupid

tight phoenix
tight phoenix
quaint grotto
#

I have a camera and have set its mode to DepthTextureMode.Depth

How do i get this texture in my shader for this specific camera ? its not the main camera

quaint grotto
#

i dont follow how that lets me get a depth texture from a specific camera in my material

meager pelican
quaint grotto
#

its shader graph

#

i assigned the RT to material.mainTexture in Awake in C#

#

and also to camera B target texture in Awake

#

now i try to render this texture in SG to my mesh and its all black

meager pelican
#

IDK what objects are rendered with what camera.
I'm thinking that you want access to that CameraB-RT from your MainCamera's rendering pass.

quaint grotto
#

the two cameras dont know about each other

meager pelican
#

That's why I posted the SetRenderTarget info.

quaint grotto
#

this is what i basically tried:

        private void Awake()
        {
            transform.localScale = new(_range * 2, 0.01f, _range * 2);
            _camera.depthTextureMode = DepthTextureMode.Depth;
            _camera.cullingMask = gameObject.layer;

            _rt = new RenderTexture(_camera.pixelWidth, _camera.pixelHeight, 24, RenderTextureFormat.Depth);
            _rt.filterMode = FilterMode.Point;
            _rt.wrapMode = TextureWrapMode.Clamp;

            _camera.targetTexture = _rt;
            
            _material = GetComponent<MeshRenderer>().material;
            _material.mainTexture = _rt;
            Render();
        }

        private void Render()
        {
            _camera.Set(_angle, _range, transform.position);
            if (_rt.width != _camera.pixelWidth || _rt.height != _camera.pixelHeight)
                ResizeRenderTexture();

            _camera.Render();
        }
meager pelican
#

What pipeline?
Usually to access a depth texture on a camera for a shader running under that camera you would declare a texture in the shader:


Depth textures are available for sampling in shaders as global shader properties. By declaring a sampler called _CameraDepthTexture you will be able to sample the main depth texture for the camera.

_CameraDepthTexture always refers to the camera’s primary depth texture. By contrast, you can use _LastCameraDepthTexture to refer to the last depth texture rendered by any camera. This could be useful for example if you render a half-resolution depth texture in script using a secondary camera and want to make it available to a post-process shader.```
https://docs.unity3d.com/Manual/SL-CameraDepthTexture.html
The engine will "hook it up" to your material.
#

But if you're trying to access the depth texture from CameraB while having MainCamera also use that texture, that can be more complicated.

#

Shader Graph will declare that _CameraDepthTexture automatically if you use Scene Depth node, AFAIK. But if you want to use that texture from the other camera, make sure that the camera you're running under is in overlay mode so it "inherits" the texture, or that you've assigned the right texture to it.

quaint grotto
#

how does the camera know which material and vice versa

meager pelican
#

The object and its material are rendering under a camera at any specific moment. It's a render context bascially.

quaint grotto
#

CameraB does not use the same texture as MainCamera as they are not related at all basically CameraB is just to generate a depth texture from the perspective of an NPC's vision

#

then i want to use that result in his shader for a field of view effect

#

which is a per npc situation since they have different fovs

meager pelican
#

OK, so you don't need it assigned as a depth texture for main camera?

quaint grotto
#

indeed _camera in my script above is my second camera

#

not my main camera

#

i linked it in the inspector

meager pelican
#

OK, and is this script on the main camera or on the other camera?

#

IDK that you can nest camera.Render() calls inside each other...

quaint grotto
#

no its not on the main camera object

#

im not nesting

#

_camera.Render() is from type Camera thats unity the script above is my custom script

#

this is how it is setup atm

meager pelican
quaint grotto
#

yeah you mean the linear01 stuff

thin crater
#

Hi! Is there a way to get the ambientIntensity in a shader graph?

meager pelican
thin crater
#

I created a day/night manager which uses both ambientColor and ambientIntensity to change colors for the twilight, morning and night. The color was then applied in every shader simply multiplying the ambientColor with the rest of the graph output. The problem is that the color turns black during the night, and if I multiply everything with black color everything becomes black, no matter if there are other light sources or not. So what I think I should do, is multiplying the ambientColor with ambientIntensity and then adding this to the shaderGraph. But I can't find ambientIntensity anywhere in the shader graph 😦

#

Here's the point where I multiply all the previous graphs with the ambeintColor (turning everything black if the ambient is black)

regal stag
# quaint grotto I have a camera and have set its mode to DepthTextureMode.Depth How do i get t...

Afaik, URP does not use depthTextureMode - to enable the Depth Texture there's an option on the URP Asset. I also think you can't just set _camera.targetTexture as that's for the colour target, not depth texture.

If you're trying to get the depth texture from a specific camera to the main camera, you'd probably need to blit it. Can try Graphics.Blit, but if you're in URP you can use a Renderer Feature, e.g. https://github.com/Cyanilux/URP_BlitRenderFeature
(You'd have two Universal Renderer assets, one with the blit (source as texture ID _CameraDepthTexture, destination ID as whatever global texture property you want to use to obtain it later), assign both to the URP Asset then on the second camera, change the Renderer to the one with the blit, and make sure the main camera has the one without)

quaint grotto
#

🤔 ill take a read of this this is stress

#

unity shader devs must surely live shorter lives with the stress of trying to figure out how to master unity's graphical api 😄

regal stag
quaint grotto
#

guess ill need to learn about custom render features

meager pelican
#

Frack, I mean...the docs need to say what pipeline a command is applicable to...

thin crater
#

If the color is black, no matter where I multiply it the result should always be black... no?

#

Here's where I calculate the lights, with custom function and subgraphs

regal stag
#

So perhaps you just need to add rather than multiply

thin crater
#

I don't use ambient in the custom functions, I just multiply it in the end, as shown in the first screenshot

#

I copied and understood only a little the code from a youtube video to create a toon effect

#

✔️ Works in 2020.1 ➕ 2020.2 ➕ 2020.3 🩹 Fixes for 2020.2 and .3:
► When you create a shader graph, set the material setting to "Unlit"
► The gear menu on Custom Function nodes is now in the graph inspector
► Editing properties must be done in the graph inspector instead of the blackboard
► In Lighting.hlsl, change the line "if SHADERGRAPH_PREVIEW...

▶ Play video
#

That's the video

#

And that's the code

#

as I see there, ambient is not being used

#

(that's why I added it in the end, in my shader graph)

frank sonnet
#
Shader "Skybox_Cube" {
    Properties{
       _Cube("Environment Map", Cube) = "white" {}
    }

           CGPROGRAM
           #pragma vertex vert
           #pragma fragment frag

           // User-specified uniforms
           samplerCUBE _Cube;

           struct vertexInput {
              float4 vertex : POSITION;
              float3 texcoord : TEXCOORD0;
           };

           struct vertexOutput {
              float4 vertex : SV_POSITION;
              float3 texcoord : TEXCOORD0;
           };

           vertexOutput vert(vertexInput input)
           {
              vertexOutput output;
              output.vertex = UnityObjectToClipPos(input.vertex);
              output.texcoord = input.texcoord;
              return output;
           }

           fixed4 frag(vertexOutput input) : COLOR
           {
              return texCUBE(_Cube, input.texcoord);
           }
           ENDCG
    
}

i get an Shader error in '': Parse error: syntax error, unexpected TOK_GPUPROGRAMID at line 6
do someone know what the causes the problem?

astral pecan
#

Anyone know how to make Star/Diamond shape in shader graph from UV?

#

Something like this

regal stag
astral pecan
tight phoenix
tight phoenix
#

The mask itself is responsible for the edges but I am not sure how to blur that out 🤔

#

hm maybe there is a hexagon SDF with rounded corners

#

no wait all SDFs are rounded, I just have to change the coordinates/falloff/maths, I should be able to solve this on my own

tight phoenix
#

yeah getting real close, should be everything I need UnityChanThink

thin crater
#

Hello, I turned a bunch of nodes in a shader graph into a subshader, and I now got this error:

#

The subshader seems to work correctly inside another shader. The code used there is used in many other shaders, and it does not create any error

#

That's a shader graph... it's giving weird errors

regal stag
thin crater
#

The custom function node is working good on other shaders, and the subshader graph itself is working correctly in another shader 😦 I also recompiled it manually... gave more errors

thin crater
#

I found that those two shaders are different. That's the shader where the subgraph works

#

That's the one where it doesn't

#

they're both unlit

bitter forge
#

Hi everyone, I again have a problem, where I seem to need a shader. I simply want to make only the edges of a cube visible. I searched a while, but I dont really find something about that. Can anyone tell me what to search, or maybe a tutorial anywhere? I appreciate every help.

grizzled bolt
bitter forge
grizzled bolt
bitter forge
#

I found something which is giving me that result, but it is judders with movement

grizzled bolt
tight phoenix
#

By every edges do you mean the wireframe?

bitter forge
bitter forge
tight phoenix
gaunt prairie
#

Hi All,

For years I have used GLSL for work and home use.

I have pushed my son towards writing shaders in Unity as well

Given that both GLSL and HLSL are two sides of the same coin I kept postponing my learning of HLSL.

Although I occasionally would find examples in HLSL I could get the general idea and rewrite it in GLSL.

Now my son switched his game to HDRP, and now HLSL is a must.

I can't deal with Shader graph where a simple line like a = b * c takes up as much screen real estate as a whole function.

Plus searching for something in the code is easier than in a Shader Graph.


I tried to follow the template code, but it makes use of a lot of Unity macros and helper functions and finding documentation or examples for those functions is a major pain.

;;;;;;;;TLDR;;;;;;;

Can someone please recommend a book on HLSL for Unity that also covers Unity's helper functions and works with HDRP?
Please

Or if one is not available a book on HLSL for Unity for people that know GLSL

bitter forge
tight phoenix
bitter forge
tight phoenix
#

it looks like Blender also calls it Lattice in its modifiers

bitter forge
#

I see, do you know how I can achieve that in unity?

tight phoenix
grizzled bolt
grizzled bolt
bitter forge
bitter forge
grizzled bolt
gaunt prairie
bitter forge
grizzled bolt
gaunt prairie
gaunt prairie
grizzled bolt
#

Perhaps your son will find Shader Graph useful, even if it seems unintuitive to you
I started with zero shader knowledge and quickly got the hang of shaders with SG, even without instructions

regal stag
#

If you want to do anything with lighting, it really won't be easy writing it by hand. It's alright in URP but no idea what HDRP would be like.
You could try a graph and generate code from it, but that'll likely be pretty unreadable.

gaunt prairie
regal stag
#

No, for shader graphs you can see the generated shader/hlsl code. There's a button in the inspector at the top (not the compiled code one)

gaunt prairie
regal stag
#

You could try using a mix of ShaderGraph + Custom Function nodes with hlsl include files

grizzled bolt
#

SG is very convenient so a lot of those operations aren't necessary for navigation, but it really doesn't teach shader coding either
If the point of the excercise is to learn shader code, then URP or HDRP are not a great choice for starting with

gaunt prairie
gaunt prairie
low lichen
grizzled bolt
#

Here's hoping!

regal stag
#

I'll probably still use SG, but yeah 😄

grizzled bolt
regal stag
#

I just find it quicker to use a node editor, but maybe that'll change with block shaders idk. Also probably depends what type of shader it is (especially since SG doesn't support some stuff)

low lichen
grizzled bolt
amber saffron
#

Yes, block shaders are pure code, and shadergraph will generate block shaders code

low lichen
amber saffron
#

I don't think there is other plans to do it the other way around 🤔

tight phoenix
#

I hit a snag with my shader that I hope is easy to fix.
I have noise calculated in world space positions, and an SDF mask that I need to calculate in object space positions

#

but just subbing in object space to the mask and world to the noise didnt work

#

it totally broke the calculations

#

hm okay recalculating it 3 times fixed it, but now its positions are not matching its position

#

and now its weirdly super shiny

#

translating it to work in world space instead of object space is non-trivial

#

its not as simple as just changing it from object to world in the position node

#

hmm the problem is because I need the mask to be centered on the object, but the noise to be in world space coordinates

#

but passing in the object space position didnt work

#

oh I fixed it, I just had to calc the world and object twice

#

I feel like I must be doing something wrong that can be better, more efficient, when looking at how much of a hot soup this has become

#

no something is definitely not right

#

that huge bright spot is completely wrong

#

gdi why is nothing ever easy or simple, why cant I just go object space -> world space, and boom it just works

#

I @#$@#% shaders, how nothing is ever logical, nothing ever easy, nothing ever makes any sense, no debug tools, no explanation, no sense

#

time to take a break because Im emotionally compromised now by this stupid POS

#

for some reason its rotated in world space and not in object space 🔥

#

take a break like you said you would

#

no where in the shader, no where at all, takes in the objecty's Y position. its never used anywhere ever. and yet this is happening despite it being physically impossible

#

i hate shaders so @#$@^%ing much

#

why does it work perfectly in object space and why is it a complete @#$@%#234 POS in world space

sleek granite
#

Hi, I‘m working on a foliage rendering system. I chop my terrain up in tiles and run a compute shader per tile to collect instance data (position, instance count, etc). I then pass that instance data to the material (every tile uses the same material) and the material to a Graphics.DrawMeshInstancedIndirect call. Now the issue is that when I have 2 or more tiles the same material instance is overridden. So essentially, my compute shaders spit out multiple instance data buffers but since they’re using the same material instance they are just overriding the material instance data buffer.
What’s the best approach to take from here? Just copy the material such that each tile has a separate material instance?
I’ve read about MaterialPropertyBlocks, are those an alternative to coping the Material?

distant dirge
#

@next solstice I believe you want to combine the frensel effect with the alpha channel

#

if you want to make it transparent where the black is rn

distant dirge
#

basically split your color into the 4 channels, then take your frensel effect and alpha channel, and multiply them. next, combine everything back into your color data that you want

#

i think thats it

next solstice
#

@distant dirge

distant dirge
#

yeah

next solstice
#

Doesn't look like the fresnel is doing anything now

distant dirge
#

i need to see the whole shader graph

#

but

#

basically

#

your red color is stuck in the multiply node

#

and you only pass the value of the multiply to one channel

#

like for example

#

why is the B input of your shader a Vector4

#

i need to know that

#

sorry B input of the multiply node

#

actually yknow what

#

i think your original shader does affect the alpha

next solstice
#

I've compacted it a bit but its still a bit low res

#

I also fixed the error in my previous screenshot where the texture rgba was going into r of combine lol

distant dirge
#

yeah

#

your red isnt being applied to the combine because you arent passing the values

#

i think it would make sense to do what you were doing before

#

but just alpha isnt rendering for some reason on prview

#

do you have the shader rendering mode set to opaque or transparent

next solstice
#

This, surface type in the graph inspector?

distant dirge
#

yes

#

try cahnging it

#

aftrer reverting the changes

next solstice
distant dirge
#

found the issue

#

well

#

at least for transparent mode

next solstice
#

im not putting anything in alpha in fragment right

distant dirge
#

you want to pass the alpha seperately to the fragment section oft the shader

#

yeah

#

but i think you do want to keep transparent mode

next solstice
#

like this?

distant dirge
#

um i think so but try setting the A of combine to 1

next solstice
#

Doesn't look like anything changed.

distant dirge
#

weird

#

what if

#

you connect the alpha output of the fragment to the fernel effect output

next solstice
#

Um, fragment doesn't have an output?

distant dirge
#

the alpha one

#

that you used before

#

i consider it an output because you are outputting it to the object

next solstice
#

Sorry I don't understand. Alpha from what node?

#

and what do you mean connect? Do you mean combine?

distant dirge
#

just get the output of the fernel

#

and attach it to the alpha

next solstice
#

so output from fesnel directly to the alpha input of fragment?

distant dirge
#

yea

#

that looks correct now

#

afaik

#

though i notice you apply a modifer to your fernel, might want to take the output of the modified fernel but before you add color too it? im not sure whatyou want, but that looks like what you wanted to me

next solstice
#

It shouldn't be transparent in the center. I want the other texture to show through. So since the other texture is black and white checkerboard it should show black and white checkerboard in the center. However it was showing black in the center.

#

I wonder if this is the problem. It's showing black in the center, so the fresnel effect isn't giving fade from white to transparent, it's giving fade from white to black. Is there a grayscale to transparency node or something?

#

It would have to be inverted because usually grayscale to transparent makes black opaque and white transparent, which is the opposite of what I want.

#

So there would be something here in the gap between invert and the multiply with color that converts the black to alpha

distant dirge
#

also, its not white to black

#

its 1 to 0

#

but it renders the preview as if r, g, and b are all following the value of the effect

next solstice
#

Gotcha. Well I got help from a friend. what I needed was lerp.

distant dirge
#

oh ok you were trying to make it transparent between the red and the checkers?

#

i thought you meant transparent in world view

#

lol

next solstice
#

No, haha. I just this.

#

Communication is hard lol

distant dirge
#

yeah

old saffron
#

Is there a way for Shader Graph to get properties from another script? I Know I can get a texture from the Sprite Renderer, but I want every instance to check an attribute script to get it's random color.

dense bane
#

how do I get a scene object's rotation in a shader?

#

is it one of these things that need a script to inject the data in the shader?

low lichen
dense bane
#

my guess is nope, just inject the materialpropertyblock on each frame

low lichen
dense bane
#

but thanks for the refresher, you're quite courageous for hand coding SRP shaders 🙂

low lichen
#

I see. Yeah it's something you would need to pass in each frame. Unity already passes in the directional light direction through _WorldSpaceLightPos0 in built-in for you. URP probably has something similar.

quaint grotto
#

i am confused with shader graph in the vertex section i created a custom interpolator to get the distance of the vertex to the game object's position, then in the frag i use a lerp to do alpha transparency based on distance but it isn't doing a radial fade. why might this be?

#

how do i get this to be radially transparent by distance - i presumed it would interpolate the vertex distances so each frag has an interpolated distance?

#

ok it works if i do all of the math in frag

#

but was hoping to do the distance in vertex to reduce the amount of calculations

#

😦

quaint grotto
#

i am using the position node

mental bone
#

The position returned by the object node is not per vertex

quaint grotto
#

it works in frag shader but not setting distances in vertex shader first

mental bone
#

Oh wait Im sleepy

quaint grotto
#

my screen shot shows the position node in use lol

mental bone
#

Whats the vertex density of the mesh?

quaint grotto
#

its the regular unity cube

meager pelican
# old saffron Is there a way for Shader Graph to get properties from another script? I Know I ...

Think about it the other way around.
Scripts send data to shaders (via material settings). Shaders don't go get data from scripts.
The script(s) are the senders, the shaders are the receivers.

So you need a script that sets something (buffer or texture or just properties) that your shaders can use. Maybe a shader global thing that is set.

If you want per-instance values, that can be more complicated, but check into "Material property blocks" and see how you can make that work with _BaseColor in Shader Graph. It might work, since _BaseColor was one of the properties that works with instancing IIRC. But in general there's an "issue" with MPBs and Shader Graph, as I understand it.

frank sonnet
#

do someone know how to get Pixelvalues from the skybox?

meager pelican
# frank sonnet do someone know how to get Pixelvalues from the skybox?

Too vague.
Skybox is drawn AFTER opaque objects are drawn.
What pipeline are you in?
So WHEN do you want to get theses values? During opaque passes? During skybox generation? During transparent pass?

If the latter and you're in URP, you can get the entire background opaque objects + skybox using the scene-color node in shader graph. But that won't give you the "sky" that is behind a scene object.

If you must have the sky, regardless of opaque objects, you're probably best off using a sky or sky+terrain camera as the first camera in a camera stack. Then drawing all your stuff on top of that.

It's hard to answer your question without more details for what and when you need all this data. I mean, since the skybox is drawn after opaques, some of it is never even generated if there's an object occluding the view of the sky.

frank sonnet
meager pelican
#

Sounds like you're trying to compare cube maps to each other.
IDK.

#

The skybox that's actually output to the screen is a subset of the cubemap and is going to be interpolated across the pixels of the screen.

#

IDK how you compare the results other than just writing your own skybox shader and using the scene color node or a grab-pass to "grab the sky" and then compare the two, and then maybe output a difference map as an overlay.

grizzled bolt
#

Kinda sounds like this "test" is more complex than what you were making originally

frank sonnet
#

it will get even more complicated XD. But for the time being i want to know if my shader works correctly or not 😄

cosmic prairie
#

Has anyone had any luck with proper auto-complete for writing shaders in Unity?

#

There's an HLSL addon for vs which does a lot, but it can't recognize some shaderlab things and also, it can't find include files at all, which is a big problem with any URP shader

cosmic prairie
#

Is there no way to compare it in paint by applying both materials to the sky separately and taking a screenshot

pure tide
#

is there a way to hide objects when being behind an invisible object?

frank sonnet
low lichen
cosmic prairie
#

Does Unity also use this in-house? They had to use something similar to write all those libraries

cosmic prairie
frank sonnet
cosmic prairie
frank sonnet
#

i would just apply the shader on the material and then give the material to my object

cosmic prairie
#

okay, you have a material, and object and a shader

#

where is the part that yields you the texture with the data

frank sonnet
#

i thought the shader is basicly the Texture, is it not? I would have taken the object as my Texture3D source

cosmic prairie
#

The texture is pixel data, imagine a grid of values

#

The shader is a program the GPU executes to render to screen pixels

#

Your screen is rendered to a RenderTexture

#

which you can read from

#

but I'm not sure how you would compare two objects that way

cosmic prairie
frank sonnet
#

can i compare the values of one object with the other in the fragmentshader? its basicly my pixel values right?

neon lagoon
#

Iam doing a vr project for school and iam trying to make objects be highlighted when touch them hoping someone knows how to do this and can help me

distant dirge
#

Also how you want the effect to look

neon lagoon
# distant dirge Also how you want the effect to look

I was hoping to create an effect like this just a simple like that shows when hand is touching the object and disappears when holding it https://youtu.be/veBOFcKC2qg

Second part of this project I’m doing to learn how to use the new XR system in Unity. In this video you will be able to see movement system, outline effect, Pick objects, interaction with physical buttons and system to prevent the player from not crossing the walls, making it always within the limits.
All done in the URP(Universal Render Pipeli...

▶ Play video
neon lagoon
cosmic prairie
#

but you only get color info