#archived-shaders

1 messages Β· Page 99 of 1

eager folio
#

Then it wouldn't be a bayer pattern but a different one, but sure.

snow depot
#

SuiThink Would probably need a lot of rewrites then I suppose. Rip. Any idea what the pattern is called?

snow depot
#

Oh it's just called halftone? I thought the pattern would have some fancy mathematical name.

grizzled bolt
snow depot
#

Yeah halftone shaded comics are the style I'm trying to emulate for my game, I just didn't think the pattern in code would be called that lol

grizzled bolt
#

A halftone image filter probably benefits from math, but there's many ways to go about it

warm pulsar
#

Does this need to be able to cover up any object, or is it just going to be on a specific object?

#

I saw a video recently about doing this sort of thing...

#

It creates a halftone-styled effect

#

(although it's not exactly a halftone)

#

i'm gonna try implementing this soon; i want to create a VRChat avatar with an Obra Dinn-style gimmick

snow depot
warm pulsar
#

ha

#

If I had to do this Right Now (tm), I would try calculating the average brightness of each pixel in square bins

coarse flower
#

Heya all, first time really digging into shaders here.

I am looking to displace a tree more and more the further up from its origin/pivot, in Shader Graph.

The logic of it is.. working but I am getting a really odd disconnect between what is being rendered and what.. Seemingly 'should' be rendered? Any advice? Pardon if this isn't the best place to ask :/

warm pulsar
#

although I am surprised by that outcome a bit

coarse flower
snow depot
warm pulsar
coarse flower
#

Like I was doing things I was not meant to be doing

warm pulsar
#

or is it just a mesh renderer?

coarse flower
#

Mesh renderer in a manually placed prefab

#

Exhibits the same behaviour when viewed inside the prefab :S

eager folio
#

Where IS the pivot?

snow forge
#

I'm not sure I understand if honest, I'm not using anything in regards to the Depth buffer (as far as I am aware), this is literally just applying an image to the albedo channel but making the material Transparent. I've done the same thing with other objects in my scene, but this is the only model that I have this issue with. It's very odd. lol.

snow depot
#

I love trying to work with shadow volumes they aren't a torturous endeavour at all! c_suicry

high hamlet
coarse flower
kind swallow
#

In the 2d light system is there any way to achieve fex specular highlights using a spec map and normal map? From what I can gather normal maps fex is handled by another system outside of the custom lit shader graph? I see no way of getting the light direction of closest light fex

amber saffron
#

Something like this ?I've found that the following blend modes matched what you showed : "Linear Light Add Sub", "Overlay", "Soft Light" :

desert orbit
snow depot
#

It was on topic I'm complaining about how hard coding a shader is

#

The dude in the picture was the guy who invented shadow volumes

desert orbit
snow depot
#

Does anyone know how I can make the forwards lit pass render both areas within and outside a stencil buffer value, but the way they're rendered is different based on if it is or isn't in the buffer value? I can only manage to make it so everything outside the buffer value is completely excluded from rendering. I'd like it to be that when part of the shader is in stencil shadows defined by this buffer it sets the texture to black. But everywhere else it displays the normal texture.

Stencil
{
Ref 0
Comp Greater // Render where stencil > 0
Pass Keep
ZFail Keep
}

warm pulsar
#

You'd need two different passes

snow depot
#

Can't you only have one forwards lit pass? And isn't the forwards lit pass the only one which can render things? Or am I misunderstanding something?

warm pulsar
#

i'm most familiar with that when it comes to hand-written shaders

snow depot
#

I'm using URP

warm pulsar
# warm pulsar You'd need two different passes

a quick test suggests that this is fine. I have a shader that does a sort of "deferred rendering" of an effect -- I stencil many small areas, then run a single pass to fill them in later on

#
Pass
{
    Tags
    {
        "LightMode" = "ForwardBase"
    }
    Stencil
    {
        Ref 32
        ReadMask 32
        Comp Equal
    }
    
    Cull Back
    CGPROGRAM
    #pragma multi_compile _ SHADOWS_SCREEN SHADOWS_DEPTH
    #define PASS_FORWARD_BASE
    #define RIME_STENCIL
    #include "rime-pass-main.cginc"
    #undef PASS_FORWARD_BASE
    ENDCG
}

It looks like this. I copied it and set the stencil to NotEqual, and it now draws everywhere

#

Typically, you get one ForwardBase pass, then many ForwardAdd passes

#

But I think what actually happens is:

  • Every ForwardBase pass runs once
  • Every ForwardAdd pass runs once per additional light
snow depot
#

Wait does that mean forward base needs a directional light?

#

Well I guess if it does I can just have base not render anything and all the textures are rendered via forward add.

#

Thanks!

warm pulsar
#

I haven't actually checked if a non-directional light can be supplied in the base pass

valid horizon
#

anyone has a video on how raycasting and basic shadows work?

warm pulsar
#

those are two very different topics!

#

were you thinking of raymarching, maybe?

#

well -- I suppose they're the same topic if you're writing a raytraced renderer

snow depot
worn crown
#

hi guys i was a month into this project and it displayed this after a lightbake
plz help 😭

snow depot
#

Can anybody help me out with this? The shadows kinda work now if you squint your eyes and look at it from the right angle but the actual object casting them is invisible and I can't figure out how to fix it. It's supposed to work with the Carmack's Reverse method.

main cape
#

quick question is there any docs for URP HLSL cause i cant find them
do they js want u to read the shaderlibrary sourcecode from the package to understand how to write them

#

like docs for all the library functions like how to calculate fog and ambient lighting cause thats what im tryna find rn since its not in any tutorials

foggy bison
#

i dont use HLSL, but i assume this is it

vast quiver
#

having issue with a screen shader, it duplicates the view in your eyes in VR in Unity 2019, resulting in this:
(view from 1 eye)

#

i dont have much experience with shaders at all so im not sure what to do about this

#

its for beat saber 1.29.1, which uses single pass stereo, it works fine on newer versions of the game which use single pass instanced

#

wait i think i fixed it

main cape
#

ty

#

i think i saw that before i js thought i was missing something since it has very little written there

hushed silo
#

I have a 3d crosshair which is raycast onto where I'm shooting. I want this to be rendered above objects on certain layers (terrain, enemy etc) due to colliders tha tmight not align perfectly and wanting to still see the crosshair. I can't think how to do this, any ideas? I am in a cockpit that should be able to occlude this crosshair object, so it still needs some kind of z testing

hushed silo
#

hmm, I hadn't considered this - is this performant on mobile vr? (probably not?)

#

but also, I think this might be visually confusing

amber saffron
#

Hum, since you want it on certain layer but not all, you would also need to enable decal layers, and this might take some additional memory ...
Else you could try a custom solution based on renderer features and stencil mask

hushed silo
#

thanks. I assume there's pretty much always a performance hit from those latter options too?

grizzled bolt
#

A vertex shader that ensures the crosshair is always a certain distance from the camera could be a simple solution
But a stencil renderer feature you could use for any number of other HUD elements too

amber saffron
hushed silo
#

draw call I don't mind, but I assume the performance of writing a full screen stencil and using it could be significant? (I'm on oculus quest, and for example can use no post processing effects as they cause another render). I haven't done stencil stuff before so could be totally wrong

amber saffron
hushed silo
#

would that rely on this? as I have this off for performance also

amber saffron
hushed silo
#

ok, cool. Thanks for this info. I'll look into stencils and render features, it would be useful for a growing set of hud elements

#

and I'd guess I could use this still in shadergraph somehow, custom nodes or whatever

amber saffron
#

Oh wait, crap, the decal does need access to depth :/

hushed silo
#

I feel decal is probably the wrong way to go for the effect I want

#

although literally every shader in my game goes through shadergraph for some universal functionality

amber saffron
#

Maybe I misinterpretted what you want, you said display on terrain so I though of projecting onto the terrain shape, but if you just want some "flat" UI masked by some objects, a regular mesh/UI that displays only over the stencil mask is enough, and no need for the additional depth texture.

hushed silo
#

I just want to be able to render a sphere on top of everything except certain things.... like my cockpit interior

amber saffron
#

Should work then

hushed silo
#

Not entirely sure but from what I see so far is that using any renderer feature causes another blit, which I can't allow. Will continue looking

ebon basin
#

Does the Depth Scene node work with WebGL? After calculating the orthographic depth and plugging it into color, I'm just getting solid white

tacit parcel
hushed silo
#

so another issue is that as I'm in stereo VR, I want the percieved depth in terms of stereo separation to be the same as the surface it's on

dapper pollen
#

Ive got a custom shader, its based on urp lit. it has some conditional logic, and basically I want to modify the alpha and shadow accordingly. in the forward pass if I set the alpha to 0, obviously the pixels wont be visible, but a shadow is still rendered. if I use a texture with an alpha(like say a tree foliage texture with alpha), both the pixels and shadow are properly modified. what am I missing in regards to the shadow portion of things?

amber saffron
dapper pollen
#

thanks for pointing me in the right direction, ugh using the same conditional logic from my forward pass inside doesnt trigger the clipping

amber saffron
dapper pollen
#

sure:
this is the last part of the vertex shader for both forward and shadow passes

#ifdef UNITY_DOTS_INSTANCING_ENABLED
#ifdef VERTEXCOLORS_ON
    // _VertexColorIndex is the instance
    output.vertexColor = _VertexColors[asuint(unity_DOTS_Sampled_VertexColorIndex) + input.vertexID];
#endif
#endif
    return output;

using the same #ifdefs at the end of the fragment passes(i was just using discard, tbh not sure the minutiae with each but it works inside of forward)

// sameifdefs
    if (input.vertexColor.a < 0.5)
    {
        color.a = 0;
        clip(color.a - _Cutoff);
        //discard;
    }

