#archived-shaders

1 messages ยท Page 35 of 1

regal stag
#

Also has the mesh (you're applying the material to) got UVs?

#

Might also not be able to see it well as there's an Emission colour being applied on top. (Usually with Scene Color that would go into emission instead of Base Color, otherwise it would be shaded)

digital gust
#

from this "Color" values I would assume it should refract

regal stag
digital gust
digital gust
regal stag
#

Yep sorry if I didn't make that clear

digital gust
#

Nah all good, I would not have assumed that I had to go to a n/1000th to get the desired result ๐Ÿ˜„ wow thank god you pointed and it was easy as that ๐Ÿ™‚

regal stag
#

So distorting with a range of 0-1 (or -1,1 in the case of these normals) is like, shifting the entire screen over. If that makes sense.

digital gust
lunar valley
#

I do not think that the problem is how you decide if its outside the view frustum or not I think the problem is more that you then don't really use this information correctly to then cull you grass

slim yew
#

yes I do

#

I decide if the object is in view or not, if it is render it, if not return and move to the next blade

lunar valley
slim yew
#

what?

#

the only peice of extracted data from the dot product is "is this geometry object going to be in view when rendering or not"

#

a boolean

digital gust
#

Is it possible to take the vertex displacement also as a normal map for the refraction calculation?

#

Or rather said, I am wondering, why I get this result, just not sure about whats happening under the hood

#

Refraction is working but also showing the cube as not refracted. Is that because of the transparency?

regal stag
digital gust
#

Oh boy, made so many shaders, but never did refraction, thanks a lot.

#

Okay, last one is the vertex to normal thing, but I try to figure it out

regal stag
digital gust
#

So basically I would have to take the scene color and offset them by the values I get from my vertex position offset basically?

regal stag
digital gust
regal stag
#

You'd probably want to avoid connecting the vertex and fragment stages together, or you'll end up just doing the calculation twice. Either pass the offset through a Custom Interpolator : https://www.cyanilux.com/tutorials/intro-to-shader-graph/#custom-interpolators
Or since it's a flat plane here, should be able to extract it from the Position node. As when used in the fragment stage that would be the displaced position. In object space, the Y axis (G from Split) should be the offset.

digital gust
#

As you are just here, may I ask you about a theory or rather possibility in shadergraph? Right now I have just a circular wave going from a vector3 position. Is there any option to like lerp this effect, so the waves actually will like emit at a position and stay and the new ones emit at the new position. Simple said, as if you drag your finger through water and generate little waves. I am afraid my circular generation is not helping in this case, just wondering if I can only with shadergraph create that effect like using the direcitonal vector and offset it or similar

#

Or if I have to use a texture that I update on the fly to generate the needed displacement

regal stag
digital gust
regal stag
#

There may be other methods, like using a compute shader to generate that heightmap but I'm less familiar with that

cursive spade
#

Same. Did you find a solution / recent version of Unity which isn't broken?

digital gust
lunar valley
slim yew
#

I'm doing per object culling, and utilizing the chunks for animations so I don't do many control point manipulations

#

if I do it per chunk, then I'd already have calculated the blades, and just decide not to render it when chunk culling is called

#

I am going to render and calculate each blade anyway so why don't I skip it using a camera check

lunar valley
#

yes I know

slim yew
#

no you don't

lunar valley
# slim yew no you don't

I do, lol, you are creating new geometry so you are allready going through every grass chunking wouldn't help, thats why I said if its even possible to make it work and besides if you really want some good optimal grass I would go and watch that video and forget about geometry shader cause they are shit, I mean lets face it what you are doing is creating grass then throwing it away, creating grass then throwing it away, creating grass then throwing it away, creating grass then throwing it away, creating grass then throwing it away, creating grass then throwing it away, creating grass then throwing it away, creating grass then throwing it away, creating grass then throwing it awayhttps://www.youtube.com/watch?v=Ibe1JBF5i5Y

GDC

In this 2021 Advanced Graphics Summit talk, graphics programmer Eric Wohllaib will discuss how they generate acres of grass within reasonable memory and performance limits, techniques for rendering and animating individual blades, and methods for making thousands of individual blades of grass look like a natural field.

Head to GDC Vault (http:/...

โ–ถ Play video
slim yew
#

you do know that compute shaders can substitute geometry shaders

lunar valley
#

anyway I need to go, good luck with your grass!

slim yew
#

that they're also using a geometry shader

#

theirs is much better, but the same approach

#

proving that you still don't know what you're talking about

lunar valley
#

I do not have time for this and to me you are just proving that you do not know what you are talking about seing that you are failing your grass culling, if you want to say something to me again, do it later I need to go now, anyway, I still wish you good luck with your grass and have a nice day

slim yew
#

?

#

guess I'll die then

hearty obsidian
#

Thank you! Currently investigating stencils, I think that ought to solve my issue

#

Any idea if you can write to the stencil buffer from a shader graph shader?

hearty obsidian
#

@meager pelican Okay, got it to work! Thanks for the help ๐Ÿ™‚ The effect is the enemies line of sight

#

So, as far as stencil go,

  • I created a shader that does nothing but assign a stencil value.
  • I render my environment a second time and override the material with the stencil material to set the stencil value for all the environment
  • I then render my line of sights 2x based on the stencil value (I needed different behaviour(binary) based on the layer)

If anybody more experienced sees anything redundant in how I handle things, please let me know

misty crown
#

Hi there,
When you out a position from the Vert function, is that being transferred directly to the GPU, or is that just being sent to the Frag function? How is it being transferred? Would love to understand further. Thank you

lean lotus
#

Hey so if I have the diffuse gbuffer, the specular gbufffer, and a texture representing the lighting of the screen, how do I combine those correctly?

#

cuz if I just add the specular gbuffer and the diffuse gbuffer, the specular gbuffer tends to be non zero

#

resulting in washed out on diffuse surfaces

low lichen
lean lotus
#

heck ok

#

cuz I already have the lighting I need to apply, but for my upscaler I rely on the gbuffer for the albedo color so I get full res textures with lower res lighting

#

is there a way for me to just get the albedo without requiring custom materials applied to objects?

unique pumice
#

question for a shader, I am rotating + tiling a texture. I wanted the shader to be united across all the sprites with screen position, but I am not sure where I add the screen postion node

#

this what I have

#

what I am trying to achieve + the tiling and rotation nodes

lunar valley
unique pumice
#

oh woops, my apologies, its 2 sprites a triangle and a square

#

I was trying to get them to overlay the same texture across despite position or scale of the sprite itself, as if it was seamless

lunar valley
unique pumice
#

the texture yes, it works while using a screen position node in the texture uv but I am unsure how to combine it with the rotation + tiling nodes (which scale the texture and rotates it on an angle)

#

without and with screeen position (

lunar valley
unique pumice
#

essentially if I put 3 of the shader it looks like the same texture is scrolling between them

#

the tiling and offset nodes have a scrolling function attached already, should I multiply that with the screen position and then feed it into tiling?

lunar valley
#

with this the size of the texture stays the same and you can still tile and offset it

unique pumice
lunar valley
# unique pumice

what exactly do you want to make do you want to make the offset change through time?

#

if so just plug the time node into the offset node

prime shale
#

<@&502884371011731486> @trim pagoda

tame topaz
#

!ban 242264872405041152 bot

echo moatBOT
#

dynoSuccess Pack#1970 was banned

crimson sky
#

Does anyone know how to use the new refract node with URP in 2022.2? The documentation doesn't any have useful examples.

silent fulcrum
#

Let's say I have a parent gameobject, and a bunch of children gameobjects with different models and materials. I want to alpha clip everything outside of the parent gameobject's bounding volume (sphere or box). How would I make a shader graph that allows me to clip all of the pixels of the children's gameobject renderings that are outside of the bounding volume? Should every child gameobject's renderer need a material/shader with a reference to the parent gameobject's position and bounding volume? Or am I missing something?

meager pelican
# silent fulcrum Let's say I have a parent gameobject, and a bunch of children gameobjects with d...

Wow, that might suck. Let's see...off the top of my head:

  1. you could pass in the AABB to the various shaders on the children (maybe a shader global if you just have one, but otherwise it will take unique material instances for each parent). The children could get the worldpos of the fragment, and do an intersection test with the AABB and discard the pixel if outside. Sounds inefficient as hell.
  2. You could pre-draw the AABB with a stencil-only shader. Do that for every parent. The children shaders would then only be allowed to draw a frag where the stencil intersected the stencil. But the stencil is basically 2D, so you might have to do some kind of depth testing.
meager pelican
# misty crown Hi there, When you out a position from the Vert function, is that being transfe...

The vert(), rasterization, and frag() are all already on the GPU, executing in shader stages.

OK, there's these things call "semantics" that are assigned to the data items in the "v2f" structure passed out of the vertex function to the frag function.
One of the required semantics is SV_POSITION (or POSITION). That value is "flagged" by the shader compiler as the requisite output of the vert...a clip space position for the rasterizer to use to rasterize all this math.

The vertex function and all the inputs and calculations for that are just in "pure math" in that they have no relation to the physical output device, pixels, etc. It's all math-land.
But between the vertex and the fragment stages...magic happens...and it all gets rasterized into the output resolution based on the values you pass out of the vertex function. The various cores are allocated then and assigned to pixels in "waves" of parallel processing, each having its own data from that v2f...interpolated values as applicable.

silent fulcrum
meager pelican
frigid yarrow
#

is there a way to make a shader only get the hue of the light?

#

im trying to have a shader with only two levels of brightness

#

(the lit part, and the shadow)

meager pelican
# silent fulcrum Let's say I have a parent gameobject, and a bunch of children gameobjects with d...

A few extra thoughts after sleeping on this and re-reading your question:
SG doesn't support stencils yet. You'd have to hand-write a shader.
If you can use a sphere as a bounding volume you only need to pass in a float4...xyz are the worldspace center of the sphere, and w could be the radius. Knowing the worldspace location of the fragment and doing a distance calc to the center of the bounding sphere, you can compare the distance to the radius. Might be fastest.

But you'd have to pass that float4 in uniquely for each parent to all children somehow. By having "parent-materials" or something. Maybe a lookup into an array of float4 parents could work too.

meager pelican
#

Don't forget about saturation along with hue.

distant dirge
#

Ok sorry if im not allowed to ask here instead after a while but I need some help porting broken URP shaders to my URP version
Here is one of the errors im getting, they are all pretty similar:
Shader error in 'CTI/URP LOD Bark Array': Did not find shader kernel 'LightweightFragmentMeta' to compile at line 453 (on d3d11)
The package is called Conifers [BOTD]
Id like to know what I should put instead of LightweightFragmentMeta, after searching on the github grep app i found a usage that hinted that I want UniversalFragmentMeta but that brings out more errors than before

BTW if you do import the package for testing make sure you import the included URP package (DONT install the 12.0 version that one TRIPLES my error count)
Im using unity version 2021.3.9f1 and URP version 12.1.7

stray rune
#

i freaked around shader for a long time but still can find anyway to change alpha color

#

and i want emission is on top transparent in shader
how do i do them all?

lunar valley
distant dirge
#

ok i have added the versions to my question if anyone needed them

scarlet crater
#

I'm having an issue with a geometry shader of mine, it works perfectly fine on my home pc , but if i load it up on my laptop it doesn't draw anything at all.

#

maybe the integrated graphics on my laptop doesnt support geometry shaders (?)

#

i honestly have no clue

#

laptop:

#

i exported the prefab / materials directly from my home pc so nothing should have changed

lunar valley
#

did you make this?

scarlet crater
#

i did yeah

#

and thank you!

#

its horribly inefficient but it looks very pretty

lunar valley
#

yeah might be its not supporting but wouldn't really be able to tell, but compute shaders have better compatibility in general and speed, but the problem might be something else dunno

lament scarab
#

hey so I have this shader code and the effect changes based on the view angle

#

I would also like to have it change over time

#

how can I add a time based component to this, i was thinking maybe of an addition (+) to "(viewAngleCustom * 2)" but how exactly?

scarlet crater
#

im sure theres a way i could get the same effect without using compute shaders / geometry shaders but im not aware of it

scarlet crater
#

there is also unity_DeltaTime

scarlet crater
#

i am less familiar with deltatime

lament scarab
scarlet crater
lunar valley
#

just do + _Time.xx or time.xy

lament scarab
lament scarab
#

Just .x or .y works tho

lunar valley
lament scarab
#

Gonna test things out see how it comes out

scarlet crater
# lament scarab What is speed?

oh it was just a stand in for a variable, you can make it whatever value you want. i just figured you'd want to be able to control the speed of the effect

lament scarab
#

works pretty well, thanks!

#

still kinda wondering what's time .x and time .y

lunar valley
lament scarab
#

(only y gives results in my case)

#

hmm

#

and it ain't time and space ig haha

scarlet crater
#

_Time.y is unmodified

#

x = t/20
y = t
z = t * 2
w = t * 3

misty crown
#

Hi I have two lights in my scene, directional light and point light, I am looking to access my point light's position so that I can use it to calculate diffuse lighting. I am wondering how to access the point light in either HLSL, or Shader Lab shortcuts, if anyone has a reference that I can look at would be helpful, thank you

lunar valley
#

specifically _WorldSpaceLightSpacePos1

misty crown
distant dirge
# distant dirge Ok sorry if im not allowed to ask here instead after a while but I need some hel...

ok i spent a bit of time here are the errors

CTI/URP LOD BARK (look for 197)

half4 LitPassFragment(CTIVertexOutput IN) : SV_Target
{
    UNITY_SETUP_INSTANCE_ID(IN);
    UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);

    #if defined(LOD_FADE_CROSSFADE) && !defined(SHADER_API_GLES)
        LODDitheringTransition(IN.positionCS.xyz, unity_LODFade.x);
    #endif

    SurfaceData surfaceData;
//  Get the surface description / defined in "Includes/CTI LWRP Inputs.hlsl"
    InitializeStandardLitSurfaceData(IN.occlusionVariation.y, IN.uv.xy, surfaceData);
//  Add ambient occlusion from vertex input
    surfaceData.occlusion *= IN.occlusionVariation.x;

    InputData inputData;
    InitializeInputData(IN, surfaceData.normalTS, inputData);

//  Apply lighting
197 half4 color = LightweightFragmentPBR(inputData, surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.occlusion, surfaceData.emission, surfaceData.alpha); // THIS IS 197 <<<<<<<<<<<<<<
//  Add fog
    color.rgb = MixFog(color.rgb, inputData.fogCoord);
    return color;
}

ENDHLSL

Not sure about Bending.hlsl but it has a function at line 57, and this is where the function is called in the two erroring scripts
Bark

CTIVertexOutput LitPassVertex(CTIVertexInput input)
{
    CTIVertexOutput output = (CTIVertexOutput)0;

    UNITY_SETUP_INSTANCE_ID(input);
    UNITY_TRANSFER_INSTANCE_ID(input, output);
    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);

    CTI_AnimateVertex(
        input,
        float4(input.color.rg, input.texcoord1.xy), // animParams,
        _BaseWindMultipliers
    );
...

ok message is too long but basically there are a lot of errors and im not sure why, hopefully someone here knows how to read shaders and can help with this

#

btw sorry that i didnt post this all in one message i was busy doing other things at the same time

frigid yarrow
#

half4 colorHue = _LightColor0.RGBToHSV(new _LightColor0(0.9f, 0.7f, 0.1f, 1.0F), out H, out S, out V);

lament surge
#

Hi, i want to create a shader which displays fractals(such as the mandelbrot set), while infinitely "zooming" in (scaling the coords) based on the mouse position.

What i'm wondering about is, does interpolation eventually become problematic due to the limitations of floats?

frigid anchor
#

Henlo, Does anyone know how i could get the transform.right of an object as a vector3 in shadergraph like you can in code

lunar valley
#

reference the material and then do material.setfloat, setVector... inside a c# script

frigid anchor
#

i want to check it from a shader

#

not another script

ancient thistle
#

hey so im following this basic shader tutorial to get shadows for 2d sprites in 3d, but for some reason the material comes up as pink and the material isnt working properly, the tutorial says its for URP and im using URP sooooo idk the problem

#

help is appreciated

distant dirge
#

whats the best way to get input from a full scene to shade stuff with? im trying to make an image bright and add shading effects to a minimap camera, but I cant figure out how to get input
So far i have tried outputting to a render texture (this step is for regular rendering of the minimap camera), and then using Graphics.Blit to apply a material using my shader to that render texture and throw it into a new render texture. For some reason, my basic unlit shader im using does not want to output correctly to my shaded render texture. If i change the material I am using (so one not using my shader), it works fine.

#

here is my shadergraph

lunar valley
lunar valley
distant dirge
#
public class MapCamera : MonoBehaviour
{
    [SerializeField] private Texture unshaded_minimap;
    [SerializeField] private RenderTexture shaded_minimap;
    [SerializeField] private Material shader_material;

    private void Update()
    {
        Graphics.Blit(unshaded_minimap, shaded_minimap, shader_material);
    }
}
lunar valley
#

hm, I always use an image effect shader for things like that but tbh. not sure

distant dirge
#

im on urp btw

#

ig that is made somewhat clear by shadergraph

#

but hdrp has it too

lunar valley
distant dirge
#

is there a good way to get this as a shadergraph?

feral mist
#

in URP , I'm using half4 UniversalFragmentPBR(InputData, SurfaceData) to get me the color in the fragment but I'm getting an error in android builds (vulkan targets) preventing me from building.
part of shader below
`
InputData inputData = (InputData)0;
inputData.positionWS = IN.worldPos;
inputData.normalWS = normalize(TangentToWorldSpace(d, l.Normal));
inputData.viewDirectionWS = SafeNormalize(d.worldSpaceViewDir);
inputData.shadowCoord = float4(0, 0, 0, 0);
inputData.fogCoord = IN.fogAndVertexLight.x;
inputData.vertexLighting = IN.fogAndVertexLight.yzw;
inputData.shadowMask = SAMPLE_SHADOWMASK(IN.lightmapUV); // that was missing. would it change the way shadows behave in app? TODO check on main.

        float3 sh = SAMPLE_GI(IN.lightmapUV, IN.sh, inputData.normalWS);
        inputData.bakedGI = sh;

        inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(IN.pos);
        inputData.shadowMask = float4(0,0,0,0);

        SurfaceData surface            = (SurfaceData)0;
        surface.albedo                = l.Albedo;
        surface.metallic            = saturate(metallic);
        surface.specular            = specular;
        surface.smoothness            = saturate(l.Smoothness),
        surface.occlusion            = l.Occlusion,
        surface.emission            = l.Emission,
        surface.alpha                = saturate(l.Alpha);
        surface.clearCoatMask       = 0;
        surface.clearCoatSmoothness = 1;
        half4 color = UniversalFragmentPBR(inputData, surface);

`

#

Really stumped why the UniversalFragPBR is giving me internal error: argument pulled into unrelated predicate at line 77 (on vulkan)

regal stag
# distant dirge ```csharp public class MapCamera : MonoBehaviour { [SerializeField] private ...

You likely need to specify pass 0.

Graphics.Blit(unshaded_minimap, shaded_minimap, shader_material, 0);

The default is -1 (all passes). Shader graphs will generate multiple passes for other stuff (e.g. shadows, depthonly, etc), but you don't want to render them all to the screen, only the main forward pass.
To obtain source texture, Graphics.Blit sends it into texture reference _MainTex.
If this is for URP, you may also want to look into using a renderer feature instead.

frigid pond
#

Hey all, wondering if anyone has figured out a way to avoid a transparent shader with a vertex offset (vertex offset = shift along the surface normal * some_factor) causing a ghosting issue cause of color blending? I've tried manipulating the ndc coordinates to see if I can shift the ghosting effect back to the edge of the object but it only works on some viewing angles?

distant dirge
#

it wasnt working

#

so what im trying to figure out now is what i did even more wrong

#

because none of my shaders are working

#

like for example @regal stag what would you expect this to do?

#

applied to a cube

#

just in case im doing it wrong somewhere here

regal stag
distant dirge
#

that was it

#

ok now to see if my renderer feature will work

#

hm render features still not working

#

what else have i messed up horribly

#

my render texture is just showing up like this

#

thats weird

#

testing with this shader graph

distant dirge
#

@regal stag btw are you still here? do you have any idea why my renderer feature wouldnt be working i can send more screenshots of configuration if you need it

#

and if you arent still here sorry for bothering you

#

im unfamiliar with common issues with shaders and you had info earlier

#

so i figured you might know this as well

rare charm
#

Is there a way (preferable in shadergraph) to calculate the sharpness of an edge? Basically so that when two tris share an edge the edge gets a value of 0..1 based on the angle 0..180 of the two tris?

distant dirge
#

it looks like if i zoom out my minimap camera it shows that the pattern is is matching what is shown in the preview

#

but why are the trees messed up then

#

hm

distant dirge
#

oh i figured out what was wrong lol, ok now if anyone knows, how do i just make the scene brighter on the minimap camera, i have shader effects working now

#

rn minimap looking like this

#

this is why i was using a light before but i cant get the hacky light toggling method to work on URP and that thing was messy anyways, messed up the lighting on my trees

#

that's why i moved to shaders

#

this would be an ideal look for the minimap but i just added a light to get this soooooo

tacit parcel
distant dirge
#

i dont know what effect to do to brighten it

#

will i end up needing plain shaders or can i use shadergraph?

tacit parcel
distant dirge
#

unless you mean something else

tacit parcel
#

weird.. unlit should make it unaffected by any lighting and give the albedo/color instead...
what color is your fog? it seems unlikely but maybe it's the fog that make it looks darker

distant dirge
#

i dont have fog afaik

#

also

#

the unlit thing might not apply because of how im using camera shaders

#

basically instead of actually applying an override shader (thats not ACUTALLY a thing in URP afaik) it will take the camera output, then run it through a shader, and set that as the new camera output

#

i think thats the reason unlit wont work

#

but

tacit parcel
distant dirge
#

already did this

#

like read it

#

yeah its using render features

#

hold on lemme fiddle with some stuff brb

#

ok im back

#

wait i have an idea

#

ok my idea worked kinda i just added post-processing

#

idk ill live with this for now

distant dirge
#

Btw dont get me wrong if i can find a way to have the minimap cam have perfect lighting and good shadows that would be very nice, as of now Im not even getting shadows on the minimap cam

lunar valley
#

if yoi only want some shading you xan just do the dot product between the normals and light

meager pelican
distant dirge
#

But

#

How do i get the light

#

Also i learned what a normal is about 19 hours ago so if there is anything important to know about them other than what they are please tell me

iron vine
#

Need a little help with some hlsl shaders(not a shader guy myself). Using this toon shader I found(second image is the code), and I want to apply Unity's built in fog over the top of the toon shader as my attempt(first image) does not work and the objects are still visible on top of the fog. Any help would be greatly appreciated!

regal stag
iron vine
lunar valley
fresh osprey
#

How can i export materials from unity to blender?

#

I made a half dissolved cube and i want to export it

distant dirge
#

Maybe if i create a vector3 input and set the reference to _WorldSpaceLightPos0

lunar valley
distant dirge
#

Its a vector 3 right?

lunar valley
distant dirge
#

K i will try that

hidden tree
#

Hi, dunno if it's a shadder issue or a VR issue but my skybox works fine in scene, but is void in VR

rare charm
prime shale
distant dirge
prime shale
#

im not sure what pipeline they were writing the shader in

#

but in the built in pipeline

#

lit shaders typically have two passes indicated by the tags

#

"LightMode" = "ForwardBase" and "ForwardAdd"

distant dirge
#

Im using shader grpah

#

And it is me writing the shaders

#

Not them

#

Im on urp btw

prime shale
#

oh well then nevermind them since what I said doesn't apply

distant dirge
#

Ok so a vector3 with reference set as that will be fine?

#

If you know shadergraph

#

Also i saw your post earlier about it maybe being worth to learn builtin shaders first over urp shaders, and im just curious why that is in case i wanna get into writing code based shaders for more complicated effects

#

But from what i understand shadergraph can do a lot of effects i might need

#

Like im going to want to have ghostly models in my game and i already have a bit of a demo for that working

prime shale
prime shale
distant dirge
prime shale
#

here

hearty obsidian
#

Does unity reconstruct the normals from depth at any point in the rendering process and can I access the texture somehow?

remote hedge
#

Is shader the solution if I wanna make multiple holographic effects for my cards (made of sprites?)

prime shale
remote hedge
#

Like irl ccgs games

distant dirge
prime shale
#

yeah looks like its simpler now

#

which is good

#

I remember it was pretty finicky to get it working

distant dirge
#

Also are docs good now?

prime shale
#

3 - 4 years

#

lmao

distant dirge
#

Isnt that when urp came out or wayy earliee

prime shale
#

but looks like im wrong

#

but the other points I said still apply, for instance if shadergraph works fine for you and you can still do everything you need/want to then no need to switch to code

distant dirge
#

Ye

prime shale
#

just switching to code gives you more flexibility, and responsibility to an extent

#

as for the vector3 not sure if I follow

remote hedge
#

Like these

distant dirge
prime shale
#

yes

#

oh I see

#

you want to input custom light coordinates right?

distant dirge
#

In shadergraph you make a texture reference

distant dirge
#

But only on one camera and using a shadrr

#

I can link you to images

#

Hold on

distant dirge
#

Someone suggested dot product light by the normal coords
And im not an expert on shading so that sounded reasonable

prime shale
#

dot(normal, light) is typically how you do lighting yes

distant dirge
#

So thats why im after the light pos thing

#

Actually how do you use the output of the dot product

#

In this case

#

I have pixel color in and pixel color out as im assuming most shaders act

#

And i can throw stuff between there

#

Magic

remote hedge
prime shale
distant dirge
#

I see

#

Before i was just trying to multiply the whole frame by a single float

#

And that wasnt looking too great

#

Yummy flat image essentially

#

Btw the light in that IS the light position right?

#

And how would i adjust the brightness of my lighting?

prime shale
#

yes

distant dirge
# prime shale yes

And its the main directional light in the scene right? Or am i missimg something

#

Missing*

prime shale
distant dirge
#

Thats what i figured but i wasnt sure because last time i tried to multiply every pixel it looked bad lol

prime shale
#

well because you were doing the dot product incorectly

#

the normal vector is a direction

distant dirge
#

I wasnt doing any dot product

prime shale
#

-1..1

#

light position

#

oh WAIT

#

sorry, brain fart

#

light directionn

distant dirge
#

I just multiplied every pixel by a number

prime shale
#

not light position

distant dirge
#

Is there a different ref for that?

#

Or is it the same

prime shale
#

so for directional lights which are sort of "infinitly large lights" so to speak

#

the light direction will be constant

#

not a single number

#

but i.e. (0, 1, 0)

#

which is straight up

#

when it comes to shading point/spot lights its a little different

distant dirge
prime shale
#

it just changes rotation

#

its a direction, not a position

#

my bad, did a piss poor job explaining it now since I forgot its actually light direction not light position

#

dot(normalDirection, lightDirection)

distant dirge
#

Is direction != rotation

prime shale
#

sort of, yeah

#

well actually no

#

is it your rotation sort of

#

jesus, fumbling hard here lmao

#

but its alright

#

direction towards where the light is pointing

remote hedge
prime shale
distant dirge
#

@prime shale btw is the ref still the same

prime shale
#

yes

distant dirge
#

Ok

prime shale
#

its still a vector3

distant dirge
#

I mean the nam3

#

Name

prime shale
#

well no the name would be light direction

#

if your trying to emulate directional lighting

#

if your doing point lights then some extra steps are needed to derive the light direction for point/spot lights

#

but at the end your still getting light direction

#

think about it also, directional lighting, its in the name itself

#

it comes from a specified direction

#

not position

distant dirge
#

So is it _WorldSpaceLightDir0 ??

#

Or am i not understanding or its a dofferent shorthand

#

Different

prime shale
#

oh right we are still on _WorldSpaceLightPos, alright give me a second

#

so for directional lights

#

wait if this is a custom shader vector3 input why name it _WorldSpaceLightPos0?

#

_WorldSpaceLightPos0 comes from unity internally to get the light position that unity passes into the shader

#

you can just name it light direction

#

if you want to do directional lighting you can just simply have a vector3 named "_LightDirection" which can be used right in the dot product

#

feel like I lost you @distant dirge

#

and in your shader you would just set the _LightDirection variable to the transform.forward value of your directional light

#

||additionally some people would say you need to normalize() it which maps the direction to -1..1 but transform.forward is already normalized so no need to||

distant dirge
#

Im back for a sec

#

I was gonna go out for a 30 minute walk in a few mins

distant dirge
#

Thats what im looking for

prime shale
#

does shadergraph actually provide that value though

distant dirge
#

_MainTex is an internal thing like i was talking about

distant dirge
#

You set the input to be referrencing the internal thing you want

#

And then you can use it

#

But is that the value i want

#

Or something else

prime shale
#

for getting light yes

#

for directional lights internally _WorldSpaceLightPos0 is already a direction

#

for saftey you can normalize them of course

#

and then plug that in to the dot product equation

hearty obsidian
#

Does unity reconstruct the normals from depth at any point in the rendering process and can I access the texture somehow?

prime shale
#

unless if you enable the depth texture generation

#

if your on forward rendering mind you

hearty obsidian
#

@prime shale Thanks! that's unfortunate

tight phoenix
#

what are possible reasons why shadergraph's preview wont update?

#

the preview is clearly completely wrong but no change I do to the graph will update the preview

#

hm changing tab and back fixed it, weird though UnityChanThink

distant dirge
#

@prime shale if you are still here, do i want a normal vector, normal from texture, or normal from height?

prime shale
#

normal vector

#

you want to shade using the objects normals

#

the normals from texture/height are usually tangent space

#

and are meant to modify the object normals

distant dirge
#

ok thats what i figured and yeah that seems to work ok

#

hmm

#

it still looks weird

prime shale
#

screenshot?

distant dirge
#

vs if i just add a light

#

i think its so dark that it looses all the color detail

#

better comparison if i just brighten it a bit more

prime shale
#

im confused on what your trying to make

distant dirge
#

minimap

#

this is the minimap with no effects at all, and just the amount of lighting i have atm

#

this is with effects back on

#

if there was a good way to i might want to just redraw everything differently but this is why i want alight

#

because it has color and just looks much nicer

prime shale
#

so just to give the impression that its from the map

#

but its just a texture lookup

distant dirge
#

?

#

right now

#

i just have a camera place above the player

#

and i set it to render using my shader

#

but since the scene is so dark it looses all detail

prime shale
#

so its a post effect or is is rendering using a replacement shader?

distant dirge
#

replacement shaders dont work in urp afaik

#

so im using a renderer feature

#

where you create a new urp renderer object

#

and set some properties for it

#

and im using a blit where basically it takes the image after a certain rendering step

#

then applies my shader

#

then continues

#

and my shader looks like this rn

#

i think its technically a post effect tho yeah

prime shale
#

I can see from the dot product that the result is completely black

#

is world space light pos not getting assigned?

distant dirge
#

i mean that is possible

prime shale
#

I would assume so, since it not being assigned would mean that the light direction is (0, 0, 0)

#

so no light what so ever

distant dirge
#

lemme test\

#

yeah

#

just a sec

#

no something is working

#

if i disconnect the node

#

it just goes black

#

weirdly tho if i assign manually 0, 1, 0 or 0, -1, 0 it doesnt render anything either but the preview updates

#

but if i reconnect the worldspacelightpos

#

it goes back to those ss i sent

prime shale
#

clamp the dot product

distant dirge
#

to what

#

-1, 1?

prime shale
#

0..1

distant dirge
#

ok

#

ok nope 0, 1, 0 and 0, -1, 0 still dont work

prime shale
#

figured, but it'll help later on

distant dirge
#

btw is shaders even a viable way to do this?

prime shale
#

for a minimap?

distant dirge
#

yes

#

sorry im playing another game so if i take a while to respond thats why

meager pelican
# rare charm I guess I hadn't really thought about it much, I just had the thought and asked....

If you only want the current mesh, you can try passing a world-space-normal from vert stage to frag stage (or shader graph will do that for you if you pass one to a ddxy node) and use a ddy/ddx function to detect the changes from the previous pixels.
I suggest you dig into how it works on the net, maybe a youtube vid will explain the ddx and ddy functions, or something. But you'd probably do it all based on surface normals.

distant dirge
distant dirge
#

alright

prime shale
#

still confused exactly what your trying to do

distant dirge
#

minimap DARK

#

because scene dark

#

as shown in SS

#

want it brihgt

prime shale
#

so is this render feature rendering the shader, is it on the entire screen or rendering for every object

distant dirge
#

its the entire screen

#

related to the minimap cam

prime shale
#

yeah then it makes no sense

distant dirge
#

any alternative solutions?

prime shale
#

can't just simply put a multiply node when you sample the minimap texture to brighten it?

#

if it was an object shader then it'd make sense, but your doing it on the screen pulling the normal vector and trying to shade with lighting which I'm pretty certain is just a quad

#

if you wanted to actually shade the scene you'd need the scene normal buffer

#

then you can do some lighting stuff with that

#

but if you just wanted to brighten the minimap since its dark, why not just simply multiply the image by a brightness factor

#

if the image is HDR it should be able to do it just fine

distant dirge
distant dirge
#

it looks the same as if i try to use the WorldSpaceLightPos0

prime shale
#

because you were shading against the normals of the quad/triangle of the post effect

#

not the scene normals

#

as for how to sample the scene normals in URP I actually am not sure

distant dirge
#

hm

#

i think it really would be nicer if i could just render a bright directional light on only one camera

#

but the method i was using for that on builtin doesnt work in URP

#

and even on builtin it would mess up tree lighting

distant dirge
#

i have no clue how to get proper lighting for just the minimap tho

#

i think a lot of games just end up making a picture for the minimap

#

but i dont want to do that i think

#

sounds complicated

tight phoenix
tepid valve
#

im working on an outline shader which works by adding an extra material with vertices scaled and masking it

i was wondering if there was a way of having it scale evenly?

#

also for more complex shapes this isnt going to work, so was also wondering if theres a better of effectively moving the vertex "away" effectively and evenly

tight phoenix
#

Where are all my cap vertexes going when I apply a deformation to vertex positions?

#

when its flat they're all there, but as soon as I apply a deformation, it deletes most of them

#

and for some reason just makes a huge slope?

#

is unity helpfully doing something incredibly stupid and useless under the hood, optimizing it or something?

#

where are those huge planes coming from?

#

no such plane exists in the source

#

there were two nearly identical meshes stacked for no good reason ๐Ÿ”ฅ that was the problem

elder vector
#

Anyone have a good resource for learning custom render textures from scratch?

#

I tried to make one last night and it...was not good

distant dirge
tacit parcel
# distant dirge basically instead of actually applying an override shader (thats not ACUTALLY a ...

seems like you are doing in wrong step
render the objects with the minimap camera using unlit shader as replacement shader, that way your object will be renderer with unlit shader in minimap camera

for "replacement shader" in URP, this could be useful (although quite a long work around, for something worth several lines of code in BiRP)
https://developer.arm.com/documentation/102487/0100/Migrating-custom-shaders-to-the-Universal-Render-Pipeline

distant dirge
#

the link you sent

#

it did not work

#

maybe i just dont understand how to use an unlit shader

#

should i just create a shadergraph as unlit shader and not change anything?

tacit parcel
#

I think you can just use a material with shadergraph/unlit (or something)
seems like URP's "shader replacement" is not working in shader level, but it replace the material instead, and using layer to determine which material to replace (in BiRP, it conveniently uses shader tag)
Darn it, URP really makes something simple way more convoluted than it supposed to.

idle comet
distant dirge
#

but URP at the same time is really powerful

#

so i wanna keep using it

distant dirge
#

@tacit parcel wait so this is really weird

#

i put a unlit shader on a material

#

and set that material to a render objects renderer feature

#

as described in the link you sent

#

and i turned off post processing in the minimap camera

#

and it makes this weird part where the camera just cuts through to the regular camera

#

thats so weird

#

what the

#

i got this after some more fiddling

#

this is so weird
it would be so much nicer if i could just have a one camera light

neat hamlet
#

did you turn on the depth texture in the urp settings?

#

are you using a orthographic camera?

#

transparent render queue?

#

in the material itself, bottom

#

change queue control from auto to useroverride

#

nice !

tacit parcel
#

๐Ÿค” is it possible for a shader with multiple pass and a grab pass to be transparent?
My shader pass setup is like this
pass 1 -> render mesh
grabpass -> grab render mesh result to rendertexture
pass2 -> process rendertexture

they are working fine, but I'd like to make the shader/mesh transparent(alpha blended)
seems like it's impossible (at least without using additional grabpass or rendertexture) since my first pass need to be transparent.
But if I make it so, the process in pass 2 would be polluted by anything under the mesh

lunar valley
#

I like to use graphics.blit for something like that, and with that well, a blur shader

#

do you know the function graphic.blit? you can basically just apply post prossesing effects with that

#

well, that function takes in a source and a destination render texture and a material with a shader that does what you want it to do

#

Look it up, I often do my post prossesing effects with that UnityChanThumbsUp

mild ether
#

Hi folks, I'm trying to use the Secondary Maps feature in a Material, but the alpha in my png is showing as black. But White color works as alpha. This happens with all textures I tried.
Shader is Standard > Opaque.
Texture imported to Show Alpha.
Render Pipeline > Built In

Any ideas whats going on?

mild ether
#

found the answer. Color 128,128,128, is transparent.

grim nacelle
#

Question: when using View Direction node, I'm getting this dark image by default. How can I get this colorful image as is in those Tutorials?

lunar valley
regal stag
#

Though in older versions of URP, the View Direction node was not normalised by default and in newer ones it is. You can use the View Vector node instead to obtain the older functionality.

distant dirge
distant dirge
# distant dirge i put a unlit shader on a material

Does anyone know why this happens or how I can finally make my minimap brighter? Im gonna start working on other things today since ive been hyperfocused on minimap for so long but it would be nice to have the minimap working

#

There is a massive chain of reply messages you can follow upwards but if you need more info and dont wanna follow the chain please ping

tender valve
#

Hey guys i imported ne axe with normals and diffuse and AO but i getting some kind of glitch on there how to fix it ?? im using URP ....... for better showing im boost rougness ...... idk whats going on in blender is everything working fine

#

okay i manage to fix it something was wrong with normal map

karmic hatch
karmic hatch
#

They might also have depth * view direction

heavy stirrup
#

Is there an overdraw visualizer for Unity where you can see which transparent pixels have heavy overlap with other transparent pixels

grand jolt
#

hi! I have an issue with some materials in my game.. Whenever my character goes out of the camera's sight, my character's materials get instanced & a transparent material I applied on it becomes fully opaque again... Can instanced material be fully transparent? The alpha channel always go back to 255 when being instanced

mental grove
#

team i need some help with my shader, can anyone explain why i cant connect the output of this multiply with the vector 3?

grizzled bolt
mental grove
#

oh so whats the vertex stage equivalent of a rectangle?

dim yoke
grizzled bolt
dim yoke
#

Looking at the generated code, it seems it uses partial dericatives so thats why it wont work for vertex shaders

grizzled bolt
mental grove
grizzled bolt
# mental grove

Now they've freakishly amalgamated together
Don't use the gradient as the UV
Just replace the rectangle node with my node setup, but otherwise keep it like you originally had

mental grove
#

im confused, what are the inputs to my absolute nodes then?

grizzled bolt
mental grove
# mental grove

but you can see i do that here and i get the wrong output in the steps

grizzled bolt
#

These look quite different

#

I cropped out the noise node but anyway don't use noise as the UV
Unless you specifically want that

mental grove
#

yeah i need the noise so that it moves the Y value of the position at the end :/

grizzled bolt
mental grove
#

oo it wasnt but it looks like its what i want let me give this a go ๐Ÿ™‚

#

perfect thanks so much!

bronze shell
#

Hi guys. I've been having this problem for hours and I can't figure out the damn way ShaderGraph works. I'm trying to create a mask to an already created blur material, but trying to move things XD and researching the little information on the internet, I came to this: it creates the mask but leaves the material with VERY strong edges and red color???? what's the point?

grizzled bolt
bronze shell
grizzled bolt
#

Can't spot any cause for the redness

bronze shell
#

It seems to be in transparent, these are the settings you have

tacit coral
bronze shell
#

Suree

#

This effect

#

It is exaggerated to be noticed

tight phoenix
#

I am doing some vertex deformation in shadergraph and I noticed that it interacts funny with SSAO.
Pictured left is deformation without recalculating normals, right is deformation with recalculating normals.
Should the recalculated normal version have the SSAO highlighting the vertexes so clearly?

#

the SSAO looks a lot better (albeit darker) on the mesh without recalculating the normals, but if I don't recalc the normals then the lighting goes wrong

#

could I be doing something wrong that is causing the very obvious SSAO faceting?

#

or is that just how SSAO works?

#

hm I guess i should import a very wavey mesh for comparison

tacit coral
tacit coral
# bronze shell This effect

But also I think you could get this same effect if you add a slider on the smoothness and applying it to the mask you already have

tight phoenix
# tight phoenix

left is modeled, right is in-shader. It looks like SSAO itself is the problem and not the deformation shader?

#

messing with the values makes it look less terrible, though still somewhat faceted UnityChanThink close enough i guess

bronze shell
bronze shell
#

I was able to fix the reddish color with the material set to opaque, instead of transparent. Now the only dilemma is the smoothness of those edges ๐Ÿ˜ฆ

tight phoenix
#

Im having difficulty deforming vertexes and fixing the normals after deforming them

#

the above works, but I am struggling to adapt it to meet my use case

#

my use case - I have a mask because I only want to affect SOME of the verts, not ALL of the verts

#

and the actual deformation itself is in world space position, not object space position

#

I cant figure out how to combine those two concepts

#

when I plug in my alterations, the normals dont get recalculated

#

the problem has something to do with the world space coordinates

#

but I cant figure out how to fix that

#

it has to be in world space

#

but the other one has to be in object space

#

I dont understand the problem

#

my guesses above are wrong

#

but I dont know what is right or how to fix it

#

this works

#

but this does not work

#

the only difference is the noise I am plugging into it is in world space instead of object space

#

but I cant have it be in object space

#

so how do I fix it

#

the problem appears to be with world space

#

now im not even sure if it IS actually working in the original

#

getting frustrated and fed up and my anxiety at failing to achieve this effect is causing me stomach pain

tight phoenix
#

======
TLDR: how do I deform vertexes with a noise map that is based on world space position, but then recalculate the resulting deformed vertexes in object space?

tacit parcel
#

So, I'm trying a simple background shader which simply put an image in the background

            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = ComputeScreenPos(o.vertex);
                o.uv.xy /= o.uv.w;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                // sample the texture
                fixed4 col = tex2D(_MainTex, i.uv * 8);
                // apply fog
                UNITY_APPLY_FOG(i.fogCoord, col);
                return col;
            }```
But for some reason, the image looks distorted. Any clue on how to remove the distortion?
tacit parcel
#

Forgot to add: the shader/material is assigned as skybox

floral fox
#

I'm keep creating trails from my footage.

latent frigate
#

Hey,

Unity says that "Undeclared identifier DepthSobel_float"
although it has been declared in the hlsl file.
What's happened here?

EdgeDetectionOutlinesIncluded.hlsl

#ifdef SOBELOUTLINES_INCLUDED
#define SOBELOUTLINES_INCLUDED

static float2 sobelSamplePoints[9] = {
    float2(-1, 1), float2(0, 1), float2(1, 1),
    float2(-1, 0), float2(0, 0), float2(1, 0),
    float2(-1, -1), float2(0, -1), float2(1, -1)
};

static float sobelXMatrix[9] = {
    1, 0, -1,
    2, 0, -2,
    1, 0, -1
};

static float sobelYMatrix[9] = {
    1, 2, 1,
    0, 0, 0,
    1, -2, -1
};

void DepthSobel_float(float2 UV, float Thickness, out float Out) {
    float2 sobel = 0;
    [unroll] for (int i = 0; i < 9; i++)
    {
        float depth = SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV + sobelSamplePoints[i] * Thickness);
        sobel += depth * float2(sobelXMatrix[i], sobelYMatrix[i]);
    }

    Out = length(sobel);
}


#endif
vocal narwhal
latent frigate
rocky totem
#

anyone knows what makes preview blank?

grizzled bolt
#

I think every version has had it breaking under some circumstance

rocky totem
#

alr I'll try restarting first thanks

rocky totem
#

I tried to create this tornado like effect with shader graph 2d is it possible? if yes what should I put at the UV to recreate the swirl effect?

manic eagle
#

Hi!) Can someone explain me why i got red color instead of transparency in sprite with animated material. This problem occurs only if canvas in "screen space - overlay" mode

upbeat topaz
#

in shader graph, if I offset a uv channel it seems to offset every other uv channel at the same time
is there a way to offset UV's of only one uv channel at a time?

sudden portal
#

Hi, I'm trying to understand Custom material inspector but I can't find proper documentation about it, someone have some link to help me ?

I'm trying to make a custom inspector for my material and I need to have the dropdown menu for the basic "Surface Type", "Render Face" and the toggle "Alpha Clipping". Like in the basic Surface Options in the URP Lit.

ancient thistle
#

i have a 2d pixel art texture i have a map for it thats white and black, i want the white part to be effected by a shader of my choice but not the black part, is that possible?

shrewd delta
#

Has anyone tried to take Knife Entertainment's Sci Fi Hologram shader and use it with the URP? I may in the wrong location asking about this but the Sci Fi Hologram shader has custom shaders I want to use with the URP

grizzled bolt
upbeat topaz
slim steppe
#

It seams like you're already doing that you just havent actually offset it

upbeat topaz
#

ye, in the screenshot the offset is set to 0, but lemme show you how it looks when moved

#

left at offset 0, right on slight offset

#

what I wanted to do was only offset one UV set, which is set to only work on the planes where the eyes are

slim steppe
#

I have no idea what your shader does, all I can tell you is what the nodes you showed me do

#

It seams like you're only offsetting one, I dont know how you're blending it with the rest

upbeat topaz
#

the shader is setup like this:
I have 3 uv sets on the head object, 1 uv set on every other part of her
each of them is stacked on top of one another, with the alpha of the layer dictating what is shown
so when nothing is offset, everything seems to be working in order, but for some reason offsetting the 3rd UV set also seems to offset every other one by the same amount

#

oh wait

#

I think I see what could be the issue

#

when imported from Blender, the UV's are in the reverse order was wrong again

slim steppe
upbeat topaz
#

oh, I'm dumb, the actual reason for all that was that when creating extra UV maps on an object, it does a copy of uv's of all the faces, not only the ones selected

#

so that's why offsetting one looked like offsetting them all

#

thank you for taking your time to try helping me!

#

now it all looks a-ok

mental grove
#

team how do i slow down the sine time value

#

coz in sin(x), to reduce the frequency i divide the x value

#

but ive tried that and got some weird results, dont know how to print values in shader graphs either

#

nvm it wokred

heady pewter
#

is it possible to round things inside of shaderlab?

shadow locust
heady pewter
#

ok cool, it just feels like i was writing it wrong so it wasn't making a difference

#

which is problematic for me because unity doesn't scream at me when i write an error in shaderlab. it just makes my textures magenta

tropic crow
#

Hello! I feel like this might be a stupid question, but if I make an Unlit shader graph, and in the color I just plug a float set to 0.5, why is the color of my object (188,188,188) and not (128,128,128), which is ~half of 255?

prime shale
#

tldr; has to do with color spaces

#

gamma/linear

tropic crow
grim nacelle
#

pls help guys notlikethis I followed this tutorial https://www.youtube.com/watch?v=jAOqmx764dA and made a glitter shader. I didn't see any nodes or settings that are related to color, but when I apply the shader to an image, there's a yellow shade. How can I get a glitter shader that I can change color with?

Everyone loves glitter, but it gets everywhere. Luckily, we can just make a glitter shader instead. In this tutorial, learn how to use random noise colors (i.e. GIMP's Hurl filter) to make a glittery effect!
As a bonus, also learn how to flip the effect on its head to make a starry night shader!

โœจ Based on a VERY GOOD UE4 tutorial b...

โ–ถ Play video
meager pelican
sour monolith
#

hello i need help. I'm following a tutorial but when I apply the sahder to my sprite it disappears and I don't know how to fix it.

https://www.youtube.com/watch?v=eD7LmXShYcs&ab_channel=Unity

In this video, we are demonstrating how you can create a stylized water shader in Shader Graph by using a combination of scrolling UV and noise patterns. We are also using 2D lights to make our water respond to the lighting.

๐ŸŸข Click here to see the entire 2D Shader Basics Playlist:
https://on.unity.com/36Ln4Nd

๐Ÿ”ด You can download the Assets we...

โ–ถ Play video
grizzled bolt
#

3D shaders won't render with the 2D renderer

sour monolith
#

ha i understand thank you very much

sour monolith
grizzled bolt
#

Make sure you follow it closely

sour monolith
#

I'm not sure I understand how I can use the vertex object position ?

grizzled bolt
sour monolith
lyric anchor
visual tangle
#

Hi Every one!

#

If anyone knows about this question, please reply..... "How To Make Color palette To Change Object Material Color and decals texture at the same time using UI buttons in Unity"?

dapper ingot
#

heya
I have a main texture that encodes X and Y values in R and G channels. What I'm trying to achieve is using these X,Y values from main texture get a pixel from another texture. (I'm not using shader graph, just trying to code it) I can't seem to get the pixel from another texture

#

I'm absolutely a newbie when it comes to shaders so please bear with me as I try to learn ๐Ÿ˜…

dapper ingot
#

if it is even possible

grizzled bolt
dapper ingot
#

I'm still failing tho

grizzled bolt
dapper ingot
#

so the idea is

#

I have texture A which again has the coords for texture b

#

I've seen this video where they used this technique to switch characters clothing

#

without having to re-draw the character for each animation

#

its kinda hard to explain

dapper ingot
grizzled bolt
dapper ingot
#

it is 2D

#

here let me send the images I'm using

regal stag
#

You likely want to make sure that texture A is imported with sRGB disabled for this

grizzled bolt
dapper ingot
#

is there also a good resource for HLSL, Shader graph and just shader stuff in general

#

stuff like UV's, texels and stuff is bit confusing for me

#

I think I got it from here thanks @grizzled bolt and @regal stag for the help :)
update: yep made it work

meager pelican
# dapper ingot if it is even possible

As you've discovered, and with help from the above, it's possible.
It often isn't recommended, though. It's called a "dependent texture read" and it's a source of potential bottlenecks in shaders. This is because the 2nd texture read is dependent on getting the results of the first texture read in order to get the coordinates. So it has to WAIT quite a bit of time for the first read to finish before it can do the 2nd one. It cannot do them in parallel.

If you've only got a few of these, it might not be too bad, but if you're doing a lot of it you might wish to seek out alternative techniques. Like a flip-book switching of clothes instead.

sinful canopy
#

Hey there, I was wondering if there was a way to change material variables by using code and having those variables only be changed on that one object. The furthest I got was finding something called Hybrid something V2 and using a Material Override Asset, but I can't figure out how to change the values in that asset with code.

lunar valley
meager pelican
#

@sinful canopy
IDK what pipeline you're in, but you can investigate Material Property Blocks.
They work per object

#

The other way is to duplicate the material to have unique ones per object. That works with SRP batcher.

sinful canopy
#

I'm using the Universal Render Pipeline, and I did find the Material Property Block but I have no clue how it works, and the documentation I found didn't help me out.

meager pelican
#

Well, with urp you duplicate the mat. Usually.
How many unique instances do you need?
MPBs break SRP batching

sinful canopy
#

A lot...

heady horizon
#

Is it possible to access per-vertex physics material properties through a shader?

sinful canopy
# meager pelican Well, with urp you duplicate the mat. Usually. How many unique instances do you...

Basically, I have a leaf shader graph the makes the game object's vertices wobble, and there are two variables I want to change. The reason I want to change them is the tree grows over time and while it's in the sapling state the leaves detach from the branches because of the wind strength. So what I want to do is make the float for the wind strength slowly increase as the tree grows. However, when I change the wind strength, all of the trees also change along. Here's an image to show what happens:

grizzled bolt
sinful canopy
#

So I can check the game object scale and then multiply that by the wind strength inside the shader graph?

#

Not multiply but do some kind of calculation.

grizzled bolt
#

Yes

sinful canopy
#

Well, that should do it. I can't believe this was such a simple solution, I spent most of the day trying to figure this out. Thanks!

sinful canopy
#

It did work, just had to do a bit of tweaking and add another float for some more control.

grizzled bolt
sinful canopy
#

It is not unique, it simply fixes a problem that arose.

brittle schooner
#

Any of y'all know why does this do this?

#

whenever I'm close to the wall it sort of dither but I only want it to dither whenever the camera is close to the body

#

like this:

brittle schooner
#

any way to fix this?

lunar valley
brittle schooner
#

I can't really tell

#

I'm new at shaders

#

maybe this will help

#

it is HDRP lit

#

as I believe

lunar valley
# brittle schooner not an object

multiple question, is the shader applied to the entire screen or does it only sit on a specific object, also what do you mean not an object what is it then?

brittle schooner
#

like on the body

lunar valley
#

and what do you mean not an object? whats not an object?

brittle schooner
lunar valley
#

yeah and?

brittle schooner
#

like camera not the object

#

as you can see in the picture

#

the black wall on the right

#

call that an object

#

it is close to the wall and it causes dither on the body for some reason

#

like a little one

brittle schooner
lunar valley
#

so you only want it to dither when it is close to the capsule?

brittle schooner
brittle schooner
lunar valley
#

you can theoretically pass over the distance between the capsule and the camera to the shader, through a script

grizzled bolt
# brittle schooner

Keep alpha clip threshold at 0.5
dither will not produce values between 0 and 1 so no point plugging anything into the threshold

brittle schooner
grizzled bolt
#

You would instead plug your distance gradient to the In of Dither
However, for some reason dithering treats a value of 1 as half-transparent and 2 as fully opaque

brittle schooner
#

do I remove the remap?

#

and put a variable instead

#

did you mean like this?

brittle schooner
grizzled bolt
# brittle schooner

This is what I have that works
though this one fades anything beyond a world coordinate rather than by distance, you should be able to use it as reference to get the effect working in the first place

brittle schooner
#

hmm???

#

what do you have these set on

grizzled bolt
brittle schooner
#

plus it still does the thing

brittle schooner
#

which one is startend

grizzled bolt
brittle schooner
grizzled bolt
#

Looks correct
Before you had the whole mesh an uniform dither, but now there appears to be a gradient which is the goal

brittle schooner
brittle schooner
brittle schooner
grizzled bolt
#

If your game window is zoomed in or out the dither pattern will get messed up visually

brittle schooner
#

still does

#

I think it's cause of hdrp

#

gimme a sec I'll check

#

it's cool the way it works but I don't want it like that so I'll go back

#

still the issue is there tho

#

I'll turn off hdrp stuff

grizzled bolt
#

As long as you grasp how to utilize the Dither node with values it expects, then adding the kind of distance math you want becomes simple
You can also do the effect with alpha blended transparency first (without alpha clipping) and then convert it to a dithered type, as long as you use the remap as well

brittle schooner
#

yeah it's not hdrp

#

whatever

#

I'll deal with it in the future

#

thanks for the time Spazi :)

#

you showed me a little some

outer mica
#

I have a material created in C# via: var material = new Material(Shader.Find("Universal Render Pipeline/Lit")); . In the documentation, it says this shader has a property called "Alpha Clipping", but I can't figure out how to set that from C#. It seems like I need to call a method like material.SetFloat(prop_name, prop_value), but I don't know how to know what prop_name should be set to. Does anyone know how to find out all the properties a material supports? Or even just the name of this particular property?

regal stag
# outer mica I have a material created in C# via: `var material = new Material(Shader.Find("U...

Can look at the shader code. https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader
The URP/Lit shader does have an _AlphaClip property, though I imagine it's only for serialisation purposes / displaying toggle in material UI. For actually enabling it at runtime you'd want to use material.EnableKeyword("_ALPHATEST_ON"), as well as edit the _Cutoff property (material.SetFloat)

#

Though imo it would be better to create a material asset and instantiate that, otherwise the required variant may not be included in the build.

outer mica
#

The first part makes sense and helps a lot. Just knowing where the source code for the shader is is very helpful. I don't understand the other part, though. What's a variant?

regal stag
# outer mica The first part makes sense and helps a lot. Just knowing where the source code f...

If you scroll down in the shader you'll see a bunch of #pragma shader_feature / multi_compile lines. They allow compiling the shader into multiple versions/variants with certain features turned on/off. That way if those features aren't needed the shader can perform better.
For multi_compile it's usually safe to toggle at runtime. But with shader_feature, unity will strip unused variants from the build. So toggling those keywords at runtime would cause the magenta error shader if it can't find the required variant.

outer mica
#

I see why unity would want to do that, but that's definitely a big, weird foot gun. I guess I can make a base material that I clone off of programatically, but I don't love the idea of having half my material defined in code and half defined using checkboxes in the editor.

#

None the less, I appreciate the warning, and I think I understand what to do to avoid this problem.

shell pelican
#

are there any updated tutorials on how to do shader stuff with the node graph because I literally can't find any up to date tutorials ๐Ÿ˜ญ

#

I have a shader that was made in blender that I wish to recreate (since porting is obviously not possible) in unity and I just cannot find any tutorials whatsoever that are up to date

shell pelican
#

nvm ๐Ÿ˜ƒ

warm sigil
#

how do i get my blender shader to work in unity?

#

how do i get the top to look like the bottom (without the bones ofc)

shell pelican
# warm sigil

You'll have to recreate the shader from scratch in unity, you cannot port shaders over from blender to unity IIRC

warm sigil
#

dang that sucks

#

ahhh unity's shader graph works nothing like blender's ๐Ÿฅฒ

#

pain

#

would texture baking work for transparent materials?

dense flare
#

does anyone know how to get this fog shader to work as a height fog shader?

dense flare
#

nvm

#

i figured it out

hot kelp
dim yoke
viral rapids
#

Can someone please guide me as in how can i make a shader which makes it looks like object has cracks on it .
I want a cube to look damaged when it is hit and number of cracks on it to increase with more hit , till it is eventually destroyed .
thanks ^^

meager pelican
# viral rapids Can someone please guide me as in how can i make a shader which makes it looks l...

If you want the actual edges of the cube to crack and not just the in-between you may want to actually crack it and modify the mesh on the CPU side. This makes it easier to move chunks of the cube and have them protrude properly with lighting and shadows. There's several ways to do this, research "destructible geometry" and even check the store for add-ons that do it for you, maybe there's even a free one.

If you're after "optical tricks" in a shader to not modify the mesh, but introduce cracks in the view/lighting perspective, you can investigate "Parallax Occlusion Mapping" and somehow generate a cracked texture that you apply and change over time. POM generates "fake geometry" inside of simpler geometry.
https://en.wikipedia.org/wiki/Parallax_occlusion_mapping
https://docs.unity3d.com/Packages/com.unity.shadergraph@12.0/manual/Parallax-Occlusion-Mapping-Node.html

So that's two basic techniques, and as far as generating the cracked-POM-texture, IDK you'll either generate it procedurally on the CPU/C# side or you'll use a few variations of "canned" flip-books that you create in a graphics editor.

Parallax occlusion mapping (POM) is an enhancement of the parallax mapping technique. Parallax occlusion mapping is used to procedurally create 3D definition in textured surfaces, using a displacement map (similar to a topography map) instead of through the generation of new geometry. This allows developers of 3D rendering applications to add ...

viral rapids
meager pelican
# viral rapids Thanks a ton , really appreciated

Another way I've done it is to generate several models of the cube in blender, each more cracked than the last. And I just swap them out at each stage. You could even have an array of them such that you have 5 versions of cracked cubes with each version having say 5 or whatever degrees of cracks. It's a pain to do the modeling, but it's worth the results and you won't get hung up in shaders. Or do it randomly, procedurally, in C#.

grizzled bolt
#

There's a lot of different visual styles for a cracking effect most of which use entirely different techniques

#

Maybe you just need a texture overlay of cracks that can spread

viral rapids
grizzled bolt
supple leaf
#

why cant a multiply my shape with a color?

regal stag
supple leaf
#

uhh soo how can i use my shape and color it? ๐Ÿฅน

regal stag
#

Create the colour property again. You chose the wrong type

supple leaf
#

oh wow. now i see

#

stupid mistake by me. thanks for point it out

regal stag
#

The multiply should work fine. Though you may want to Saturate before to make sure the values are between 0 and 1.

supple leaf
#

thank you. big fan of your work btw.

lunar valley
#

I would like to get some subsurface scattering going in my water, I am just very unsure how to do that so if anybody can point me in a direction would be great cause all of my try's have not been very successfull

sleek kite
#

Any ideas why my shader that uses a compute buffer works in the editor but not in a build?

#

RenderDoc just reports the buffer as not set

#

I'm setting it on the material, so I'm not sure what's going wrong

#

_material.SetBuffer(_computeBufferShaderPropertyId, _computeBuffer)

sleek kite
#

Odd, setting the buffer globally works.

slim steppe
#

My shaders features using depth break when the objects transform isnt the complete dafualt at thw world center, could the way I'm converting the distance to local space be the problem? ```glsl
float3 rayOrigin = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1));
float3 rayDirection = normalize(i.positionLS - rayOrigin);

//https://www.cyanilux.com/tutorials/depth/
float linearSceneDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.screenPos)));
float fragmentEyeDepth = -i.positionVS.z;
float3 worldPos = _WorldSpaceCameraPos - ((i.viewDirVector / fragmentEyeDepth) * linearSceneDepth);

