#archived-shaders

1 messages · Page 4 of 1

open sable
#

if it is a lit graph it will

#

ahm

tight phoenix
#

it does the same in scene

#

I can gif capture it there but it will be the same

#

im assuming nothing is showing up because the dot product is returning zero between whatever the RNG colors are and the object space view direction?

open sable
#

seems like your normals or view angle might be in world space, goingt to object space might help that

tight phoenix
#

if I absolute it so there are no negative values, that 'fixes it' by making the values never negative

#

but im not sure if that is the correct fix or if that is doing something else that will shoot me in the foot later

#

im guessing the back side was dark because its the dot of the negative values pointing into the 3d objecf

open sable
#

if it's stupid, but works, it's not stupid.

tight phoenix
#

I mean, I hope its not stupid to take the absolute, I hope its the correct sollution. I don't feel like I am learning if I'm doing stupid hacks

regal stag
#

I don't fully understand why it fixed it, but it shouldn't cause problems afaik

open sable
#

my turn to spam a bit ;]
as for things that don't work...my interpolated UVs don't work...because I don't know why?

#

terrain UV with normal draw

#

terrain UV's with instanced draw

#

interpolated UV's

#

(so far so good)

#

control texture, with normal draw, terrain UV's

#

waiiiit...it started to work out of the blue by it self now...?

regal stag
#

lmao

tight phoenix
#

Thank you Cyan and Marcin, the shader is working now as I hoped to have it look. I am still frustrated that I couldn't do it on my own but I appreciate the help

#

Now to start on the next bit and try not to lose my shit when it doesnt work on the first 50 attempts 💦

open sable
#

hey

#

I think I found a shadergraph bug...yay

#