the bottom snippet is literally right before setting outColor = color in forward, and return 0; in shadowcaster

#

oh and in shadowcaster fragment its
clip(-1);

#

obviously just setting clip(-1); outside of the ifdefs in the shadowcaster frag just kills all the shadows so at least that is working

#

but the buffer being sampled is the same

dapper pollen
#

ahhh was missing the shader keyword declaration #pragma shader_feature_local _ VERTEXCOLORS_ON in the shadowcaster pass 😌

ebon basin
#

Surprisingly, works fine with WebGPU /shrug

ebon basin
#

Actually only seems to be a problem for orthographic though? I'm confused. Must be some flag that's not fliping when using WebGL2

lyric hill
#

can anyone explain this piece

#

Here the dude is computing o.positionSS which is basically the screen space positions of the co-ordinates

#

and in the fragment function near the end, he just took the xy position of the computed co-ordinates divided it by w and called it screenspace UVs

#

how does that work

regal stag
lyric hill
#

bro put it in tex2D

#

which is wild

regal stag
#

UV is just the usual name used for coordinates that are going to be used for texture sampling

lyric hill
#

oh wait, is the dude taking the current screen position of the object to sample the texture onto?

#

that makes sense

regal stag
tight phoenix
#

I could use a billboarded quad but for a 3d sphere, what type of input (position, view direction, normal, other) will give me a consistent -1 to +1 xy "UV" on a 3d sphere no matter what angle I look at it from?

#

I tried various inputs but I couldnt get a surface that was always a -1 to +1 XY UV from all view angles

karmic hatch
tight phoenix
#

I think a direction is I take direction and multiply it by a vector pointing the direction I want? UnityChanThink

#

not this UnityChanThink

karmic hatch
#

I think you could use a Transform (direction) node and transform from view space to world space?

#

Alternatively you can pick an orientation vector v (any vector!); so long as the camera direction isn't parallel to v, you can get "up" (a) and "right" (b) as a=normalize(v-camera direction*dot(v, camera direction)) and b=normalize(cross(camera direction, a))

#

(if camera direction is parallel to v, the thing inside the first normalize becomes zero and it returns divide by zero error)

tight phoenix
#

uhoh

karmic hatch
tight phoenix
#

I am surprised by how nontrivial it is to return a sphere looking like this πŸ‘€

#

this isnt your code working yet, this is just it centered in view, im still trying to program what you said

lyric hill
karmic hatch
tight phoenix
#

Im trying to map this distortion quad to be a distortion sphere

#

I could just billboard the quad but I don't want to do that, I wanted to see if it would work on a sphere

#

I wasnt intending to texturemap the -1 to +1 uv space, if that changes things

#

Fresnel gives me the right radii, but its not pushing the correct directions without some kind of adjustment there

#

pictured is the UV -based version

karmic hatch
# tight phoenix

I think this does need the same orientation in screen-space, so go with the first one (Transform (direction) Vector3.up and Vector3.right from view space to world space and that should give camera up and camera right)

tight phoenix
#

Yeah since when I combine it to distort the scene color it needs to be mapped in a UV-ish way

regal stag
tight phoenix
#

this is sorta working in that the distortion is seamless, but its direction seems a little funky

#

top is the sphere, bottom is the plane

#

maybe its fine like this UnityChanThink

#

Ill probably still use the plane version but its good to know as a learning thing that sphere can work

#

reminds me of the black holes in outer wilds

#

sticking something more regular into it shows the sphere is working right I think

#

I guess the last question is: is there any way to get this to work with transparent things? UnityChanThink

#

right now its rendered in the transparent queue and even if I use a render objects feature to make it render after transparents, it overwrites them

#

but afaik this is not possible to solve UnityChanThink

#

all that comes to mind is using opaque alpha-clip particles with patterned dithering and bloom to make them appear not totally opaque

regal stag
tight phoenix
#

yeah I figured you wouldnt stack these distortions no matter what, thats a good idea to try to get it working on transparents

tight phoenix
#

getting all kinds of errors probably because im not using the right api or right latest revision to URP's latest render feature syntax

#

I'd really like to avoid being forced to write my own render feature if there is any other way to sample blit the screen

#

im trying to use this as my baseline but I cant get it to pass in the blit, and even if I do im not sure how to then do the distortion stuff when not using the scene color node 😧

#

yeah I cant get it to work

#

it just renders grey

#

I am not experienced enough in render pipelines to know where in the alll possible places im doing a tiny thing wrong ruining the entire effect

#

getting anguished by this, so ill give it a break for tonight

#

just trying to see the blit take effect

#

but I cant even get that to occur

#

could be any number of places where im making a mistake

#

this 'works' but I dont know how to use actually USE it

#

the material has the blit on it, but thats not what I want to do, I want to map the blit as if the material was the screen

#

trying to use the screen position as the UV didnt work either

snow depot
#

Yeah........ that's me and shadow volumes.......

#

I've spent like upwards of 20 hours on these damn shadow volumes and they're still not working

lyric hill
#

I look at all the cool 2d art and lament and my lack of ability at being able to write shaders which can enable me to make the game look like that

warm pulsar
#

This stuff consistently makes me feel clueless

#

Renderer features have a lot of weird intricacies that I just...can't grok

#

magic names and weird incantations

lyric hill
#

Little help with something
I wrote this piece of code, to make the object show up as black if its behind the thing, and it does work, it however doesnt work when I have objects with custom shaders behind it however

#

The two red cubes are shaders with shadergraph

#

the rest are custom shaders written in hlsl

#

what Im curious about is, why isnt that part being stored in the depth texture?

#

I think my custom shaders are not writing to _CameraDepthTexture

#

Wait, I figured it out

#

I have to write a depth only pass to custom shaders on URP to ensure it gets written to the depthTexture

#

it doesnt do it automatically apparently

plain urchin
plain urchin
# plain urchin

@pseudo narwhal
I'll continue here
Is it possible to make a tree sway shader with shader graph/amplify? What is wind zone node? What's a typical setup for the mask for the displacement? Is vertex color for that mask how it's set up for unity tree?

plain urchin
#

I'm really confused with windzone and shadergraph. Is windzone supported for custom shader or what?

split sparrow
#

would it be possible to recreate the "hall of mirrors" smudging effect that occurs out of bounds in older games with a shader? UnityChanHuh producing it through setting the camera flags to "don't clear" with an uninitialized background isn't an option in urp, but the effect looks really cool so it'd be really nice to at least have something similar-looking without the tradeoff of downgrading render pipelines

pseudo narwhal
# plain urchin <@544260011430248467> I'll continue here Is it possible to make a tree sway sha...

yes, you can make one with amplify and shader graph, the wind zone is a legacy feature when you don't make your own shader. If you make your own, the approach would be to inject the shader a few global parameters that contain a wind mask (texture, typically a utility render texture representing the area around the camera) or wind zones (a bunch of positions that form a shape). You will have to figure out how to make that system flexible enough without being a able to inject a dynamic number of such masks/zones into the shader.

tacit parcel
grizzled bolt
mighty glade
#

I have a material from a shader graph, that sets the color based on a maintexture. But for some reason my sprites are not updating in runtime. Can someone explain to me, why material shows green but the sprite in the scene has its color unchanged?

regal stag
mighty glade
#

ah yes that was the issue, thank you!

bitter dawn
#

how can i have 2 transparent shaders render on top of eachother?

#

this is liquid in a plastic cup

#

if i have them both fully opaque, the cup renders in front of the liquid

#

i want the liquid to be inside the cup. Is this not possible?

#

or is this not possible on urp

kind juniper
#

Might be possible with a stencil bufferπŸ€”

ebon basin
#

You don't. Make the cup opaque

thick vale
#

Anyone have an idea how to make a marble shader? πŸ₯² i've come close but i'm still super confused and i'm new to shader graph

amber saffron
thick vale
#

because my mentor doesn't allow me to πŸ₯²

#

So a marble shader without texture is nearly impossible to make you say?

amber saffron
thick vale
#

yeah, i've noticed.. i'll try that. i'm coming from blender too and it looks similar but it's so very different hahaha

amber saffron
#

You should also probably try to noise the UV input of the voronoi to make it a bit more chaotic (like you did for the upper gradient noise)

amber saffron
spare badger
#

AssertionException: The RenderTextureDescriptor used to create a TextureDesc contains both graphicsFormat and depthStencilFormat which is not allowed.
Assertion failure. Value was True
Expected: False
Got this error, any solution?

amber saffron
#

Or use colorFormat and depthStencilFormat I guess.

tight phoenix
#

What are possible reasons why a full screen blit pass seems to be culling elements on the up/down axis in mirror to the actual geometry? Stuff that isnt occluded by opaque objects is getting occluded exactly in a screen mirror up/down πŸ€”

#

What are possible reasons why geometry would occlude other geometry that its not actually occluding at all? But only on the X axis?

nova bear
#

Guys I know it might be basic question but how do I pass a material type to Shader Graph's vertex?

#

I have so many material types in my world, its basically Minecraft. I know I did it before I just cant remember how I did it

#

Ah ha ur answer!

tight phoenix
#

no weird geo clip UnityChanThink
Thought im still having issues with getting it to render before PostProccessing

warm pulsar
#

I could believe that. The image winds up upside-down at some points

nova bear
#

Guys how would you guys do rendering Miencraft like worlds with many different material types?

tight phoenix
warm pulsar
#

yeah, if most surfaces differ only in what texture they use, then they can all use the same material

#

note that using many materials with the same shader is what the SRP Batcher is good at

#

so if this is a URP or HDRP game, you might just do a bunch of materials

nova bear
flat hedge
#

