#archived-shaders

1 messages · Page 97 of 1

reef grove
#

what are you using for a skybox whats the material is it a texture or a shader or what

rain scaffold
#

is a spherical one, im not sure if the noise is turned or the sphere itself

ebon sorrel
#

Hello, I have put together this shader here

#

for this effect,

#

But I cannot figure out how to get the distortion to encircle the disc entirely

#

It stays in the lower left quadrant regardless of camera position, rotation, etc.

#

I know it's related to the screen position node, if I invert colors there it does move but it also flips the distortion on the skybox, so thats no good

rain scaffold
fringe karma
#

How is emission calculated? I'm trying to add it to my toon shader

kind juniper
fringe karma
#

I presume that on the regular lit shaders, the emission settings are just ``value + (emission colour * multiplier)`?

devout quarry
#

Have you read that outline tutorial that was linked? It explains it.

thorny owl
spare rain
#

I was following a old guide about water shaders, up this point it was going okay, but the light. I am using HDRP, i think my scene color is over exposed, not sure where 2 begin.

devout kayak
#

trying to calculate how much an object should rotate on the y axis to always face the camera but not working correctly

#

also tried dot product between that normalized vector and (0,0,1) then arccosine but same problem
the problem is it only updates the angle when there is a big difference and overshoots the rotation about 90° or a bit less

kind juniper
fringe karma
#

so I think that all I need is 'existing value + emission colour' and a bool that only adds on the emission value if it's enabled

kind juniper
#

Not sure about addition. I think the standard behaviour is that it overwrites the calculated lit color if emission is stronger. At least if I remember correctly how it works. You can test it out with a standard shader and see for yourself.

fringe karma
#

@kind juniper I guess I'll give it a try later, thanks mate

#

currently I need to diagnose my thermal vision overlay's dodgy performance, I think it might be because I'm fetching a command buffer from the pool and releasing it every frame, instead of just keeping the same one

azure geyser
#

How do you set a GraphicsBuffer on a material when using CommandBuffer?

azure geyser
kind juniper
#

On lower level, there are no materials. Once you bind a buffer, it's gonna be used for the next draw call. That's what it means to be global I think.

kind juniper
#

Setting a buffer on material would just bind it to the specific material instance. That's the only difference.

azure geyser
kind juniper
azure geyser
kind juniper
#

Also, perhaps because if you add more draw calls to the command buffer, they all are gonna have that buffer bound. Until you override or unbind it.

azure geyser
kind juniper
#

Modifying the GPU state costs performance, so it's cheaper to just leave it as is instead of setting null or something. Though, in this case, the difference is probably negligible

topaz marsh
#

I have a custom Scriptable RP that uses the Vulkan render passes for deferred rendering, but sometimes I have random stretched triangle artifacts that appear on the screen for a single frame. To investigate I opened frame debugger and saw that every render target is flickering.

#

I noticed that if there is a scene view and game view the flicker is between 3 "TempBuffer x" and if I hide one of them its between 2 and if I hide both its only a single blank buffer.

kind juniper
#

Sounds like tripple buffering issue? Do you know what that render target is used for?

azure geyser
# kind juniper Modifying the GPU state costs performance, so it's cheaper to just leave it as i...

So I had this code in OnPostRender attached to the camera, but I'm trying to move it into a render pass of HDRP.

_lineMaterial.SetPass(0);
_lineMaterial.SetBuffer("lineBuffer", LinesManager.lineBuffer);
Graphics.DrawProceduralNow(MeshTopology.Lines, LinesManager.lineCount * 2);

I have this code in the render pass, but the lines are not drawing correctly. The positions appear to be wrong.

ctx.cmd.SetGlobalBuffer("lineBuffer", LinesManager.lineBuffer);
ctx.cmd.DrawProcedural(LinesManager.lineBuffer, Matrix4x4.identity, _lineMaterial, 0, MeshTopology.Lines, LinesManager.lineCount * 2);
kind juniper
#

What shader are you using in the material?

azure geyser
#

A custom shader I wrote (with help from Rukhanka), It works in when using the first approach.

struct LineData
{
    float3 startPos;
    float3 endPos;
    float4 color;
};

struct v2f
{
    float4 pos : SV_POSITION;
    float4 color : COLOR;
};

StructuredBuffer<LineData> lineBuffer;

v2f vert (uint id : SV_VertexID)
{
    v2f o;

    uint lineId = id >> 1;
    LineData ld = lineBuffer[lineId];

    bool isEndPoint = id & 1;

    float3 vertexPos = ld.startPos;

    if (isEndPoint)
    {
        vertexPos = ld.endPos;
    }

    o.pos = UnityObjectToClipPos(vertexPos);
    o.color = ld.color;
    return o;
}

fixed4 frag (v2f i) : SV_Target
{
    return i.color;
}
kind juniper
#

Well, you'll need to debug it.

#

I can only guess that either the buffer contains invalid positions or the matrix is incorrect. Perhaps identity matrix is not correct for default transformation? Never touched on matrices. Or perhaps there's some parameters missing that get bound during DrawProceduralNow but not if you use command buffer?

#

Something that unity uses in UnityObjectToClipPos

#

Like a camera matrix or something

azure geyser
#

I'll keep digging, thanks for the suggestions. They are world positions so I thought identity is correct, but maybe not.

robust path
#

Any idea why my assigned texture in a custom shader that I have, doesn't match what is displayed? seems like a UV issue to me. That multiply in shadergraph goes directly to color on the fragment shader

#

no messing around with the vertex part of the shader

#

I'm setting the texture via material.settexture

digital gust
robust path
digital gust
#

is it an image component?

robust path
digital gust
#

tried it with an image yet? to be sure its the shader and not your custom comp?

robust path
digital gust
#

yeh, i mean you can just ignore my suggestion 😄

robust path
#

the component generates a custom mesh in OnPopulateMesh, and disabling it does indeed fix the problem I guess...

digital gust
#

Does your mesh have uvs assigned?

robust path
#

I can see uvs being assigned, but it's not my code and it's pretty complicated so I struggle to figure out if they're correct

digital gust
#

I would guess, they are not, as the texture is strechted weirdly

robust path
#

I have, for testing, set it up so that it renders just the UV, and it's correct, but on the objects where a texture is set, it renders a black image instead of the UV

#

the texture is set on the images above, but the image below doesn't have a texture set

warm pulsar
#

it does some evil stuff to support masking

robust path
#

oh my god the issue was that there was a canvas somewhere up the parent tree that had "additional shader channels" as everything and one of the channels broke everything

warm pulsar
#

ah, that would make sense

#

I'm not sure how that actually works, but I've had similar breakages with particle systems where my vertex data layout didn't match up with what the shader expected

kind juniper
azure geyser
teal igloo
#

@warm pulsar im sorry for ping but i just came back on pc, should i upgrade to 2023, or is there any better versions?

#

cause i dont feel like upgrading to 2023 just to find out there is one feature later that i would need 😭

#

also im kinda low on space would it be alright?

warm pulsar
#

you can certainly give it a try -- you'd upgrade to the latest Unity 6 LTS release

#

I would try to get a little more room.

#

Make sure you have a backup of the project, of course

teal igloo
#

cause if i get lower than 20 my pc doesnt work 😭

warm pulsar
#

Yes.

#

If you have old projects you aren't actively working on, deleting their Library folders can free up a lot of space

#

(and, notably, your project backup can exclude the Library)

teal igloo
#

like if 2021 is 10 gb

#

how much is unity 6

#

this is the best i could do

#

all of my projects are on another drive
i only have programs here

azure geyser
teal igloo
#

im just saying like the program files if that would exceed 12gb

azure geyser
teal igloo
#

okay thanks

#

im installing 36f1

#

its the LTS

azure geyser
#

shouldn't be much of a difference in size

teal igloo
#

i already have vs code and vs

#

i unchecked this

#

all will be good right?

azure geyser
#

yes

teal igloo
#

okay thank you

azure geyser
#

Going back to my problem from earlier, I have tried passing the view projection matrix manually to my shader like so.

Matrix4x4 vpMatrix = ctx.hdCamera.camera.projectionMatrix * ctx.hdCamera.camera.worldToCameraMatrix;
cmd.SetGlobalMatrix("_ViewProjMatrix", vpMatrix);
cmd.SetGlobalBuffer("lineBuffer", LinesManager.lineBuffer);
cmd.DrawProcedural(LinesManager.lineBuffer, Matrix4x4.identity, _lineMaterial, 1, MeshTopology.Lines, LinesManager.lineCount * 2);

I created a second pass in the shader,

struct LineData
{
    float3 startPos;
    float3 endPos;
    float4 color;
};

struct v2f
{
    float4 pos : SV_POSITION;
    float4 color : COLOR;
};

float4x4 _ViewProjMatrix;
StructuredBuffer<LineData> lineBuffer;

float4 WorldToClipPos(float4 pos)
{
    return mul(_ViewProjMatrix, pos);
}

float4 WorldToClipPos(float3 pos)
{
    return WorldToClipPos(float4(pos, 1.0));
}


v2f vert (uint id : SV_VertexID)
{
    v2f o;

    uint lineId = id >> 1;
    LineData ld = lineBuffer[lineId];

    bool isEndPoint = id & 1;

    float3 vertexPos = ld.startPos;

    if (isEndPoint)
    {
        vertexPos = ld.endPos;
    }

    o.pos = WorldToClipPos(vertexPos);
    o.color = ld.color;
    return o;
}
#

My math must be wrong somewhere.

azure geyser
# kind juniper Would be nice to know what was the issue when you figure it out.

Okay I figured out the problem and it kind of makes sense now.

I was doing this which was not working:

cmd.SetGlobalBuffer("lineBuffer", LinesManager.lineBuffer);
cmd.DrawProcedural(LinesManager.lineBuffer, Matrix4x4.identity, _lineMaterial, 0, MeshTopology.Lines, LinesManager.lineCount * 2);

And this is what works:

cmd.SetGlobalBuffer("lineBuffer", LinesManager.lineBuffer);
cmd.DrawProcedural(Matrix4x4.identity, _lineMaterial, 0, MeshTopology.Lines, LinesManager.lineCount * 2);
#

So I guess I was incorrectly using the wrong overload

#

and shouldn't pass the buffer in cmd.DrawProcedural

I don't know what the use case for that overload is, but it is working now nonetheless.

teal igloo
#

i will go to unity talk

azure geyser
minor remnant
#

hey, any attempt to use the .Gather() hlsl function in my shader results in this error:

cannot map expression to ps_4_0 instruction set at [line where I use the function] (on d3d11)

#

any way I could fix this?

thorn vessel
#

I don't really know if this is achieved in HDRP or URP, if it's a post-processing or a shader. But I was curious if anybody knew how to replicate a shader like so: https://www.youtube.com/watch?v=ZsMHY4LDyRE&ab_channel=t3ssel8r

Currently I'm using Unity's toon shader, which I really like! But I would like to get towards something a bit more pixelated in 3D.

Date of Recording: 2021-01-22

It's been a while since the last update from before the holidays. Several things have been in the works, including a fairly involved procedural terrain generator that deserves its own explanation video some day. Here we are showing off the improvement to the main pixel art shader including light-aware edge colorati...

▶ Play video
warm pulsar
#

I'm not sure what Gather you're talking about here -- if it's the one Texture2D, that requires Shader Model 4.1

#

and ps_4_0 is 4.0

azure geyser
#

That would be my guess as well

warm pulsar
#

I thought this was going to be a compute shader thing at first

#

(which would probably demand Shader Model 5.0)

minor remnant
#

changing it doesnt fix it as the function is in a separate script, hm

azure geyser
warm pulsar
#

alternatively, there is #include_with_pragmas. I guess that'd wind up respecting the #pragma directive in the included file

#

I don't know how that works out (especially if you declare multiple versions)

thorn vessel
azure geyser
minor remnant
#

still new enough to this that I didnt realize I could just set the target in the separate hlsl file

serene condor
#

how would one recreate this property on the standard BIRP shader?

warm pulsar
#

the dropdown in particular?

#

it lists some built-in property drawers for materials

serene condor
#

i'm building a flash effect over standard shader properties

#

so need to recreate some things

#

ah i mean how would i create that property in my shader graph?

#

oh, keyword enum?

#

SmoothnessTextureChannel

#

looks like

warm pulsar
#

What are you looking at right now?

serene condor
#

"Source"

warm pulsar
#

That will correspond to creating an enum keyword property in your shader graph

serene condor
#

yeah one of those

#

it looks like

#

huh, it seems to have converted to the correct property name automatically when i put in _SmoothnessTextureChannel

#

just wild guess but the dropdown wont appear in my shader settings

warm pulsar
#

"Predefined" is incorrect

#

that's used for a keyword that can't change

#

you want "Shader Feature" here.

serene condor
#

oh i thought it was referring to a property that is known by the engine

warm pulsar
#

no, there's nothing special about this name

#

Note that you can really just leave this out entirely

#

unless you genuinely need to be able to configure where the smoothness comes from

serene condor
#

is it metallic alpha by default i'd assume?

#

hm, this produces very different results from the standard shader

#

standard

#

my shader

warm pulsar
#

Your shader is not using the alpha of the metallic map.

#

It's just using a constant value for smoothness

warm pulsar
serene condor
#

oh

#

yea there it goes

#

curious why the smoothness float on the standard seems to affect it though

#

or is it multiplying?

warm pulsar
#

It multiplies the slider with the value it got from the metallic map, yes

serene condor
#

aha

serene condor
#

basically at 1.0 it should just appear all (color)

warm pulsar
#

I'd use the Lerp node to blend between the original albedo color and the solid color

#

you'll also want to add some emission

serene condor
#

yeah the color is hdr too

warm pulsar
#

basically just (1 - t) * a + t * b

serene condor
#

hmk

warm pulsar
#

But emission can go arbitrarily high

serene condor
#

yeah i mean it works sort of

warm pulsar
#

(It wouldn't make sense for albedo to go past 1 -- that would mean that the surface reflects more light than a perfectly white object)

serene condor
#

it needs a significant intensity level to flush it out

#

its getting the same result as the Overwrite blend style

warm pulsar
#

i don't use the blend node much, so I'm not sure how that'll work

serene condor
#

i guess thats not quite what i was going for but itll do

#

i wonder if i just set the texture alpha inverse to the fade time

warm pulsar
#

what are you actually trying to accomplish here?

serene condor
#

flush the entire mesh with the color at fade time = 1.0, and show the standard texture at 0, and blend between them in between

#

like when you get hit in a game and your character flashes a color

#

thats what im going for

warm pulsar
#

lerp between the color you get from the albedo map and a solid color

#

that's it

serene condor
#

i tried that, didn't quite work

warm pulsar
#

show me the graph

#

as well as the result

serene condor
#

at 1.0

warm pulsar
#

ah, yeah, you'll still be getting normal lighting on the object

serene condor
#

it looks like it should be working according to the lerp node preview but it doesn't appear to be flushing it out

warm pulsar
#

so you'll see dark areas and shiny areas

serene condor
#

ohhhhh shit right

#

cuz its lit

warm pulsar
#

Consider doing the following:

  • Lerp the albedo to black
  • Lerp the smoothness to 0
  • Lerp the emission from black to the fill color
serene condor
#

is there a node that could reduce its light receiving property?

#

i could tie it inversely to fade time

warm pulsar
#

you could also go ahead and lerp the Ambient Occlusion value to 0

#

That will prevent ambient light from showing up at all

serene condor
#

hmk

warm pulsar
#

unfortunately you can't just say "The color is exactly X", because you're just telling unity about some material properties

serene condor
#

ah... yeah this web is getting tangled and not really getting results

warm pulsar
#

it is possible to hand-write a shader where you can do both "exactly this color" and "actual lighting", but not in the shader graph

serene condor
#

i think

#

just having the hdr flash was fine

#

it get sthe job done with a certain intensity level

warm pulsar
#

A bright emission will wash out everything else pretty well

serene condor
#

yea good enough for now i dont wanna get too hung up on this rn

warm pulsar
#

make the albedo color black as well

serene condor
#

with a low intensity color that seems to be closer to correct

warm pulsar
#

one important thing -- if the color is really intense (say, [16, 16, 16]), then you'll only need to slightly blend it with the original albedo to get white

#

That will make the albedo go to white super quickly

serene condor
#

yeah this was very enlightening thanks

warm pulsar
#

I'd just set the base color to black while flashing

#

so, instead of using your Color input, use black

#

also, it looks like you've wound up double-counting the fade time

#

you're multiplying it with the color and then using it to lerp to the resulting color later

#

you can just lerp between the original albedo and black

serene condor
#

i was having it subtract the albedo towards black as the float goes from 0 to 1

#

oh hm

serene condor
#

i think we're not getting around the lightning influencing it

warm pulsar
#

plug this directly into the Base Color node

#

base color goes to black; emission goes to white

serene condor
#

although with the color being white it does seem to get better results without as much intensity required

#

actually yeah i just need to tweak the emission color but thats better

#

red result 1.0 intensity~

#

white at 2.0

#

its more responsive either way

#

at'll do thanks so much for your time

pulsar forum
#

Anyone recommend a good shader to have walls show a hole to see through it to your player / target?

foggy bison
#

how can i stop the texture from stretching around the edges? (offscreen stuff is just rotation)

kind juniper
#

Ah, you're using object position for uvs..? That might be the problem. Thing of what values it would have at points close to the poles.

#

You might need to use triplanar mapping for it to work

pure vapor
#

is there a way to detect if a shader is being rendered in the shader graph final preview (+ inspector/project tab preview)

#

cause from digging online ive found a property called SHADERGRAPH_PREVIEW

#

however when hooking it up to a shader graph using a custom function, it returns false in the final preview

#

yet it returns properly in the node preview and ingame

#
void IsPreview_float(out bool IsPreview)
{
    #ifndef SHADERGRAPH_PREVIEW
    IsPreview = false;
    #else
    IsPreview = true;
    #endif
}
#
  • game
  • scene
  • node preview
  • shader graph preview
  • material preview
#

(black is false, white is true)

devout kayak
#

how to get the rotation of the object in your shader ?
I am using shader graph and object node only has position and scale

rough lotus
devout kayak
rough lotus
#

As long as the object with the material also has a component which does youMaterial.SetVector("_myPos", yourVector3); that's the most straightforward way to set it

#

Shadergraph is pretty limited with what it can really do, writing actual code (whether C# or custom HLSL functions) is sometimes a necessary evil

devout kayak
kind juniper
#

What's the goal of that shader anyway?

devout kayak
# kind juniper What's the goal of that shader anyway?

snapping the position and rotation of the mesh to mimic the effect of cartoon/anime as if it's moving in a lower fps
looked weird when snapped every vertex independently so used object position then snapped it then calculate each vertex position relative to snapped origin but it stopped rotating so added what in the screenshot to rotate , will try add snappiness to the applied rotation

#

would be better if I can control when vertex position should or shouldn't be updated

rough lotus
cobalt storm
#

t:material shader:Universal Render Pipeline/Lit"

i want to search for materials that are lit , how can i do this in editor ?
this doesnt seem to work

can anyone let me know how this works?

warm pulsar
#

You cannot get information like "where was this vertex one frame ago?"

#

(without it being provided via scripting, at least)

magic trellis
#

Hi everybody. First time writing in this Discord. I need some help: I have a shader that have some strange kind of "motion blur" that I don't want.

#

p.s.: When I rotate the stone or I switch off post processing on camera, there is no problem. it only show up when I orbit my camera.

warm pulsar
#

Can you try switching the anti-aliasing mode? That's going to be a property of your camera

#

i wonder if this is TAA going haywire

magic trellis
warm pulsar
#

Do you have both the HDRP and URP packages installed?

#

I noticed you had an "HDRP" section under the Quality setetings

#

it does look like you're currently using URP, though

#

I would try turning off the upscaling -- set the render scale to 1 and switch the filter to something else (note the warning about it not working mobile)

#

this is in the URP asset, which is in your second screenshot, in the "Quality" subsection

magic trellis
brazen nimbus
#

Hello there ! Nothing crazy here but I'm struggling to understand how the culling works here. My Alpha is set to 1 (so the result should be similar as an opaque object) but some (not every) backfaces are culled after the front ones. Is there a way to fix this and make it work properly with the alpha ? 🤔
thanks in advance !

warm pulsar
#

Every face is being drawn -- but because this is a transparent shader, there is no depth information

#

If face A draws before face B, face B will always render on top of it

#

even if face A should be in front

sharp radish
#

Hello. I need help with this texture. I want to make it double sided using Free Double Sided Shaders asset from the asset store. But could not get past this poing. What is happening here?

warm pulsar
#

Youl'll see different results as you rotate the cube

warm pulsar
sharp radish
#

I chose the Cutout and its like this now

warm pulsar
#

where did you choose that?

sharp radish
#

Also the image has transparency.

brazen nimbus
sharp radish
#

From the shader tab on inspector

#

dropdown menu.

warm pulsar
#

Show me where you chose that.

warm pulsar
sharp radish
#

Okay you see my plant is selected.

#

Here I went

brazen nimbus
warm pulsar
#

one thing that sticks out is that your base color has an alpha of zero

#

notice the black bar at the bottom

#

The alpha of the texture gets combined with the alpha of the base color (presumably, at least)

sharp radish
#

Its maxed now and still the same.

warm pulsar
#

If you switch to the Standard shader and put it on Cutout mode, does it look correct?

#

(just not double-sided, obviously)

sharp radish
#

It works as you said yes. Not double sided though.

warm pulsar
#

hm, maybe there's a setting you need to change on the double-sided shader, then

#

Can you share the entire inspector for the material?

sharp radish
#

The double sided?

warm pulsar
#

Yes.

sharp radish
#

This is how I got to that window if its any help

warm pulsar
#

ah, try ticking "Use BaseColor Alpha"

#

it looks like the shader expects you to provide a separate map otherwise

sharp radish
#

I checked it and its like this now

pastel grail
#

anybody knows if it's possible using the frame debugger, render graph viewer, or some other tool to display what's in a given structuredbuffer for a given frame / pass in that frame?

warm pulsar
#

Note that alpha clipping is all-or-nothing. Every pixel is either drawn opaquely or skipped

#

Since your texture is a bit blocky (I presume you set it to use Point filtering deliberately), the edges will be rough

#

You could use a separate cutout mask that's set to do bilinear filtering

sharp radish
#

Yeah I've done that on purpose.

warm pulsar
#

also, i'd turn down the specular intensity and the smoothness

#

i suspect that's why it looks washed-out

sharp radish
#

It doesnt do anything when I play with the sliders. For both smoothness and specular intensity

#

Oh wait

#

It looks like this after dragging specular to 0 but smoothness does not have any affect.

warm pulsar
#

I'm a little fuzzy on the specular workflow

#

But yeah, that looks nicer

#

You were getting a reflection of the skybox (which I presume is solid gray)

sharp radish
#

Skybox is not solid gray. We dont have that white part at all in our original texture. Not as this much at least.

sharp radish
#

@warm pulsar Sorry for pinging you but I forgot to say thanks. I messed with some sliders and got the look I wanted.

hearty obsidian
#

using unity low level graphics API, Graphics.RenderMeshInstanced, we can provide our custom struct as long as it contains an objectToWorld matrix. From the shader, how do I access the additional per-instance data passed via the method call?

grizzled bolt
#

@sharp radish @warm pulsar Assuming the other side of the plane does not look "washed out" it happens because of Double Sided option, and appears the same way with metallic workflow

#

I believe that's because the normal still remains inverted so it always produces the maximum fresnel value if not more

warm pulsar
#

Hm, that'd make sense

#

I know that Poiyomi Toon has an option to flip normals on backfaces

#

probably for that exact reason

grizzled bolt
#

Likely, and that helps with outlines too

#

I guess the other option would be for the shader to mirror fresnel and other view to normal calculations across the halfway point

sharp radish
#

Oh okay. I'll take a look. It looks the same from both sides though.

grizzled bolt
#

It would if you already toned all specular to zero

#

and/or smoothness

sharp radish
#

Ah yeah I did that. Specular all the way to zero.

warm pulsar
#

If you put those sliders back up, do the two sides wind up looking different?

sharp radish
#

Opening the project real fast

#

It looks the same from both sides

frigid jay
#

Or Unity has unity_InstanceID

hearty obsidian
#

@frigid jay thank you!

teal igloo
#

mode is canvas, on unity 6

warm pulsar
#

ah, you're editing the original material asset

#

when you access the .material property of a renderer, a copy of the material is made

#

Changing the original asset will not do anything to that particular renderer

#

(until you exit play mode and re-enter, at which point the asset gets copied again)

#

You can use .sharedMaterial to avoid this duplication. Note that this means that changing the shared material will change the material asset, which is often unwanted

teal igloo
#

uhm, i go play, go into the object, double click the material, and if i change it still doesnt update

warm pulsar
#

so the game view might not update reliably

warm pulsar
#

ah, and here's the other thing

#

unity does some weird stuff to support UI masking

#

it creates a new material and uses it instead of the original when rendering the image

teal igloo
warm pulsar
#

I think you just need to grab materialForRendering from the Image (instead of material)

#

This is a property of the Graphic class, which has different behaviors from Renderer

teal igloo
#

okay i will try

#

thanks

warm pulsar
#

i'm a little fuzzy on that -- i remember running into this issue before

#

but i don't recall what i did about it

#

looking at my existing code, I just use Image.material -- I don't think any masking is involved

#

I can tell masking happened here because the name changed

teal igloo
#

when i get to scripting it, i could update you on what works and what doesnt if u want

warm pulsar
#

The main thing I'm unsure about is whether the newly-created material is shared amongst many images

#

a snippet from my "radial arc" menu's code:

#
        private void Awake()
        {
            arc.material = Instantiate(arc.material);
            HighlightOff();
        }
#

clearly that needed to have a unique copy made

#

I wonder if it'll fall apart if I add a mask to the same canvas..

teal igloo
warm pulsar
teal igloo
#

my shader falls apart if i delete mask

warm pulsar
#

I'm not sure what happens when it creates the new material, actually

teal igloo
#

i meant to say delete **

teal igloo
warm pulsar
teal igloo
#

i think it is alright for placeholder

zenith bronze
#

Is there a such thing as a hair shader? If there is I need it I tried looking for some for vrchat to make it look like this on the left but my outcome was the right.

fast igloo
zenith bronze
fast igloo
zenith bronze
#

Yeah I'll do that. Thank you, I also just downloaded a shader called Alloy, so I'll mess with that aswell.

#

@fast igloo

fast igloo
#

also if you want more anime style hair a suprisingly good way to do that is just with an angel ring matcap

#

works on quest too bc its just vrc matcap lit for the hair

magic acorn
#

Currently, the slicing works however it slices in the wrong area when passing through portals.
I have to be missing something because the code itself that interacts with the shader is untouched and I confirmed that this shadergraph variant doesn't work in the original codebase.

#

In the shadergraph, where am I going wrong? I'm mainly been adjusting the order of the math nodes. The current screenshot is what I got from adjust the order of the math which at least gives me something.

lament scarab
#

i'm not sure this is solvable so thought i'd ask here for input
i modified the sprite shader, adding a shadow pass, so that it would render a shadow

       Pass {
           Name "ShadowCaster"
           Tags {
               "LightMode"="ShadowCaster"
           }

           ZWrite On
           ZTest LEqual
           ColorMask 0

           CGPROGRAM
           #pragma vertex ShadowVert
           #pragma fragment ShadowFrag
           #pragma multi_compile_shadowcaster
           #include "UnityCG.cginc"

           struct v2f {
               V2F_SHADOW_CASTER;
           };

           v2f ShadowVert(appdata_full v) {
               v2f o;
               TRANSFER_SHADOW_CASTER(o)
               return o;
           }

           float4 ShadowFrag(v2f i) : SV_Target {
               return 0;
           }
           ENDCG
       }

thing is, my sprite has some perspective drawn into it
is there a way i can adjust the shader to get the right result?

#

(and if it's really unsolvable, what technique could i use for "fake" shadows)

kind juniper
fringe karma
#

Is there any practical difference between combining then lerping, versus lerping then combining? E.g. in terms of performance? I mean the difference is probably negligible, but I'm trying to learn stuff and grasp the inner workings

#

also the third option, which I'm pretty sure is the most performant out of all of them

fringe karma
#

Actually, a more important question in terms of actually achieving stuff: How would I go about overriding just one part of a shader, but not the other part? E.g. overriding the fragment phase but not the vertex phase?

kind juniper
#

I'm not sure that's achievable with shader graph.

#

If you have hlsl code, you could just use keywords/defines to define different versions of a shader. Or if you have access to the low level rendering api, you can specify vertex and pixel shaders that you want to bind to the next draw call manually.

glad jetty
#

I've created a shader following a youtube tuturial for a forcefield. I got it to look good in the preview and on the material in the assets panel, however when I bring it to an object in game it loses all of its color and brightness.

Any ideas?

glad jetty
#

Offscreen on left in a time input.

glad jetty
kind juniper
#

I think, perhaps it's because you're using emission and transparency. You can't make color brighter than white, so adding whatever color is outputted doesn't change the final color.

#

Just a guess

#

What blending mode are you using?

glad jetty
kind juniper
#

Maybe try additive

#

But there's probably not gonna be much difference, unless you're using hdr colors

glad jetty
#

Using Additive caused the whole thing to become almost invisible.

hearty obsidian
#

In URP, can I somehow perform stencil ops with the low level graphics API and a shadergraph shader? Since it's not meshrenderers via the standard render flow, I'm under the impression I can't use renderer features for stencil ops.

The idea is I have a GPU trail of meshes with fading transparency. They're rendered front to back, they overlap significantly to form something that ressembles a smoothed mesh. I want to discard all fragments that overlap for a gradual fading effect.

kind juniper
glad jetty
#

I am using HDR for colors.

hearty obsidian
#

@glad jetty What RP?

glad jetty
#

HDRP

kind juniper
#

Ah, hdrp. Then it should be enabled by default I think

#

I guess alpha blending is the correct one.

#

I'd maybe check the alpha values that you get

glad jetty
#

I found these settings under player in project settings.

#

They were disabled

kind juniper
kind juniper
glad jetty
kind juniper
glad jetty
#

Well, I can see it now. Seems like something is causing the color to wash out.

kind juniper
#

I'd check the different noise/effect nodes you're using and see what value ranges they output

glad jetty
#

So, disabling the directional light for the scene causes it to look correct.

kind juniper
#

Maybe your directional light is super bright

#

Also, for such effect it might be easier to use an unlit graph. This one is lit, right?

glad jetty
#

It is lit

kind juniper
#

Is there a reason it needs to be lit?

glad jetty
#

I just followed the tutorial 🙂 I am VERY new to unity.

ruby sonnet
#

Can I put shader assembly(dxbc) into a ShaderLab(URP/HLSL) file?

glad jetty
kind juniper
amber saffron
# glad jetty Offscreen on left in a time input.

HDRP uses quite high light intensity values by default to mimic real life lighting.
What is happening here is that the emission color of the material is not high enough to be visible with the direct sun light.

The solution like dlich mentioned is to use an unlit shader, or to use the "emission node" between the color and emission output of the graph, with an "exposure weight" set to 0.

warm pulsar
#

You can use this to exactly compensate for exposure

warm pulsar
#

that makes it even simpler

candid pine
#

Hi i have a problem with a model in Safari WebGl Build

plain urchin
#

Hi i hope texture optimization fits in this channel
So having power of 2 sized texture is important to allow mipmapping. But my style is pixel art, with low res tex, filter Point, and mipmap off. Is there then any benefit in having POT tex size?

warm pulsar
#

I'm not aware of any other reason to keep a power of two

#

Note that some formats also put constraints on the resolution

#

e.g. some require the resolution to be divisible by 4

warm pulsar
#

I don't like how point lights don't get very bright as you get very close. The light should be super-intense right at the origin of the light, given how brightly-lit the whole wall is when I pull the light back.

I'm guessing I would need to change how light attentuation is calculated, but I'm a little unclear on what to do, exactly.

I see that AutoLight.cginc is sampling something called _LightTexture0 here:

#   define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \
        unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xyz; \
        fixed shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \
        fixed destName = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).r * shadow;
#endif

Maybe I need to write my own version of this macro that samples the texture differently?

#

For comparison, here's a point light in an HDRP game. This is what I'm looking for.

#

the light is astonishingly bright when it's very very close to a surface

warm pulsar
#

((and I'm doing forward rendering, if that matters))

#

well that's vaguely promising -- I just copied AutoLight.cginc and replaced the texture sample with a formula

#

and that's annoying: _LightTexture0's meaning changes depending on whether or not a cookie is being used!

#

the attenutation now lives in _LightTextureB0

#

This doesn't show up when I bake lighting, though. I imagine I have to go mess with something else.

#

Ah, that's configured elsewhere -- in the Progressive lightmapper

#

So nothing really matters in my shader! That's good (and bad) to know

#

It's a little annoying for the realtime light to not match the baked light, but I don't plan to use any mixed lights, so that's okay

#

and implementing proper inverse-square falloff in the shader looks plausible (but unnecessary)

warm pulsar
#

yeah, I got that working. It almost matches my inverse-square falloff I hacked into the shader

kind juniper
teal igloo
#

just changing the color, doesnt update it. so yeah, doing the .material = instantiate works

#

sadly if i want to make it real time, i need to do instantiate every single time i update it, i dont think its the best way but it just doesnt work if i dont

warm pulsar
#

That should work.

teal igloo
#

hmm let me try

#

yeah it works

#

thanks

warm pulsar
#

When you plug a new material into the material property, Unity makes a new material with the modified shader

#

and that material goes into materialForRendering

#

So the problem was that you were trying to modify the original material (which isn't the one being used)

#

Making a new copy every time meant that Unity was seeing a new material every frame and copying its values into the modified material

magic acorn
teal igloo
cunning thicket
#

how do I use an object to effectivley illuminate an intersecting object?
Where any object that enters the area is lit up using a shader?

candid pine
#

on Chrome it looks good, while on Safari no. But I do not understand why all the other assets go and this no

#

this is the problem that does on Mac

kind juniper
# candid pine

These are some really blurry screenshots.
Is it the textures being white in some places? Is that the issue?

#

It could be a graphics API difference issue. Does it work if you build a standalone Mac build?

tacit parcel
tacit parcel
#

like currently its
float3 offsetToSliceCentre = IN.worldPos - adjustedCentre;
not
float3 offsetToSliceCentre = adjustedCentre - IN.worldPos;

grand jolt
#

is it possible to import the textures from a blender model that uses slots into unity?
Like i've got a model with 5 different texture files for a single human body. Can unity import all of that?

warm pulsar
#

No -- shaders are, generally, not portable between different programs

#

I believe some very basic shaders can get exported into an FBX (basically, blender can figure out that the base color and normal textures are being used)

magic acorn
grand jolt
#

that's fine then. I just wanna prototype for now anyway. Wasn't planning to use slots anyway but thanks that's helpful. I'll just put a checkerbox patter on the model i downloaded

tacit parcel
tacit parcel
snow depot
#

Does anyone know a way to get sharp harp shadows without using shadow volumes? Because I tried to build shadow volumes from scratch once and it was a nightmare.

tacit parcel
snow depot
#

I'm using hard shadows at max resolution and max cascades but it's still jaggy in places SuiPensiveFukkireta

#

Is is possible to set a custom shadow resolution higher than the normal max? Nearly everything besides player and enemy shadows will be baked anyways so it should fine.

magic acorn
candid pine
candid pine
candid pine
#

e on Chrome does so and it looks good

grizzled bolt
#

@candid pine I would try different platform specific texture compression formats for those particular textures in their import settings
And different graphics APIs for the build too as mentioned

feral bronze
grizzled bolt
feral bronze
grizzled bolt
# feral bronze like this

So, the sprite is composed of 3x3 slices, and then reduced by removing/skipping those 3x3 rows and columns?
But in reverse to build it up instead

#

(Composed of 3x3 slices virtually, not as "sprite slices" in unity terms)

feral bronze
feral bronze
grizzled bolt
#

Regardless of the exact slice size I assume I'm understanding right that the shrinked version of the sprite is made by skipping over odd or even rows and columns of the grid

feral bronze
grizzled bolt
#

Old games used to store sprites as smaller chunks, so this kind of effect was convenient to make

grizzled bolt
# candid pine You say that solves it?

I'm not familiar with that issue but those are what I'd start tweaking first to see if they affect the issue at all to try to figure out what's causing it
And solve it, with luck

grizzled bolt
# feral bronze yup defenitely

If you don't want to make a flipbook animation for each sprite that only mimics the effect, a procedural option would probably work so that instead of UVs going linearly from 0 to 1, you'd have a math function that can skip repeating ranges

feral bronze
grizzled bolt
#

Then make sure the ranges match the pixel grid, and to snap to multiple ranges for each stage of the animation

feral bronze
grizzled bolt
grizzled bolt
#

This is the kind of math function you need instead, first image would be linear UV and the second the skipped
Something that jumps ahead in the curve for each interval
But I don't know off the top of my head what that would be in math language

#

(also it'd have to be centered separately, and fit to the pixel grid)

feral bronze
#

I think it should be sin right

grizzled bolt
#

Might be as simple as adding another linear curve to it that's stepped or "posterized"

grizzled bolt
#

I would use a higher resolution test image to see exactly what's going on
The few pixels make it hard to see if it was successful or not

feral bronze
#

I want these to take place instead

grizzled bolt
#

Yes, I think that's clear

#

But it won't look like that before you have the right method, and also the exact right variables for it

wide locust
feral bronze
echo moatBOT
kind juniper
wide locust
#

yes, and in accordance to that, the same spot light is working on all other shaders except this one

#

issue is only in build, in editor spot light making this shader lit too

kind juniper
#

Can you confirm what I asked? Take a screenshot of the quality settings tab.

kind juniper
wide locust
kind juniper
#

Maybe just take a screenshot of the player settings where the graphics API option is.

kind juniper
#

Also, what renderer asset are you using?

wide locust
#

URP balanced

#

the default one that we, just kept modifying as per my use

wide locust
kind juniper
wide locust
#

ok

wide locust
kind juniper
feral bronze
feral bronze
grizzled bolt
feral bronze
wide locust
grizzled bolt
feral bronze
grizzled bolt
#

That's what my images are showing
every 4 pixels 4 pixels are skipped
So the sprite is half as wide and tall

wide locust
grizzled bolt
feral bronze
feral bronze
grizzled bolt
#

The math is no different, and can be expressed in many ways

grizzled bolt
kind juniper
wide locust
#

because I don't have amplify shader I didn't made this shader

kind juniper
kind juniper
wide locust
kind juniper
wide locust
#

nah

kind juniper
#

I wonder if you can use the frame debugger with a build.🤔 That could help. Maybe.

kind juniper
wide locust
#

ok

wide locust
kind juniper
# wide locust nothing worth is there

Okay.
So you have several options:

  • Use some shader debugger tool, like PIX to debug the shader live.
  • Experiment with the shader code to determine where it goes wrong.
    Can't think of anything else at this point
wide locust
#

I don't know shader programming, gotta find someone

#

btw one more thing, the same shader material that is not getting lit by real time spot light is getting lit by real time directional light @kind juniper

kind juniper
#

I could have a look in PIX. But you would need to share a build(the simple scene from earlier would suffice), shader debug symbols and possible the shader source code too.

kind juniper
wide locust
kind juniper
wide locust
#

oh let me see if I can

kind juniper
#

Yeah, it would be easier if you share a minimal project with the setup that reproduces the issue.

muted carbon
#

i tryed drawing dotted line renderer

#

and i got this error

#

why this happening, and how to fix it?

grizzled bolt
feral bronze
feral bronze
kind juniper
# wide locust

Gonna have a look. Let's hope the issue persists in unity 6, since I don't have 2022.3 version ready 😄

cunning thicket
#

how do I do light projection via mesh without using unity lights?

kind juniper
feral bronze
wide locust
kind juniper
wide locust
#

that's just the sky box color

kind juniper
wide locust
#

not the spot light

kind juniper
#

No no. The env color is set to black

#

aah

wide locust
kind juniper
#

In fact, the wall doesn't seem to be affected by the ambient light at all

wide locust
#

everything will work on that shader except for a realtime spot light what I am using

wide locust
wide locust
#

*without baking it's only realtime light

kind juniper
#

Ok, so I was confused by your initial screenshot. I thought the problem was that the mesh is entirely black

wide locust
grizzled bolt
feral bronze
wide locust
#

found something ? @kind juniper

kind juniper
#

Still checking a few things

wide locust
grizzled bolt
feral bronze
kind juniper
wide locust
kind juniper
#

There's no such thing as "dirt" in unity. This is something implemented in the shader.

wide locust
kind juniper
wide locust
#

made a script to switch real time directional light on and off

kind juniper
wide locust
#

in forward+ it becomes matrix

#

ig shader only have support for forward

west knoll
#

Hi folks! I'm trying to make a world space projection of one set of textures (albedo,normal, smoothness). Albedo and Smoothness seem to work but normal break when the plane is rotated (red square). Has anyone already encountered this problem? For info i'm using shadergraph, the mesh is a quad created in unity

warm pulsar
wide locust
#

@kind juniper can't we replicate the shader in shader graph ?

kind juniper
candid pine
kind juniper
candid pine
#

But Don’t go

#

I sent both videos of how you see on Safari and on Chrome, but on Safari always makes me the same problem

kind juniper
candid pine
#

the problem is there anyway

kind juniper
candid pine
#

No

candid pine
kind juniper
candid pine
candid pine
#

but I can’t understand the problem, because on Safari it gives problems to that model creating that effect, and on Chrome it is seen very well

#

I mean a week that I have this problem and I tried everything, but I can not solve

kind juniper
candid pine
#

This is with Unlit

kind juniper
wide locust
ebon moss
#

Anyone have advice: I have a shader graph of medium/large size and I need to go and convert it to shader code so that I can have it interact with unity lighting features in a more custom way. Am i better off just rewriting the shader entirely or copying the auto generated shader graph mess and trying to work off of that

fringe karma
#

When I'm making a fullscreen shader in Shader Graph, how do I set up the effect to directly replace pixels that need to be modified, while leaving other areas completely untouched? I've messed around with some blend modes, but the best I can get is 'it mostly looks the part but some bits of the overlay end up transparent'

grizzled bolt
candid pine
grizzled bolt
#

What did you try precisely

candid pine
grizzled bolt
#

That's word for word what I said
Like which formats and APIs specifically?

kind holly
#

Guys, I'm trying to apply this shader to my sprite in Unity, but it doesn't seem to work in the Game window. I think the Pixel Perfect setting might be messing with it. I have no clue, but it seems like the shader is affected by the game's resolution. If the game is set to a specific resolution, the shader behaves one way; if it's set to another, it changes again. However, in the Scene view, everything works fine..

Shader: https://www.void1gaming.com/free-2d-wind-shader-for-unity-urp#:~:text=With this 2D Wind Shader,very simple and interactive way.&text=Just assign this shader to,of the Simple WInd Shader.

VOiD1 Gaming

FREE 2D Wind Shader for Unity URP for help with your Grass Sway and Flags Fluttering in your Games

drowsy shuttle
#

hello guys I need a quick help how can I render death information using camera?

ebon moss
#

is there a way to isolate the shadow functionality of URP/lit shadows? I want to calculate the shadows in the same way they are doing it in that shader for a different shader

#

I've looked at the docs and they provide a few methods but they just give basic black and white, un anti-aliased shadows

tacit parcel
chilly robin
#

I'm having a quirky normal map issue. I have a two channel normal map stored in the RG of my texture. The B channel has different data stored.

I'm using Normal Unpack node and then Normal Blend to mix it with my base normal map. This all seems to work from what I can tell.

The problem comes if I remove the texture. Empty texture defaults to black which is what I want, but the all black texture doesn't seem to play well with the normal unpack/blend. I assume I want to blend with 0,0,1 vector3 but I'm not sure how to get that and keep the texture unpack working correctly.

ebon moss
tacit parcel
chilly robin
tacit parcel
chilly robin
#

B needs to be 0

tacit parcel
#

ah, then it should be 0.5, 0.5, 0. But that assuming there's no remapping to blue channel, I'm not sure if the blue channel get remapped too or not (or remapped to another range)

#

so, yeah, if it;s remapped the sameway as other channel, then yes, it's grey (0.5, 0.5, 0.5)

chilly robin
#

Thank you, I'll try that!

chilly robin
#

Hmm, unpacking remaps the B to 1, but I need it to be 0.

#

But it's okay. Thinking about it, I can probably just substitute it with a small 2x2 texture with the defaults that I actually need. That would fix my issue.

main cape
#

Hello, I am not experienced with shaders in Unity so I was trying to learn how to write them for URP with HLSL by following an online tutorial.
The example code from the tutorial works as expected in my project, however the visual studio linting falsely detects errors related to importing the URP shader library and this means none of the library functions in the script are recognized by the IDE. I could just turn off HLSL tools, but I would like to have the linting features if it is possible to make them work. Has anyone else had this problem and how might I fix it?

#

I checked the packages folder in file explorer and it appears to be empty (it is not empty in the unity file explorer)

kind juniper
main cape
#

no its all imported

#

this is for the urp

kind juniper
#

I don't think the urp package includes the source code.

#

Did you find the hlsl file in the package files?

main cape
#

theyre all here

#

the shader literally works

#

its just that visual studio

#

says it doesnt

#

visual studio cant find the file

#

and this is js copy pasted code from some tutorial
i was looking for a way to make vs linting work so that i can easier write what i need later

kind juniper
#
  1. This is not the same path as in your ide.
  2. Unity shader compilation pipeline makes things more complicated. Try copying these files into the same directory as your shader and modify the include path.
main cape
#

ok

#

leme try

#

even js copying the shaderlibrary folder into assets causes problems

kind juniper
#

Yeah. So it's not gonna be as simple.

#

Just to make it work in the ide I'd try opening the file path in explorer and making sure your shader include is using the correct path.
That might or might not break during actual shader compilation

main cape
#

oh i tried that

#

the Lighting.hlsl also includes other files from the library

#

with paths that lead nowhere

#

so it just causes around 60 new errors

#

bc of the missing files

#

idk theres something weird going on
when unity compiles it it somehow finds the files
even though they arent in the packages folder

#

i pasted it into the packages folder now too

kind juniper
#

I see. Well, then the best thing you can do is just create some interface that would isolate the ide errors so that you don't get them in your shader.

kind juniper
main cape
#

ok

#

nice i js pasted their example code from the manual about "writing custom shaders" and it has the same thing

vocal narwhal
kind juniper
# lyric hill What the heck is an input assembler

Before your vertex shader executes, the draw call and it's data are passed through the input assembler. It prepares the data for use in the vertex shader.
The POSITION semantic tells it what data to put into that struct variable. It would take the corresponding vertex from the vertex buffer and out it's data in a thread for the GPU to execute.

lyric hill
kind juniper
#

Behind the scenes unity takes that position and probably transforms it with some matrices. Not entirely sure without seeing the underlying code.

lyric hill
#

This is the stuff that confuses me

#

oh wait

#

nvm

#

its clear now

proper iron
#

hello, i require some help for shader graph. i have made a dissolving shader graph for affecting alpha based on comparing the rgba values of a main texture vs another texture, but i want to implement it such that it can work in a particle system. how should i approach this?

#

an example of how i want the shader to work:
the dissolve float should switch from 0f to 10f on runtime.

#

is there something that i may be missing?

tacit parcel
vestal musk
#

@tacit parcel Continuing from the last channel, is it possible to do it with a shadergraph instead?

tacit parcel
vestal musk
#

Yeah, I'm still quite new to shadergraphs too 😅

#

So even if there is a solution, I won't be able to understand it unless someone guides me step-by-step haha

lucid thicket
#

okay, this is probably incredibly easy, but i just cant seem to find an answer

How do i add two sprites with a shader graph?
like, just layer them on top of each other. as if I had two seperate objects with a sprite renderer each on top of each other, including alpha?

west harbor
#

Can someone get me a shader for Haircards? I can't do it

lucid thicket
#

i want an RGBA input and a UV input to get an RGBA output

drowsy shuttle
drowsy shuttle
lucid thicket
proper iron
#

also does sprite size influence shaders somehow? smaller sprites are able to be used by my blur shader just fine whereas larger sprites have these weird lines/streaks to them

#

i was following this tutorial here

#

the shader graph

drowsy shuttle
loud comet
#

Hey how can i clear the bike wheel ?

warm pulsar
#

the rendering mode is currently set to "Opaque"

#

try using Cutout mode instead -- this discards pixels that are transparent

willow summit
#

Hello everyone, i was hoping to get help with a question:

Recently i upgraded from 2022 to unity6 version. It seems that the lit material of the urp renders darker shadows (normal based shadows not casted shadows). Is there a way to lighten this shadows without creating a new material?

drowsy shuttle
lyric hill
#

ok I still dont understand

#

In app data struct, Im telling the input assembler that vertex should contain positions in object space right?

#

In v2f Im telling vertex that it should contain positions in clip space

#

So I dont get why I need to run a seperate function to tell unity to compute clipPositions again

#

What am I misunderstanding

#

AM I DUMB

kind juniper
#

Also, it's not even the IA job. There's some other stage between vertex and pixel

#

Rasterizer I think

lyric hill
kind juniper
#

Kinda. You seem to be thinking of these 2 structs and variables as the same thing, but they're not related to each other whatsoever

lyric hill
#

So one is variable assignment and the other is variable declaration. Who made this syntax

kind juniper
#

In any case the semantics just tell something to the GPU about the variable. How it is used is context dependent

lyric hill
#

Any idea as to where I can find information about what each of the semantics mean @kind juniper

lyric hill
#

thanks

lyric hill
kind juniper
lyric hill
#

So it means something different in each use case? Input and output, as well as depending on where it is inside vertex or fragment functions?

neon hazel
#

Any known issues when trying to get alpha working on a Render Texture? Unity 6000.0.31f1. Doesn't seem to work no matter what I do

amber saffron
neon hazel
#

Tried a bunch of different texture formats (with alpha channel) and solid color camera bg color with alpha zero

#

My camera is of mode Base (since Overlay can’t have a render texture target). My render texture is in UI of screen space type Overlay

amber saffron
neon hazel
#

Because of the alpha issue I changed my plans to do a visual "scene" instead so that I don't need alpha, and it worked great. 🙂 So I don't have an "issue" anymore that would stop me from progressing, but RT alpha does seem to be either buggy or I just don't get something

west knoll
amber saffron
west knoll
amber saffron
amber saffron
neon hazel
west knoll
amber saffron
west knoll
brazen nimbus
#

Hello there ! I'm trying to use scene color node with transparent objects and I found something that might be interesting. The GrabPass / grab screen feature (https://gist.github.com/Refsa/54da34a9e2fc8e45472286572216ad17).
I'm using unity 6 and the thing is that it is deprecated. Does anyone would have any solution to this ? 👀
Thanks in advance ! 🌺

low lichen
timid jolt
#

any idea on how to make the following shader?

#

is this a toon shader?

#

cel shader?

civic lantern
#

What game is it?

#

Cel shader = toon shader

timid jolt
timid jolt
#

ty man

civic lantern
#

Ah i remember seeing this

#

Pretty crisp visuals

timid jolt
#

the movement in the clips looks crazy too man

#

just looks like a smooth game

civic lantern
#

Yeah, there's no harshness to any of the movement

timid jolt
#

you reckon thats possible in unity?

#

never really see games like that in unity

dim yoke
# timid jolt never really see games like that in unity

The gun and the enemies don't look too far of the Genshin Impact cell shading (the methods/shaders used there are quite extensively covered on countless online articles if you want to take a look). Floor/ceiling/walls look more realistic style, maybe combination of some sort of precomputed lighting (like APV) and screen space reflections. Everything is possible but will require some custom shaders etc.

versed dew
#

I'm trying to make a shader where the sprites alpha will flash when the turret is selected. How do I remove this black box around the sprite when the shader is active? (I'm new to shaders so if there is also a better way to accomplish this. I'm all ears)

timid jolt
# dim yoke The gun and the enemies don't look too far of the Genshin Impact cell shading (t...

https://www.youtube.com/watch?v=DlxuvvYZO4Q&t=213s

perhaps this with screen space reflections, as you said, will simulate the light well. plus post processing for colour correction and that

Step into the famous Sponza Atrium to see how to beautifully light an environment from scratch using a mix of baked and real-time techniques. Pierre Yves will showcase the GPU Lightmapper, the new Probe Volume system, ray tracing, and path tracing.

00:06 Introduction
01:18 Speaker
01:40 Volume system
02:47 HDRI sky setup
04:16 Direct lighting &...

▶ Play video
#

only issue is performance as this is hdrp

timid jolt
dim yoke
# timid jolt only issue is performance as this is hdrp

APV work on URP too but unfortunately screen space reflection don't. I think there are some assets that do that though. The game you showed definitely has some advanced reflections though, likely SSR. Could be planar reflections too but rendering everything (or even some of the objects) for the floor and ceiling again doesn't sound very performant either

timid jolt
# dim yoke APV work on URP too but unfortunately screen space reflection don't. I think the...

so URP plus APV and maybe the following SSR asset could simulate graphics like that game?

i’m pretty sure all the materials used in the game were from Quixel as well

https://github.com/JoshuaLim007/Unity-ScreenSpaceReflections-URP

GitHub

SSR solution for Unity URP . Contribute to JoshuaLim007/Unity-ScreenSpaceReflections-URP development by creating an account on GitHub.

#

thanks for helping me man btw

#

cause as you said the environment has pretty realistic lighting and materials

whereas the effects and models aren’t necessarily that detailed

uncut gyro
#

Hey hey, I have a simple texture, which is black, and each pixel of that texture has different transparency, based on light level in my lighting system

https://pastebin.com/vH2Z4jEr this is my shader for smoothing light between pixels. (my texture is around 64x64 but has local scale *= 8)
For some reason, when I move and light updates, it starts flickering, it doesn't happen if I don't use the shader

feral bronze
#

hello everyone so I have made this shader to swap palettes with a revealing effect this is the image having an error so basically ffe773 also gets converted to ffefff instead of just being like in this image here is the shader code https://paste.ofcode.org/fqmgHYk6LYSxLpSvvsyiM apparently it works well with some but in some it doesn't

uncut gyro
drowsy shuttle
drowsy shuttle
drowsy shuttle
tight phoenix
#

Noise function question:
Pictured is Photoshop's Filter > Render > Clouds.
When I google what kind of noise this is, the net calls it Perlin Noise.

When I search Perlin in shadergraph, I get Gradient Noise, which doesn't look like what Photoshop produces.
What actually is photoshop's cloud noise and how can I recreate it in nodes?

#

Other places call it 'Fractal Noise' so I assume there is some steps of plugging the noise into itself? I haven't been able to find an exact formula for how this noise is made though UnityChanThink

dim yoke
tight phoenix
dim yoke
spark frigate
#

Do any of the included shaders have an option to use a roughness / smoothness image as opposed to the slider in the universal render pipeline?

dim yoke
spark frigate
spark frigate
dim yoke
#

You have to put the roughness and metalliness in the same texture. rgb (I assume r alone is sufficient) for metalliness and alpha for smoothness

spark frigate
dim yoke
dim yoke
#

Alpha values of 0 to 1

spark frigate
dim yoke
hazy olive
#

hi! not sure where to ask this but anyone know why it's pink color in the content browser?

brave sable
#

Hello, im wondering if someone knows a solution for a problem of mine. I have a compute shader which accumulates triangle normals onto vertices. But i have a race condition which seems to only be fixable by using InterlockedAdd, but this only accepts integers which would need conversions and id rather avoid that. Is there some other way to do this? Here is the code in question:

[numthreads(64,1,1)]
void CumulateNormals (uint3 id : SV_DispatchThreadID)
{
    if(id.x * 3 > triBufferLength)
        return;
    
    int vertexIndex0 = triangleBuffer[id.x * 3 + 0];
    int vertexIndex1 = triangleBuffer[id.x * 3 + 1];
    int vertexIndex2 = triangleBuffer[id.x * 3 + 2];

    float3 v0 = verticesBuffer[vertexIndex0];
    float3 v1 = verticesBuffer[vertexIndex1];
    float3 v2 = verticesBuffer[vertexIndex2];

    float3 edge1 = v1 - v0;
    float3 edge2 = v2 - v0;

    float3 normal = normalize(cross(edge1, edge2));

    //Does not cumulate correctly because of race condition.
    normalsBuffer[vertexIndex0] = normalsBuffer[vertexIndex0] + normal;
    normalsBuffer[vertexIndex1] = normalsBuffer[vertexIndex1] + normal;
    normalsBuffer[vertexIndex2] = normalsBuffer[vertexIndex2] + normal;
}
feral bronze
#

hello everyone so I have made this shader to swap palettes with a revealing effect this is the image having an error so basically ffe773 also gets converted to ffefff instead of just being like in this image here is the shader code https://paste.ofcode.org/fqmgHYk6LYSxLpSvvsyiM apparently it works well with some but in some it doesn't

drowsy shuttle
ebon basin
#

https://i.imgur.com/Q2FDGgh.png
Let's say I've a render texture where each of these decals represents an entity's proximity. Now, I want to make an interactive vertex shader such as grass trampling, and I'm trying to figure out the best way to handle the trample direction. Maybe something like adding an eye (probably another color value) to these decals then have the vertex operation check a radius away from itself is one idea. Anyone any suggestions? Also looking for resources for this stuff as I seem to not been having that best of luck.

#

Yeah, maybe that's the idea. Instead of a color, I could also just find some opacity threshold, then grab a direction towards the lesser opacity value.

feral bronze
#

hello everyone so I have made this shader to swap palettes with a revealing effect this is the image having an error so basically ffe773 also gets converted to ffefff instead of just being like in this image here is the shader code https://paste.ofcode.org/fqmgHYk6LYSxLpSvvsyiM apparently it works well with some but in some it doesn't

steel notch
#

Alright question about general PBR stuff. As a sanity check.

#

If I have some ambient light/color, and a region on a mesh is white and fully illuminated, and I have bloom turned on with a threshold of 1.

#

I'm assuming it will glow? Right? Like that's the gimmick?

ebon basin
steel notch
ebon basin
cosmic thorn
#

Idk where to ask this but i have a transparent shader for a kind of destruction effect and i learnt that unity really doesnt like realtime sorting of anything transparent, which causes conflicts if two destructible objects are infront of eachother or whenever anything transparent like particles goes infron of the destructible objects, this causes incorrect sorting and objects that are behind will appear as if they are infront.
Anyone know any good sources to fix this issue? My game is graphically not expensive so a more expensive aproach is perfectly fine

grizzled bolt
slow socket
#

Hey guys, I'm making a 2D Pong-like game and I wanted to simulate some waves/ripples when the ball collides with something, as if the game was underwater, and I wanted the ripples to react to each other "naturally"

I have no idea where to start tho, if anyone can guide me toward a tutorial/documentation I would really appreciate it!

ebon basin
#

Probably need some SDF where each pixel value represents a velocity. Probably similar to how people do wind zones

#

Otherwise there's always some math solution which I'd probably wouldn't bother with

hazy olive
uncut gyro
#

Hey, I'm trying to recreate lighting system from Terraria. Thats how it looks right now.

It doesn't look good, I can't tell exactly whats off but I feel like the color is too intense?
Thats my light system: https://pastebin.com/tzHhX1NM
And the shader: https://pastebin.com/H0aiana4

any ideas how to improve it?

grizzled bolt
uncut gyro
#

okay interesting

#

I've never heard about something like that

#

mind elaborating?

grizzled bolt
uncut gyro
#

yes but like, what do I multiplicate, what do I do with transparency etc etc

shut remnant
#

guys i took a shader material i made with shader graph from an older unity version to the new unity 6 37f version and each material i take always comes like that , does anyone have any idea why ?

grizzled bolt
uncut gyro
grizzled bolt
#

I expect you probably don't want to do that

#

Since you get all kinds of weird results that way
Like how the brightest part of the light is darker than the area around it, which in turn has a dull sheen

uncut gyro
#

thats how it looks right now, without color lights

#

just pure alpha manipulation

ebon basin
#

What would be some ways to bend say grass vertices with the shader graph such that verts lower on the y bend less than those above? I don't really make vertex shaders with the graph, but I'm feeling like I'd probably want some geometry shader for this which I don't think is possible, right?

#

The only thing I can think of is giving the verts a minimum y to compare to via world position, but that would only work well on flat planes.

#

But, I could get the object position that the shader it assigned to right? Maybe that's the idea

grizzled bolt
#

Object position works just as well, but only if they're not batched or instanced in a way that they share the object position

ebon basin
#

I'm using terrain detailed meshes, I assume that's not instanced, or maybe it is actually

#

ahhh

#

What's the painting idea? I'm painting a texture from above using an ortho camera to create some interactive shader for grass trampling already

grizzled bolt
#

So like a black to red gradient in vertex color terms, as only one channel is needed for it

ebon basin
#

Oh interesting, where do I go about sampling that in the graph?

#

actually that does give me ideas of just painting a texture as well and sampling that

#

do like a green-red gradient texture

#

Oh, right you can acess the vertex data directly

#

duh lol

#

Yeah painting the vertex sounds like the idea

grizzled bolt
#

Sample Texture 2D LOD node works as well if you want to use a texture mask in vertex stage
But since then it's per vertex also the effect is practically the same as with vertex color

ebon basin
#

One problem with painting vertex though is I do kinda do modify during the fragment stage, but probably ways around it

#

anyway got some ideas ty

ebon basin
#

That grass there is all vertex colors, with a texture cutout

grizzled bolt
ebon basin
#

Oh right right, sounds like the idea then

prime shale
#

anyone here familiar with command buffers? Trying to draw an object by itself normally in a command buffer but the object is not being rendered

#
[ContextMenu("TestRender")]
private void TestRender()
{
    if (renderTextureConverterV2 == null)
        renderTextureConverterV2 = new RenderTextureConverterV2();

    if (commandBuffer == null)
        commandBuffer = new CommandBuffer();
    else
        commandBuffer.Clear();

    if (renderTexture != null)
        renderTexture.Release();

    renderTexture = new RenderTexture(1024, 1024, 32, RenderTextureFormat.ARGBHalf);
    renderTexture.filterMode = FilterMode.Bilinear;
    renderTexture.wrapMode = TextureWrapMode.Clamp;
    renderTexture.enableRandomWrite = false;
    renderTexture.Create();

    meshFilter = GetComponent<MeshFilter>();
    meshRenderer = GetComponent<MeshRenderer>();

    //Camera camera = SceneView.currentDrawingSceneView.camera;
    Camera camera = SceneView.lastActiveSceneView.camera;

    if (cameraToRender != null)
        camera = cameraToRender;

    Matrix4x4 cameraViewPosition = Matrix4x4.TRS(cameraToRender.transform.position, cameraToRender.transform.rotation, Vector3.one);
    Matrix4x4 cameraProjection = cameraToRender.projectionMatrix;

    commandBuffer.SetViewProjectionMatrices(cameraViewPosition, cameraProjection);
    commandBuffer.SetViewport(new Rect(0, 0, renderTexture.width, renderTexture.height));
    commandBuffer.SetRenderTarget(renderTexture);
    commandBuffer.ClearRenderTarget(true, true, Color.red);

    for (int i = 0; i < meshRenderer.sharedMaterials.Length; i++)
        commandBuffer.DrawMesh(meshFilter.sharedMesh, Matrix4x4.identity, meshRenderer.sharedMaterials[i], i, 0, null);

    //for (int i = 0; i < meshRenderer.sharedMaterials.Length; i++)
        //commandBuffer.DrawRenderer(meshRenderer, meshRenderer.sharedMaterials[i], i, 0);

    Graphics.ExecuteCommandBuffer(commandBuffer);

    renderTextureConverterV2.SaveRenderTexture2DAsTexture2D(renderTexture, "Assets/CommandBufferShadowTest.asset");

    renderTexture.Release();
}
#

this is my sample code

#

my actual camera view

#

but when rendering to a rendertarget via the code above

#

not showing up

#

what am I missing?

#

for the moment I'm trying to do a test to determine if I can render an object normally, with the materials it nomrally has, and see if they also sample a shadowmap, since there is another project I'm doing where this is a requirement

#

although in this quick test I'm already hitting a wierd hurdle lol

#

I've rendered objects with command buffers before, and this is the same setup I've also used before... but not getting anything now for some reason?

#

tldr;
trying to render an object in a command buffer render target, with it's default materials (default unity standard) and its not showing up

#

and yes, I know for the mesh matrix I'm passing in an indentity matrix, I also have tried (and done in the past) transform.localToWorldMatrix but that doesn't change the oddity thats happening here of the mesh still not appearing

ebon basin
#

Would it be possible to make these verts slowly lerp back into place after being displaced? Perhaps I can do it with the render texture, but I feel like that may get a little messy.

#

I guess it's not that bad, but it does feel a little too springy

#

could do something like a particle system trail perhaps that fades, hmm

ebon basin
#

Problem with that idea is I would have to give each entity a trail and that kinda defeats the purpose of trying to optimize this lol

#

does work though

mental bone
#

Perhaps you can do it with a computer shader that holds a buffer with a t value for each vertex. The shader will decrement the value and then the grass shader will read it as the t of a lerp to the original vertex position.

#

It’s how I fade out sphere mask hits on energy shields

glad jetty
#

I am trying to make a decal that displays a shadergraph I have made on it.

The shadergraph visually looks how I want it, but when I apply it to a material and assign that material to a decal projector it just shows up as a grey block.
Any ideas on where to be begin troubleshooting this?

ebon basin
#

Why can we still not use gradients as a color input? I know you can lerp two colors to make one as an alternative, but I'm looking for quite a few different colors here.

grizzled bolt
#

The editor's gradient fields are converted into lerps between an arbitrary number of colors

#

Which I guess is why they can't be a standard data type

strange prairie
#

You could definitely implement it on the GPU. But indeed, it’s a complex type

warm pulsar
#

So I just fixed a problem, and I don't understand how I fixed it. I have two prongs to this question, starting with this one:

I have a shader that needs to reconstruct world positions (based on depth) in the fragment stage. Therefore, it needs to compute a grab position and use that to sample the depth buffer.

I originally computed that position in the vertex stage and passed it over to the fragment stage.

That worked fine -- until I started testing in VR and discovered that the right eye was getting bogus positions.

I have switched to passing a copy of the clip-space position in a TEXCOORD semantic (because apparently SV_POSITION is...different??), then using that to compute the grab position in the fragment stage.

That works perfectly. Both eyes get exactly the right values.

...but why? Nooo

#

My second question is hopefully a bit simpler. My fragment stage now looks like this:

i.clipPos /= i.clipPos.w;
float4 grabPos = ComputeGrabScreenPos(i.clipPos);
grabPos /= grabPos.w;
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, grabPos.xy);

Why am I dividing by W here?

#

If I don't do that, it violently explodes

warm pulsar
regal stag
warm pulsar
#

yeah, and we're using homogeneous coordinates

#

so, IIRC, [1,1,1,1] and [2,2,2,2] represesnt the same 3D point

round coyote
#

i need help this is my first week using a game engine. i want to try game development but im getting pink textures. i bought this environment from the unity store. can anyone help me fix this in beginner terms. thanks

warm pulsar
#

These materials probably use custom shaders