plug it like this:
(don't mind the debug spagethi)

#

looks like this

#

plug it like this

#

and looks like this...

tight phoenix
#

time to never use a redirect ever again 😨

open sable
#

seems so. Guess it's bug reporting time...?

regal stag
#

Wow yeah.

#

I've never had troubles with redirects but I guess this might be a problem with using redirects with custom interpolators?

open sable
#

seems like it. Also never had issue with them so far

regal stag
#

I wonder if using another node inbetween, like a Preview or an Add with 0 works still

tight phoenix
#

speaking of shader graph bugs

#

UV03 must come from external or it blows up

open sable
#

all of these, work

regal stag
# open sable

How about Custom Interp -> Preview -> Redirect -> Sample. (just curious)

open sable
#

Too add to good things...they just shut of my power ;p

#

Construction work nearby...

#

Either way...I'll test this more tomorrow. But: if i plug a redirection node AFTER the preview node, it worked

#

But if the redirect is right before the interpolated node, it does not

tight phoenix
#

look ma, sparkles at different depths 🔥

midnight crater
#

not to derail from the bug talk but am testing moving some shaders from amplify to shader graph - is it correct that properties from subgraphs or custom functions do not propagate to parent graphs?

tight phoenix
midnight crater
#

or is there a clean way to do this that doesn't involve re-declaring these for every graph that will have have the same inputs?

tight phoenix
tight phoenix
#

pictured above is a subgraph not having its parent properties ^

regal stag
#

Yeah, if you need exposed properties they must be defined in the main graph and connected to the SubGraph node when used in that graph

midnight crater
#

dang, thanks

#

really would like to move us over but little things like this keep turning me off

open sable
midnight crater
#

cheers - perhaps i'll make a tool that does this

royal gazelle
#

Is it possible to change the ZTest value of a shader in code/at runtime?

regal stag
royal gazelle
royal gazelle
hazy meteor
#

Hello, How can I convert this shader from shadergraph to an unlit shader? It is moving vertices down using the texture. Thats what i need.

torpid sapphire
#

@hazy meteor If you click the master node (Fragment), you should be able to select unlit from a dropdown

#

I am facing a weird issue on some mobile device. I have a very simple shader (code) that scrolls texture over time. Thing is it scrolls at very different speed on some mobile devices, it get really slow on some, and regular speed on other (same as editor). It is not related to lag, some very high end device with 30fps still get a very crappy and blocky texture scrolling. Speed is not the right word, it is the frame rate of the scrolling that is affected. Anyone has an idea^

#

It is a UI shader I must say

hazy meteor
native otter
#

I noticed that my custom made shader for the leaves don't render it when viewed from a distance. (leaves slowly disappears)
It only happens with this shader, not with the URP lit shader or with the tree itself.
I'm stuck how to fix this. Any idea?

open sable
open sable
karmic hatch
#

^

broken elbow
tight phoenix
#

Im trying to finish this effect that I didnt finish before
I have the inside-out UVs, and the direction of the main light
how do I use those two inputs with the Refract method to get this appearance on the left side

#

I was told:

So just acos(dot(object space sun direction, object space position))```
#

but neither of those things worked for me at all

#

I couldnt transform the space, and if I could, it was still wrong because it was stuck in object space and would fuck up if the object rotated at all

#

here is ( acos(dot(object space sun direction, object space position))

#

but its just white, then what? I have no idea how im supposed to use that

#

If I use it as color, its completely wrong, its supposed to be on the inner backside, not the outer surface

#

but I have no idea how im supposed to combine the inside out UVs

#

with the other part

#

definitely not this, this just blows up the entire shader and screen

#

this is -almost- right

#

but something wacky is going on with the angles

#

also its in object space so as soon as you rotate it, it fucks up

#

none of this works because I have no idea what im doing

#

im just plugging things into things, doing math on things to see if it will do what I want

#

and none of this will do what I want

#

im a stupid ape who is literally trying everything on everything bnecause I have zero comprehension of how to actually work towards what I want

#

the literal only thing I can hope to do is accidentally luck into it by trying every possible combination

#

frustrating, getting agitated again

#

this seems almost right except for it being completely wrong

#

and I cant figure out how to unfuck it

#

I feel like im very close to figuring it out, if only I could figure out what is causing the big black circle to form

#

uhhhh if I add nothing, it fixes it

#

I'm not enough of a mathematician to understand why adding zero actually does something

#

mfw

pearl frigate
#

New to shadergraphs here. Made a shader that takes the vertices height into account and lerps between materials. I want to add normals to this, and setup the normals with the same lerp function. The normals are setup pretty basic (sub-tree image attached), but this doesnt work.

The error doesnt help me much with any debugging.

#

Here is the error:

tight phoenix
#

scratch that about adding 0 fixing it, its still like this in scene even if its fixed in preview

#

making it a PROPERTY of 0... fixes it in scene

pearl frigate
thorny falcon
#

how could I bring a float[ , ] to a shader in script

pearl frigate
thorny falcon
#

it is a noise map

#

a float array

pearl frigate
#

Yes, that is a Vector2

#

a Vector3 holds 3 floats

#

and Vector 4 holds 4 floats.

thorny falcon
#

it is a surface shader

#

cant do vector2

pearl frigate
#

I might be misunderstanding what you are looking for though. I am fairly new to shading myself.

thorny falcon
#

so a float 2 i think

pearl frigate
#

(And just so you know, a float is referred to as a Vector1 as well)

thorny falcon
#

yea i know

#

float2 is vector2

#

i need a

#

Float Array

tight phoenix
thorny falcon
#

what about surface shaders?

tight phoenix
torn bronze
#

Heyo, I've looked everywhere for a solution to this and either there's nothing there or no one responds when I ask for help, does anyone know what causes this? I'm trying to make a map for VRChat and the water shader bugs out bad and I don't even know what to call this bug. It's the "RED_SIM Perfect Water Shaders" if that helps at all

#

I'm also not sure if this is the right channel to be asking lol

#

If not I'll move it

torn bronze
#

Im guessing that it may have something to do with a culling issue?

#

But I'm extremely new to Unity and don't even know where to start trying to fix it

#

I've been trying to figure out this single issue for months

open sable
#

If your are sampling a lot of textures, reuse your sampler

#

Create one on the blackboard, and plug it to all the sampletexture2d nodes, that you use with the same sampler settings

open sable
# thorny falcon what about surface shaders?

A texture is an 2d float array. Exactly what you are asking for. Create a noise texture in Photoshop, or download one from the web, and you will haver your float2 array (even float4 actually, but you can filter that out in the graph). Or save your c# [,] into the red and green chanel's of a texture, and use that. (U can ignore the other chanel's.)

frosty linden
#

Hi, would anybody know why doesn't the HDRP lit layered display the layer with the proper transparency? Here is the texture.

#

And here is the result when applying this texture on any layer above 1

#

The half dot should be semi transparent, shouldn't it?

grand jolt
#

I tried the example from the amplify package to reveal an object when it's hit with a certain light

#

But in the example you need to select also a object behind it (the brick wall)

#

I don't want that, because I want to place those markers on walls/ceiling/floor...

#

But I have no clue how to do this :/

#

this is the graph

#

URP

cosmic prairie
#

I'm not sure if amplify supports URP decals, check docs

#

seems like amplify has a urp decal output nvm this is a custom solution?

#

(random image I stole from twitter)

pearl frigate
open sable
#

this way, you will not hit the 16 sampler limit.
Keep in mind though, that sampling 16 textures in your shader, is quite a hassle...are you doing a terrain shader by chance?

open sable
native otter
open sable
#

hmm

pearl frigate
open sable
pearl frigate
open sable
#

and see if that changes the effect

#

if yes, than it seems it might ma mipmap alpha issue

pearl frigate
open sable
#

it looks like like a mipmapping issue, but might be wrong

native otter
open sable
native otter
#

Oh I see your second reply, sorry I'll check that

open sable
open sable
native otter
#

You mean just one unchanged value for the threshold correct?

open sable
#

you should find a combination that works well enought

#

play with this, in combinathin with the alpha treshold on the shader

native otter
#

I'll check this out, thx

open sable
#

best: put the alpha threshold as a material paramtere

#

and then set it in the material in scene. You'll find a combination that works.

If you'll be interested on why this happens, there are some cool materials online 😉

#

✔️ Works in 2020.3 ➕ 2021.1

Mipmaps are scaled down versions of textures Unity generates and draws when a texture takes up a small area on the screen. This saves memory and looks better to boot! In this video, I go over Unity's mipmap generation settings and show how to create custom mipmaps. I also quickly demonstrate a cool trick Nintendo use...

▶ Play video
native otter
#

Thank you!

grand jolt
regal stag
open sable
# torn bronze No one...? q-q

oof, it's not about no one. It's more about the problem definition.
You are new to unity, but are asking a pretty advanced question. And yes, sometimes you might get a hit, that someone has the exact same problem, but otherwise, more specific info is needed: what unity version, what pipeline, and as Cyan said: in cases of asset specific problems, their creators should be your first go to, as they know the shader. We don't 🙂

torn bronze
#

Yeah fair enough, I did try to contact the creator but they never responded to me. I guess I can just try using a different shader which is annoying but might be my only hope

#

Again I don't even know what to call this issue so idk how to even search for a solution

rain minnow
#

How do I declare a texture2d array in a hlsl file being used as a custom function node in shadergraph. I've tried using UNITY_DECLARETEX2DARRAY(baseTextures) as stated in the docs, but I just get an "unrecognized identifier"... Btw, I'm setting the texture array from script using Material.SetTexture

regal stag
rain minnow
regal stag
rain minnow
#

I see, thx a lot

grave gorge
#

this is probably not the right place for this but do you guys know how to make objects that cast shadows but are invisble to the camera?

regal stag
# rain minnow I see, thx a lot

You'd also likely need SAMPLER(name) btw

Or alternatively define the Texture2D Array in the graph blackboard. Can then use UnityTexture2DArray name as an input param (if in URP v10.3+). That should allow you to obtain the sampler via name.samplerstate too.

For sampling, can use SAMPLE_TEXTURE2D_ARRAY(name, sampler, uv, index)

regal stag
grave gorge
#

I'll try checking that out ty

regal stag
#

Otherwise could probably use a shader that uses ColorMask 0 and ZWrite Off in it's main forward pass.

grave gorge
#

Wait how do I hide objects though? I literally started unity yesterday

regal stag
#

I checked the docs so that Shadows Only setting should be available in all pipelines

grave gorge
#

yeah it worked ty

tight phoenix
#

I have a bit of pink in my shader I am working on UnityChanThink
adding, subtracting, multiplying, negating all doesn't get rid of it

#

Is there an easy way to fix this?

#

trying to force those values to be something instead of nothing doesnt seem to be working

#

I know what the cause of the pink is, sorta, but the problem is that I need it to be the value that it is (which is causing the pink)

#

so I need it to be that value, without causing pink 🤔

regal stag
tight phoenix
#

hmm, clamp completely changes how it looks

#

it does fix the pink, but it also completely destroys all the step before that

#

sphere radius is responsible for causing the pink to happen

#

but I need the look it has there, just without the pink

#

in the output you can see the pink gets interpreted as just black

#

all the relevent nodes

regal stag
#

Hmmm what happens if you Normalise after the Subtract node

hearty obsidian
#

From the Screen Position node in unity's docs :
This mode divides Screen Position by the clip space position W component.
Could someone explain to me what this means?

#

In reference to default mode of the node

tight phoenix
#

though it still sorta looks like the effect just not to the degree it did before, maybe I can bring it back closer after the arcosine with mult/power/other maths?

#

Looks real interesting though 👀

#

ill try doing maths to it now after the arcosign step, this seems like the right direction

regal stag
# hearty obsidian From the Screen Position node in unity's docs : `This mode divides Screen Positi...

In order to calculate the screen position, Unity goes through numerous spaces. From Object space coordinates stored in the mesh, to World space, then View (relative to camera) and Clip space (using camera projection matrix). It then does a bit of remapping and a "perspective divide", which as the docs mention is dividing by the w component. clipPos / clipPos.w.

This results in (0,0) in the bottom left of the screen and (1,1) in the top right. I think Z is just cleared to 0 from what I've experienced with the Default mode. And W is then 1 - since anything divided by itself is 1.

In some cases, obtaining the W axis (and maybe Z) of the clip space before that divide can be useful, hence why the node has a "Raw" mode too. Specifically because of the way the projection matrix works, the W component is the View/Eye space depth to the current fragment. That's commonly used for "edge foam" on water shaders.

I've got more related info here : https://www.cyanilux.com/tutorials/depth/

grizzled bolt
regal stag
tight phoenix
#

now that I have the inside working, I will add the reflection/refaction cubemaps

hearty obsidian
#

@regal stag Thank you so much! I learned tons from your website in the past, again, thanks for making this knowledge accessible to newcomers

naive root
#

I downloaded Shader Graph and made a simple shader, but I get this error when trying to apply it. What's up with that?

#

Shader error in 'Shader Graphs/shad': Couldn't open include file 'Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/Shims.hlsl'. at line 559

naive root
#

i tried reimporting everything but it didn't fix it

#

i'll give that a try

tight phoenix
#

after adding reflection/refraction of cubemaps, it looks kinda goofy to me, especially on things other than the sphere UnityChanThink Ill leave it this for now and tweak the values more later

#

it might be because the cubemap is not the same as the scene background

regal stag
#

Might be able to use unity_SpecCube0 to get the auto-generated cubemap for environmental reflections

tight phoenix
#

I think it might by default - in this scene the object's smoothness is set to 1 - perfect reflections, and you can kinda see the cubemap bg on it

#

or do you mean something more than that?

regal stag
#

Or does the Reflection Probe node just use the default? Idk I haven't used it much. Ah yeah it would.

tight phoenix
open sable
#

hmmm...I'm still having a hard time getting the depthnormal shader to fire up on my instanced geometry...some more insight coming:

This is the depthnormals shader doing it's job on a normaly drawn terrain:

frosty linden
#

Would anybody know how to handle semi transparency when using the HDRP lit layered on the additional layers? At the moment, even a pixel with 50% opacity is displayed with 100% opacity in the lit layered, is this normal? If nobody knows, is there more documentation on the lit layered somewhere ? The official doc doesn't seem to cover this point.

open sable
#

when instanced, there are no passes. It's just collapsed to this single entry

#
    Properties{
        _MainTex("", 2D) = "white" {}
        _Cutoff("", Float) = 0.5
        _Color("", Color) = (1,1,1,1)
    }

        SubShader{
            Tags { "RenderType" = "Opaque" }
            Pass {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"

        struct v2f {
            float4 pos : SV_POSITION;
            float4 nz : TEXCOORD0;
            UNITY_VERTEX_OUTPUT_STEREO
        };
        v2f vert(appdata_base v) {
            v2f o;

           
           /*ApplyMeshModification(v);*/


            o.pos = UnityObjectToClipPos(v.vertex);
            o.nz.xyz = COMPUTE_VIEW_NORMAL;
            o.nz.w = COMPUTE_DEPTH_01;
           /*o.pos = v.vertex;*/
            return o;
        }
        fixed4 frag(v2f i) : SV_Target {
            return EncodeDepthNormal(i.nz.w, i.nz.xyz);
        }
        ENDCG
            }
        }```
#

this is the substitute shader that renders the depthnormals texture

#
{
    class Pass : ScriptableRenderPass
    {
        //int GrassLayerIndex = 17;
        //int TreeLayerIndex = 18;
        //int OtherLayerIndex = 19;
        //int BillboardLayer = 20;
        //int VP_NoOutlines = 21;
        int layerMask = ~((1 << 17) | (1 << 18) | (1 << 19) | (1 << 20) | (1 << 21));

        private Material material;
        private List<ShaderTagId> shaderTags;
        private FilteringSettings filteringSettings;
        private RenderTargetHandle destinationHandle;
        public Pass(Material material)
        {
            this.material = material;
            //This contains a list of shader tags, The rendere will only render objects
            //with materials containing a shader with at leat one tag in this list
            this.shaderTags = new List<ShaderTagId>()
            {
                //new ShaderTagId("MyShader"),
                new ShaderTagId("DepthOnly"),
                //new ShaderTagId("Opaque"),
                //new ShaderTagId("SRPDefaultUnlit"),
                //new ShaderTagId("UniversalForward"),
                //new ShaderTagId("LightweightForward"),
            };
            this.filteringSettings = new FilteringSettings(RenderQueueRange.opaque, layerMask);
            destinationHandle.Init("_DepthNormalsTexture");
        }

        public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
        {
            cmd.GetTemporaryRT(destinationHandle.id, cameraTextureDescriptor, FilterMode.Point);
            ConfigureTarget(destinationHandle.Identifier());
            ConfigureClear(ClearFlag.All, Color.black);
        }
        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            //Create the draw settings, which configures a new draw call to the GPU
            var drawSettings = CreateDrawingSettings(shaderTags, ref renderingData, renderingData.cameraData.defaultOpaqueSortFlags);
            //Overide material to render all objects with our material
            drawSettings.overrideMaterial = material;
            context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref filteringSettings);
        }
        public override void FrameCleanup(CommandBuffer cmd)
        {
            cmd.ReleaseTemporaryRT(destinationHandle.id);
        }
    }

    private Pass pass;

    public override void Create()
    {
        //Using inbuild renderers depth normals texture shader
        Material material = CoreUtils.CreateEngineMaterial("Hidden/MyStupidShader");
        this.pass = new Pass(material);

        //Configures where the render pass should be injected
        pass.renderPassEvent = RenderPassEvent.AfterRenderingPrePasses;
        //pass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
    }

    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        renderer.EnqueuePass(pass);
    }
}``` and here is the render feature that uses this shader
#

is it, that I'm using not the corrent drawSettings / filteringsettings? is the mesh simply invisible to the shader due to it beeing instanced? wrong renderpass event with combination with something else?

regal stag
#

Hmm, shaderTags is only including the DepthOnly one. But your shader doesn't use that, it has no LightMode tag so would use SRPDefaultUnlit.

open sable
#

hmm...is that not indicating it actualy does?

#

enabling SPRDefoultUnlit -> no change
Enabling all the tags, same thing

regal stag
#

Ah right, I guess the shaderTag is like a filter. But in this case you would likely want whatever the main pass in the Terrain is. "UniversalForward" perhaps?

#

When you don't use Instancing, does this pass work / appear in the Frame Debugger?

open sable
#

yes

#

and the resulting texture is beeing passed to the actual shader as intented

regal stag
#

I'm guessing that using instancing is removing it from the DrawRenderers call then :\

open sable
#

I'll try to revert to the original internal shader

regal stag
#

@open sable Hmm what about adding drawSettings.enableInstancing = true;

#

Oh, though the docs say it's enabled by default

open sable
#

, no dice 😭

#

I had high hopes when you said that ;]