Hey, I was wondering if it's possible to create an effect similar to directional blur with the shader graph, at least for 2d elements?
Offsetting vertices of course works, but requires the image to have a lot of vertices in order to look clean.
I tried simply offsetting the uv of the main tex but that's got a huge limitation of exiting the bounds of the image.
Would a render pass be a better choice for this?
Please @ me if you are able to help and thanks in advance!

tight phoenix
nova bear
#

I mean, how r u uploaindg it

#

per vertex?

tight phoenix
#

Sorry I am not very good at shader programmming, I can't really help.
My use case i take the object's position and hash22 it to get a random value that I clamp to an int and use that

amber saffron
# nova bear per vertex?

Basically, yes, when you generate the mesh of the terrain/voxels, you also store the texture index in a vertex attribute, like the vertex color.

warm pulsar
#

You can stuff a lot of data into the texcoord streams

ebon basin
#

I've done it before with the help of the shader graph

#

Then using the Mesh library to set the UVs accordingly

nova bear
warm pulsar
#

and you can nominally use up to eight streams

#

(although the shader graph only exposes UV0-UV3)

#

I often put a 3D position into UV1.xyz, and then sneak an extra float into UV1.w

ebon basin
#

I'd probably do it as post-processing ,yeah

#

Not so much just exiting bounds of the image too, but having it bleed onto other sprites if you're using sheets

flat hedge
ebon basin
#

Well, usually when you're using some blur it's distorting the pixels around it so I'm not too sure what you mean by individual bluring

#

It could be fine in the fragment if you did just want to do it that way, but if you are using atlases you'd probably want to island out the sprites a bit more

#

But the thing too with spriterenderer is that it'll trim the quad to the greatest pixel bounds and no more
Actually, just tested a few thing, but the sprite renderer will actually feather the quad bounds depending on the texture bounds so it should be fine if you island out your sprites

#

You'd have to try to apply it within* the cell of the sheet though, cause it'll apply it to the whole sheet otherwise, but may not be a problem if say it's a single character material instance

flat hedge
#

yeah, I am using a single sprite, not multiple in one image

#

I tried extruding the edges but that didn't help either

#

to clear this up a bit, I would like to go for this effect:
https://youtu.be/7BUnCtU9ARY?t=8

In this quick tutorial, I explain how to use the Directional Blur effect in Adobe After Effects.

🀝 Support more YouTube tutorials through Patreon: https://www.patreon.com/jakeinmotion

πŸŽ“ Learn from me other places:
Skillshare: http://bit.ly/jbskill
Explainer Camp: https://www.schoolofmotion.com/explainer-camp
Photoshop + Illustrator Unleashed: ...

β–Ά Play video
#

it's fairly common in editing, found in p much all editing software

#

from my understanding, I'd just have to create multiple copies of the main texture and offset them on the x/y axis in opposite directions

ebon basin
#

Well, that's one of the more easier ways about it ;p

#

If you want more of that distorted/smear blur, you're looking into the scene color which is also what you'd use for post-processing blur

flat hedge
#

Another thing, if I use the offset node I end up with the same limitation, the texture being cut of at the edge, as can be seen in the picture.

#

I am assuming it's due to me sampling the sprite out of it's bound(as I offset the uv), but idk if it's possible to offset an already sampled sprite

#

Actually nvm, my brain died for a second, it happens because I exit the bounds of the image so the render gets cut off, genuinely no clue if there's a way around this...

ebon basin
#

Oh, you're using this for UI. So yeah I was saying before spriterenderer actually does handle that for you, but you're probably needing to extend the quad bounds, or perhaps just reducing the tiling (or was it increase?) there should work

flat hedge
ebon basin
#

What's happening is you're going past 0 - 1 of the UVs so it's being cut off from the rendering here. Offsetting doesn't care if it's moving those pixels off of it, so you need to manage the sizing.

flat hedge
#

Sorry if I am not getting this right, I don't have a lot of experience with the shader graph.
Am I supposed to make the tiling bigger(say 2), apply the offset and then get the tiling back to the original value(multiply with 0.5)?
If yes, it sadly didn't work.

ebon basin
ebon moss
#

anyone know what these shadow artifacts are from?

nova bear
#

Just some simple terrain.. ugly af

ebon moss
nova bear
#

no just commenting on my own work

#

its ugly because its ulgy

ebon moss
#

be nice to yourself

nova bear
#

I wish I could

#

is there any tree model that looks like this ?

#

in the asset store?

ebon moss
#

you're unlikely to ever find an exact copy of something, but you look for trees of a similar shape or style, and then modify them

ionic python
#

So I made a shader inside of shadergraph, but I would like it to work with the URP lit shader somehow. Is there a way to do it?

#

Or do I just have to figure out what I did in the shadergraph manually?

ebon basin
#

The graph settings/properties have fields you can set, which you can also override to allow you to change in on the editor

high hamlet
# warm pulsar Does this need to be able to cover up *any* object, or is it just going to be on...

Sorry for the bother, if you're able to give this a look again would appreciate it. My reply was a little lower (but the next day πŸ˜…):

One of a few different objects, maybe up to a dozen, and they're all 2d sprites.

For full context, I'm basically looking for some way under 2d URP to apply an effect that presents "corruption". the objects can be Pure / Standard or Corrupt. I was thinking of some "dancing" noise pattern of darkness moving around on the object kind of like Lava. But I'm clueless on visual stuff so maybe there's an actual term / straightforward way to approach this πŸ™

snow depot
#

For shadow volumes would it be better for an individual shader to generate a volume within its passes or to look into compute shaders and how to use them?

ionic python
ebon basin
#

It has a parallax node

#

which is what lit's height map is

ionic python
#

I found a sample in the shadergraph package which has the URP shader rewritten in shadergraph

#

i think ill just make a copy of it and modify that

ionic python
#

okay yeah I figured it out!!

#

the problem is that I had to turn off the Unity GUI for the shader inspector, which made it so I just can't turn off emissions and such?

proven rapids
#

Hi! I have this weird thing where My shader shows up in scene view no issue , but the image my shader is attached to in game view is pure black.

hazy gale
proven rapids
#

I changed that to canvas and boom

hazy gale
#

ahh, good to know!

#

I have the strangest problem that I can't track down. When I move objects or the camera some of the objects with the shader will become invisible.
Even deleting all nodes in the shader graph doesn't fix it.
the only thing that makes a difference is making the material transparent instead of Opaque. Which since the shader is used in a bunch of things, that wouldn't be a practical work around.

ionic python
#

I'm trying to use triplanar for something, and it just completely breaks when I try to change the position

#

on one axis its fine, but it breaks on the others

#

and no, the problem isn't with the UV mapping of my mesh

#

it worked without triplanar

spring urchin
# ionic python

hey, not a solution, im just letting you know, theres quite a good software that i use for mapping lowpoly maps like that, its trenchbroom, you might like it :D

#

it makes texturing stuff really easy, but its mostly used for quake and retro games

hazy gale
spring urchin
#

good luck

hazy gale
#

thanks!

ionic python
#

im just testing shaders

#

i want to create some effect, but im kinda struggling as you can see

spring urchin
spring urchin
#

oh damn

#

that looks cool

#

i think the reason it looks a bit buggy is because you are filling out the square with a circle so edges and further things just look a bit weird at times

ionic python
#

I basically want to create a transition from "real world graphics" to "neon graphics"

ionic python
#

right now I'm using a normalmap to cover the basemap

spring urchin
#

hm alright

ionic python
#

plus I wouldve kinda liked if the normal map itself also works the same way that the base map does

#

right now i just fade all of the normal maps

#

instead of the effect that I do with the base map, where it turns red once an invisible sphere overlaps it

#

sorry for the lag in the vid

#

i dont think its possible to do this without triplanar

ebon moss
tacit parcel
warm pulsar
#

it's meant to be used with a 3D input

#

(typically a world position)

#

you're putting in a 2D texture coordinate

#

so you're not really gaining anything from the triplanar node

#

(the 3D world position is having its Z coordinate thrown out by the tiling-and-offset node)

#

If you want to blend between two different textures based on distance from a point, you can measure the distance, compare it to a threshold, and use that to lerp between two options

warm pulsar
#

moving along the world +Z axis doesn't change your X or Y positions

stray orbit
#

Is there a documentation example of when to use the keyword:

#pragma multi_compile

I found a forum post that said you need to use it and that seemed to be true because now normals with accurate on/off have the same colors and are correct. The keyword for reversed Z can be used without the multi compile so i am wondering when it's required?
Is the multi compile used when it's a checkbox that can be changed at runtime? and keywords like reversed_z are actually static and can't change?

ionic python
#

i mean

#

i do smth similar but idk

ionic python
#

yeah I use a spheremask so

ionic python
#

I tried something like this

#

oh wait im dumb

#

I got it!

#

@warm pulsar actual godlike suggestion, tysm!

ionic python
mental bone
#

Are you scaling a actual mesh renderer? If so you can turn off shadow casting on that component

#

Or use a unlit shader graph

ionic python
#

I mean

#

okay

#

for the visual sphere I do use a mesh renderer, but that doesnt have shadows enabled

#

what I wanted is to have all the objects in the sphere with the shader have their shadows turned off gradually

warm tinsel
#

I have this project where I have 2 worlds. I have this example picture of someone doing this online but cant figure out how they did it. In the picture, they are surrounded by a mesh that renders the green world, allowing them to walk on a birdge that isnt present in the main world. I tried to implement this with 2 environments, 2 cameras, with one box around the player that has a shader that should render the 2nd dimension.

Im not sure if this is even the correct approach to take as wouldnt the rendering with the shader just make it visible and not actually have the object be active? Of course I dont want the player to be able to walk a bridge that isnt rendered, and instead behave in the picture shown. Some guidance would be extremely helpful Ive been researching for hours 😦

#