float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1));

float actualDistance = distance(rayOrigin, localPos);

#

It seams logical to me but I'm afraid I've got no idea what I'm doing

#

Thanks in advance!

meager pelican
#

It looks like you should be using all world-space. The camera position is world space to begin with.

slim steppe
#

I'm converting it so I can compare the results to a box intersection which I had done locally

meager pelican
#

Wait...
you're using past-tense in that sentence.

#

So you did the box BEFORE THIS and now you're doing something else.

slim steppe
#

yes!

#

Now I want it to be hidden behind other stuff

#

And I'm culling the front faces which wont allow it to be done by default

meager pelican
#

Let's say you're using a sphere now, and intersecting with the previous box.
The box's local space is not the sphere's local space.

#

Local space is object-space.

#

It's what you have in the model.

#

So the model has the origin, and all verts are relative to that for that model

slim steppe
#

right

meager pelican
#

So you can't do a distance calc between two object's local spaces, it won't mean anything.

slim steppe
#

Wait what

#

The box is just math not another object incase I explained that wrong

meager pelican
#

Is it an axis aligned bounding box?

slim steppe
#

I think so

#

Thats why I thought I'd do it locally so I can just rotate the object (and all the other stuff just moves relative)

#

Not sure if thats how it works tho

meager pelican
#