regal stag
#

Same, I saw it in the docs and thought that might be it

open sable
#

this is the original shader

#

(at least, I hope it is...im using 2021.2, but I thing the main body will be the same...)

#

might there be a problem with the instance ID setting up?

#

for example, if I could pass the instance ID, instead of settring it up?

#

UNITY_VERTEX_INPUT_INSTANCE_ID //Insert

regal stag
#

Maybe comment out the drawSettings.overrideMaterial = material line for now. The important thing is if we can get the Draw Mesh (Instanced) Terrain to appear in the Frame Debugger for our pass

open sable
#

for example, the instancing code part has this at the head:

#ifdef UNITY_INSTANCING_ENABLED
    sampler2D _TerrainHeightmapTexture;
    sampler2D _TerrainNormalmapTexture;
 
    float4 _TerrainHeightmapRecipSize;   // float4(1.0f/width, 1.0f/height, 1.0f/(width-1), 1.0f/(height-1))
    float4 _TerrainHeightmapScale;       // float4(hmScale.x, hmScale.y / (float)(kMaxHeight), hmScale.z, 0.0f)
 
    UNITY_INSTANCING_BUFFER_START(Terrain)
        UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainPatchInstanceData)  // float4(xBase, yBase, skipScale, ~)
    UNITY_INSTANCING_BUFFER_END(Terrain)
#endif
#

then in the function body it gets the instace data using this

    float2 patchVertex = vertXYZW.xy;
    float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);
#

hmm, but that data is not the most importang thing I see. just some scaling and hight information

regal stag
open sable
#

damn, got to go...to be continued. Thank you Cyan for the efforts, I'll give an update if I move forward with the puzzle 🙂

tardy oar
#

Hello I am making a shader based on this tutorial: https://danielilett.com/2021-03-19-tut5-15-wall-cutout/
I have it working but I want to make it toggle-able. I have tried putting the code part that actually culls the pixels in an if statement and that works for "toggling" it on, but I cant figure out how to reverse that.
Any help is appreciated!

rain minnow
#

Hi! Could anyone give me some clue about how I could convert this BRP surface shader into a URP fragment shader? I need to have lighting and all those things surface shaders just do.

hazy meteor
#

How can I add lighting to my shader/model? I havent found any tutorial

knotty juniper
hazy meteor
#

nope

meager pelican
thorny falcon
#

is there a way to get a texture2d out of a texture2dArray

#

as a texture 2d

grizzled bolt
thorny falcon
#

in a surface shader

regal stag
#

Why do you need it as a texture2d?

thorny falcon
#

so i can apply it

#

it is a sampler2D in shader

regal stag
#

If it's a sampler2D, it's not a texture array

#

If you use Texture2DArray, you can sample it directly. You don't need to convert to Texture2D/sampler2D

thorny falcon
#

ok

regal stag
tight phoenix
#

I've been plugging away at this shader making it look real nice but ive come to realize something that's missing
The interior highlight bit is perfectly on the opposite face of the sphere as if it was perfectly hollow, but on a real gem it can look more/less 'deep' based on... something (the index of refraction maybe?) 🤔

#

Tryin to figure out what I would need to change to make the glow spot seem less 'deep' inside of it

#

I think it has something to do with the view vector angle?

#

from another tutorial this sorta does it I think? I will try to weld the way this one works onto my gem

torn bronze
#

Will update if I confirm that's the issue

tight phoenix
#

I sorta got it working but it gets smaller the closer it is to the middle, but also that it gets bigger on the backside equally to how small its become 🤔

#

which is interesting but not what I am going for UnityChanThink

tight phoenix
#

hm not getting any closer

#

for once I cant even describe in words what im trying to do

#

this is really neat, its kind of the exact opposite of what im trying to do but its neat 🤔
Maybe it is the opposite, I can try inverting that

#

Yeah im stuck, I tried all kinds of dumb things that don't do what I want

#

I dont have a clue how to obtain what I want, and blindly attaching everything to everything in random orders with random values isnt achieving it

#

a few interesting looks came of that but none of them were 'it' that im seeking

#

im 80% sure the thing that has to change is the view direction

#

or maybe the normal vector?

#

or just -something- in here

#

yeah I just don't get it

#

no matter what I plug in where, the result is the same, which is to say the result is not what I want every time

tight phoenix
frosty linden
#

Still nobody here to let me know how to have the HDRP lit layered shader handle 50% opacity on the extra layers? At the moment, it displays all pixel with opacity > 0% as if it was 100% opacity. Is it a wrong set up on my side or can't the HDRP lit layered shader handle semi opacity on the additional textures?

storm summit
#

ok

rain minnow
open sable
rain minnow
# open sable textures are float4 arrays, and SG does support them

But the arrays I'm passing are quite small and composing textures to encode the values, to then decode them again in the shader seems to be very ineffecient. Also , ShaderGraph doesn't support for loops, meaning I'd have to repeat a lot of nodes and end up with an unreadable graph. What I really want is to write a shader, I just don't know how to incorporate lighting - that was my question

open sable
karmic hatch
regal stag
cinder path
#

is there a way to abstract groups of nodes to repeat operations instead of copying and pasting in Shader Graph?

#

a bit like how the node groups would work in the Blender Shading Nodes

mental bone
#

Select nodes -> right click -> Conver to -> SubGraph

open sable
#

hey Cyan ;] would you like to take part in the continuation of my struggles? ;p
cause, there have been some developments, but I'm missing the last piece of the puzzle.

The main point forward, was enabling instancing, not on the drawSettings, but on the material that does the override. So it was a good idea on your part 🙂

        this.pass = new Pass(material);```

This made the terrain appear in the frame debugger, but still rendering null. I've added the instancing pragmas to the DepthNormalsTexture shader, 

``` #pragma multi_compile_instancing
        #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap```

and the meshmodification function, that I use in the main shader.

And it gets the _TerrainHeightmapRecipSize and _TerrainHightmapScale correctly, but is does not get the _TerrainHightmapTexture.
#

the terrainhight map, is beeing correctly assigne in the main shader, on all the stages

#

I've tried, brute forcing it, and force feeding the shader the texture

regal stag
open sable
#

to see if anything happens

#

        Texture2D hightTexture = LoadPNG("C:/vp4/VP/Assets/Heightmaps/Untitled-2.png");
        //Debug.Log(hightTexture == null);
        material.SetTexture("_Texture", hightTexture);

        material.enableInstancing = true;
        this.pass = new Pass(material);```
#

and in deed it does, but highttexture I exported from photoshop, is a bit different than the original (different encoding?)

#

and it does render something...just not accuratly

regal stag
open sable
#

it was edited in the shader too

#
    Properties{
        _Texture("_Texture", 2D) = "white" {}

       
    }```
regal stag
#

Okay gotcha

open sable
#

I was sort of proding and checking, and mixing different definitions of the texture

#

atm ``` TEXTURE2D(_TerrainHeightmapTexture);
TEXTURE2D(_TerrainNormalmapTexture);
SAMPLER(sampler__TerrainNormalmapTexture);
SAMPLER(vertex_linear_clamp_sampler);

//sampler2D _TerrainHeightmapTexture;
//sampler2D _TerrainNormalmapTexture;```
#

this is how the texture is declared in the main shader

#

and both ways work (the commented out one, and the not commented out one)

#

samping as:

    float hm = UnpackHeightmap(_TerrainHeightmapTexture.SampleLevel(vertex_linear_clamp_sampler, sampleCoords, 0));```
#

depeding on the definition

#

I'm doing the same thing in the depthnormals shader...but for the life of me, I cant get it, to 'aquire' the TerrainHeightmapTexture

#

it's always the defoult 16x16 gray box

regal stag
#

Oh or, use terrain.terrainData.heightmapTexture

open sable
#

hm, but i have scenes with multiple terrains. multiple terrain textures

regal stag
#

Ah yeah :\

#

It's annoying that it doesn't seem to be sent through correctly

#

I guess because it's set on the regular material and not the override

#

Maybe not ideal, but it would probably work if rather than using an overrideMaterial, you convert the ShaderGraph to shader code. Can then add a custom pass into it (e.g. with tag `"LightMode"="DepthNormals") and have only that pass in the "shaderTags" list in the renderer feature.

open sable
#

for exapple., this is the effect, if I "force feed' the texture

#

so...I'm close...

regal stag
#

Doesn't force feeding the texture also only work with one terrain? Or does the heightmap cover all of them

open sable
#

jup, it dose. This scene has only one terrain (a debug scene)

#

but the scene this will be used in have 4 or sometimes 16 terrains

regal stag
#

Then yeah, I think you'll need to convert the graph to code as I mentioned above

#

I don't know how else to copy the texture over when using overrideMaterial, as it replaces all property values

#

Unless the terrain system can work with material property blocks? (But then if it did use that, it should already work)

open sable
regal stag
#

You wouldn't necessarily need to rewrite it, you can generate code from the graph

#

It's a button in the inspector on the graph file

#

You can view the generated shader, and copy that into a .shader file

open sable
#

interesting. a bit of a hack, and changing anything in the graph, would mean a new generation and reimplementing the depthpass right?

open sable
#

hmm, still don't get, why

 float4 _TerrainHeightmapScale;    

these values are imported correcly, but not the texture

#

the code is the same