It seems like this is a mechanic that exists more commonly in godot but idk if this is something that could be implemented in Unity

tacit parcel
regal stag
shadow thistle
#
Shader"NoteBeat/Game/LevelIcon"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "black" {}
    }
    SubShader
    {
        Tags { "QUEUE"="Transparent" "RenderType"="Transparent" "BuiltInMaterialType"="Unlit" }
        Blend SrcAlpha OneMinusSrcAlpha
        ZWrite Off

        ColorMask RGB
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            float _Radius;

            float square(float a)
            {
                return a * a;
            }

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {    
                fixed4 texColor = tex2D(_MainTex, i.uv);

                if (square(i.uv.x - 0.5f) + square(i.uv.y - 0.5f) <= square(0.5))
                {
                    return texColor;
                }
                else
                {
                    return (0, 0, 0, 0);
                }
            }
            ENDCG
        }
    }
}

When i give it an image that i think is a "jpg", it's fine, but when i give it a "png", it's completely white. It shouldn't be white.

kind juniper
shadow thistle
kind juniper
#

Well, then your png texture has non 1 alpha(a texture created from jpg would always have alpha == 1)

shadow thistle
#

ok so the issue seems to be somewhere else. I know the only thing it can be, but that thing is impossible.

kind juniper
warm pulsar
thin lintel
#

Hey guys, I'm having a weird issue with my shader. Sometimes when trying to enter playmode it will compile the shadow layer forever until I force unity to close and then disable the shadow mask (for some reason it toggles itself back on again at random). However this particular time I have a new issue where the shader refuses to regenerate and I have no idea why. The error message when printed to console is:

Error in Graph at Assets/workflow main/weapons/optics/parallax sight shader/parralax sight.shadergraph on line 1: Parse error: syntax error, unexpected $end, expecting TOK_SHADER (Filename: .\Library\PackageCache\com.unity.shadergraph\Editor\Importers\ShaderGraphImporter.cs Line: 402)

warm pulsar
#

That error means that the shader file was completely empty

#

No idea what to do to fix it though :p

#

the very top of the parse tree is TOK_SHADER, which expands into more tokens until you have an entire shader definition

#

and $end is the token you run into at the end of the file

#

hence that error

limpid flint
#
Shader "Custom/InvertColors"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            CBUFFER_START(UnityPerMaterial)
                float4 _MainTex_ST;
            CBUFFER_END

            TEXTURE2D(_MainTex);
            SAMPLER(sampler_MainTex);

            struct appdata
            {
                float4 position : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float4 position : SV_POSITION;
                float2 uv : TEXCOORD0;
            };

            v2f vert(appdata i)
            {
                v2f o;
                o.position = TransformObjectToHClip(i.position);
                o.uv = TRANSFORM_TEX(i.uv, _MainTex);
                return o;
            }

            float4 frag(v2f i) : SV_Target
            {
                float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
                return float4(1.0 - color.rgb, color.a); // Invert RGB, keep alpha
            }

            ENDHLSL
        }
    }
}

#

i can't quite get the minimal post procccessing shaderlab shader

#

i am using URP, created a renderer feature of full scren post prossessing

#

on buit-in renderer its just using onRenderImage function

#

how do i do it this way...

solid scaffold
#

have this sphere where the color is set to scene color

#

but theirs this outline material on almost every object that has this pink but cant usually be see because of the wood texture

solid scaffold
#

got the outline shader from online

regal stag
limpid flint
tribal pond
#

ey. mockhmd is apparently not available on linux unity editor. any reasonable fashion in which I can do the left/right/both eye debugging for shaders?

snow forge
#

Hi all, I have this simple 'front projection' shader that I'm using, but as it stands, it makes thing a little difficult to work with in the editor.

Is there a way to reference the scene camera to project from it's point of view?

amber saffron
snow forge
#

As an example..

amber saffron
#

Oh, ok, so it is more about projecting from the Game camera point of view, at all times ?

snow forge
#

Yeah, that would be the ideal.

amber saffron
#

If it is for a background plate, why not simply use an unlit shader on a plane, child from the camera ?

snow forge
#

It's for a few different planes at varying depths (layered with various alpha masks), I've already got the planes autosizing etc. just need to figure this out.

amber saffron
#

Okay.
Well, the only way is to pass the camera projection matrix as parameter to the shader with a script, and transform the world to projection coordinates in the shader.

snow forge
#

uuuuh....okay. Well just after a quick read, I think that's way beyond me atm tbh, and no clue how to make it run in the editor. lol.

Sokay though, thanks for the help, I have another idea I can try.

amber saffron
snow forge
#

Ah okay, good to know πŸ™‚

warm pine
#

Can anyone steer me in the right direction? (Sorry if this is the wrong channel to ask)

In my 2D game project, I'm trying to make a window for the player that shows another place in the scene and when moving or adjusting the window size it should act as a sort of mask/window to that area so you could look around by moving the window or changing it's size.

I'm pretty noob to this stuff and I'm sure I could handle actually moving and adjusting the window, but I'm a bit lost on what would be the best approach for the texture having that mask/window effect.

I'm guessing a camera with a render texture and a Raw Image with a script that's adjusting as the window moves, but it sounds like this might be better done with a shader or material or something? I just wonder if I'm overcomplicating it.

sour tapir
#

uh how do i get the "movement" node in tutorials like i dont see any in current version
i realize Twirl wont work well with cubes

#

all tutorials are 4 years ago πŸ˜”

regal stag
sour tapir
#

wait let me.. i think i could find it

#

nvm i found it its "tiling and offset"

regal stag
#

Ah if you're offsetting coords then yeah. Can also use Add (e.g. with a Vector2 and UV)

sour tapir
#

thx

regal stag
#

If it's purely 2D/sprites, there's also the Sprite Mask component (which I think uses stencils behind the scenes)

warm pine
#

Stencils look very close to the effect I was thinking of. The idea is there is an internal world in your bag that is going on its own to produce results outside of it, so I'm having it do its stuff in another location (though giving it masks and rendering restrictions so it would never show up on camera or effect anything outside the bag world).

It is all 2D Sprites pretty much, but they will being interacting with triggers and possibly collisions and such as well

#

i think there will also be line renderers and such as well so I guess it's not purely sprite components. Still working things out but it does sound like Render Texture is what I'm gonna need to do.
I appreciate the help!

#

Just wanted to make sure I wasn't being stupid lol

tight phoenix
#

inside shadergraph, what can subsitute for a Matrix4x4 Object To World matrix? SG doesn't have that listed on the avaliable tranformation matrixes

#

If you can help we can change the code to make it use something else that shadergraph does have avaliable UnityChanThink
that is if we can't just get that matrix from somewhere

regal stag
tight phoenix
#

Thanks I'll try that out πŸ‘€

#

ill go over it with a fine tooth comb for errors in conversion

#

I can't find any errors in this port of the code, do you see any? Left is the code that behaves oddly, right is Ben's

#

the fact that it 'works' without crashing but is showing wrong behaviour is making me think ive supplied the wrong inputs in shadergraph, that the problem is not the code itself UnityChanThink

#

as far as I can tell I am using all the right matrixes however

#

everything appears to be 100% correct except for that it doesnt project correctly UnityChanThink

#

maybe the problem is like an axis conversion that differs between CGCode and shadergraph?

#

like some of these matrixes are constructed differently?

#

I necro'd the original post in hopes someone will see there

#

I hate how you can make no mistakes and nothing is wrong but it doesnt work right because of back end differences in shader languages or render pipeline or any one of thousands of reasons why its not working right

#

and there's no possible way to debug a shader, no debug values, nothing to step through line by line like C# code to just see where the two shaders differ

#

its completely identical except its not and I dont know how to fix it but I need it fixed and its stressing me out reading the same block of coder over and over and over trying to find a difference and I cant find a difference

#

the fact that it doesnt spin to face the camera must be screaming soemthing to someone who knows exactly why its not working

#

but I need that someone to see this post and tell me why its not spinning to face the camera with their knowledge sadok

#

I dont see any reference to the facing direction of the camera in Ben's original code yet it spins to face it, so I dont know why his even works in order to fix mine to work the same way

#

Does anyone know the Matrix arrangement/interpretation order for Row / Column major orders and how they differ between a CGPROGRAM shader and Shadergraph?

#

Its the only thing that I can find that might be the cause for the wrong behaviour, because I am making assumptions that
float3 planePoint = unity_ObjectToWorld._m03_m13_m23;
is equivalent to
float3 planePoint = float3(ObjectToWorld[0][3], ObjectToWorld[1][3], ObjectToWorld[2][3]);
which very much may not be the case

#

everything I can find on google is suggesting the matrixes may not be built in the same row/colunm or the same indexes of those row columns, but I can't find the actual answer to how they are actually built in order to be certain if this is in fact the problem or how to fix it is to chbange how the tables are built

regal stag
# tight phoenix