You can project the box from world space locations to the objects local space, I suppose.

#

But right now I don't see a box, just ray-origin of camera.

slim steppe
#

Do you want me to share the whole code?

#

Or the part where I'm doing the box intersection?

#

That might help

meager pelican
#

First, what I'm confused by is why you're so insistent on object-space.
I mean, the objects transform contains translation, scale and rotation. Don't you want that all to be able to happen?

meager pelican
#

But once that happens, you're basically in world-space.

#

So do the distance calc in world space and have your math-box be world space.

slim steppe
#

But the function doesnt take rotation, how'd I do that?

meager pelican
#

The objectToWorld matrix does all that.

#

TRS = Translate, Rotate, Scale.

slim steppe
#

Is that how intersection functions work?

meager pelican
#

Intersection functions work on points, or whatever they're designed to work on. So you'd transform the data to the same-space (like a common denominator) and then do the intersection test.

#

It's easiest to work in world-space, particularly if you want to end up with a world-space distance result.

slim steppe
#

So I'd rotate, scale, and position it manually? (this is the one I'm using)```glsl
https://iquilezles.org/articles/boxfunctions/

// Calcs intersection and exit distances, and normal at intersection.
// The ray must be in box/object space. If you have multiple boxes all
// aligned to the same axis, you can precompute 1/rd. If you have
// multiple boxes but they are not alligned to each other, use the
// "Generic" box intersector bellow this one.
vec2 boxIntersection( in vec3 ro, in vec3 rd, in vec3 rad, out vec3 oN )
{
vec3 m = 1.0/rd;
vec3 n = m*ro;
vec3 k = abs(m)*rad;
vec3 t1 = -n - k;
vec3 t2 = -n + k;

float tN = max( max( t1.x, t1.y ), t1.z );
float tF = min( min( t2.x, t2.y ), t2.z );

if( tN>tF || tF<0.0) return vec2(-1.0); // no intersection

oN = -sign(rd)*step(t1.yzx,t1.xyz)*step(t1.zxy,t1.xyz);

return vec2( tN, tF );

}

slim steppe
meager pelican
#

OK.

#

I see what you're attempting.

#

The function expects a local ray and local box

#

You're taking cameraPos, and a vert/frag's worldPos and projecting them to local space with worldToObject()

slim steppe
meager pelican
#

NP.
But remember the box has to be in THIS object's local space. Is it?

slim steppe
#

Yes

meager pelican
#

Would it help to have a routine that works in world-space for an AABB?

#

Maybe just for testing?

slim steppe
meager pelican
#

AABB is axis aligned bounding box.

slim steppe
#

So you're saying I should try see what happens if I'd have the box in worldspace?

meager pelican
#

It's easiest, IMO

slim steppe
#

Sure, I guess I'll try that

meager pelican
#

That routine would probably work as long as both spaces are the same space.

#

It can't really tell local space from world space, it's all just 3D numbers. XYZ coordinates.

#

I think the programmer was trying to say that they have to be same-space to make it work, and that makes sense.

#

In fact, local space is un-translated, un-rotated, un-scaled world-space. That's why your stuff is working at (0,0,0)

slim steppe
#

So should I apply rotation, position, and scale myself and take that as solution or make it work in worldspace and then in objectspace?

meager pelican
#

I'd do everything in worldspace which is what you get AFTER applying translate, rotation, scale to whatever they apply to. Including having your AABB in worldspace.

#

If you need an intersection test there's a ton on the net, just look for "AABB intersection test" or some such.

#

I can dig one up if I must, I used it in a ray-tracer.

calm mortar
#

Is it possible when I have Sprite A and Sprite B, to remove everything from part B from part A?

meager pelican
calm mortar
#

ty

sacred kraken
#

I made simple floor material in Blender, my question is how do I export it to unity in PBR Graph since half of the nodes I used in Blender are missing and im also noob :P

grizzled bolt
sacred kraken
tranquil wolf
#

Is there a curve node in unity? Cant find one and googling isnt giving an answer

#

wanted to create something like this

dim yoke
tranquil wolf
dim yoke
tranquil wolf
#

It's not my first shader project but I have only been using Unity for a few weeks

meager pelican
# tranquil wolf I was going to try to go big by making leaves with a shader but it's seeming way...

Just a suggestion out of the blue without knowing your full use-case:
Do yourself a favor and try it by making a double-sided quad (two quads, back to back) and map the UV values to a RGBA texture with a leaf on it. The alpha values are for using a simple alpha-cutout (alpha clipping threshold) shader. You can go nuts with leaves and shaders, but often, this is the easiest, IMO. You can implement a simple alpha clipped shader in shader graph, and randomize color variation and move verts in wind and stuff in the shader. Rather than trying to generate geometry in the shader or even procedurally. That's possible too, but often problematic.
Or not, it's up to you of course.

deft frost
#

How do I make a shader that just clips out any pixels in the volume of its mesh renderer to the skybox?

meager pelican
#

The trick with what you want is that the skybox is drawn AFTER the opaques are drawn. So what you have to do is NOT DRAW where you don't want to, and let the skybox be drawn in the hole. That, or use stacked cameras where the first one is just the skybox. You can then have a background to "grab" later I suppose, but it's better to not draw what you don't want.

So you'd use a stencil. Draw your special mesh using a stencil and no color output (color masked out).
ALL YOUR OTHER SHADERS have to honor that stencil and not draw where you don't want them to.

That's one way.

deft frost
meager pelican
#

OK

deft frost
#

The particle system is intersecting with the stencil, and it won't appear underneath it.

#

[The white rectangle outside the viewable area is meant to be a fake volumetric effect that should be visible in the cracks]

#

[Here's how it looks with the stencil and environment disabled]

regal ivy
#

Trying to make a noise effect go over a fill Image component that is controlled by a slider. Even if the fill image changes width, the noise should maintain aspect ratio. Right now, it's just strobing the whole thing and there's no individual noise pixels.

opaque mist
#

Sorry, I'm quite new to Unity's shader system, and I'm attempting to use a toon shader (from a tutorial) and apply a rim light effect (from another tutorial), but instead of getting the rim effect, I'm getting the opposite effect lmao.

#

It's a bit messy, but the top half is the toon shader, while the bottom half is the rim light effect

shy fiber
#

Does anyone knows how to write a shader like this? that adds volume to the mesh

lunar valley
shy fiber
#

created by the ice

#

look at his hammer

#

the shape is different after it is frozen

lunar valley
shy fiber
#

with shader graph?

lunar valley
tight phoenix
#

in this gif I've recalculated the normals of the mesh ๐Ÿค” Is there a clear cut way I can test if ive done it correctly? Looking at it it looks 'right' but is there some way I can debug to know 100% garuntee its right?

#

just the R and B channels (without mesh deformation) look approximately correct? But how can I be sure?

dim yoke
nova orchid
#

is this where i can talk about sprite mask

#

i had this sprite mask but i cant see it when i play

#

but in the editor i can see it

#

i think i fixed it

autumn sigil
#

Hey, anyone know the best way to achieve a radial gradient effect on a texture in Shader Graph? As if you were blurring the texture?

tight phoenix
#

I am changing the normals in the shader itself

#

is there some way I can force that change forward or make it realize this?

#
{
    private Mesh mesh;
    private Vector3[] normals;

    private void Awake()
    {
        mesh = GetComponent<MeshFilter>().mesh;
        normals = mesh.normals;
    }

    private void OnDrawGizmosSelected()
    {
        if (mesh == null) return;

        Gizmos.color = Color.yellow;

        for (int i = 0; i < mesh.vertexCount; i++)
        {
            Vector3 vertex = transform.TransformPoint(mesh.vertices[i]);
            Vector3 normal = transform.TransformDirection(normals[i]);

            if (normal == Vector3.zero) continue;

            Gizmos.DrawRay(vertex, normal.normalized * 10f);
        }
    }

    private void Update()
    {
        if (mesh == null) return;

        for (int i = 0; i < mesh.vertexCount; i++)
        {
            Vector3 vertex = transform.TransformPoint(mesh.vertices[i]);
            Vector3 normal = transform.TransformDirection(normals[i]);

            if (normal == Vector3.zero) continue;

            Debug.DrawRay(vertex, normal.normalized * 10f, Color.yellow, 5f);
        }
    }
}```
#

this is the script I am using to visualzie the mesh normals

#

but im getting the mesh normasl and not the material's shader's changes to the mesh normals after they get recalculated

#

why are there no good shader debugging tools? Trying to interpreter color values visually is so incredibly dumb and frustrating way to go about this

#

this is doing weird things and I don't know why and I cant find an easy way to diagnose exactly what is going wrong or how to fix it

#

getting extremely frustrated with it which is only making it harder to debug going into an infinite loop with no escape of failing to debug it and getting more frustrated by failing to debug it causing me to fail to debug it ๐Ÿ”ฅ