regal stag
#

That is pretty odd yeah

#

Are those global properties maybe? And the textures aren't?

open sable
#

i've tried adding #include "TerrainEngine.cginc" and "TerrainSplatmapCommon.cginc" and it took me nowhere

regal stag
#

Oh wait, _TerrainHeightmapTexture should also be global!

#

When you defined it in the shader did you also put it in the Properties section, or just the hlsl?

open sable
#

now, it is defined only in the hlsl section. I think, i tried defning it in the properties yesterday, but maybe I messed it up somehow

#

as i understand it, it should not be defined there, right?

regal stag
#

Yeah it shouldn't be defined in Properties

#

Still not working though?

open sable
#

nope. I also wonder, it might have to do, something with the particular instace ID...

regal stag
#

I think this is just a limitation of overrideMaterial then :\

#

No idea why some of the float4s still work. Maybe they are "left-overs" still stored in the global property references somewhere. (If there was actually multiple terrains with different sizes in the scene they might be the wrong values)

open sable
#

huh, damn...well, thank you for your time 🙂 I'll see where the code generation and pass implementation takes me :] Haven't done that before, but shoooould be easy enough 🙂

broken sinew
#

I think I found a bug in the shaderlab or something

#

I added a property in the properties section for ZTest:

#
        [KeywordEnum(Less, LEqual, Equal, GEqual, Greater, NotEqual, Always)] _ZTest("ZTest", Int) = 1

and later in the shader I use it as:

ZTest [_ZTest]
#

it doesn't work for LEqual, GEqual - and I have no idea why

#

written from hand, like ZTest LEqual everything works as expected

#

This is in a context of writing custom Depth, so if anyone has some problems with using SV_Depth -- try specifying properties by hand, not from insepctor

regal stag
cyan loom
#

I'm having an issue where I can't use the shader graph in the standard render pipeline.

#

The shader graph want's me to assign a pipeline target here, but there is no "standard pipeline" asset

regal stag
# cyan loom

You need to be using Unity 2021.2+ for a Built-in target to appear

broken sinew
#

I would have never guessed that

cyan loom
#

I can't use URP or HDRP because my project is heavily dependent on the deferred lighting option (which is only available in SRP)

regal stag
cyan loom
regal stag
#

URP does also support a deferred path in 2021.2+ btw. Can't help with your OS problem though, may just need to provide bug reports and wait for a fix 😦

cyan loom
broken sinew
broken vigil
#

I have no clue how to even get started doing this, but I want to set up a custom shader graph for a UI Image Panel, and I'm pretty much stumped on how to actually do so.

I have a basic dialogue panel in this pic, where I've got a bright magenta color set up for the inside of the dialogue panel. What I want to do is add a shader to the panel which replaces the magenta with an image texture.

The issue is, no matter what I do, adding ANY material to the Material entry of the panel makes it no longer display, and Unity's shader graph doesn't let me input a Sprite Image as a texture input, only the entire spritemap itself.

#

Am I going about this in the wrong way?

#

I'm trying to emulate the effect in RPGs where the background of dialogue boxes has something like a gradient in the middle of it, or even a subtle image texture, with the border surrounding it being unaffected. I thought the way to do this would be to simply make the middle of the dialogue box a specific unused color, then use a shader to replace that color with a texture of my choosing.

regal stag
# broken sinew sorry to impose, but I had some mixed results (with docs being ambiguous etc) --...

ZTest is the same thing as Early-Z, kinda. It's a stage in the rendering that occurs after the vertex shader. The depth of the fragment (basically a pixel) is tested against the depth buffer, base on the ZTest compare function.
If it passes, the value would also be written to the depth buffer (assuming ZWrite On)
If it doesn't pass, that fragment/pixel isn't drawn.

Except, if you use clip(), discard; or alter SV_Depth in the fragment shader, that early-Z can't occur as the depth of the fragment isn't really known. So the depth test then occurs after the fragment stage instead.

"Depth or Z Prepass" is also something different, where you render opaque geometry first to the depth buffer only. Then render again normally. I'm not too familiar with it. I guess it saves time rendering pixels from overlapping objects. In URP there's a "Depth Priming" mode on the Universal Renderer asset which does this.

regal stag
# broken vigil I have no clue how to even get started doing this, but I want to set up a custom...

If the magenta color is intentional, you should change it to a different colour as magenta typically means the shader has an error (or is for a different render pipeline), so it's hard to tell if that's what is happening here.

The other problem is that ShaderGraph doesn't really have proper UI support. In URP, I think the Sprite Unlit graph has worked in the past, but that may have changed. You'd also set up a Texture2D property with the reference changed to "_MainTex" to obtain the sprite image from the Image component, rather than using an exposed texture.

broken vigil
regal stag
#

If it goes invisible, it's probably just because shader graph doesn't support UI shaders yet. Switching the Canvas type from Overlay to Camera space (and applying camera in field that appears) might help? 🤷

broken vigil
#

Damn. Guess I'll try to figure out shader code, then.

#

Yeah, I'm not going to be able to do that. Just looking at it, I can tell I'm not cut out to actually code a shader in script.

frosty linden
#

Why is the stocking not showing in the game view? Here is the scene view, the stockings show

#

And here is the game view, they become invisible???

#

Using HDRP lit

#

If I zoom reaaaally close, it starts to show but only some parts? I don't get it

broken sinew
native otter
#

I'm trying to understand vertex color node in shadergraph.
To control vertex position on some parts of my mesh I painted that part with green vertex color.
The rest is white, or no vertex color. When I put in a vertex node and want to split this, my first thought
was to use the green channel but that doesn't show any vertex color, only the red and blue channel do. (grey/black)
Is there something I need to understand here? The manual seems very short on this topic.

regal stag
native otter
#

Maybe I don't need the combine, but another node that add those channels up?

regal stag
#

The combine would leave the R component of the resulting Vector3 at 0, so the Lerp would then only apply the G/Y and B/Z parts of the displacement.

Instead you could use a Maximum node with the G and B channels.
Or Add together then Saturate.
Or use Red output and One Minus.
Or, instead of painting blue/green you could paint cyan (0,1,1) and green (0,1,0). Both of those would have 1 in the G output so you'd then only need to connect that to the Lerp.

native otter
#

Ok, I need to think this through, thank you

tight phoenix
#

Is there a way to make normal from height less pixelated when using noise-generated non-textures?

#

googling it there doesnt seem to be much answers, there was one but it only worked with a very specific geometric shape

mental bone
broken vigil
#

Am I just missing something?

mental bone
#

Yeah that would be the background

#

You then add more ui elements as children to that panel

#

They will render on top

#

But why it has a canvas component idk

#

Anyways check out a ui tutorial

tight phoenix
#

if you pass in the noise as a vector 3, how would I connect a UV input to a vector3?

#

maybe a custom node that takes in a UV and a vec3? But I am not certain how the math works

broken vigil
# mental bone They will render on top

Yes, but if I render a rounded border over the top of the background panel, it will have corners poking out, won't it? Do children of a background panel clip out the edges of their parent object when using nineslice sprites?

tight phoenix
mental bone
mental bone
tight phoenix
#

this noise has to be a vec 3, not a noise node

#

but vec3s dont have a UV input, so I need to somehow make a way to do whatever/however the sampler works to make it do this

#

maybe X/Y problem - I need to pass in an arbitrary code-generated texture and then edit its uv's somehow

#

an input here that replaces these four

mental bone
#

So how are you generating the texture ?

tight phoenix
#

I am not generating it in any one single fixed way

#

maybe its not possible? 🤔

mental bone
#

Im still confused

#

Why cant you plug in your desired uv in the simple and gradient noise that generates your final noise

tight phoenix
#

okay, root question:
How do I make Normal From Height not pixelated low res

#

problem with this: you cant pass in the center bits

#

so problem is now: how do I pass in the center bits if I cant?

tight phoenix
#

and remaking the same thing four times is a terribly inefficient thing to do

mental bone
#

Well yes this is essentially supersampling

tight phoenix
#

So the answer is... you can't make normal from height not be a low res pixelated mess? 🤔

regal stag
#

This is where you'd likely start passing in a pre-defined noise normal map rather than generating one

tight phoenix
#

I can just make a texture I guess but its easier to edit the look on the fly fast from within unity itself than doing it in photoshop

mental bone
#

Have a high res normal map and add micro details procedurally with some noise

tight phoenix
#

okay I guess Ill have to do it in photoshop 😿 was hoping there was a way around this

mental bone
tight phoenix
#

When working with individual channels from textures or vectors, is split -> combine/ vector# the method I should be using or is there a more efficient way?

regal stag
tight phoenix
regal stag
#

Ah yeah, the old version isn't as good :
I'd keep using Split & Vector2 then.

#

Could make a SubGraph to be a bit cleaner

tight phoenix
native otter
#

A question regarding the remap node. This screenshot is taken from a tutorial which
I'm trying to understand the remap node, and what does exactly in this case? Is it limiting the gradient reach perhaps?
The manual saids: "Returns a value between the x and y".
Without it it works great with randomizing the colors on the object.

tight phoenix
#

so anything that was a 6 before is now a 1, and anything that was a 1 before is now a 0

#

with a linear lerp between for all values between

#

so for example passing in floats between 0 and 10 and remapping them to be between 0 and 1, values that were a 5 before are now 0.5

#

I am getting a weirdness I don't fully understand - using parallax node, the paralaxx gets more pronounced the further you zoom away from the object

#

is it supposed to do that or am I using it wrong? and is there some way I can counter-act that?

native otter
tight phoenix
#

oh interesting, it doesnt happen with parallax mapping, only with parallax occlusion mapping 🤔

#

hm but the non-occlusion versions results are way worse

#

huh in scene it looks WAY different 🤔

#

it doesnt get deeper the way it does in preview

#

but it 'tears' the texture the same way it does with parrallax mapping (non occluded)

#

I dont want to make 'spikes' in the mesh, I want individual dots at different 'depths'
Is there some way to make it look like it does in the preview?