Haven't checked everything but note that vertex shaders output in clip space, but shadergraph's Position port in the Vertex stage expects object space. It does the object->clip conversion for you behind the scenes, which in the case of billboarding is... a bit annoying. (But kinda makes sense, as otherwise you wouldn't be able to use the Position node in the fragment stage)

tight phoenix
#

that does sound like a significant difference that would break the shader πŸ‘€

regal stag
#

So instead of outputting clipPos you may need to use the inverse matrices to convert back to object

tight phoenix
#

Ben's solves it seen left, Your link shows the code, but does the result sort in the same way?

regal stag
#

Ah, mine probably clips, don't think I'm doing anything special to prevent that

tight phoenix
#

gif showing ben's work how it remains unoccluded despite the steep angle, it should be occluded because its totally inside the 3D geo

#

but the point is to get a 2D sprite in a 3D space that can share the space without that occlusion occuring

#

Ill look now into converting from clip space back to object space that you suggested UnityChanThink

#

float4 objPos = mul(clipPos, invWVP);

#

multiplying the vector by the matrix is how you convert right? No extra steps?

#

this gave it an angle UnityChanThink

regal stag
#

Think it should be projection * view * model

tight phoenix
#

Oh, I was just using inverse view matrix

#

I misunderstood what I was meant to use

#

if its projection * view * model, I have those 3 things input right there right? UnityChanThink

regal stag
#

Wait I confused myself that would be MVP not inverse

tight phoenix
#

Oh

regal stag
#

Would it be inverseModel * inverseView * inverseProjection ? I'm actually not too sure

tight phoenix
#

my googling says: inverse WVP is (Projection * View * ObjectToWorld)

regal stag
#

Could also do it separate. Maybe

float4 positionVS = mul(inverseProjection, clipPos)
float4 positionWS = mul(inverseView, positionVS)
float4 positionOS = mul(inverseModel, positionOS)

Not sure which is more performant

tight phoenix
#

Hmm right now ill take anything. unperformant is fine since I won't have more than like 10-20 instances of this sprite on the screen most likely

#

Hmm progress

#

multing it by inverse view projection before passing it out
hey wait no

#

I overwrite it right afterwards

#

except somehow this is doing something

#

oh wait maybe its just working because I broke it exactly the wrong way

#

its back to working like a regular billboard, I think I just broke it is all

#

okay yeah ignore all this I just broke it briefly

#

===
position = mul(clipPos, Matrix_I_VP);

#

First one didnt work, ill try the other two

tight phoenix
#

Should I be using all 3 methods or just one of them?

#

positionOS is object space position, which is what I want I think, but I am not sure how to use that when I have clip space position since it needs object space as part of it πŸ€”

regal stag
#

All 3 but I was assuming you pass the matrices in separately. If you use Inverse View Projection those two are already combined.
I think mul(WorldToObject, mul(Matrix_I_VP, clipPos)) should work but my brain isn't really working today

tight phoenix
#

Thats fair, Ill try that now

#

hey that almost worked πŸ‘€

#

its behaving correctly like a billboard now

#

but when you go to a steep angle, it seems to grow too quickly

#

so I am guessing the part of the multiplication for steepness is the wrong space

#

is what's shown there

regal stag
#

Hmm, does mul(Matrix_I_Model, float4(mul(Matrix_I_VP, clipPos).xyz, 1)) make a difference?

tight phoenix
#

it does make a difference, now height gives it x-directional lean

#

maybe I just have to set the right vec4 value to 1?

#
    float4 positionWS = mul(Matrix_I_V, positionVS);
    float4 positionOS = mul(Matrix_I_Model, positionOS);
    
    position = positionVS * positionWS * positionOS;```
#

Is PositionOS meantt to use PositionOS inside of itself?

#

or should it be positionWS?

regal stag
#

WS yeah. And position = positionOS, no need to multiply them together

tight phoenix
#

Ahh okay, this is a step backwards then,

    float4 positionWS = mul(Matrix_I_V, positionVS);
    float4 positionOS = mul(Matrix_I_Model, positionWS);
    
    position = positionOS;```
this code, the quad vanishes entirely
regal stag
#

Oh it's applying the inverse view twice since you use Matrix_I_VP not Matrix_I_P

tight phoenix
#

ooh

#

fixing now

#

Darn, the result of both of these methods is the same

#

infinite steepness

regal stag
#

How about

float3 positionVS = mul(Matrix_I_P, clipPos).xyz;
float3 positionWS = mul(Matrix_I_V, float4(positionVS, 1));
float3 positionOS = mul(Matrix_I_Model, float4(positionWS, 1));
tight phoenix
#

tryin;
Side note I find it super funny we're using every single transformation matri4

#

Oh, error about converting float3 to float4

regal stag
#

One of them has to be correct surely πŸ₯²

tight phoenix
#

For sure catcrymic

regal stag
#

Might need to change your position output to float3 in code/graph

tight phoenix
#

can do

#

we're close

#

its now completely billboarded as expected

#

but also clips because its not sorted by its bottom most position

#

maybe one of those 1s has to be a 0

#

because we want it to sort by its foot not its head

#

Hm wasnt that, tried all 3 possible variations as a 0

tight phoenix
# tight phoenix we're close

maybe the problem is shadergraph, like maybe we nailed it here 100% but something about SG itself is causing the sort to not sort the way Ben's does?

#

progress πŸ‘€

#

its wacky but almost works right

#
    float4 tempVS = mul(Matrix_I_P, clipPos);
    float3 positionVS = tempVS.xyz / tempVS.w;
    
    //float3 positionVS = mul(Matrix_I_P, clipPos).xyz;
    
    float3 positionWS = mul(Matrix_I_V, float4(positionVS, 1));
    float3 positionOS = mul(Matrix_I_Model, float4(positionWS, 1));
    position = positionOS;```
#

in ben's code the original clip space sorts by the depth of the bottom edge

#

but we had converted it back to object space entirely πŸ€”

#

hm maybe the problem is shadergraph? Like we're trying to do something that only works in clip space? which SG doesnt do?

#

maybe it CAN be done

#

because its sort of almost working

#

just the two triangles of the quad are not happy at the moment

#

maybe some answers in here

#

Actually maybe it is Shadergraph and we're just screwed UnityChanThink
It seems like the shader relies on editing the clip position, which afaik Shadergraph simply cannot do

ionic python
#

any way to make the voronoi wrap around the sphere correctly?

#

ofc without just making it viewspace

#

right now I'm using it's object space

tight phoenix
tight phoenix
#

yeah so am I

ionic python
#

is there a way to do that in shadergraph?

tight phoenix
#

maybe I linked the wrong github 1 sec

ionic python
#

well it says hlsl

#

also wtf is 4D voronoi noise?

#

for rotations?

tight phoenix
#

no idea, ive never used it. I am not very good at shaders

ionic python
#

how could you use voronoi noise for a rotation and why lmao

ionic python
#

I have also seen the suggestion of making an octahedron sphere

#

I mean, I don't know how you'd do that inside a shader

#

maybe I can model it in blender

dim yoke
ionic python
dim yoke
ionic python
tight phoenix
#

im trying to find the original github repo I got them from but can't find the project anywhere online anymore

tight phoenix
#

found it

ionic python
tight phoenix
#

@regal stag Here is as far as we got if you want to take a look at it later.
I -think- the answer is that its just impossible in shadergraph since the original relies on clip space sorting πŸ€”
But this sort of almost kind of works

ionic python
#

for some reason it REALLY doesnt want me animating it by time

#

wow, engineering

#

this fixed it for whatever reason

sour tapir
#

i dont find a option about that in node page

#

oh

#

its already on but it's still not working i have to turn it off and back on again for it to work? youbastard

warm pine
lyric hill
#

Fellas Im stuck somewhere

#

Im trying to get my custom shaders to write to the depthbuffer

#

So that I can use _CameraDepthTexture to setup different kind of shaders but its not working

#

the red one is a standard shader graph texture

#

which shows up correctly

#

This one is my custom shader

#

to which I added this

#

Pass {

        Name "DepthOnly"
        Tags {"LightMode" = "DepthOnly"}

        ZWrite On
        ColorMask 0

        HLSLPROGRAM

            #pragma vertex DepthOnlyVertex
            #pragma fragment DepthOnlyFragment


            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            struct appdata {

                float4 positionOS : POSITION;

            };

            struct v2f {

                float4 positionCS : SV_POSITION;

            };
            //is this really not working?

            v2f DepthOnlyVertex (appdata input) {

                v2f output;
                output.positionCS = TransformObjectToHClip(input.positionOS);
                return output;

            }

            float4 DepthOnlyFragment(v2f input) : SV_TARGET {

                return input.positionCS.z/input.positionCS.w;

            }

        ENDHLSL


    }
#

and I believe it writes the depth texture

#

but I dont know what it doesnt display it on my the plane

lyric hill
#

Pass {

        Name "DepthOnly"

        Tags{"LightMode" = "DepthOnly"}
        
        ZWrite On
        ColorMask 0
        
        HLSLPROGRAM
            #pragma vertex DepthOnlyVertex
            #pragma fragment DepthOnlyFragment

            #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"

            #pragma multi_compile_instancing
            #pragma multi_compile _ DOTS_INSTANCING_ON

        ENDHLSL

    }

also tried this

#

not working

#

T_T

foggy bison
echo moatBOT
foggy bison
#
Pass {

            Name "DepthOnly"

            Tags{"LightMode" = "DepthOnly"}

            ZWrite On
            ColorMask 0

            HLSLPROGRAM
                #pragma vertex DepthOnlyVertex
                #pragma fragment DepthOnlyFragment

                #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
                #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"

                #pragma multi_compile_instancing
                #pragma multicompile  DOTS_INSTANCING_ON

            ENDHLSL

        }
#

nvm, double checked in my browser, guess this is only a vencord thing

lyric hill
nova bear
#

their grass is color of the ground

#

does anyone have an idea how to render grass that looks like that?

#

very weird grass but it looks so aesthetically pleasing

#

You see the grass?

#

it makes the game look like a painting almost

tacit parcel
nova bear
#

does anyone know wahts wrong with this? there seems like stains on my objects

#

its persistent both on editor screen and in game world

#

does anyone know what this is?

#

This is drviing me nut

amber saffron
# nova bear

Looks like SSAO. Check your post process settings.

nova bear
amber saffron
nova bear
#

none of these look like SSAO

#

I can't find SSAO setting in the post processing setting

amber saffron
# nova bear

Oh, sorry, I forgot that it is a renderer feature, check the current active URP renderer settings.

nova bear
#

Found it!

cerulean nexus
#

started playing Avowed and was met with this. im ignorant when it comes to all things shader-related, but how does something like this work? is this a simple process in unity?

foggy bison
#

nvm, just read the text in the screenshot

#

i think this explains it (never looked into it myself though)

amber saffron
cerulean nexus
#

ah ok thanks

neat orchid
#

How scary is hlsl? I see the shaders contain a lot of code. Is it mostly boilerplate? Should I just stick to shader graph?

low lichen
#

If you're thinking about learning HLSL, it would be better to stick with simpler unlit shaders to start with.

warm pulsar
#

Yeah. You have to write all of the individual passes yourself when doing a hand-written shader

#

I've only done forward lit shaders that way (for VRChat)

#

Unity does still do most of the work for you. I started out writing my own Phong shading math before I realized I could just invoke UNITY_BRDF_PBS to get very nice lighting, lol

#

Surface shaders are similar to the shader graph for the built-in RP -- in fact, it's basically the same thing

#

you tell Unity about surface properties and it generates the shader based on that

#

and I know we're getting block shaders Soon(tm)

lyric hill
#

Find a book and learn

warm pulsar
#

I honestly don't remember how I started writing shaders

neat orchid
warm pulsar
#

The big hurdle is learning the magic incantations

lyric hill
#

yea, magic incantations are driving me nuts while learning em

neat orchid
warm pulsar
#

all I can say is: bless bgolus

lyric hill
#

that is understandable

#

but, the stuff that drives me nuts is not having documentation for unity functions

low lichen
# warm pulsar I honestly don't remember how I started writing shaders

This is where I started.
https://www.youtube.com/watch?v=T-HXmQAMhG0
I think the built-in render pipeline is very good for learning graphics and shaders. Not too complicated, but still low level enough to be useful.

Another video/tutorial thing. This time about shaders. Still trying to find my voice and my style for future videos. Let me know what you guys think.

Get the shader code used in this video here:
http://danjohnmoran.com/Shaders/

Unity Documentation on Providing data to Vertex Programs:
http://docs.unity3d.com/Manual/SL-VertexProgramInputs.html
...

β–Ά Play video
warm pulsar
#

I do really weird stuff for VRC

lyric hill
#

There's also a book called building quality shaders

#

which is what Im following to learn, its pretty good

dapper heath
#

heya, I've set up a grab pass renderer feature in URP 17 and actually got it to work, which is a 3 day long miracle for me. but I'm having trouble figuring out how to render a plane using the texture with a render event after transparents. atm it looks like shown when the event is anything before rendering transparents, but is black if the event is after. this makes sense since it rendering the plane before the texture exists would obviously show as black, meaning if the plane is in the transparent queue at all, it won't work

but I'm struggling to work around this. I've heard you can exclude it from the camera culling mask and render it with a render objects feature, but that doesn't seem to be working either (it just shows as black still)

EDIT: nevermind, I'm stupid, it just also needs the layer excluded from the transparent layer mask on the URP asset

rare wren
dapper heath
#

sure, I don't have a non-work related github to dump it on atm but I can put it here for now

#

for future lurkers

#

not even remotely closed to polished, but it works, and it tracks the texture in the render graph inspector as well
any object using the texture needs to have a layer the camera can't see and also that is exempted from the urp asset's layer masks
then, use a renderobjects feature to render only that layer

serene condor
#

on the UV map for this model, the eye's island is set up in a way that i should just be able to create the illusion of it moving by shifting the island over some, can i do this with just one material or is it going to take two? (the eye is a separate mesh child in the heirarchy, but changing it's properties also changes the rest of the mesh). Also is that problematic (to have two materials per entity) if there can be up to 100 of these on screen?

crisp vale
#

Anyone have an idea how to add some nodes to the shader graph that allows me to adjust levels of a roughness map? I want to be able to crush levels and really have a lot of control like Levels in photoshop.

dawn junco
serene condor
#

would multiple UV maps also work?

serene condor
#

i saw something about UV1 is reserved for light maps or something (i have no idea what im doing, sort of)

#

i'm still working it out but using a secondary UV map got this result

dawn junco
#

That is how you would create UV2 in blender. But I'm not sure it'd work how you expect.

serene condor
#

trying to visualize the mask texture approach

#

right now i'm not worried about blinking so much as being able to move the eye independently without messing up the rest of the texture

#

was trying using different uvs but its not quite working the way i thought it would

dawn junco
#

The lerp idea is like this

serene condor
#

oh huh

#

ok i think i'm getting something

dawn junco
#

The grass and sand are just to help see what lerp is doing. In your case the two options would be blinking and without blinking

serene condor
#

couldn't i just put like a "code" color in that spot on the albedo map so it would lerp just that section?

#

one sec rough mockup

#

left turns into right

#

then i can take just the eye texture as a secondary input texture, apply the tiling offsets and lerp it over the blue?

#

essentially wouldn't need extra UVs for it either ...i think?

dawn junco
#

that could work

serene condor
dawn junco
#

You're welcome! They look great

serene condor
#

i would've expected it to show the lower half too

#

nvm got it

eager folio
eager folio
#

Though I generated the mask right in the shader instead of using a second texture

serene condor
#

only 1 material and uv map

dawn junco
#

There's really a lot of ways to do masking. Like you can use vertex colors instead of a mask texture.

Or you can make UV Tiles. (in the screenshot) Which is a technique where you create a second UV map and organize things into squares. And then check the range of the UV2 coordinate. For example if U is between 1 and 2, you know it's in the second tile. And make parts look different using that.

serene condor
#

Pixel math my dad called it

snow depot
#

I'm more of a coding beginner but I'm in this channel since this is more of an advanced problem. Which is far above my weight class c_suicry. I have a compute shader which is supposed to find the silhouette edges of a mesh, but it currently can't find any even though there should be some. Silhouette edges are like the image below, edges where the lit and unlit sides of the mesh meet. I've cut out only the sections used in finding the silhouette edges edges and put them in blazebin. I know it's the issue because if I change line 151: "bool isSilhouette = (FindSilhouetteEdges(edgeIndex, v0, v1));" to just be "bool isSilhouette = true;" then all of the vertexes render. It can't be light position as the issue either since the volume extrusions move about fine based on light position. So it's not an issue with the edge detection or light position, it has to be an issue with finding the silhouette edges. But compute shaders are hard to debug and I'm kinda working with things that I don't fully understand so I've been really stuck.
https://paste.mod.gg/ecdvfygukkwx/0

#

Some more context:
When FindSilhouetteEdges returns on return (frontFaceTriangles > 0); it shows the first image
When FindSilhouetteEdges returns on return (backFaceTriangles > 0); it shows the second image
When FindSilhouetteEdges returns on return (backFaceTriangles > 0 && frontFaceTriangles > 0); it doesn't find any silhouette edges despite some being clearly shared between the last two

spark frigate
#

How would I add transparency to the base color here?

#

I have already changed the graph setting to a transparent surface type

kind juniper
spark frigate
kind juniper
spark frigate
#

You know I looked for it to be there and completely missed it. thanks

digital gust
#

Dear shader people, so I was able to achieve masking out opaque materials. Now I wonder, why the heck is it working? I somehow can set rgba on the base material and it is cutting it out softly even if the shader is set to opaque.

neon mason
#

Hey. I use Canvas Shader Graph to create gradient on UI, but I have a problem that gradient draws over the text, even if it has higher priority

digital gust
amber saffron
neon mason
digital gust
amber saffron
digital gust
#

And thanks for pointing out the obvious 😞 🀣

amber saffron
neon mason
supple tinsel
#

Hello, how are you all?
I'd like to generate multiple depth maps based on different cameras. I know there's a keyword to get the depth map of a camera, but it only allows one camera to generate the map. Does anyone know how to get multiple depth maps?

slender ore
#

Do you guys know any program or website that would allow me to give it bunch of screenshots from image sequence recording and it would make me a flipbook?

digital gust
#

I am sure, there are tons of those online tools. Nothing really related to shaders

grand jolt
#

[Shader Graph] Struggling to convert world position's Y into a LERP node T input (0-1 range probably)
Im trying to blend two textures

amber saffron
amber saffron
grand jolt
amber saffron
# grand jolt Blending two textures basing on Y position

Well, I guess the only thing you are missing is a way to remap the Y position to the [0-1] lerp T range.
Any of the following nodes will do this for you :

  • inverse lerp
  • smoothstep
  • remap

Then also saturate the value just before the lerp node to be sur it doesn't go out of range.

grand jolt
amber saffron
grand jolt
#

Cant get it to work πŸ’€

amber saffron
grand jolt
#

Okay got it to work somewhat

#

Thanks

#

Still it doesnt respect the values i inputted

#

It changes at -30

#

Instead of -3

grand jolt
#

Nvm i think i got it, my pivot points are messed upp

#

Ya know how it is

amber saffron
#

Only the incriminated part then ^^

grand jolt
#

This was the issue

#

I sorta know how to fix it

amber saffron
#

That's not the part of the graph I was thinking of.
Also, maybe I didn't make it clear, but you need to enter values in the A and B inputs of the inverse lerp node.

grand jolt
#

Ya i know

#

Im saying it changed at -30 instead of -3 because the object's pivot was offseted by 30 meters

amber saffron
grand jolt
#

Ya dont worry about it

#

The reason it happens is bc when i was creating the mesh procedurally i accidentally raised the vertices by 30 meters

#

I think this is the first time somethnig i did in shader graph worked

#

Lol

mental creek
#

Hello,

If i wanted to create mesh vertices in a compute shader and pass then over to a vertex and fragment shader what would be the simplest way to do that?

timber cypress
#

does anyone know how to change the specular color with the shader graph

kind juniper
mental creek
kind juniper
#

Though, maybe you don't if it's draw procedural indirect.πŸ€”

mental creek
#

hmm I wish i had like a working example

kind juniper
#

Google and you might find one

#

You basically need 2 buffers. One for the arguments and one for the vertices.

prime sail
#

How do I make these null text boxes to go around nodes in the shader graph?...

prime sail
#

select the node or nodes Ctrl+G... They are groups... This should really be in the unity docs for the shader graph.

sharp frost
#

anyone suggest how I can scroll the overlay emission UV in one direction? Currently, it is scrolling based on the model's UVs.

neon mason
drowsy shuttle
sharp frost
warm pulsar
#

you don't have a transform matrix that could convert UV coordinates to any other space

warm pulsar
#

Different UV islands are going to be pointing in different directions

#

Have you considered triplanar mapping?

#

You'd do it in object space, not world space, so it would be stable as the player moves and looks around

#

The emission texture is pretty random and noisy looking, so the seams wouldn't be too bad

sharp frost
warm pulsar
#

Right, but you don't know which direction in UV-space corresponds to "forward" on the weapon

#

That's why you're having the problem in the first place

#

Scrolling in the +U direction means different things on different parts of the weapon

sharp frost
#

Yes I have tried triplanner but it is not working

warm pulsar
#

What about it is not working?

sharp frost
#

UV

warm pulsar
#

you don't use the triplanar node to compute a UV coordinate. you use it to sample a texture

#

(which does involve computing a UV coordinate, yes, but it's blending between three different textures samples internally)

drowsy shuttle
warm pulsar
#

No coordinate space's positions will correctly scroll the UVs.

#

unless the UV map is set up in a very specific way

#

(where "up" on every UV island points in the same direction on the model)

#

You could certainly do that.

#

I was helping someone get good scrolling emissions on their VRC avatar, and the solution was to copy their UV map and rearrange some islands such that a +X scroll did what they wanted

sharp frost
#

I am trying something, once it's done I will share it here.

Thanks for the suggestions.

uncut crown
#

Hi all, I'm in Unity 2022.3, builtin pipeline. I've got UNITY_SETUP_INSTANCE_ID(v) setup, and can access instance stuff, except the ID itself. I've found a fair few variations in different documentations, like v.instanceID, and unity_InstanceID, etc. But non work. UNITY_VERTEX_INPUT_INSTANCE_ID is in the input struct, not sure what else I need...

uncut crown
#

nvm, got rid of the UNITY_VERTEX_INPUT_INSTANCE_ID macro and declared SV_InstanceID myself... these macros man...

eager folio
silk forge
#

Hey ya'll, had a question about how to accomplish something and was hoping someone could point me in the right direction. Basically, I have a spotlight with a cookie texture, which projects a certain shape onto objects in the scene. I need to be able to access the projection of that spotlight in one of my shaders, respecting occlusion. Essentially, I need to output a mesh's texture with the projection of the spotlight on it.

Does anyone know the best way to do this? Do I need to do some sort of custom render pass to make that information available in my shaders, similar to depth?

ebon moss
sour tapir
#

i dont actually find a tutorial i want on ytb

#

nah im gonna test around myself

#

nobody post something like that

eager folio
mental creek
#

Do Graphics.RenderPrimitivesIndexed and Graphics.RenderPrimitives essentiality do the same thing. I see in both they are passed a position and triangle buffer.

silk forge
#

@eager folio Here's a simple example. Basically I have a spotlight projecting onto the object, with a cookie determining the light pattern. I'd like to be able to, in my shader, know when the light is hitting the current fragment. I feel like it's probably pretty simple and I'm just missing something.

#

Specifically this spotlight, not other scene lights.

#

I could probably manually calculate it based on the projection matrix, but then it wouldn't take shadows into account.

steel notch
#

So sprite renderers generate the quad for you.

#

What if I want a transparent mesh that's not a quad, but I want it to interact with sprite masks/sorting groups, what do I do?

#

Only way I've found is to use the particle system.

ebon basin
#

custom sprite shader ;)

eager folio
steel notch
steel notch
#

Can you set it?

#

How?

eager folio
#

Easiest way is the sprite editor. Usually used for rigging bones for sprites but you can also edit the mesh directly.

#

Otherwise, you can edit it using code

ebon basin
#

Does sorting layer / groups not work on meshes if you removed depth testing?

steel notch
ebon basin
#

actually never tested that but I would assume that should work because why wouldnt it just be part of the spriterenderer component

steel notch
steel notch
# ebon basin actually never tested that but I would assume that should work because why would...

I've seen some people ask how the Noxus Portal in Arena is made, so here is how!

It is using a stencil mask (very similar to a Photoshop Layer Mask) to hide geometry that is placed in front and behind it to fake a parallax effect.

This video shows with and without the stencil enabled.

The reflection layers are in the front, while the several ...

β–Ά Play video
#

This cone is what I'm after.

#

The rest seems to just be 2D elements.

#

And can be handles by sprites or particle systems.

ebon basin
#

Yeah idk the documentation isnt there for sorting groups. No clue wtf it's doing honestly, but you can use physical layers and just order everything using URP objects

eager folio
#

Just use a stencil shader.

#

That's all that sprite masks are anyway

ebon basin
#

sorting groups do work tho

steel notch
#

Sprite Renderers let you define how it interacts with the mask.

#

But I don't have that setting on Mesh Renderers 😦

ebon basin
#

Yeah, interesting there's not a Stencil component

#

well, custom shader or use URP render objects

steel notch
#

Well, particle system it is then.

shy halo
#

I am painting on a render texture using graphics.blit. It is working fine on my PC but it is not working on Android build.

Code for blit

Graphics.Blit(blitTexture, currentTexture);```


Code to create new render texture on start
```private void CreateRenderTexture(ref RenderTexture renderTexture, int size)
{
    renderTexture = new RenderTexture(size, size, 0, RenderTextureFormat.Default);
    renderTexture.enableRandomWrite = true;
    renderTexture.Create();
}```

Please help
digital gust
#

Anyone in here ever had issues making a screenspace shader for polyspatial/realitykit for visionOS? my current result is a mask on both eyes in the center of it, which makes it look like through goggles. Any experience about that issue or how to solve it?

sour tapir
#

i want a "circle fade out" effect for this distortion, what should i do

amber saffron
sour tapir
#

ok thx

grand jolt
#

I really don't understand what's going on. I opened the editor today and some of my shaders are acting wonky in scene and game view, but not when the game is running. For example, this one is invisible in the editor

grand jolt
#

Ok it seems to me that something is going wrong with the scene depth for some reason

#

This shader is dependent on that and that's why it looks invisible

#

The scene depth is just so low that I can't see it

#

Same with this one
Editor

#

In game

prime sail
regal stag
# grand jolt Same with this one Editor

Scene view camera might have a different near/far plane distances which might be affecting things. I think there's some camera settings in the top right of the scene view window?

grand jolt
#

Far was set to 10000

#

Somehow

#

It wasn't even an enabled setting

#

it was grayed out

#

thanks

silk forge
amber saffron
prime sail
ripe shell
#

Does anyone know of any tutorials on curving a terrain in Unity built in? Everything I'm finding uses shader graph with URP. I see the asset for world curving, but I'd like to try and solve this myself. I've got the curve part down with a custom shader, but the terrain is using Nature/Terrain/Standard so I'm basically losing the ability to paint my terrain by switching to a custom shader.

digital gust
grand jolt
#

So ACES lighting causes emissive things to sort of turn whiter the brighter they are.
I still want to use ACES, but I want the glow to be the actual color that I specified.
Is it possible to make a glow shader that isnt dependent on Unity's emission and bloom?
Image.

Cant find much by searching, everything I find relies on Unity's bloom post processing.

silk forge
frigid swallow
#

I think the starter pack of "No Code" from Unity with Ellen is pretty amazing. Do you guys tried to make it work with Unity 6? I'm getting the pink nightmare stuff and my knowledge in terms of shaders can only go so far... Any tips on where to start? I've been doing some courses on how shaders work but Unity doc is pretty obscure to me... Would love some directions from experimented shader magic wizards

light anchor
#

I wrote a palette swap shader in U6 shader graph where a color is swapped based on the red channel index using a palette texture. Considering the palette uses 0-255 indices, should I keep the original sprite as a rgb unorm format? I did tinker with colorspace conversion in the shader to avoid this but it always results in a wrong final result

low lichen
grand jolt
low lichen
#

It won't glow with bloom because it doesn't have enough intensity though.

grand jolt
#

Honestly this isnt a big issue, so if theres no an easy solution, I dont mind not adding it

low lichen
#

In theory, you could try to reverse that process and find a color that turns into pure green in ACES, if such a color exists. But it's finicky.

grand jolt
#

Well, I need it to be with any color, but honestly it isnt worth the hassle, ill just let the player choose ACES or Neutral in settings

#

Thanks for trying to help

eager folio
naive relic
#

When I create a material and change its shaders to "Standard", the material turns pink, does anyone know how I can fix that

kind juniper
naive relic
#

thanks

grand jolt
eager folio
grand jolt
#

Alright

bold mural
#

Hey guys, i recently wanted to add CRT to my project but i am running to a bit of a problem, i wanted to like use this CRT Shader (https://github.com/Cyanilux/URP_RetroCRTShader) but instead of making it fullscreen i wanted it to be shown on a screen with a mask that make sure that the effect only effect that mask while everything else is not affected, is there any way to achive this ?

GitHub

A shader graph which replicates some retro tv/monitor effects. CRT (cathode-ray tube) warping, scanlines, static, distortion, etc. - Cyanilux/URP_RetroCRTShader

amber saffron
bold mural
#

so is there any thing to change in the shadergraph itself ?

amber saffron
#

No, it would have to be in the RendererFeature.
And if you want it for UI, the UI needs to be in ScreenSpace Camera or World Space, as Overlay is not affected by post process.

@regal stag can probably help you better since it's his code πŸ˜„

bold mural
#

oh cool he is in this server ?

#

didnt know :D

bold mural
#

i managed to jerry rig it up a bit and this is how it is looking so far

amber saffron
#

Oh, maybe it can work with some injeciton point...

bold mural
#

dont know what i am missing

amber saffron
#

Oh wait, you want the mask to be "static" ?
Like, provide a fullscreen mask texture and that's all ?

bold mural
amber saffron
#

I think you could just sample the mask texture and apply it to the "Alpha" output of the stack.

bold mural
#

i did but it didnt work as excepted

#

it clip out the entirely of the "device" frame

#

i just want the crt to be a part of the device

amber saffron
#

Ok, I think I got it.
In that part of the graph, at the UV input of the sample texture node, lerp between the distorded UVs and the base UVs, based on the mask texture

bold mural
#

hmmm let me see

bold mural
amber saffron
#

That's exactly what I said πŸ™‚

bold mural
#

what about T ?

amber saffron
#

A is un-modified UVs, B is distored UVs, T is the sampled mask texture

bold mural
#

like this ?

amber saffron
#

Almost, you're missing the UVs in the A input.

#

(texture coordinates node)

bold mural
#

i am so confused, sorry 😭

amber saffron
#

Hum, yes, that prevent distortion outside of the mask, but the rest of the effect are still visible.
You'll also have to mask them out like this :

bold mural
#

ok that worked but now there is like effect like this on the corner

amber saffron
#

The colors in the bottom right ?
I'm usure about what is is, what does it look like without the effect ?

bold mural
#

i have like a fake ish bloom thingy

amber saffron
#

At that point, I think it would be better to "simply" integrate the effect into a UI shader, and apply it on the screen UI image object.

bold mural
#

i am way too dumb for that

#

that is for sure

amber saffron
#

I guess that "screen" will also have some other UI in it, that needs to be distorded ? (if yes, you need to keep the post process)

bold mural
#

yeah, some child below

amber saffron
#

Could you send the screen texture and mask, I think I should be able to quickly come up with a solution

bold mural
amber saffron
#

Ah, that's great, the effect just doens't do anything on my side :/
Let's wait for Cyan to pop I guess ...

bold mural
#

are you using unity 6 ?

#

cus i am using that version 23f1 to be specific

amber saffron
#

Yep, I tested on 6.0

bold mural
# amber saffron Yep, I tested on 6.0

i did some testing i found out that the distort come from the above sample 2d that is connected to the main texture, it have that type of effect when i connect it to RGBA, if i switch to from RGBA to A when connecting to the redirection node, it shhow that the sample texture 2d borked

manic niche
#

can someone explain to me how to get a lit urp shader running in the newest unity version? even the "default" lit shader you get from just creating one spits out this error:

sour tapir
#

i just wanted the edge distortion

#

for something like black hole

#

(2:46 there)

#

nvm its uv problem mb

bold mural
regal stag
bold mural
# regal stag I'm a bit unsure what the problem is

oh hey there, uh i wanted to modify your shader graph (https://github.com/Cyanilux/URP_RetroCRTShader) but instead of it being applied on the entire UI Image GameObject, i just wanted it be like applied on a specific area that is determined by a white mask with black background, so that the white area have like a CRT effect while the black background area are basically untouched and rendered normally

GitHub

A shader graph which replicates some retro tv/monitor effects. CRT (cathode-ray tube) warping, scanlines, static, distortion, etc. - Cyanilux/URP_RetroCRTShader

#

me and Remy goes back and forward a bit and manage to hit the result above, tho it is what i wanted to be but still having a bunch of error that remy and i didnt seem fix it

regal stag
# bold mural oh hey there, uh i wanted to modify your shader graph (https://github.com/Cyanil...

Well if you're working with UI you'll want to make sure you use the Canvas Graph type (can change it under graph settings)
At the end of the graph before connecting to the Base Color, I think you'd want to use a Lerp with A set to the RGBA output of your monitor texture, B set to the graph result and T set to the mask texture.
And also connect the A output of the monitor texture to the Alpha port of the master stack.

#

Might be fine as-is, but you could also optionally remap the UVs at the beginning of the graph to shrink the whole effect towards the center, to make it better fit the monitor texture. I think UV -> Subtract a Vector2 of (0.5, 0.5) -> Multiply some value, maybe 1.5 -> Add (0.5, 0.5) should achieve that

bold mural
regal stag
#

By "monitor texture" I'm referring to the right one you posted here (and "mask texture" being the left one) #archived-shaders message

bold mural
cedar sand
#

I'm having an issue with the screen depth in shader graph. I simply wish to invert the value I get from the scene depth node. Plugging the original scene depth value results in this:

#

if I one minus the float value I get from the scene depth I get this:

#

am I wrong to expect to have seen different shades of white after one minussing the scene depth value?

#

(also note, this is a fullscreen shader)

neat orchid
#

How hard do you guys think it is to learn hlsl if you know shader graph and c#?

amber saffron
cedar sand
#

It is currently set to Linear01

amber saffron
cedar sand
#

Yeah I understand, just wondering whats best to amplify the effect. But thank you!

amber saffron
#

You can apply some gamma curve to the result, power to 2.2 (or 1/2.2, I'm never sure)

sand fulcrum
neat orchid
neon steppe
#

Did anyone import this sample into their project? The lit shader gives me the too many keywords error

modest elk
#

Does anyone here have experience with Spine in Unity?

drowsy shuttle
bold mural
stiff epoch
#

Could use some help with making a shader that when two transparent objects overlap the color doesn't get darker, it just remains ONE solid color.

#

What I don't want to happen:

#

And here's what I want to happen:

#

oh and also I'm using shader graph and would want this to work in shader graph

hearty obsidian
#

@stiff epoch Can use the scene color node to get the color before transparents from the opaque texture

stiff epoch
manic niche
#

how do I stop the transparent part from receiving lighting?

hearty obsidian
#

@stiff epoch You need to enabled the opaque texture in your render pipeline asset to use scene color if that isn't done already

manic niche
stiff epoch
#

still not one solid color

manic niche
stiff epoch
#

here's just 2:

manic niche
#

I'd imagine this is less of a fix in the shader itself but more of a change on how unity does transparency.

stiff epoch
#

perhaps but I've seen it done in a game and now I've been trying to figure out how to get it in mine

manic niche
#

cuz the shader says the plane has this color and then in the end every transparent pixel gets pushed down to the opaque pixel below

stiff epoch
#

I know it's possible

stiff epoch
manic niche
#

sadly not. I am guessing that those are blood splatters. is there any reason they have to be on seperate planes and not just all written to the same texture?

hearty obsidian
#

@stiff epoch Can you show your graph?

stiff epoch
#

yeah sure one sec

#

the large screenshot is the whole graph which has some stuff from a tutorial I followed about custom decals (doesnt affect color) then the second screenshot is where I actually input the colors with the scene color node (the node with "multiply" is the texture multiplied by a color)

#

I hope that was concise idk

stiff epoch
hearty obsidian
#

@stiff epoch Well I can't see anything on your first screenshot, but is there any chance that it is actually working and you're just feeding varying alpha values?

#

And by I can't see anything, I don't mean I can't see any issues, I mean I can't see what's on there literally

#

@stiff epoch Perhaps you're blending additively?

#

That's the thing right. When you feed the unblended raw color straight to the ouput, then you're choosing a "mode" defining how it's going to blend with what's already rendered.

If you pick the scene color, then you need to handle the blending manually, otherwise you'd blend currently rendered color with scene color and then whatever your operations are, rather than what you want which is simply scene color blended with your own stuff.

What you can do is set the blending mode to alpha, and leave the alpha output as 1. Transparency only matters because what you need is that the object isn't fed to the opaque texture when rendered, as to not affect the color for the next blood splatter (if that's what they are).

I'm not 100% certain but I think the object could even be opaque if it was rendered in the transparent queue, but don't quote me on that.

stiff epoch
#

🀷 still need to figure this out but it might be more complicated than I thought

hearty obsidian
#

@stiff epoch You don't need an alpha value. Alpha is just a scalar used in blending computations.

If you use the scene color, you already know what the color is for that fragment, you can do the blending yourself

stiff epoch
hearty obsidian
#

@stiff epoch What's your understanding of scene color?

stiff epoch
#

It's the color of the material (before) applying the transparent pass?

hearty obsidian
#

No no! It has nothing to do with the current object that you're currently shading. To try to put it in the simplest form, opaque objects are rendered first in the opaque queue. As they are rendered, they update something called the opaque texture if you have that enabled.

You can think of the opaque texture as one big texture that stretches over the span of the screen. It reflects exactly what the screen looks like at that point in time, before transparent objects start being rendered. If you're downsampling it for performance, then not exactly but close enough πŸ™‚

So when you read the opaque texture (scene color node), you're basically querying what the color is on the screen at that fragment's position, irrelevant of the object being rendered.

hearty obsidian
#

So for you, the scene color returns this bumped grassy dark green in your screenshots above. It knows nothing of the red the other transparent objects are applying because the other transparent objects are not written into the opaque texture.

#

@stiff epoch You don't need transparency per-se, because you already know what's underneath. But you do need transparency in the sense that the object you're currently shading cannot be written to the opaque texture, else the next blood stain will pick up on it and then it'll be factored in, which is what you were trying to avoid in the first place

#

Now, if you render one blood stain with an alpha of 0.5, and another one on top with the same alpha value, they will be blended with what's underneath, there's no workaround. If you don't want the blending, and you don't, you need to give them an alpha value of 1 so that they completely overwrite the fragments they're being blended with.

stiff epoch