#

hhrm this is kind of frustrating, I want it to look like how it looks in the main preview, not how it does in scene, but I am not sure how they differ to correct it

tight phoenix
#

hm, adding more steps stretches it into spears, adding more amplitude tears the texture apart
how do I make it have depth without tearing the texture apart? without making the dots into spears?

nimble swallow
#

question is there a way to return a uint from a custom function node in shader graph? or sample a uint texture?

tight phoenix
#

algebra question - if I want to make the multiplication go equally on both sides instead of just one side eating the other, I have to also subtract by a certain value relative to the multiply value

#

how do I determine that value with math instead of just manually adjusting it afterwards?

#

I assume I can derive the value from the multiply value in some way

shadow locust
shadow locust
tight phoenix
#

I want to move the mid point so the value change is always at the 50% of the two sides

#

I do that by subtracting right now, but I need to make subtract automagic from the mult value

shadow locust
tight phoenix
tight phoenix
#

there is nothing to blend, its a single vector, I dont have two inputs

shadow locust
tight phoenix
#

Maybe I am not explaining clearly, let me try again

#

when multiplied by absurdly high value, its 50/50 white black
when multiplied by a very small number, white side becomes gradually more black
when multiplying by a number AND subtracting by a number relative to the multiplication number, the difference band between white and black can be kept centered between the two sides

#

how do I determine the subtraction value from the multiplication value to keep the band gradient centered?

#

without just manually adjusting it till it looks right

#

for example - if multiplying by 5, then subtracting by 0.3 seems to roughly keep the band centered

#

if multiplying by 2, then subtracting by about 0.4 seems to keep it centered

#

how do I find the subtraction value from the multiplication value to keep the band centered?

tight phoenix
#

I dont know how to explain it to be any more clear

#

subtraction = multiplication (???), solve for ??? where ??? is always 50% of the way between the two sides

#

the answer is going to be an extremely simple math formula

#

I just don't know how to find it

#

ill DRAW what I mean since words arent working

regal stag
#

If I'm understanding correctly, I think you want (x - 0.5) * someValue + 0.5

tight phoenix
shadow locust
#

sorry I -- just didn't get a chance to read that

tight phoenix
#

All good, trying Cyan's formula now

#

Hmm it kinda worked but it seems to be happening at the wrong place

tight phoenix
tight phoenix
#

it kinda looks like its centered without the intial subtraction, is the problem maybe my input value?

#

I don't want 'kinda sorta' though, I want to be mathematically sure its at exactly 50%

#

hm maybe the problem is because the black values might actually be going "darker" but aren't because it cant display values darker than 0?

#

yeah that is kinda the problem, it IS going in both directions equally, but i cant use that as a mask

regal stag
tight phoenix
#

Hmm yeah trying just the add 0.5 it does seem to be centered now

#

I don't really understand the underlying math why that is the case 🤔

regal stag
tardy spire
#

I'm trying to tweak a shader that draws a ui image with rounded corners and a border
so I can use it as a selection outline on worldspace images.

The camera is orthographic so the image will always be viewed front-on
I've got it working I think, but is there a better way to scale the line width to a constant screenspace size than using the derivative of the world position?

half widthScale = ddx(IN.worldPosition) / 2; // 👈 this is my very good code 😅
float l = (IN.lineWeight * widthScale + 1/IN.pixelWorldScale)/2;
fossil cloak
#

Hey Guys. The Shadergraph i did is telling me "Material doesn't have meta pass" when baking the light.
Didnt find anything how to deal with this. Does someone have an idea?

fervent garnet
#

Hya, anyone has experience using shaders with a tilemap? I'm getting some weird results
Anyone knows why this is happening and how to fix it?

uneven phoenix
#

Any idea why this shader is not working properly in WebGL? I swear it's as simple as it could possibly be, just outputting a hardcoded yellow. There's no errors on building. I'm pretty sure the warnings on the web browser are irrelevant.

Shader "Test WebGL"
{
    Properties
    {
    }
    SubShader
    {
        Tags
        {
            "Queue" = "Transparent"
            "IgnoreProjector" = "True"
            "RenderType" = "Transparent"
            "RenderPipeline" = "UniversalPipeline"
        }

        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha
        Cull Back

        Pass
        {
            CGPROGRAM

            #include "UnityCG.cginc"

            #pragma target 4.5
            #pragma vertex vert
            #pragma fragment frag

            struct appdata
            {
                float4 vertex : POSITION;
            };

            struct v2f
            {
                float4 position : SV_POSITION;
                float4 worldPos : TEXCOORD0;
            };

            v2f vert(const appdata v)
            {
                v2f o;

                // calculate the position in clip space to render the object
                o.position = UnityObjectToClipPos(v.vertex);

                // calculate world position of vertex
                o.worldPos = mul(unity_ObjectToWorld, v.vertex);

                return o;
            }

            fixed4 frag(v2f i) : SV_TARGET
            {
                fixed4 col = fixed4(1, 1, 0, 1);
                return col;
            }

            ENDCG
        }
    }
}
kindred harness
#

what shader do i use to make a texture transparent but not the object? I used the Standard shader's Fade and Transparent, but I could see through the object that didn't have transparent Alpha channels

umbral pewter
#

how do I change/edit the shader becuase it is grayed out for me

keen cloud
#

damn
I feel like coding in c++ from scratch is easier than writing using unity shaders.
anyways; is there anyone who could very simply explain to my 3 braincells how to set a specific pixel on a texture to a certain colour?
and also how to read a specific pixel on a texture.
notes: the shader is an image effect and i'm using it as a "post processing" effect by bliping it.

more context: I want to make a canny edge detection shader that would look through the camera and compare the depth and normals.
I'm first trying to make a guassian blur becuase it feels alot easier than the canny edge detection algorithm.
I have the depth and normals set up, but I have no idea how to loop through every pixel to compare the neighbours and then smooth out the center pixel depending on the neighbour weights.

to put it simply:
is there something that allows me to get the pixel at the position (0,0) (0,1) (0,2) ... (1920, 1080) and then read/write to it?

grand jolt
#

Pretty cool effect

kind juniper
kind juniper
# keen cloud damn I feel like coding in c++ from scratch is easier than writing using unity s...

In pixel shaders you would sample the texture to get it's pixel at specific point. The uvs that you input into the sample function are what determine the position to sample. They range from 0 to 1 on x and y axis. If you know the resolution of the texture, you can get a pixel at specific point with uv = actualPixelPosition / textureResolution.
You can't write to any arbitrary pixel though. Only to the one that the pixel shader is running for.

keen cloud
kind juniper
#

You'd just add an offset to the pixel position.🤷‍♂️

keen cloud
#

but what about the borders

kind juniper
keen cloud
#

that sounds like unnecessary performance down the drain tho

cosmic prairie
#

maybe sample an extra texture that looks like a baked border and use it as a mask? 🧐

#

or use a 2d square signed distance field? but that still requires using min and max functions

#

try if it's noticably slower when u decide to continue

kind juniper
dim sequoia
#

When Graphics.Blit is called, will the fragment pass of the used material only evaluate for existing pixels in the destination texture, or are there any implications based on the size of the input texture too? Couldn't really find anything in the docs

#

or will each pixel of the source texture be evaluated and then interpolated for the output if the resolutions don't match?
the first assumption would make sense to me, to only run for target texture pixels, but I'm just not sure

regal stag
# dim sequoia When Graphics.Blit is called, will the fragment pass of the used material only e...

Graphics.Blit draws a "full-screen" quad. It'll always cover the entirety of the destination texture. The quad is set up with UVs, (0,0) in bottom left and (1,1) in top right (well, the Y might be reversed depending on platform I think). Those UVs are used to sample the source texture, so regardless of it's resolution that also matches the size of the quad/destination.

It would be interpolated/filtered depending on the source texture's filter mode (Point - no interpolation, Linear/Bilinear, Trilinear - also blends between mipmaps, that one probably wont be used in a screenspace effect like this)

dim sequoia
dim sequoia
#

thanks!

regal stag
regal stag
# kindred harness what shader do i use to make a texture transparent but not the object? I used th...

This is a limitation of how transparency works. You can fix it somewhat by using a pass prior to the main one which renders the model to the depth buffer only. (ZWrite On, ColorMask 0).
There's a full example here (assuming Built-in render pipeline, since you mentioned Standard shader) : https://forum.unity.com/threads/transparent-depth-shader-good-for-ghosts.149511/

regal stag
# uneven phoenix Any idea why this shader is not working properly in WebGL? I swear it's as simpl...

WebGL probably doesn't support #pragma target 4.5. If you don't need any fancy shader features you could just leave that line out, or use 2.5 instead which is the default. See docs for more info : https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html
You may also be able to switch between OpenGL 2.0 and 3.0 in the build settings which could support a higher target. (But I still doubt as high as 4.5)

regal stag
regal stag
# fossil cloak Hey Guys. The Shadergraph i did is telling me "Material doesn't have meta pass" ...

I thought all graphs generated a Meta pass (but maybe the Sprite ones don't? Assuming URP). Could check the generated shader code (there's a button in the inspector to view it, when the shadergraph asset is selected). But there's not really a way to fix this if it's not there, without manually writing one.
If you are using a sprite graph, maybe you can switch to Lit/Unlit and copy the Meta pass from there? 🤷

kindred harness
regal stag
#

That also works, wasn't sure which parts you needed to be transparent

tight phoenix
#

formula adjustment question 🤔
This is the graph to make object space interior cubemapping work, but I have an adjustment I'd like to make that im not sure at which step how to achieve.
You can see in the preview that each cell has is a small snippet of the cubic UVs tiling in every cell, I want to adjust it so that each plane has the full texture stretched over the entire thing 🤔

#

im pretty sure all I have to do is plug in the object space positon node instead of whichever part of this graph is the part that makes the texture tile in the cube

#

like this but still with those extra bits 🤔

regal stag
tight phoenix
#

Ill see about trying to plug in my object space to the upper part before the mult

#

Im pretty sure some length of this's primary job is tiling the texture in each cell, if I could isolate which part I could chop out the whole thing

#

removing nodes one at a time just turns it into a broken mess so I won't be able to brute force it

regal stag
#

Oh right, the fraction node would still used in the calculations at the top. But maybe not the bottom part (like in that final Add node)

tight phoenix
regal stag
#

Yeah

#

I think that final Add node is what is tiling it

tight phoenix
#

if you look at it dead-on a single side, it works, but at any angle, each cell is getting filled with pink

#

I'm thinking it must have something to do with these

#

something in there is still trying to repeat the texture over the cell

#

hmm maybe it IS working and im just misreading what im seeing?

#

whoops discord didnt like that

#

okay its not working correctly

#

if I replace it with a texture instead of the colors its def not working

#

more clear version of whats happening

#

looks wild though

#

so its something to do with the viewing angle I think 🤔

#

this is totally an x/y problem as well

#

what im actually trying to do is fake raymarching in shadergraph

#

and I think that this will be able to do it

#

if I can just map each plane to object position space instead of whatever its doing, and then plug in 3d noise

regal stag
#

This is for the sparkles right? You had problems with parallax mapping because it stretches them out iirc

tight phoenix
#

Yeah

#

I reached out to a guy on twitter who did them really well but he said he did it with raymarching, which I know is both not easy and not supported by shadergraph

#

this is the next best thing I can think of 🤔

regal stag
#

I mean, you can do it in a custom function node

tight phoenix
#

ive tried googling other people's pre-made raymarch node but no such thing exists

#

its almost kinda working, im positive this will be close enough if I can just figure out how to correct the distortion its doing there 🤔

#

its interesting what removing random parts of the graph does to it, not what I am trying to achieve but interseting to look at

#

HMM If I multiply the object space position, it does this

#

does that help deduce why it looks the way it does look wrong?

#

it feels like its closer at least, its not distorting now

#

ill try arbitrarily multiplying after each step to see what it does to it

#

kinda better but still way wrong

#

maybe i shouldnt be adding at the end, maybe multiply there? nope definitely not

regal stag
#

Oh I think I've got it, adding the Position without the Fraction does work, but you still need the Position * CubeScale → * 0.999 → + 0.5 → *2 → -1 part

#

(same thing just without the fraction node)

tight phoenix
#

my technique of 'try things on things until it just works all on its own' would have never figured that out, setting it up now to test

regal stag
#

Think we can then divide by the CubeScale after adding to scale it back down

tight phoenix
#

oh didnt have the position

regal stag
#

Eh no, sorry maybe I didn't explain it that well.
I'm referring to duplicating this part again, but without the Fraction node

tight phoenix
#

oh

#

not this then

#

Ill duplicate like you suggested

tight phoenix
#

I must be plugging this in the wrong place

#

its doing some wild stuff

#

I don't know where im to use this new segment

#

replacing the added position with it wasnt the correct answer

#

oh wait 👀

#

I think we're in business

#

that looks like what I was expected

regal stag
#

Ah yeah that's right, the divide should be after the add, if you need to adjust the scaling back to more of a 0-1 range

#

But not too important. Can also just adjust the scaling on the noise node

tight phoenix
#

you dont mean this add but the add when I combine the two lines of graph?

regal stag
#

Yeah I mean the final add when they combine, sorry

tight phoenix
#

woo now we're taking

regal stag
#

Quite like how this looks. It almost looks like it has some ambient occlusion applied.

tight phoenix
#

same result when I remove my noise texture

#

now to see if I can even make them not opaque 👀 the y has been solved but does it solve the x.
Ill post results / when I get stuck

tight phoenix
#

sort of a start

regal stag
# tight phoenix now to see if I can even make them not opaque 👀 the y has been solved but does ...

Good luck! 🙏

If that doesn't work out, maybe the next thing to look into for getting sparkles at different depths, would be to sample the texture* multiple times with different amounts of parallax. Not using the parallax mapping node, but offsetting with the View Direction in tangent space. It's the same idea used here for cracked ice : https://www.youtube.com/watch?v=rlGNbq5p5CQ (but you wouldn't need that many layers so close together)

*But this assumes you have a texture to sample to produce the sparkles. Since duplicating generated noise/voronoi/etc would likely be quite expensive - but could still work for testing.
If you can't make a texture manually you could use a shader outputting the noise/voronoi and use that to bake a texture (e.g. using Graphics.Blit). This might help with that : https://www.ronja-tutorials.com/post/030-baking-shaders/
(I guess that texture would probably need to store the sparkle vectors in rgb & maybe noise in the alpha channel for masking)

tight phoenix
#

I am sure there is some use for object space compartments like that for something, just maybe not to fake raymarching

tight phoenix
tight phoenix
frosty linden
#

Hi, I'm trying to use the HDRP hair shader but I've got this bug when moving the camera around, it seems like random parts of the hair become see-through or are distorted. I can't figure out the problem. Any help welcomed 😢

regal stag
shadow locust
frosty linden
#

OK nevermind my problem, it was due to the skin shader behind which had a problem compiling, causing both my problems. Changing to another shader on the skin fixed the hair issue

rare halo
#

Why did my water turn into this?

#

It was an asset i got from asset store

#

Worked fine

tight phoenix
shadow locust
#

so it piqued my interest

tight phoenix
shadow locust
#

nice

tight phoenix
#

When I finally start to roll all these different shaders into a single entity I can share the graph for study, but I imagine thatll be a while yet

hazy meteor
#

Hey, how can I update a mesh collider when Im modifying the vertices in shader?

dim yoke
hazy meteor
#

ok thanks

dim yoke
#

you would be better to deform the mesh using c# script instead

hazy meteor
#

How can I output a value from shader?

shadow locust
#

do like AlksiH said

hazy meteor
#

No thats something different

tight phoenix
#

to do the above I had to use three separate parallax nodes, into four separate texture samplers (of the exact same texture) which I then split up by channel and then blended all together

#

oh and each depth set is just pushed equally further in, the layers are spaced linearly

#

its kinda warbly looking which the parallax node does the deeper you set the amplitude, and I don't like having to have three separate textures and samplers like this

#

it proves it works, but is there ways to optimize this? As it stands I don't have much control over how the insides looks programatically, I have to rely on the texture being good 🤔

#

Im stopping work on it here though today because its the weekend, ill be back on the ball tomorrow or monday to do the cracked ice tutorials in hopes they have the key to making the above less jank

#

major-ish flaws, the interior is not consistent across each face (not actually volumetric) but I can live with that since getting that would be really hard without real raytracing?

grand jolt
open sable
# grand jolt Turn into what

It turned into a cellphone photo ;p btw. doing a photo of your screen, instead of a screenshot, and sharing on a technical discussion, should be somehow punished ;p how does that work...how can you come to a conclusion, that makeing a photo of your screen, and uploading it from your phone, is the right way to do it? It's...mesmerizing

grand jolt
#

What

grand jolt
open sable
grand jolt
#

Man can you just say what happened wrong

open sable
#
  1. Nukeythewise posted a cellphone picture of his screen, with the msg: "Why did my water turn into this?"
  2. You asked, "Turned into what?". A valid question.
  3. I wanted to be a smartass, as taking picture of your monitor with a cellphone and posting it on discrod, asking for technical help...is sort of offensive
  4. You misunderstood my msg.
  5. We don;t know what happend to the shader
regal stag
# tight phoenix to do the above I had to use three separate parallax nodes, into four separate t...

By using 3 parallax mapping nodes it's sampling the heightmap 3 times using the same uvs. It's very possible that the compiler would optimise this, but personally I'd still prefer handling it using a Sample Texture 2D node, then input G channel into 3 x Custom Function nodes using (or SubGraphs replicating) the ParallaxOffset1Step function. It's the same thing that the Parallax Mapping node uses but doing it this way, we know it'll sample the heightmap only once.

The other separate texture samples is unavoidable though. But it should be okay. In proper volumetric raymarching, you'd typically be sampling a 3D texture even more times along the view ray - so this should still be an improvement over that (in terms of performance, not quality of course)

e.g.

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ParallaxMapping.hlsl"

// (G channel of Heightmap goes into Height input)
void ParallaxUV_float(float2 UV, float Height, float Scale, float3 TangentSpaceViewDirection, out float2 Out){
    Out = UV + ParallaxOffset1Step(Height, Scale, TangentSpaceViewDirection);
}

Or could recreate these in nodes & use subgraph instead. (using ParallaxOffset1Step function here as reference : https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.core/ShaderLibrary/ParallaxMapping.hlsl)

#

Can also be less warbly looking if you want, should just need to use a constant Height value (maybe 1?). But it looks quite good with the noise texture imo.

tight phoenix
#

Those sound like perfect optimizations

#

You just made me realize that I might have put a height map image into those paralax nodes causing the warble

regal stag
#

Yeah, the heightmap would be responsible for that

tight phoenix
#

I was about to be like "I set the height to a single value" but I set the AMPLITUDE to a single value, and almost definitely forgot a height texture in there

#

🤦‍♂️

tight phoenix
regal stag
tight phoenix
#

But using a cloudy noise texture for it instead of something more deliberate didnt work great in the above

regal stag
#

Idk, I think the cloudy texture does work still (I like it a lot!)
Just without that outer layer and maybe some colour tweaks.

tight phoenix
#

Oh yeah sorry I meant the same thing - that the outer layer didnt work, the rest worked

#

the clouds worked on the insides, just not on that outer surface flat part

#

I closed out of unity for today since its the weekend but looking at my own screenshot I totally put a height map texture in there, rip

tight phoenix
strange sonnet
#

Hey there!

I'm feeling kinda stupid right now, but I can't figure out how to transform a world space position to screen space position. I transform WS to clip space, then run ComputeScreenPos, but it outputs wrong result for some reason.

regal stag
rain moat
#

Hey, after moving a car from core project to HDRP project my car is all pink and I see something is wrong with shaders on materials (I'm a total newbie). Someone might know how to fix that? siprana

strange sonnet
# regal stag Typically you'd do that transformation (WS -> Clip then ComputeScreenPos) in the...

That's what I'm doing, and it doesn't seem to work.

The shader should practically nothing: extract positionWS from screen position, then transform it back, instead, I get... this.

half4 frag (Varyings input) : SV_Target {
                half3 positionWS = (float3)ComputeWorldSpacePosition((float2)input.uv, GetDepth(input.uv), UNITY_MATRIX_I_VP);

                float4 positionHCS = TransformWorldToHClip(positionWS);
                float4 positionSS = ComputeScreenPos(positionHCS);
                return float4(positionSS.xy / positionSS.w, 0, 0);
            }

It's a fullscreen blit, though, but I don't think it should have any impact.

regal stag
#

It's possible the result is incorrect because the positionWS isn't what you expect

rain moat
strange sonnet
#

What I'm actually doing is, khm, compressing world space position into irregular pieces using voronoi, so multiple points in the world correspond to the same coordinates on the camera color map.

regal stag
#

I see

strange sonnet
#

hm, you're right, there's something funky with positionWS, it doesn't seem to be right

regal stag
# strange sonnet hm, you're right, there's something funky with positionWS, it doesn't seem to be...

I believe UNITY_MATRIX_I_VP doesn't work in blits, as I've had troubles with using that matrix in the past.
Instead, I use unity_CameraInvProjection and an _InverseView matrix - sent into the shader via Shader.SetGlobalMatrix("_InverseView", cam.cameraToWorldMatrix);.
(Specifically using this, though it's shader graph : https://www.cyanilux.com/tutorials/depth/#blit-perspective)

Since you're already using the ComputeWorldSpacePosition function it might be okay to multiply those matrices together and use that in place of UNITY_MATRIX_I_VP

#

(Heading off, so hope that helps!)

strange sonnet
#

Thanks, checking it out now

rare halo
rare halo
grand jolt
#

That was awkward

last wadi
#

What is going on here? The shader offsets the vertices in y direction, and as the translation is applied in object space, it should offset the vertices in the direction of the arrow. However, as soon as there are two or more copies of the object, the vertices are being offset upwards, regardless of rotation. Enabling GPU instancing on the material solves this problem, although I don't understand why.

#

This is the shadergraph

neat hamlet
#

Looks like theyre getting batched together?

regal stag
#

There is some automatic batching when dealing with sprites, combining the meshes. Object space isn't really a thing then.

last wadi
#

And with gpu instancing enabled, this doesn't happen?

regal stag
# last wadi And with gpu instancing enabled, this doesn't happen?

So... Shader Graph doesn't fully support GPU Instancing automatically. Because you have exposed properties, what I think is happening here is that it is just breaking the regular batching that sprites do and rendering them separately. (The Frame Debugger window can probably confirm this)

#

It's not ideal, as you're dealing with separate draw calls which will be more expensive to render, but you do retain the object space.

#

One way that could fix this without the GPU Instancing ticked, might be to offset along the Tangent Vector stored in the mesh 🤔 (assuming sprites generate those)

terse whale
#

How would I make a texture position itself relative to where the mesh is located in the world?

#

so that if I were to move the mesh, the texture wouldn't move along with it

regal stag
tight phoenix
#

Did I make a pedmas mistake in re-creating this implimentation? 🤔
Or maybe I am misunderstanding how to use the output? Changing either Height and Amplitude seems to just tile the texture, neither adds/removes depth

#

I am assuming viewDirTS is view direction in tangent space, I don't think that part is wrong

regal stag
#

To use the output, should Add it to the UV node before putting into the UV port on Sample Texture 2D.
(Or can put it into Offset of Tiling And Offset node, since that is equivalent to Add)

tight phoenix
#

oh yeah you are right, I looked at this like 10 times and my brain said every time "yep you got the order right"

tight phoenix
terse whale
#

a texture won't do it since the world is virtually infinite

#

I got the world pos stuff covered but I have no idea how I can tell my shader what the value is

#

I guess a solution could be generating the biomes from scratch inside the shader, but I'd prefer to get the values from outside of the shader if possible

#

hmm I think I'm going to handle my generation like before, turn the values into a texture, and handle that much like a noise map for the shader

lament bramble
#

HI! It seems I'm lacking some basics. In a shader graph, when inputting a vector (1.0,0,0) to the base color, the displayed color is pure red. However, when using a vector (0.5, 0, 0) and afterwards multiplying it by 2, it is not pure red. I would expect the multiplied vector to be also (1.0, 0, 0) but guess I'm wrong. Could someone explain me what is going on or give me some source to read about it? 🙂

regal stag
lament bramble
tight phoenix
# regal stag By using 3 parallax mapping nodes it's sampling the heightmap 3 times using the ...

Optimized shader and its two sub-nodes. Do you see any inefficiencies I could eliminate?
I noticed the view direction calculation is always the same so I made a subgraph for that.
I was also wondering why in the View Direction step that 0.42 is added to Z value. It seems like an arbitrary magic number? Its like that in the source code you linked, but why 0.43, that's not something obviously like 0.5 is a half

regal stag
tight phoenix
#

Hmm im having some dificulty hooking it into 3d voronoi

#

I want to sample the voronoi at a certain object space depth 🤔

#

but like the repeatedly copy pasted textures, its kinda looking like I would need 3 identical 3d voronois

#

which is not something I want to do, plus no matter what I plug in as its coordinates, when I change the height/amplitude value, the 3d voronoi doesnt change the way it does if say an object was moving through worldspace 3d voronoi

#

im pretty sure I need the object space node and then math it with the depth offset, but that still wont eliminate the need for 3 3D voronois

#

Thoughts: I could open up the script that makes the voronoi and try to separate the construction of the voronoi from the sampling of the voronoi, but I'd have to learn a lot about HLSL I think

regal stag
#

Yeah, you're always going to need multiple voronois. Which is why it would likely be better if that was baked into a texture

tight phoenix
#

Yeah that was my other alternative, just using a texture and doing math to hide any obvious repeating patterns

regal stag
#

Well, shouldn't have any repeating patterns as long as the voronoi texture isn't scaled. Though if you bake the voronoi to a Texture2D it will be the same for each face - but could use a Texture3D instead.
Though I guess if you only have 3 or so layers, there's probably quite a lot in the texture that goes unused, so kinda wasting some memory there.

tight phoenix
#

Part of me realizes I might also be wasting my time looking for optimizations instead of seeing how it performs and optimizing after

#

Im struggling to find ANYTHING on 3d textures online, its just tons of 2D textures with normal maps, or 3d models, adjacent things

#

'textures for 3d models' are not 3d textures 😬

regal stag
#

Searching for "Texture3D" with the quotes might give some things, but yeah there might not be a lot on it. I've only known them to be used in volumetric raymarching.

#

But they're basically the same thing as 2D textures, storing colours for each "pixel" (in this case, those are cubes, so "voxel" is probably more accurate). Rather than sampling with a 2D coordinate, you sample with a 3D one.

tight phoenix
#

Ooh okay, I didnt realize Texture3D was a specific unity thing

regal stag
tight phoenix
#

Ronja has good tutorials Ill read through that 👀

#

oh I DO have just one 3d texture asset, I just found it in my project, it was imported from someone's shader github example I must have downloaded and imported at some point

karmic hatch
tight phoenix
#

hmm looking through the repo, there are some compute shaders but I didnt see a 3dtexture asset

karmic hatch
#

In his terraform video

tight phoenix
karmic hatch
#

yep

#

a pretty huge texture too i think

tight phoenix
#

while I wait for his package to import, trying to sample this 3d texture I do have with the parallax thingy but not getting much results

#

at least I can use the same asset and sample it repeatedly

#

unlike the voronoi

#

👀 I just had a thought I might not need 3d textures at all

#

the default unity cube has every face the entire UV map, but my cube is an unwrapped cube with 6 unique faces, but that also means there is unused area in the texture file. I might be able to store info there? hmmm maybe not, as soon as I 🦆 its starting to look murky

#

I was thinking I wouldnt need to sample three times if somehow I could encode parts of a texture to be like 'this bit is at X depth'

#

but that is making me realize that I would need to have sampled the texture before I can sample the texture 🤔

#

actually I might be onto something here, going to work this through

#

Hmm nope I goof'd it. I was thinking I could map segments of a texture to be at higher/deeper depth, and then overlay parts of the same texture together
but in practice going to other parts of the texture, the texture itself changes but the depth its at does not

#

🤔 also I would still need to use more sample texture 2ds for each overlaid but so now im not even sure what I thought I was going to achieve here

#

texture changes but height does not, because the height data isnt in the texture space, its in the UV sampling

#

okay im going to stop messing around with weird optimizations and go back to trying to get glitter to work with the paralax depthses

tight phoenix
#

I ALMOST have Depth Glitter working but there's one bug I can't seem to figure out how to fix 🤔

#

if I turn the power way down, you can see that im masking out some of the glitter from the surface, but thats not what I WANT to do, I want to mask it based on how deep it is

#

but I cant seem to figure out where that 'deepness' value is coming from

#

im using two 2D voronois with only one paralax pass to do all the different glitter depths atm

#

Somewhere in here im pretty sure the 'Depth' value comes into existence

#

but I cant seem to isolate it

#

the view thing and tiling and offset are all X/Y, there's no Z to sample depth

#

Like if I try to take the minimum of X and Y, the result gets plastered on the surface

#

I havent been able to find a point where the result goes where it should be, instead of on the surface of the mesh

#

Where can I get the 'depth' to multiply the end product with???

#

So that deeper bits are darker

#

hmm maybe everything I think its doing is wrong and its not at all doing what I think its doing

#

yeah im stuck, im struggling and its starting to agitate me

#

time to give this a break

#

trying to visualize it, the darker the cell is, the more powerful/pronounced the parallax offset is to the UVs as viewed through that cell

#

which means... there is no depth? 🤔 depth is an illusion? or does depth exist?

#

anything viewed through one of the black cells there is the most offset the glitter can be, thus I should tint those cells darker... except that darkness is less like a distance and more like a window on the surface that lets you view deeper than the other windows

tight phoenix
#

unrelated but I just found a human face from profile view in my noise texture 😱

regal stag
#

If you want to be able to tint sparkles darker when deeper without the "windowing" effect, you'll probably need to use constant Height/Amplitudes per layer and sample the voronoi multiple times similar to before. Can then turn into sparkles, multiply to tint each layer and combine with lerps/blend nodes.

tight phoenix
#

I think this is maybe good enough?

#

the illusion falls apart slightly when you look dead at it straight on

#

HMM actually 👀 🤔 new idea

#

Parallax depth mapping is trying to make something look deeper into the surface

#

but for glitter I don't need to keep the same thing deeper

#

maybe I can dramatically tile/offset the innards to other parts of the glitter?

#

so the parallax doesnt just show the same thing but deeper, but shows the texture offset bit?

#

I think I can pull that off, giving it a try now

terse whale
#

how do I put a texture with transparency above another texture

#

nvm I think I did it - multiplied the first texture with the reverse transparency of the second texture

rose lance
#

Hey, how does Unity decide the sort order of the material array in a Skinned Mesh Renderer?

#

I need the materials in the arraay to be in a specific order

#

but it brings them in opposite

tight phoenix
#

LOOKS like tons of depth, when its actually a single pass no depth at all

#

now to test it in scene and find out it look way different and p a n i c 👀 (it worked fine) ill post it when its cleaned up tomorrow

grand jolt
#

Can someone help me? I'm trying to implement refraction in my water shadergraph, but I keep having this issue where the effect is being applied to objects that are in front of the water. Does anyone know how to solve it?

tight phoenix
#

To the best of my knowledge, thats one of the downsides/flaws of scene color refraction is things in front will do that even when it makes no sense visually to refract like that

tight phoenix
#

I don't know how to fix it but maybe something to do with the depth buffer might help, I know that its non-trivial to correct

grand jolt
#

I've looked everywhere for a solution but never found it.

undone anvil
#

well any idea how to get object node scale work with element in UI Canvas ? currently i work with constant ring line size in any zoom

#

its work in world space

#

but in canvas not working

regal stag
# grand jolt Can someone help me? I'm trying to implement refraction in my water shadergraph,...

It's kinda old but I have a water shader graph tutorial here : https://www.cyanilux.com/tutorials/water-shader-breakdown/
About half way down it goes over a common method to fix this issue. It uses the depth texture to ignore distortions for pixels above the water plane, and instead just use the undistorted pixel colour.
(Based on https://catlikecoding.com/unity/tutorials/flow/looking-through-water/ - which also goes through removing some of the slight artifacts you get)

It can look a little strange but I imagine it would be cheaper than alternatives like rendering the scene twice (that's kinda similar to planar reflections, but not reflected)

naive shuttle
#

Whyyyyy is this moss so dark? It doesn't even look like moss anymore. I've been trying to fix this for over 2 hours ugh

#

please help

#

Turning off cast/receive shadows doesn't do anything, so the fact that it's so damn dark doesn't have to do with shadows

grand jolt
karmic hatch
naive shuttle
karmic hatch
#

Also the 'cheap' way would just be to multiply the base color by some float >1

karmic hatch
naive shuttle
#

Ill have a look

naive shuttle
#

I mainly used a shader graph so that I can use the other maps as well

karmic hatch
#

Just test it, see if it looks ok

#

You can multiply the glossiness map by some float instead of adding something

naive shuttle
#

I tried that too

#

anyways, Ill do what you said

#

1 sec

karmic hatch
#

Say, 0.1?

naive shuttle
naive shuttle
#

thats with the smoothness node only

#

same thing happens when I use the multiply node and the map, though it's less sensitive

#

Same thing happens when I do it with the add node @karmic hatch

#

it just turns greyish smooth

#

not smooth smooth

mental bone
#

Try inverting your gloss map

naive shuttle
#

inverted gloss map * smoothnes at 0.5. Smoothness value seems to clamp between 0 and 1

#

Also, grey

naive shuttle
regal stag
#

As you're rendering both sides of the quads, you may want to use the Is Front Face node and flip the normal on the False input.
That should get both sides looking consistent at least. Not sure about the "grey"-ness, maybe that's coming from the ambient lighting values.

hushed depot
#

Anyone know why I'm getting this weird sampling from my sprite sheet?

regal stag
# hushed depot

The previews don't show transparency, just the raw RGB data stored in the texture. It's typically stretched out like this in completely transparent areas to reduce artifacts at the edge

naive shuttle
#

I already have a flipped normal map if that's what I need @regal stag

#

Idk what you mean 😕

regal stag
naive shuttle
regal stag
# naive shuttle Hmm I see, what does the negate do tho?

Flips the normal vector, so it points in the opposite direction.
The normals stored in the mesh are only correct for the "front" faces. When using both sides, the lighting on the back face is incorrect unless you manually flip it like this

naive shuttle
regal stag
#

If you use it on the normal map output, sure

naive shuttle
#

Wait no it doesnt work

#

I had to use the flip node with the green value enabled

regal stag
#

Off the top of my head, I am not too sure if it should flip the map entirely or just the Z axis in this case though (which would be Multiply by (1, 1,-1))

naive shuttle
#

looks flipped if you ask me 🤷‍♂️

#

this is the result after doing that

regal stag
#

That's a different problem due to different programs storing vectors differently in normal maps. You may also need to do that

naive shuttle
#

uhh

#

Anyways, it looks more like moss now

#

Thanks for the help

regal stag
# naive shuttle this is the result after doing that

Can still see that some sides here are pretty dark. If that's okay can leave it, but I believe the correct result would be
Normal Strength -> Flip (Green)
-> into True on Is Front Face
-> and Multiply by (1, 1, -1) for False input.

naive shuttle
regal stag
#

If your normal map Y axis is flipped yeah, which I think it is looking at the preview

#

It should look like the green is "lit from above", if that makes sense

naive shuttle
#

uhh not that doesnt make sense

naive shuttle
#

oh wait

#

ignore me

regal stag
#

Referring to the node

regal stag
#

Multiply after the Flip (so that has two connections coming out)

naive shuttle
#

🤨

#

Soo this? @regal stag

regal stag
#

Yes, hopefully that's correct

#

Does it look any different in scene?

naive shuttle
#

Looking from this angle it looks like this, but....

#

looking at it from the other side it looks like this

regal stag
#

I'm guessing that's opposite to the light direction, so it would be darker

naive shuttle
#

The worst one is this...It's sooo dark on the other side

naive shuttle
regal stag
#

I guess you'd fake some light going through by adding to the base color or using the Emission a bit.

naive shuttle
naive shuttle
#

brb in ~7 min

fervent flare
#

Is it safe to edit lighting.hlsl ?

#

I should probably make a backup before editing it, right?

echo briar
#

Need help with a shader issue.

I'm trying to add water shader to my game and everything seems very well in editor mode. But, once I make a build the shader disappears and the water is no longer visible.

People have suggested me to add the shader to Preferences -> Graphic Settings -> Always Include, but this method doesn't work for me.

I'm using URP.

hearty obsidian
#

Is there a way to read a global vector array from shader graph?

regal stag
hearty obsidian
#

@regal stag Great, thank you!

orchid wharf
#

(look on hand)
Hi, does anyone know is it standart shader ?
or what kind of shader is it?

orchid wharf
#

arm skin

dim yoke
#

Definitely not the standard unity shader atleast

warm gate
#

I’m not sure if anyone can answer but are there any performance differences between generating grass using compute shaders, and modeling grass in blender or any modeling software to paint all over the terrain?

hollow cypress
#

in terms of performance, is it worthwhile to strip out texture samples which are generally empty?

#

I got a shader that takes an emission sample, does like 2 multiplications against it - but i'm only using the emissive in like 2-3 places. Is it worthwhile to consider splitting the shader into two versions (one with emission, one without) or is just defaulting fine?

#

i really have no sense for where costs are in shaders

#

or if this kind of thinking is even worthwhile in the grand scheme of things

regal stag
#

There is probably a bit of a balance, as objects with different keywords won't batch.

hollow cypress
#

hm

#

true

drowsy linden
#

Is there a way for me to have an arbitrary number of textures fed into a shader through the inspector? Like be able to add to the list. I want an arbitrary number of layers I can composite, and a color to go with each

tight phoenix
#

Is there a simple/cheap method to blur these cubes that doesnt involve sampling and offseting and recombining in a bunch of passes?

#

ideally something more like this (photoshop) 🤔 I could just use this as a texture but then I'd lose the ability to scale it up/down

#

my brain: "Try Posterize, that might help."
turns out that IS posterize

#

Ill just try the blurred texture because this is just an x/y problem that I think blurring this will fix and most likely it wont 🤔
Yeah it didnt work, moving on from this, even if I did blur it it doesnt do what I hoped

dim yoke
tight phoenix
tight phoenix
#

I'm having a problem with this shader 🤔 It looks great on a sphere, but on a cube you can see how there is sorta of a center point from which the light all spills away from
I'm trying to adjust whatever portion operates from that single point into a sphere into like, four points, to make a cube

#

uploading a gif that illustrates what im trying to correct out of it more visually

#

depending on viewing angle you can see that hard point forms

#

Ill post the graph in a sec, its getting very bloated and messy gotta clean it up

#

You can see the point forming in the dot product and arccosine, its already there when it gets normalized

#

I do have a value that I know directly adjusts it, but it only softens it into a spherical shape 🤔

#

hmm the problem might be because distance math is inherently spherical

tight phoenix
#

certain combinations of values makes it les apparent but it still totally shows up 🤔

#

maybe the problem is that its coming to a single 'point' like that, maybe I can find the last place it is a point and use like a minimum maximum to widen it arbitrarily 🤔

#

maximum does kind of fix it but then it creates an obvious spot optical illusion