#archived-shaders

1 messages · Page 203 of 1

meager pelican
#

But you're using URP. That's not well documented. You should probably use Shader Graph rather than writing the shader yourself.

However there's overlap with
https://docs.unity3d.com/Manual/SL-Reference.html
But that's not the same thing, that's the standard pipeline. (Are you sure you're using URP?)

#

Pastebin code

fair sleet
#

I'm so confused...
URP doesn't support Depth + Normal Textures

#

yet

#

This built-in render feature uses them

meager pelican
#

IDK

odd dagger
#

I tried using shader graph but I wasn't able to do additive blending with it. I heard there was a way to access the code but it wouldn't let me

#

I forget what error it gave

#

And yeah I am using URP because I made an attempt at shader graph but then stopped because of above

meager pelican
#

Pastebin code

regal stag
odd dagger
meager pelican
#

@odd dagger
Get rid of the "{}" on line 6
Add line 34
float4 _Color;

fair sleet
odd dagger
#

Did that. This error still persists

meager pelican
#

IDK.
That doesn't look like a URP shader to me.

odd dagger
#

Maybe that's the problem

#

I barely know anything about shaders

meager pelican
#

You should be able to get shader graph working.

odd dagger
#

But from what I remember there was no way to get additive blending on shader graph

#

But iirc someone on here told me some time back during another problem that you could include additive blending by accessing the code of the Sprite Lit Master node

regal stag
# fair sleet oh it does? I was just looking in the render feature code because I wanted to ma...

Yeah, should be _CameraNormalsTexture, it requires a renderer feature (well ScriptableRenderPass to call ConfigureInput(ScriptableRenderPassInput.Normal);) for it to be created. The SSAO feature is one that already does that.

It only contains objects if their shader contains a DepthNormals pass though. I think only Lit shaders include this so anything unlit (including Unlit Shader Graphs) won't appear in the texture, (and so, for example, won't contribute to SSAO). I've also used this before to render unlit objects into the texture after it's created : https://gist.github.com/Cyanilux/be5a796cf6ddb20f20a586b94be93f2b (but that won't work for shaders if they need alpha clipping or vertex displacement).

fair sleet
#

I see
I think I won't use the unlit shader in my project so I should be fine but if I do use it I could make my own DepthNormals pass by overriding every material and rendering

#

Thanks for the help!

odd dagger
#

Right this is the error I come across when I try to access generated code from the Sprite Lit master

meager pelican
#

My other sandbox has an old version of unity/SG/URP. I have to make a new project, so give it a few minutes.

#

@odd daggerI forgot to ask if you were 3D or 2D project

#

And what version you're using on what unity

odd dagger
#

2D and 2020.1.2

#

@meager pelican

meager pelican
#

OK, I just made the wrong one. lol So I won't be able to tell the diff.

#

Will take a bit.

#

Yeah, it doesn't look like transparent blend modes are available for sprites.
And even for plain lit:

#

No subtract. Although you might be able to add negative color values.
The other thing is that last I knew the SceneColor node didn't work in 2D. @regal stag might know more, if it has been fixed or not.
But otherwise you could blend manually if you can get hold of the back buffer.

regal stag
#

Haven't used 2D renderer in a while but I think Scene Color is still not supported. It is a bit annoying that blend modes can't be changed for sprites

odd dagger
#

What a shame

#

So there's no way I can additively blend sprites?

meager pelican
#

In standard it would be easier.
But in URP, you'll probably want to sick with the Shader Graph, and thus, not right now I guess.

grand jolt
#

@meager pelican bug report submitted

#

I hope that the problem stops haunting me soon ;-;

meager pelican
#

I'm exuding optimism as I type!

hearty wasp
#

Hey guys! I'm trying to make this mask-based sun for my skybox UVs, and it kiiiiinda works? 😅

#

I think I basically just need a way to project the texture and keep it as in tact as possible, I tried a few different things already - right now it's based off Cyan's skybox uv method

#

which is this

#

yeah, if anyone has any ideas or can point me in the right direction, I'm open for suggestions!

lean lotus
#

is there a way in a compute shader to have each thread of a compute shader able to increment a global counter that I can then get out of the shader?

meager pelican
# lean lotus is there a way in a compute shader to have each thread of a compute shader able ...

Yes it is called atomics/locking. But beware, since all cores share a program counter (current instruction address), if most but not all of them are trying to increment at once is going to slow things down, as I understand it.
https://stackoverflow.com/questions/65233108/interlockedadd-hlsl-potential-optimization

lean lotus
#

ok thx

exotic garden
#

These two variables should never be different values right? I'm getting different behaviour depending on which one I use. I can swap out the return _rangeIncrement * i using rangeIncrement with no underscore and my shader messes up. Why would these two be different.
NUM_COLORS is a #define NUM_COLORS 5 which is assigned at compile time so that shouldn't be a problem.

#

The local float works fine, but I would like to use this value elsewhere. But the global float isn't being assigned the value, it has the value of 0

meager pelican
#

IDK.
But you could try static const float ....
if that doesn't work you can use a macro #define instead. Wrap it in some parens and let it substitute it into the expression.

meager pelican
lean lotus
#

ok

lean lotus
#

I remember looking at those, ill have to look again cuz the main thing I took away was them storing the scene data in global memory, but mines too large

misty flame
#

How do I add custom nodes for shader graph that are .cs written in c#? I just assumed I'd put them in my project but searching for the node when I press space or dragging the actual file in doesn't work.

meager pelican
# misty flame This is the one I'm trying to get https://github.com/hwaet/shadergraphnodes

Well, it will still have to be HLSL, but there could be a custom node API to make them. I mean, for graph functionality. But the code they generate would be HLSL.

IIRC they used to have a C# interface but IDK if it is still active. (doesn't look like it)
https://docs.unity3d.com/Packages/com.unity.shadergraph@5.7/manual/Custom-Nodes-With-CodeFunctionNode.html
They do have custom function nodes:
https://docs.unity3d.com/Packages/com.unity.shadergraph@11.0/manual/Custom-Function-Node.html

sleek mural
#

Is it possible to create a shader using the Shader Graph that works inside a Canvas? I am specifically using Screen Space - Overlay. Every shader that I try to add to an UI component that I created using the Shader Graph makes the component disappear on play.

blissful lynx
#

anyone have any experience by chance rendering motion vectors using MRT?

#

or even just having a motion vector pass that is using forward instead of deferred rendering, and without having to also have a depth pass?

alpine blaze
#

I'm trying to fix a shader so that it successfully compiles a GLSL version (so that i can use the unity editor on linux). Keep getting errors along the lines of GLSL link error: error: tessellation evaluation shader output 'ds_PID0' specifies no interpolation qualifier, but geometry shader input specifies flat interpolation qualifier

#

the struct carrying information between the domain shader (read, tessellation evaulation shader) and the geometry shader looks like this: ```c
struct DS_OUT {
// discrete vertex ID used to color the output, starting from the beacon (targetPos)
uint pid : PID; // GeometryShaderに実行用の一意連続なIDを発行する
// note: w is -1 or -2 on error
float4 centerPos : POSITION;
float4 quad_normal : QUAD_NORMAL;
};

(pid seems to be the field it is currently complaining about)
#

domain shader is defined as: ```c
[domain("isoline")]
DS_OUT mainDS(CONSTANT_HS_OUT In, float2 uv : SV_DomainLocation) {
// <snip>
}

geometry shader is defined as: ```c
[maxvertexcount(14)]
void mainGS(line DS_OUT input[2], inout TriangleStream<GS_OUT> outStream) {
    // <snip>
}
meager pelican
# blissful lynx or even just having a motion vector pass that is using forward instead of deferr...

I'm not sure where you're going with this. But I'm intrigued and so I thought I'd ramble:
As I'm sure you already know, Unity has motion vectors in standard and HDRP. URP is in the works now. But you'll likely want to use their methodology as it is integrated into the engine, IIUC. So they "cull" on the C++ side those objects that don't have settings activated for motion vect (you get camera motion at those locations).

As for depth buffer writes, generally if you write the depth buffer, you write the motion vector. But if you don't, you don't. Think transparent objects (window) and a car flying by on the road outside. You don't want the window's motion vector, you want the car's motion vector. But they have an option already integrated that let's you write motion vectors for transparent (at least they do in HDRP) if you wish to.

You want to do it in the same pass? Using MRT? Trying to save draw calls? Is that what I'm reading? So you'd pass two transforms in and use MRT to write the per-object motion vectors? I think you're fighting the engine if you do that. You may end up having to roll your own motion vector system and completely bypass theirs. But I think you could do it with two transforms, but I haven't tried it. You'd have to update the objects at the end of the pass to move the current transforms to the previous transforms, then let the game have at them again to get the new ones updated. Then add a camera motion pass at the end to fill in the gaps and/or update the object motions allowing for camera motion too.

Interesting. But I'd stick with their system if I could. Better engine integration. URP is in the works.

#

The other thing is that I think the engine is set to use multiple passes for certain things simply because all target platforms don't necessarily support MRT. I suppose it's often easier just to do separate passes and get greatest compatibility rather than having a multi-pass and an MRT-pass version of everything. And of course there's rendering method where with things like deferred you want a depth pre-pass (and g-buffer) for other reasons.

#

That's all just me rambling/discussing.

#

What's discord for, eh?

meager pelican
meager pelican
#

Anyone know about this error?
Shader error in 'TheShaderName': this variable dependent on potentially varying data: MyIntVar at kernel CSMain at blahblah.compute(80) (on d3d11)
What I'm doing is

// Things we'll stuff into group shared memory  (defined global scope at top of shader)
groupshared float4x4 GS_localToWorldMatrix;
groupshared float4x4 GS_worldToLocalMatrix;

....later....

    if (threadID == 0) {
        GS_localToWorldMatrix = meshObject.localToWorldMatrix;
        GS_worldToLocalMatrix = meshObject.worldToLocalMatrix;
    }
    GroupMemoryBarrierWithGroupSync();

<loop uses GS_localToWOrldMatrix, etc. for calcs....>

But everything above that point blows out as a dependency that it thinks might be "unstable" and it won't compile. Anyone know a reason. I know it thinks it will be varying, and it will, but it will be group-consistent as needed. Does it track all dependencies and somehow I have to be able to use this memory for calcing a result.

Is there something about groupshared that I can only set it once or some weird thing? What the heck?

Never Mind. Found a way. Only needed GroupMemoryBarrier()

whole socket
#

Anyone knows how to fix this error? Shader error in 'x': maximum ps_4_0 sampler register index (16) exceeded at line 180 (on d3d11)
Not an expert on how shaders work

#

developer of the specific asset said something probably took away a texture sample

#

but I've never worked with shaders before

meager pelican
pastel pilot
#

Hey guys! looking for some help. I am trying to animate my trees using shaders and I got it to work after 3 days of working on it..... but the issue is they only move while my character is moving, if my character is standing still, so are my trees. Some help?

#

I am using an HDRP pipeline if that makes a difference

twilit geyser
#

Hi guys 🙂 How can I find out what shader model my hardware supports? I have written a shader that requires Shader Model 4.0 as a minimum and now I'm trying to find out if that's available on Samsung Galaxy S7, but I can't find any info.

#

Are mobile devices using something completely different on a technical level and my shader would not work in the first place?

twilit geyser
#

Thanks, I will try that!

grand jolt
#

I need a flashing or lighting shader like lighting storm

queen spoke
#

Hello Krato did you thought about using Shader Graph for that ?

misty flame
#

Can you no longer use C# to make custom shader graph nodes?

#

Is hlsl the only thing you can do now?

meager pelican
#

Shader graph needs the HLSL anyway....they just changed the features to be from a custom node instead of a C# created node. IDK why.

grand jolt
#

Idk im new to this

sterile plaza
#

Hey! Do any of you know how to approach something like this? Where my player could fall through this manhole, walk through a door you name it - and where the part sticking out on the other side wouldn't be visible? I'm guessing something with alpha masks, but i don't really know

#

I figured that i might need to have two seperate sprites that shows behind my player and in front of my player, creating the illusion of the player entering the hole, but i dont know how i would make the part sticking out be invisible

queen spoke
#

@grand jolt You have this tutorial where Brakey is making the monkey glow by time.
Making a very short time and adding a random/hooked to your lightstorms would do this kind of flashing lightstorm effect you want.
https://youtu.be/Ar9eIn4z6XE

● Check out Bolt: http://ludiq.io/bolt/download

The time has come... Let's explore Unity's new Shader Graph!

♥ Support Brackeys on Patreon: http://patreon.com/brackeys/

····················································································

♥ Subscribe: http://bit.ly/1kMekJV

● Website: http://brackeys.com/
● Facebook: https://f...

▶ Play video
#

Hope this helps.

keen sparrow
#

Heya everyone,
I have a shader that I use to get a constant effect on a UI Image. When I place the UI-prefab in my scene and start the shader weorks properly. However, if I instantiate the UI-prefab from script at run time the shader doesn't work properly. It seems to do its thing for a single frame and then freeze.
Does anyone know what causes this and how to solve it? Thanks in advance.

tardy sage
#

Is there a way to unpack subgraphs (like prefabs) into their constituent parts?

toxic flume
#

How can I add intersection lines to blue zone/ death zone like in pubg or cod mobile efficiently
Depth map + stencil buffer?

ivory rover
#

I wanted to have 4 UV coordinate channels so I thought maybe I could just bring in all the channels, make an array with them all and index it with an int so I can change it with a script or something
but then unity was all like

#

I have narrowed it down to the indexing of the array because I can use a constant UVMaps[0] but not UVMaps[UVIndex]

#

this is the shader for people who dont want to download it

Shader "Game/Track/VariationShader" {
    Properties{
        _MainTex("Texture", 2D) = "white" {}
    }
    SubShader{
        Tags {
            "RenderType"="Transparent"
            "Queue"="Transparent+50"
        }
        Pass {
            Cull Off
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            struct InputData {
                float4 vertex : POSITION;
                float4 uva : TEXCOORD0;
                float4 uvb : TEXCOORD1;
                float4 uvc : TEXCOORD2;
                float4 uvd : TEXCOORD3;
            };

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

            sampler2D _MainTex; float4 _MainTex_ST;
            int UVIndex = 0;

            v2f vert(InputData i) {
                v2f o;
                o.vertex = UnityObjectToClipPos(i.vertex);
                float4 uvmaps[4] = { i.uva, i.uvb, i.uvc, i.uvd };
                o.uv = TRANSFORM_TEX(uvmaps[UVIndex].xy, _MainTex);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target {
                return tex2D(_MainTex, i.uv);
            }
            ENDCG
        }
    }
}
#

is there something im missing here? I dont believe I can convert it to what it is asking for

junior crow
#

When you use normal maps to make a 2d sprite appear 3d, is there away to also have it render shadows on the sprite?

#

Like if Mario was lit from above, his cap should cast a shadow on his face. Is there a way to do that without going all-out 3d?

white cypress
junior crow
#

Maybe a better example: a character holding an umbrella. If lit from above, I want the umbrella to cast a shadow on the character holding it

white cypress
#

right, and the pixel's normal value is the only real lighting information you can have on an image. I suppose you may be able to do it if you made the cap a separate sprite and made it cast shadows

junior crow
#

I think what I want to do is create a 3d model for each sprite, apply the lighting to the 3d model, and then apply that lighting to a flat sprite

#

Just not sure how to go about that, or where to get started

junior crow
white cypress
junior crow
#

I have an unlit pixel art sprite and a 3d model that matches that sprite. Want to apply lighting to the 3d model, take that lighting, make it flat and apply it to the pixel art sprite.

white cypress
#

i mean creating models for the items you want to cast shadows, not the whole sprite

junior crow
#

I mean if I want the shadows to appear accurately on the character, I may as well model the whole thing

white cypress
#

exactly lol

#

anyway i don't think there's a real way to map 3d shadows on a sprite other than normal maps, your best bet is to modify the normal map enough that you can fake shadow casting

junior crow
white cypress
#

maybe? its how you get lighting information on a sprite, so I assume there's some way to modify it to an extent that you can cast shadows. this is all conjecture of course

junior crow
#

Maybe some kind of double normal map, where 1 map gives the normal angle of each pixel, and another map gives the distance each pixel extrudes from a flat plane

white cypress
#

and probably a custom shader thrown in

white cypress
#

holy hell that link

junior crow
#

lol

#

I think there must be some way to do it with height maps

#

It's all going over my head rn though

white cypress
meager pelican
ivory rover
# meager pelican You're trying to assign four float4's to one float4. And usually uv's are float...

I fixed it with this, I had A track model where each of the UV channels held a different track UV where I could switch it out depending on the track with the UVIndex

Shader "Game/Track/VariationShader" {
    Properties{
        _MainTex("Texture", 2D) = "white" {}
    }
    SubShader{
        Tags {
            "RenderType"="Transparent"
            "Queue"="Transparent+50"
        }
        Pass {
            Cull Off
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_instancing
            #include "UnityCG.cginc"

            struct InputData {
                float4 vertex : POSITION;
                float2 uva : TEXCOORD0;
                float2 uvb : TEXCOORD1;
                float2 uvc : TEXCOORD2;
                float2 uvd : TEXCOORD3;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct v2f {
                float4 vertex : SV_POSITION;
                float2 uv : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            sampler2D _MainTex; float4 _MainTex_ST;

            UNITY_INSTANCING_BUFFER_START(properties)
                UNITY_DEFINE_INSTANCED_PROP(int, UVIndex)
            UNITY_INSTANCING_BUFFER_END(properties)

            v2f vert(InputData i) {
                v2f o;
                UNITY_SETUP_INSTANCE_ID(i);
                UNITY_TRANSFER_INSTANCE_ID(i, o);
                int _UVIndex = UNITY_ACCESS_INSTANCED_PROP(properties, UVIndex);
                float2 uv = float2(0.0, 0.0);
                o.vertex = UnityObjectToClipPos(i.vertex);
                float2 UVMaps[4] = { i.uva, i.uvb, i.uvc, i.uvd };
                for (int i=0;i<4;i++)uv+=UVMaps[i]*(_UVIndex==i);
                o.uv = TRANSFORM_TEX(uv, _MainTex);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target {
                return tex2D(_MainTex, i.uv);
            }
            ENDCG
        }
    }
}
#

but thank you for the help, if this looks dumb (which it probably does) still then feel free to recomend the last thing I was trying to implement

meager pelican
#

Well that's pretty clever. Will probably work.
But since you assign things and hard code loop counts and such, you can just do:

float2 uv = 0; // or float4 or whatever type you want that matches the others
uv += (_UVIndex == 0) ? i.uva: 0;
uv += (_UVIndex == 1) ? i.uvb: 0;
uv += (_UVIndex == 2) ? i.uvc: 0;
uv += (_UVIndex == 3) ? i.uvd: 0;```
I haven't tried that, but it looks sound.  
so you won't need the for loop and you won't need a different variable for UVMaps...
#

@ivory rover

#

Or a switch()

ivory rover
#

but now there is an if statement, isnt that like the worst thing you could do for a graphics card since it has to wait for that execution and they arent optimized for it?

#

just like you would favour a 3x3 rotation matrix for rotation in a shader and multiply it across instead of doing element by element with the same deriving math

#

@meager pelican

meager pelican
#

Any conditional is an "if statement".
So your multiply above where you say *(_UVIndex==i) is a check/conditional that returns a true/false just like the ternary operator does.

And it's a good bet that the compiler will look at your loop, with the hard-coded <4 in it, and unroll that into 4 statements as an optimization.

Basically if you're selecting like that, you're selecting. A switch would be an "if" too. But it's not that bad. It's not like you have two huge code blocks where all sides are executing on all cores. It's just ternary operations.

ivory rover
#

well I mean I had if(_UVIndex & i) before since the and operation is a bit less heavy? (dont quote me on that but doing the operation is less complex than)

sub x, i
cmp x 0
bne somelabel
somelabel:
#

but then it gave me some weird things after 1, and I just went whatever

#

basically the first thought process was just to bring in all the UV maps

float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
...
``` then make it an array then index it on the _UVIndex
#

but then unity gave me GLSL compilation errors and as much as I would have loved to do this in GLSL, I dont think you can do that

meager pelican
#

You need the data per vertex, since UV's correspond to verts. So letting the engine figure all that out the way you've got the input structure is good.
But all that extra variable creation is probably overkill. IDK, you could benchmark it. IDK why you got an error with the index use after the assignments to the array.

ivory rover
#

If I was to do it like the other shaders in my game, I would have made a tool to bake the UVs into arrays then make a material property block to send that to all the instances (global) then send the index (instanced local)

#

all the animation is done on the GPU in this game so overkill is kinda meh, but that is because Im going to have a lot of the same thing on the screen

StructuredBuffer<int> PassInfo;
                StructuredBuffer<int> PassBnds;
                StructuredBuffer<float3> PassData;

                v2f vert(InputData i) {
                    v2f o;
                    UNITY_SETUP_INSTANCE_ID(i);
                    UNITY_TRANSFER_INSTANCE_ID(i, o);
                    #if AnimationEnable
                        int MeshOffset = PassInfo[0];
                        float UnityTime = mul(_Time.y / _AnimTime, _AnimSpeed);
                        int FrameIndex = (int)mul(frac(UnityTime), mul(_AnimFPS,_AnimTime));
                        int kindex = PassBnds[FrameIndex];
                        float fpos = InverseLerp(PassInfo[kindex+1],PassInfo[kindex+2],FrameIndex);
                        float3 ThisDisp = PassData[(MeshOffset * (kindex)) + i.id];
                        float3 NextDisp = PassData[(MeshOffset * (kindex+1)) + i.id];
                        i.vertex.xyz += lerp(ThisDisp, NextDisp, fpos);
                    #endif
                    o.vertex = UnityObjectToClipPos(i.vertex);
                    o.uv = TRANSFORM_TEX(i.uv, _MainTex);
                    return o;
                }
``` something Like this for animation
#

I could make a tool that makes a mesh, then binds it to all the UVs and send it with the same methods but UV maps seemed a little less... time consuming...

meager pelican
#

Yeah, you could. But what's actually happening "under the hood" is that unity is already doing that for you. So when your vertex shader is called, it's grabbing those 4 values and assigning them to the structure. Sure, it's not an array. It's mapping that structure to the memory. But it manages it somehow.

I'll bet those 4 ternary operations will run really fast anyway. It's up to you. But unity has several UV sets already available. But be careful that you know that UV set #2 is for lightmaps and such. Other sets might be reserved too.

ivory rover
#

lol what lightmaps

#

I mean the difference of the ternary is probably going to be small compared to the time it takes to allocate for the array then do a for loop to add and multiply

#

if there was a way to send the full TEXCOORD array I would

#

since that would make more sense; sometimes I hate heavily managed things for this reason

small hinge
#

I have an image that has RGB values stored in the same place as transparent alpha. but unity seems to be corrupting the rgb values of those pixels in particular, not sure what could be doing it. either the nodes im using in shadergraph (sample tex 2D) or the import settings for the image.

#

actually i think its the import settings, because i recal this happening while i was using a non shadergraph shader

#

hm, I fixed it by just choosing to ignore the alpha in the import settings.. but I still want to be able to access the alpha :/

ivory rover
#

you could split the alpha of the image into another image and use that along with the RGB

stark canopy
#

It looks like setting Double Buffered to true on a CustomRenderTexture asset with a shader makes it stop working on WebGL. Anyone else notice this?

dusky cobalt
#

Hey all, got a bit of a WTF Shadergraph issue:

I have a pretty simple dissolve shader, with an extra fresnel on top to provide some fake lighting.

#

Anyone got any ideas as to what the heck's going on here?

dusky cobalt
#

Got it... I must have forgotten to remove that add node attached to dissolve amount when I was messing with it before.

#

removing the add node fixed the issue.

pastel pilot
#

Hey guys can I get some help with this? I got some trees being animated with a wind zone by using a shader graph.... but as you can see in the video, the wind is heavily affected by player movement, whenever I’m moving the wind is far more intense.... any ideas?

hearty wasp
pastel pilot
#

I used the Basic Wind shader from Unity’s Fontainebleau

#

And found this related to player position

#

Do you think could be something here?

hearty wasp
#

I'm unsure, I've opened that demo before and they've some very complicated stuff going on

#

maybe someone else with a more advanced understanding of wind shaders can help you out, I've not done much with wind shaders myself yet sadly, sorry!

pastel pilot
#

No worries man thanks ))

grand jolt
#

is it possible

#

to make shaders use specific submesh position?

#

instead of mesh position

marble thunder
#

Hmm is there a tag to hide tiling and offsets for normal maps?

#

I am aware of the [NoScaleOffset] that I can use for other maps, but I can't have [NoScaleOffset][Normal} at the same time?

#

Tried [NoScaleOffsetNormal] and it didn't seems to do the trick 😦

#
[NoScaleOffsetNormal]_NormalA ("A Normal", 2D)               = "bump" {}
[NoScaleOffsetNormal]_NormalB ("B Normal", 2D)               = "bump" {}
regal stag
marble thunder
#

Ok that works...

acoustic jolt
#

Hi, I'm new, does anyone know how I can put the textures here?

marble thunder
#

AssetBundle Browser under Window.

marble thunder
regal stag
#

Mine does something similar, the extension probably doesn't take multiple flags into account properly.

acoustic jolt
marble thunder
marble thunder
acoustic jolt
acoustic jolt
#

I'm going to open unity

pastel pilot
#

I’m bout to delete it 😆😅🙃😒😔😢😭

acoustic jolt
#

;-; my project was deleted :c

pastel pilot
#

😦

acoustic jolt
tame topaz
#

@acoustic jolt This is an English only Discord.

acoustic jolt
grand jolt
#

i have one issue, i want to combine meshes to save cpu and gpu usage

#

i heard its good to do it with objs that have same material

#

now heres the thing, its custom shader and it doesnt work this way

meager pelican
grand jolt
#

builtin

meager pelican
#

Good

#

Firstly, just combining objects isn't always a good idea. I mean, unity's batching system will do that for you if they have the same materials, so you don't have to do it yourself. You CAN do it, but you should do it in clumps. So as not to make too large of a group, since the whole group gets submitted to the GPU even if only one pixel is showing.

grand jolt
#

yeah the shader is quite complex i think its better to search for optimizations else where

meager pelican
#

OK

#

Do you have several instances of these types of complex-shaded objects?

#

Have you seen GPU Instancing?

#

Does the shader support instancing?

grand jolt
#

i have highly comprresed textures only, and of small size, i also have gpu instancing everywhere

#

but my cpu cant stand this many

#

mesh renderers i believe

#

is it advised to combine only instances that are close to each other or can they be far too

#

gpu instancing cant help me any more tbh

#

cause the issue is with cpu

meager pelican
#

If you combine, say, 25 objects. And then 5 of them are on the screen and 20 are behind you, the CPU still has to process and send all the triangles for that combined mesh, so all 25 worth of data to the GPU.

#

Another thing you might want to research is LOD (level of detail) so you have fewer triangles on the screen at farther distances. And simpler meshes.

But I have no idea what you're doing on the CPU side that is causing this.

#

IDK what to tell you if you're CPU bound, shader tricks won't help much. And if you're already instancing, you won't need to combine meshes, theoretically.

#

You could look into the DOTS system, but it's still experimental and not recommended for prime-time yet. They use that with lots of on-screen pieces like in their demo. And it's a CPU-side thing (mostly if not all).

rustic jewel
#

Hii, so I downloaded a custom Skybox from the Unity Asset Store and now I got bloom enabled in my Season but it the Sun from the Custom Sky Box is extremly bright and I just want to remove it or dim the light from it. How can I do that?

loud remnant
#

The base map texture cuts off depending on the camera angle. Anyone knows why?

#

It's the regular URP/Lit shader

frigid pond
#

Hmm does anyone know how Unity sets the depth texture in built in render pipeline post processing stack v2? (I should specify that I'm using the deferred rendering path, not forward)

toxic flume
#

How can I add intersection lines to blue zone/ death zone like in pubg or cod mobile efficiently
Depth map + stencil buffer?

fathom temple
#

In HDRP, can hide pixels on objects between my character and the camera? Like with stencils? I've been trying to figure out to do this all today, but I can't seem to find much. Picture is what I'd like to do in HDRP

slim skiff
#

I'm trying to rotate and translate an object in a shader. I'm calculating both offsets then adding them together, but it seems like as I apply the rotation, the translation disappears. I can't get both to happen at once. What am I missing?
Graph:

knotty juniper
fathom temple
knotty juniper
slim skiff
# knotty juniper mmm wired it works in my test case

i changed the axis and i think it is working, but it looks like it doesn't because...I'm not sure. Maybe the rotation is changing the translation direction as it rotates such that i can't tell it's moving or something

#

let me compare to what you have and test with a cube though, that's a good idea

knotty juniper
#

ah i used world position

#

mmm let me check if it that

#

nope still works

slim skiff
#

yeah, i think it actually is working but it looks wrong, so I have to figure out why 😅

#

if i am rotating around a center pivot while i move to the side, it makes an arc

#

i guess my question at this point is...do those affect each other? like if i rotate 45 degrees then move 'left', is left now rotated 45 degrees, or is left still relative to the mesh's position?

#

i think i was expecting the latter, but what's happening is the former?

knotty juniper
#

hope you get it working 🙂

tacit parcel
loud remnant
#

@tacit parcel I changed from bilinear to trilinear and that did the job, thanks for the help though

amber gust
#

Hey ! I don't know if this is the right chan. I just bough a 3D model online, with texture, and I have no idea how to set material on the model in Unity. Can you help me with this ?

#

The pack give me this

shadow locust
#

Then drag each of those textures into the various slots in the material

#

then assign the material to the renderer on the model

#

Depending on the shader you use for the material, you may or may not be able to use all of those textures

#

(for example some shaders may not support a "roughness" map)

amber gust
#

It's working

#

Thanks !

waxen wind
#

How hard would it be to convert this to something URP-compatible?

waxen wind
#

I finally figured out how to do Triplanar Vertex Blend in shader graph 🥳

mental bone
#

Too much or ?

mental bone
#

So quick question what vs plugins do you guys use for shader work ?

tidal harness
#

hello people i have a question ... to use Shader Graph in Unity 2020.3 do we have to change the project to URP?

mental bone
#

Or HDRP as far as I know shadergraph support for buildin pipe is comming but its not out yet

tidal harness
#

we cant use the shader graph on SRP?

tame topaz
mental bone
#

Yet

tidal harness
#

thank you guys , another thing if you dont mind ... can someone point me to a good tutorial to make sword slash or trail , its been a week i m watching videos i cant find one that shows me the process from start to end ... =/

#

thank you very much ^^

tame topaz
# mental bone Yet

Have they actually confirmed this? Considering they're moving away from the old renderer.

mental bone
tame topaz
#

Oh okay, that's interesting.

mental bone
#

with the news about the X-Pipeline and this I think we are moving towards one super merged pipeline and our lives will be spent compiling shader variants

thick chasm
#

https://youtu.be/SOK3Ias5Nk0?t=139
I am new to shading, how do I use the shader graph made here so my world actually bends?
What do I need to apply it to?

Recreate Animal Crossing’s world bending shader in Unity.
In this shader graph tutorial, we will recreate the world bending shader (“rolling log” effect) from games like Animal Crossing and Subway Surfers.

🎁 Quality hand-painted assets: http://bit.ly/2dhp-dungeon-yt
🌎 Curved World shader asset: http://bit.ly/curved-world-shader-2021
📦 Download ...

▶ Play video
white cypress
grand jolt
#

Hi everyone, so, I recenlty added outline to my game, as a renderer feature

#

They are rendered as a post processing effect

#

I also used Brackey's dissolve shader tutorial to make a dissolve effect, but this causes the outlines to dissapear:

#

Is there any way to prevent this?

#

Also, here's the shader for the dissolve effect:

regal stag
# grand jolt I also used Brackey's dissolve shader tutorial to make a dissolve effect, but th...

I assume you're using a renderer feature with an override material to draw the normals texture (e.g. like the one provided in https://alexanderameye.github.io/outlineshader.html). This method cannot support shaders that use things like vertex displacement or alpha clipping (like in this dissolve effect) as the override material doesn't include them (and even if it did, the properties do not carry over). You could probably change it to Transparent surface mode, but then you'll see outlines through it instead which may not be what you want.

Since it looks like you're in v10, URP contains a method for creating a _CameraNormalsTexture without relying on an additional render feature. Instead of override material each shader includes a DepthNormals pass (which can support alpha clip). You can ask URP to generate the normals texture using this pass. It only works for Lit shaders and Lit Graphs though. Unlit ones do not have the pass, (I have used an additional feature in the past to render the unlit ones manually https://gist.github.com/Cyanilux/be5a796cf6ddb20f20a586b94be93f2b, but it's the same idea as the override material so they still won't support alpha clip. At least lit ones do though).

You will still need the feature to blit the outline material to the screen, which can also call ConfigureInput(ScriptableRenderPassInput.Normal); in the setup before EnqueuePass to request URP to create the normals texture. I've got a blit feature that can do that if you don't want to edit your current one. https://github.com/Cyanilux/URP_BlitRenderFeature

grand jolt
#

So I have to add your blit feature instead of the one I already use?

#

Hope I understood everything right, I don't know much about shaders though

#

I followed a tutorial for an outline effect, since I had no idea how to do it on my own

regal stag
grand jolt
#

Lol, added your blit script and it works perfectly

#

Haven't tested with the dissolve effect though

#

But as you said

#

Small chances to work with such effects

#

Or is it possible and I am just dumb?

regal stag
#

If you tick the Requires Depth Normals on the blit script, and use _CameraNormalsTexture in the outline shader, it should work with the dissolve effect too (for Lit graphs at least)

steel notch
#

Hey so I'm struggling a bit with trying to get Emission maps working. This is my current Shader graph.

#

And this is the result

#

for some reason the entire flower is getting bright
as opposed to just the bulb

regal stag
# steel notch

Are you using a secondary texture on the sprite to pass the emission texture in? If so, is it using the same reference on the property as set in the Node Settings tab. (Ideally the texture's mode should also be Black, so it defaults to black when no texture is assigned. I assume it's white atm, which is why the whole thing is affected)

If you aren't using textures based on the sprite, just make sure the texture is assigned on the material I guess.

steel notch
#

Kinda getting used to shaders atm, so sorry if I ask some dumb questions.

#

Was that second sentence a question?

regal stag
#

Yea, the texture properties need to have specific references to obtain the textures from the sprite. _MainTex being the main one which you might have already set, but have you set the emission one to use the same reference as your secondary texture set?

#

(referring to the "Reference" field in the Node Settings tab of the Graph Inspector window, when the property is selected)

regal stag
#

Hmm it should work then afaik

steel notch
#

I just dont see why the whole thing is lighting up

regal stag
#

What colour is set on the Sprite Renderer? Is it white or pink?

steel notch
#

its white

#

problem is when I mess with the HDR, the color of the whole thing changes

#

not just the bulb

misty flame
#

How is information in normal maps stored?

#

I get how they work and that they change how light reflects to make it look like there's a lot of complicated geometry without actually having it

#

but when you sample texture 2d it and get an rgba, does it just fill up the rgb? Is it a normalized vector3 that tells unity what direction light will be reflective from? Or is it a vector2?

knotty juniper
#
The RGB colour values are used to store the X,Y,Z direction of the vector, with Z being “up” (contrary to Unity’s usual convention of using Y as “up”).
#

so only two off the color channels are realy used

misty flame
#

So z is just 1 always? What do you mean by z is up?

regal stag
# misty flame How is information in normal maps stored?

The docs page here might have some info : https://docs.unity3d.com/Manual/StandardShaderMaterialParameterNormalMap.html.
The texture is stored in a 0-1 range, but normals are -1 to 1 so after sampling the values are remapped (typically using the UnpackNormal function, For SRPs can see them here : https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl). I believe most use the UnpackNormalmapRGorAG function which basically ends up reconstructing the Z axis so the blue stored in the texture is ignored.

The result is in "tangent space" though (relative to the surface, following the uvs), and needs to be transformed into world space for lighting calculations. This is handled by constructing a matrix using the mesh tangent (x axis), bi-tangent (y axis) and normal vectors (z axis). e.g.

half3x3 tangentToWorld = half3x3(tangentWS.xyz, bitangent.xyz, normalWS.xyz);
normalWS = TransformTangentToWorld(normalTS, tangentToWorld);

In Shader Graph most of this is handled behind the scenes, you just need to select Normal mode on the sample node and connect it to the Tangent space Normal port.

misty flame
#

Ohh ok so basically it's able to be only a vector2 because it's in tangentspace and tangentspace is just relative to the triangle's surface so it only needs two coordinates

#

like relative to the geometry normal

loud remnant
#

How can I achieve a more accurate mirror effect? This is a standart metallic shader with smoothness set to 1

#

I use a reflection probe for the reflections on the shader

#

The reflection probe method causes the environment to look a lot closer in the mirror

knotty juniper
#

you will need a planar reflection if you want to have "perfect" reflections

mental bone
#

Hey Im going to ask again. What visual stidio plugin/s do you guys use to make writing hlsl and unity shaders easier?

tranquil cipher
#

hi all, may i ask what cause the mesh have this weird rim light ? the problem appear both in scene ( custom shader with very basic fresnel effect with power=10 ) and in preview panel which using unity's default shader so i think the problem lie in the mesh itself, not the shader.

#

i checked the dress, recalculate normal for it, and checked the facing, all no issue, i don't understand why the upper dress and the bottom have very different rim light effect

#

and also, both bottom and upper are in a same mesh not seperated

tranquil cipher
#

Okay i found the problem caused by normal, using weighted normal modifier in blender fixed it

timid minnow
#

Anything obvious I'm missing as to why this shader works in URP but not HDRP?

#

It's meant to dither the object the material is assigned to when the camera gets too close

#

There aren't any issues with how it renders in HDRP, it just doesn't do any of the dithering (playing with the alpha/alpha clip threshold manually didn't appear to improve things)

#

Hrmm, there don't appear to be any tutorials that explore this effect in HDRP. Is it simply not possible?

regal stag
timid minnow
mental bone
#

im still looking for a plugin that gives IntelliSense for hlsl and srp stuf

meager pelican
# mental bone im still looking for a plugin that gives IntelliSense for hlsl and srp stuf

https://marketplace.visualstudio.com/items?itemName=TimGJones.HLSLToolsforVisualStudio&ssr=false#overview
That's one option, YMMV. But instead of posting here, you could just google it.
IDK what ones are better than others, it's largely personal opinion. And frankly I hate the colors in this one, have to edit them.
Others use Jetbrains Rider or VS Code editors. Rider is experimental right now
https://www.jetbrains.com/help/rider/Unreal_Engine__HLSL_Shaders.html

#

That took me 5 minutes to google.

#

None of them are shaderlab specific that I know of though.

mental bone
mystic plank
mental bone
#

do you mean without the material ? You cant exactly export a blender material to unity afik

mystic plank
#

I have those balss with a shader toon

#

but when I export it as FBX or .blend file to uniy its appear gray

#

without shaders and nothing and the base material is kinda gray too so what happend

desert orbit
#

@mystic plank You already got the answer in another channel you cross posted in.

mystic plank
#

btw look

#

I xported just one to test

#

and look the blue material is withe

tame topaz
#

Shaders are not exported. You have to recreate in Unity.

meager pelican
mystic plank
#

dude I spend all this time making this in blender :'u

tame topaz
#

Yep

mystic plank
#

this shader toon how can I make it on uniy so

tame topaz
#

You can take the approach and redo it in Unity's shader graph.

#

The concepts are usually transferable.

mystic plank
#

btw so if I have an Anime Character in blneder and and I want to make it looks like one of Genshin impact but in unity, so I have export the FBX with base color and put the shader toon in unity to make it look like an anime ?

tame topaz
#

Yes, and that's exactly what Genshin does. This is just how the workflow works.

mystic plank
tame topaz
#

No, as I said already, you have to recreate it.

mystic plank
mystic plank
mystic plank
# mystic plank btw look

can I use this base material exported from blender called blue in this picture and use it to remake the shader in unity?

#

I mean should I make a new material or I can use this as well

tame topaz
#

Everything from scratch. New shader, new material that uses that new shader.

mystic plank
#

nice so I only will take from blender the FBX nothing more

mystic plank
#

and VFX made in blender like a fire ball

tame topaz
#

Animations will be imported. VFX, no.

mystic plank
knotty juniper
#

you may be able to bake out texture sheets from blender that you can use in the unity particle system

tame topaz
#

It's a combination. You make any mesh, figure out any masks etc. And then import them into Unity and put it together.

mystic plank
mystic plank
knotty juniper
tame topaz
#

There's many ways to do anything. Figure out what you're wanting to do and break it down into the steps to recreate.

mystic plank
#

okay so much thanksss

#

I have an other problem but is fir the Physics channel

#

haha

#

I mean how I make this in unity

spark crystal
#

how can I tweak the 'reflectiveness' of a material with shader graph? this is how my character looks under the sun

#

and this is how I want it to look instead

toxic flume
#

The best efficient way to have intersection lines (objects) is to use depth map?
I want it for the whole scene
android devices

brittle owl
#

how do i do custom lighting in hdrp?

#

just trying to get the main light direction and shadows

soft harness
#

so I have this code that generates a little cone around the light, but there's a bit of a problem, it doesn't exactly work with shadows. I tried multiplying the alpha with the atten, but that doesn't work

grand jolt
#

Does anyone knows a method to sample a cubemap that takes an origin and a direction instead of a direction only?

#

I know this may sound odd, since the cubemap has no physical size

#

But that could be an emulated size

lean grove
#

Hello, I'm looking to do an effect like Doom Eternal glory kill highlight

#

It looks like it is a material that overlays the enemy materials and it's activated when the enemy is close to dead

#

How can I do that? Having a material overlaying a render that already has it's materials

#

for context:

#

Or should I just add this logic to ALL shaders/materials?

junior iris
meager pelican
#

Or just swap the material on the object in C# side

lean grove
#

But ideally I just want it to overlay

meager pelican
#

You can set a material every frame.

lean grove
#

adding one material will create an overlay?

meager pelican
#

Sure. They're drawn in order. Mat0, Mat1...

#

But if you do that, you basically render the mesh twice. Generally not a great idea.

#

So make a shader for no-effect. And then make a shader WITH the effect, and pass the same textures so you have the base colors. At least that's one option.

Generally with shaders, your goal should be to draw each pixel ONCE and only once. That's an ideal, not a reality. But still...

#

Or just pass the option to use or not-use to the shader, and turn the effect on/off. And then you don't have to swap anything, just set the effect "switch" on or off.

lean grove
#

Got it

#

But this would mean I have to duplicate all the marerials / shaders that I have

#

right?

vocal narwhal
#

If you're using a render pipeline you can also make a draw objects pass that will apply a material to something on a specific render layer at a specific point in the rendering process

#

All without writing any code

meager pelican
#

There is no one answer, only many possibilities. So think about it.

#

The wall behind the demon probably doesn't need that shader effect. But most all demons probably do.

lean grove
#

Exactly 👍

meager pelican
#

And you could make the effect a sub-graph if you're in SRP land.

#

Or an include in standard.

lean grove
#

Need to explore subgraphs. That’s probably the path I’ll take.

#

Can I use subgraphs on non shader graph shaders?

meager pelican
#

Nah

lean grove
#

Hmm

#

I think the extra material will be the viable way as a solo dev 😂

#

If my mesh has multiple submeshes, how can I add one material to overlay all submeshes?

junior iris
#

Ideally in this case you'd store all your submeshes in an array or similar and then go through it.

lean grove
#

Ok I’ll check it out 🙏

#

Thanks!

meager pelican
#

Do a simple test case. Take a model, add a 2nd material to each mesh that does some kind of blend/overlay with an input color. Make sure it works throughout your workflow (animation, skinning...).

#

The thing is that that 2nd materiel won't know much about the first material if it's 2 separate materials. It depends on what you want to achieve.

#

@lean grove

lean grove
#

👍

#

I'll experiment with this, I have a lot of ideas 🙂

meager pelican
#

I'm exuding optimism. 🙂

#

Shaders are fun.

left stump
#

i wanna commission someone to change a shader from a color RGBA to a Texture

#

anyone interested?

vocal narwhal
left stump
#

Thx

warped pike
#

Hey, I am trying to use the cubemap shader (6 faces) to render skybox in HDRP, I used this:
https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@7.2/manual/Creating-a-Custom-Sky.html

In order to customize the skybox, but when I try to use this shader:
https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/Skybox.shader

(And of course cleaning the errors / warnings if there is any, *even tried outputting red color for everything)
But there the result is just a black skybox, plus, the renderer doesn't clear the buffer, so the rendered objects seems to be not cleared and leaving a trail

GitHub

Unity Built in Shaders. Contribute to TwoTailsGames/Unity-Built-in-Shaders development by creating an account on GitHub.

#

Is there something I am missing in order to achieve this kind of effect? It seems like HDRP broke the shader I made for the skybox

vocal narwhal
#

Are you trying to use the built-in skybox shader for HDRP? I'm not sure I understand how the second shader is relevant

#

if you want a different shader you'll need to port the logic to the HDRP sky shader example they provide in the custom sky example, something that's HDRP-ready

meager fable
#

do i get this error because of i am not using lts version ?

#

or is there something to fix this

warped pike
#

@vocal narwhal I needed a shader that render 6 faces of the cubemap, the second link is the shader that used to do that (in URP and standard), and it worked fine, now it doesn't (probably because as you said, the shader needs to be HDRP-ready), the problem is that I am not sure how to convert it to be working with HDRP

vocal narwhal
warped pike
#

@vocal narwhal Actually yes, I am writing to the depth buffer + use the alpha there

#

and I am rendering sprites in the same shader pass

#

(Those needed to be rendered that way)

vocal narwhal
#

The sky shader in the "Creating a custom sky" takes a cubemap, is there an issue with modifying that shader?

warped pike
#

@vocal narwhal I am trying to achieve this right now, will update

vocal narwhal
#

I cannot be of more help, but if you do have issues, #archived-hdrp tends to also be a good place to go for pipeline specific shader issues, as long as not crossposting it can be good to try there instead.

drifting lance
#

hi

#

when i upgrade my project to URP

#

shader doesnt work

charred wing
#

Ok you're giving almost no context, and technically that is a statement not a question

#

Where is the shader from? etc.

warped pike
#

Hey, I had a shader with 6 passes in standard/URP, which each pass is assigned a face for a cubemap, which somehow Unity does automatically, in HDRP, it doesn't seem to be happening, AND the only pass that get's called is the second one, every other pass is ignored, any idea why?

grand jolt
#

guys I would like to use unity's shader graph but I don't think it's available for the standard built-in render pipeline, is there any way I could use shader graph?

fathom temple
#

pool

paper oar
tame topaz
#

@paper oar Don't crosspost please. If someone can help, they will.

grand jolt
fathom temple
# grand jolt what?

I'm so sorry, lol I probably accidentally typed that when trying to google stuff, did not mean to type that here 😆

white cypress
#

Upgrade to srp or dont use shader graph

shadow locust
# grand jolt guys I would like to use unity's shader graph but I don't think it's available f...

Get the Amplify Shader Editor package from Amplify Creations and speed up your game development process. Find this & other Visual Scripting options on the Unity Asset Store.

#

Costs $$$ though

grand jolt
grand jolt
#

but I have one more question

#

I'm pretty sure shader graph supports HDRP, i tried switiching to HDRP and my game went from 200 - 400 fps to 60 - 90 fps and my gpu was starting to heat up

#

Im using an rtx 2070 super btw

#

Why is HDRP taking so much performance? and is there any solution?

quiet flume
#

Hey all. I am trying to figure out what I would need to do to achieve this effect. Essentially I want to make a cube or a plane that's transparent and anything inside/behind the cube would be dimmed a little bit based on some slider value. Is this some kind of stencil shader? What modules should I be looking into for the shader graph to achieve this?

meager pelican
#

"inside" is logically different than "behind", so you should pick one. But...
Stencil works for "behind", in a post-processing type of thing. Could be custom render pass, I think.

Inside is a volume calculation, so that's different. Like if green grass behind the cube is not dimmed by the top of the cube, even if nothing is inside it. You could do that too but you have to compute the worldspace coordinates of the pixel, and see if it is in the bounding box.

subtle garnet
#

hi, can someone please help me on something? im porting a shader from unity to GLSL and thres a special operator that im not really used to

``` (*color* is a half3)
that ">" in the end is doing what to *colors*? isnt ">" suposed to a comparisson operator?? what i can switch it to?
meager pelican
#

It is a comparison. That code doesn't seem to be a good way to do it, IMO.

But that expression (color < 0.5) is a boolean expression, and would return 0 or 1 (false or true). And then the result of the lerp would return either C_u or c_d, it's not really lerping.

Better to use an expression like:
half3 final = (half3) (color > 0.5) ? c_d : c_u;

#

I haven't tried that and the cast may be weird.

subtle garnet
#

ahhh ok, tysm helped a lot

meager pelican
#

The question is "Is lerp faster than the ternary?" considering both have to evaluate the expression anyway.

#

I suspect it is not. YMMV though.

subtle garnet
#

yeah its a bit confusing... i substituted it with a + before and it seemed to work fine too so yeah

quiet flume
shadow locust
#

It will run faster in a build.

meager pelican
# quiet flume so I think for the sake of simplicity I would lean more towards behind. just bec...

Oh, then you'll want to do it before the skybox or filter that out with a distance check somehow.
But yeah, if you stencil the box, then you can "just" darken the pixels or do whatever with a stencil-aware pass kind of like a post-processing for opaques. Not sure off top of my head how to insert that pass, but you could do it with things like command buffers or maybe URP has a setup in its render features that will do it, maybe full screen.

#

Like "After rendering opaques" and as a full-screen-quad:

meager pelican
#

What's a vector3.zero normalized?

#

oh, wait.

#

Saw the parens.

#

lol

#

There's no need to subtract the zero vector. It's like saying 42 - 0. That's just 42.

#

They're hardcoded zeros though. OK, place holder

#

So the 0,0,0 represents the center of your planet. And the point coming in is the terrain's point (well, vertex point).

#

So that gives you, for each vertex, a "normal" that is relative to the sphere. I guess. So it's a set of spherical-normals for the 3 verts. Then you want to figure out what the "steepness" is.

#

But regardless of the planet being spherical, you should have a normalized lighting of the triangle itself. Relative to the light.

#

So some self-shading would work. I would think. And that's an Normal dot Light-Dir type of calc for the triangle.

#

Sphere or not.

#

OK, but a triangle is a triangle. Maybe I'm not catching what you're doing. Is your lighting 360 degrees?

#

So it's directional.

#

So a triangle is a triangle.

#

Shaded relative to that.

#

So for the 3 points, you can calc the normal, or you already have it.

#

Sec

#

Well, you can interpolate them. Or you can calc a flat normal for the triangle from the 3 verts.
That is float3 normal = normalize(cross(v1 - v0, v2 - v0));
where v1-3 are float3's in HLSL (or Vector3 in C#)

#

Try just plugging the mesh's vert normal straight into the normal in the vertex stack. Does that not work? (would be smoothed shared normals I think, depending on how recalc normals worked. Maybe it would end up flat. Not sure, may depend on if you shared verts in the model or didn't).

toxic falcon
#

can you set a shaders albedo to a scriptable object data point and it changes each frame?

meager pelican
#

But that's not really a shader issue, in and of itself.

#

Try general code if that's what you're after (I'm not sure). Shaders have color properties

sinful veldt
#

anyone know why i cant update deprecated shader?

grand jolt
#

my gpu is running at 100% usage

grand jolt
mental bone
#

Dont know about the bake times but you should use the profiler and frame debugger to see what is going on.

toxic flume
#

The best efficient way to have intersection lines (objects) is to use depth map?
I want it for the whole scene
android devices

modest fern
#

Hey got a question - I recently came across this PR on the unity Github. It is supposed to add Shader graph support to the default render pipeline. Does anyone know if this will be merged in a point release or a major release?

https://github.com/Unity-Technologies/Graphics/pull/4283

GitHub

Purpose of this PR
Update the built-in target main branch with latest master (620dbe2 as of this edit).

Testing status
Kicking off yamato jobs for foundation and lighting (see checks below)

Comme...

vocal narwhal
#

Nobody knows anything

modest fern
#

There is no spoon

vocal narwhal
#

Shadergraph is a package, so you would presume a major release of it. Whether they've had to modify the engine that much for this, maybe someone else knows

modest fern
#

Got it 🙂

grand jolt
turbid hamlet
#

or is there a better way to get ps1 graphics with urp?

proud anvil
#

when you define certain properties in a shader (the Shaderlab part), what exactly is the function of the curly braces after the initialization?
Example:

_ExampleName ("Texture2D display name", 2D) = "red" {}```

You'd think this would say but it doesn't https://docs.unity3d.com/2020.1/Documentation/Manual/SL-Properties.html
I'm trying to really _understand_ ShaderLab, but the documentation doesn't feel complete
#

I actually figured this out from some legacy documentation. It's an options object that can contain some options about textures

meager pelican
#

It's the default value if left blank.

#

It has to be initialized to something, so you specify what that is.

#

The braces are due to it being a texture object, I guess.

#

That works for other texture-type objects, such as a cubemape too.

#

That's distinct from other things, like vector, which uses (1,2,3) notation.

#

Or simply a float 1.01

#

So you'll see things like _ExampleName ("Example vector", Vector) = (.25, .5, .5, 1)

You'd think that the "red" would go inside the braces but it doesn't.

bitter forge
#

Whats the correct syntax for returning a fixed sized array in hlsl? (I tried googling)

#

I'm trying to return float3 fv[4];

#

float3[4] function( complains

low lichen
#

float3 would be vec3 in GLSL

#

@bitter forge It's not possible to return an array from a function in HLSL. Best you can do is an out parameter:

void function(out float3 array[4])
{
    array = ...
}
bitter forge
bitter forge
meager pelican
#

Generally, a return value of a struct is used for MRT's.

#

IIUC

#

Why would you want to return multiple values outside of MRT's?
What you'd usually do is store data in a texture or some such. Set a structured buffer's value.

#

Remember this stuff is bound to hardware stages. Outputs end up in render textures/GPU buffers.

low lichen
meager pelican
#

True. Then use the "out" modifier.

#

As you said.

sinful veldt
silver moat
#

Hello there. I am using HDRP and I would like to triplanar-ly project a grid from within a shader, but the triplanar node seems to only allow a texture for an input, which I don't have. Is there any workaround to turn the output of a node into a texture-like node, or a better way of creating a triplanar projection?

#

Basically I've got this, which I would like to apply triplanarly.

molten violet
#

Does anyone have an idea on why my preview differs from the editor and game?****

autumn girder
#

Do you guys think it's possible to make a "Field of view/line of sight" effect in 2D using only shaders?

autumn girder
#

Oh, that's the tutorial I followed for my project. It works perfectly.... Except that since it uses a URP forward renderer instead of the 2D one, I can't use lights in the scene. Which is why I asked if it would be possible to do it using only simple shaders, so that I don't need to use the forward renderer.

#

I have searched the web everywhere I could think of and got no closer to a solution

autumn girder
#

Sorry I saw all of this now, but thank you so much for sharing your knowledge! This is a huge help!

merry garden
#

Getting started with shader graph 2020 version 10 and doin some tests to try it out

#

trying to follow along with online tutorials but most of them involve a step connecting a node to their master's albedo input

#

However, theyre using older versions with PBR master

#

and the newer versions (iirc) got rid of PBR and merged it into lit

#

basically Im trying to find the albedo input and have no idea where to look lol

regal stag
#

Albedo is Base Color

merry garden
#

Gotcha, that was what I was thinkin

#

thanks!

#

honestly, the switch over to the newer version has left a lot of tutorials Ive been using extremely hard to read since lingo and terminology has changed/options have switched places, etc.

simple jolt
#

Does someone here know how to go about applying a 2d texture to a raymarched shape?

simple jolt
#

@grand jolt I'm relatively new to all this, do you know of any links that could further help me with what u described?

merry garden
#

workin more with the shadergraphs and tutorials are asking to call upon a main light node, which does not exist in newer versions

#

how would you call that in newer versions?

regal stag
merry garden
#

I can send a pic of what theyre using for reference brb

merry garden
#

thanks for pointing it out, wouldve kept lookin for it if not for u

simple jolt
#

Thank you very much

prime pasture
#

Hey, anyone tried writing to SV_Depth with HDRP? I tried using it and it doesn't seem to work for me, any idea why? (used ZWrite On).
I tried setting constant values to it but it doesn't seem to make any effect

meager pelican
prime pasture
#

@meager pelican Sorry for not giving more info:

I have 3D plane facing the camera (blocking the view), behind it are some objects, I want the objects to be visible on some parts of the plane (controlled by the shader)

#

What I have tried is outputting from the fragment shader, SV_Depth values of 0-1 (and higher and lower) to see the results, but the result still is the same no matter the value

#
FragOut frag(Varyings input) : SV_Target
{
  // ...
  output.depth = 0.0; // 1.0;
  return output;
}

Something like that.

meager pelican
#

It shouldn't be a void return.

prime pasture
#

ops, just a mockup

meager pelican
#

But you don't want to alter the z value to do what you want....I don't think.

#

Maybe think about it as "what shows through the semi-transparent plane". You can draw the plane in the transparent pass even if the pixels are opaque. But I don't know what you're really doing (yet). Somehow you may need a stencil to tell if a pixel should "show" or not.

prime pasture
#

The plane has a texture, which is used as a background, I want some parts of the texture to be visually in front of other gameobjects

#

I used it in URP and it worked great

meager pelican
#

HDRP may be using its own depth texture.

#

For example

prime pasture
#

Oh, didn't think of that

meager pelican
#

Doesn't matter. I don't think you want to alter the z-value, just to "see" it.

#

How do you tell one type from another?

prime pasture
#

Actually I don't need to, I only have 1 background and it has its own shader, the others use the built-in shaders

meager pelican
#

But somehow, you decide to alter the z-value or not, right?

prime pasture
#

right

meager pelican
#

Well, how do you decide that? Is it an attribute of the object?

#

Can you use a stencil instead?

#

Then just clip the pixel on the plane if the stencil is set.

#

That let's you do an "early stencil" test. Won't even run the frag().

prime pasture
#

I'll test that out thanks!

distant sleet
#

Ahhh god alright so

#

Im trying to make a raytracer and later a raymarcher in HLSL and C#

#

So for that I would like to pass gameobjects into the compute shader to compute their intersections and draw them

#

Currently I have game objects with a script with all of their parameters

#

I was able to easily pass the radii of spheres from C# to HLSL but Im struggling with the positions

#

Ideally it should be an array of float3s with a variable length

#

So what I have is a list of all the gameobjects in the C# code

#

and I would like to pass all their positions (x,y,z) from C# to HLSL

#

I also want to be able to add spheres to the scene

#

What would be the best way to approach them?

grand jolt
#

Hey, does anyone have an overrender shade that doesn't overlap itself? i can't seem to find one anywhere

distant sleet
#

I give up on making the number of spheres changeable

#

Its gonna be 50, but I still cant figure out how to send all the positions as an array fo float3s to the compute shader

#

Do I just do List<float[]>.toArray()?

meager pelican
#

@distant sleetCheck out Structured Buffers and SetBuffer().

distant sleet
#

Ill check it out, I saw it and didnt know itd apply to this

#

Thanks

#

Still tryna figure out how to push float3s

meager pelican
#
distant sleet
#

I saw the first one

#

Its what Im following lmao

#

Before I tackle raymarching

#

Didnt see him passing in GameObjects in part 1

#

lemme see 3

meager pelican
#

He does it, and has an "IntersectTriangle" routine, but it's brute-force for all tris in the scene.

distant sleet
#

Ahh I see

#

Ill tackle it later

#

for now Im just doing an array of 50

#

But is there a way to just pass float3s? Because I'd rather stick with that

#

For now atleast

meager pelican
#

In the end, a structuredBuffer is just a block of memory. IT can be read-only or read-write. You could see if you can find a way to pass a CBUFFER (constant buffer) and benchmark if it is any faster. But IDK.

distant sleet
#

I see, yeah thats waht I understood

#

Ill try that lor raymarching definetly as efficiency is needed

meager pelican
#

The nice thing about SB's is that they're not fixed size at compile time.

#

So you don't have to hard-code things like "50"

distant sleet
#

Oh i figured out float3s btw

#

So Ive linked all the spheres to gameobjects whcih is nice

#

but buffers are better for raymarching

#

But for some reason only 1 sphere is working, Ill figure it out

meager pelican
#

It all depends on what you're doing. If you describe the whole scene mathematically, like with SDF's, that's different than shipping up geometry and intersecting it. But the nice thing is that spheres are "easy". I implement them in a special sphere buffer and then use editor gizmos to draw them on the unity side in the scene. So they're always perfect SDF type spheres.

#

But the rest is usually mesh geometry.

distant sleet
#

Yeah with raymarching I can add a lot more meshes

#

so Im using only mathematical expressions, not triangles

meager pelican
#

Have at it, and have fun! 🙂

distant sleet
#

Thanks!

#

Ive managed fractals and raymarching before

#

In native java

#

this time I hope I can get it realtime

distant sleet
#

I am still confused about the SetFloats function

#

it states :

#

" This means that the the array elements must be aligned on float4; for example, float4 data requires no padding, float3 data needs one float padding for each element, float2 data needs two floats, and so on."

#

What does float3 data needs one float padding for each element mean?

indigo frost
#

so i have a general newbie question about meshes

#

and i'm not entirely sure if this is the right channel for this... but i figured i might as well ask...
Basically, so far i have the knowledge from watching and reading tutorials online that everything is rendered in triangles ~ polygons basically.
So it was only recently that i noticed that almost every ( if not every) mesh has X amount more triangle than vertices?
How is that possible, when we know that a triangle requires 3 vertices, but in this case, there are many more triangles than vertices, even for a simple plane mesh?

regal stag
sinful veldt
#

how can i stop my objects changing color when i change skybox color? does it has something to do with the skybox shader?

indigo frost
# regal stag Neighbouring triangles can share vertices

That makes sense, but my original thought was that there is extra vertices to accommodate the fact that there need to be more information for the normal vectors of the faces
I'm not sure how to works, i'll probably have to check it out.

regal stag
# indigo frost That makes sense, but my original thought was that there is extra vertices to ac...

That is correct, if normals (as well as uvs or vertex colors) do not match there may be more vertices in the same position. A plane all has the same normals though so can easily share the same vertices.
For more 3D models, the vertex count will change when imported into unity depending if the model is "flat" or "smooth" shaded. Smooth meaning the normals are averaged for all connecting faces/tris so can share.

indigo frost
#

I see

#

that makes sense

regal stag
spare wedge
#

Hi, it seems like when I create a material with the hdrp/lit shader I have an option that I can control called based uv mapping that I can change to planar, I've created a shader (with shadergraph btw) and I would like to have the same option is there a way to do this ? thx for your answer

regal stag
# spare wedge Hi, it seems like when I create a material with the hdrp/lit shader I have an op...

For planar mappings you can use the Position node (probably Absolute World space). Split and take two of the axis into a Vector2 node (which ones depends on the axis wanted. R/X and B/Z would project from the Y axis for example).
Can then use that in nodes with a UV input, like Sample Texture 2D. If you want to control it from the inspector you'd probably need to use a branch or keywords to switch between them.

meager pelican
# distant sleet I am still confused about the SetFloats function

Padding is just extra filler to meet a required size. D3D/HLSL specs demand a size of float4 multiples for the ComputeBuffer.SetFloats() function to set the data in the buffer.

So use a float4. Better yet, instead of unused padding, pack some other data in there. You can also have a struct with 4 floats in it. Or 2 float2's or whatever, but keep it at 4 x float boundary sizes.

distant sleet
#

Ahh yeah Ill just use a float4

#

Thanks!

silver moat
#

Hello there. I was wondering if there was any way to implement a "supersampling" effect when making a procedurally generated shader without a texture.

#

I can't quite wrap my head around as to how to do so...

low lichen
#

For each pixel, divide it and do the calculations on the divisions and then average them together?

meager pelican
#

Off the top of my head, since it is computationally generated ?mesh? (you don't generate a shader) or ?texture? you can sample pixel offsets. Imagine that you're sampling at pixel centers now. So integer-pixel-location.xy + (.5, .5), you could also sample at, say, So integer-pixel-location.xy + (.25, .75), and +(0, .25) and + (.25, 0)....

paper oar
meager pelican
#

@paper oarIDK much about AR but I can tell you you'll want to get the camera feed (probably via API) and then use the AR toolkit to blend your shader over that. Not blend that over the shader. At least I think. I'm sure someone will chime in. May take a bit.

little fossil
#

hi anyone knows how to write simple sprite 2d shader i just want to swap colors, sprite itself will be white and i just want to change color like it sarts full red then becomes more and more blue in example picture its going just down but like for me direction is not even locked it can be any direction just to look nice.
Something that i can feed just colors and it will swap to next and next ...

paper oar
#

the thing is - there is no ar tolkit on that platform

meager pelican
#

So you're screwed.

paper oar
#

@meager pelican there is only camera - thing of that plarform as a webgl

#

you have video

#

but you need to manually blend in the Unity camera

#

into it

meager pelican
#

If you can get the render texture, you can overlay on top of that with a camera. Or manually with a blit-combine. But AR toolkits do magic things with issues like worldspace depth from photos.

#

@little fossilWhat pipeline (I know you're going to say URP, I can almost feel it coming, lol)

little fossil
#

i dont even know waht URP is but am using Unity2018, prefebly some shader that will work on mobile

paper oar
#

what I have right now = 2 camera setup - one camera purely for streaming with renderteture and it sees on the far back - a renderer of the webcam - it works as you've desribed - the problem is - my render is too far away an when object shold sit on the surface - it is not sitting in properly

#

@meager pelican

meager pelican
#

"sitting" comes from the AR toolkit that you don't have.

#

I think. Not an AR expert.

#

Maybe someone else will know. 🙂

meager pelican
little fossil
#

yep 2d for sprite

meager pelican
#

Note that sprite colors usually come from vertex colors.
But you look like you want to override that anyway.

You can get the built-in shaders for your version of unity here:
https://unity3d.com/get-unity/download/archive

Unity

Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.

little fossil
#

that answer for me right, ok will check ty :)

silver moat
little fossil
#

@meager pelican you gived me link for downloading unity??

meager pelican
#

So you want to do your own anti-aliasing.

#

So "jitter" it and average the results.

silver moat
#

Yes, I was wondering if I could do such math within the fragment shader itself

meager pelican
#

You do it now, right?

silver moat
#

I do it now? I don't get what you are asking but, yes I do have the shader made. But when I look at some object with a material using said shader from far away, it looks... well, like how you would look at something with 0 mip-maps, a mess to the eyes

#

What I am using thus far to generate the pattern is the UV that comes with the object, which for the moment are cubes/cuboids even though I want to try projecting it from above later

#

I keep searching for how to implement antialiasing on a fragment shader but every example I have seen implies that I am using a texture

little fossil
#

hmm am kinda confused now

#

what shader i need to create, anyone know some tut about 2d shader for swaping colors

meager pelican
#

@silver moat I see. Yeah, you're probably dealing with anisotropic filtering issues too.

silver moat
#

Ok, to illustrate a bit further

#

This is the pattern my shader generates

#

When I look at it from far away, however, it stops looking so nice.

#

At least compared to, say, the floor, which comes from a textured material

meager pelican
#

Are you mapping that to anything round? Is it alway square?
To tell you the truth, you're better off generating that to a texture. Mapping the texture to a quad. And then letting the GPU deal with all that stuff...mips and anisotropic stuff...in silicon. It's built for that.

But YOU and your shader could still generate it.
That make sense?

silver moat
#

So what you're saying is... what I should do as a workaround is to output the shader into a texture, like a render texture, and then use that?

meager pelican
#

Yeah. It's not a workaround, it's a design feature. 😉

silver moat
#

That is indeed an option

meager pelican
#

But you can set the iso level on the texture filtering, and the mip levels.

#

And it will auto-magically work.

silver moat
#

I know, I know

#

If I don't manage to find the way I want to make it, I might try that in the end, then

#

I just wanted to try and make actual procedural textures without shader, like

meager pelican
#

It's a 1000 times faster in silicon.

#

It does all that stuff as part of the pipeline.

silver moat
#

I know somehow shadergraph has to enable it as output (I am writting my own fragment here, not shadergraph) because when I tried to do a grid, it applied filtering there

meager pelican
#

Screen space derivatives and stuff.

silver moat
#

Yeah but I don't understand how to apply those, is my issue

meager pelican
#

You can set sampler options.

silver moat
#

Sampler options?

meager pelican
#

In the sampler state. In SG

silver moat
#

I am not this well versed in shaders

#

Ah you mean Shadergraph

#

Yes, but thus far I have been NOT using Shadergraph

meager pelican
#

Yeah, or in the shader for vert/frag too.

silver moat
#

🤔

meager pelican
#

I'd have to look it up.

silver moat
#

And I'd have to go get dinner

#

Anyhow, I'll investigate further, thanks for the commentary

meager pelican
#

Read up on texture samplers.

#

enjoy dinner. 🙂

little fossil
#

hmm, can i now get help?

meager pelican
#

@little fossilWhat is the question? did you find their 2D sprite shader?

little fossil
#

no

#

@meager pelican there are standard shaders but duno how will it help me with my problem

#

i want to colorize white square betwin 2 colors

#

so i give my shader Red is your atm color move to blue like on img, ofc ower time

#

dont know how to split color a square

#

if i would know how to do that i can allwes change some variable to collor it full or half or change color

silver moat
#

Oh god

#

You're trying to do what the TF2 developers did for a color sprite

#

Which was featured in a video analyzing such code

#

You're probably asking to make an unlit shader, making it so that the fragment shader handles the input of the 2 colors and the angle

#

You can work it out using the UV of your square, if it will always be a square, and working from the coordinates then

#

The lower left corner would be 0 0 and the upper right 1 1, and so you can write your own fragment shader to multiply the texture you're sampling depending on the values of X and Y

meager pelican
#

Start with the standard sprite 2D shader. But in your own shader.
Then in the frag(), decide on the color based on the Y value, like Naxum just said. Or whatever you want to do. But you want to start with a sprite-shader base, basically.

silver moat
#

Quick and dirty example of what you might want to try is this, I think:

#

(the line where col is declared is to be ignored, it's what the template had)

little fossil
#

ok i think i know maybe what you all takling about :)

normal sable
#

Hey guys! I made this question some time ago and I couldn't find anywhere something that could help me. So, rephrasing the question, in URP how I can inject a shader pass to ALL scene materials with clip function in a custom dissolve effect. This is different to Render Objects feature, as it re-renders each object in the scene with the specified material.

grand jolt
#

Hi, anyone knows how I can apply a shader to a UI image so it's like an overlay to the Source Image and not replacement?

#

(using URP)

#

nvm figured out, duplicate the element, apply the shader with aplha

silver moat
#

@grand jolt alternatively, use only a material and no image. You can put the "image" texture (not sprite though, must be texture) into the material as a parameter.

grand jolt
#

I think its better to keep 1 mat and simply dupe the images

silver moat
#

But are all of them going to need to have the filter itself?

#

Like, the overlay?

grand jolt
#

yeah

silver moat
#

Sounds rough, good luck with it

grand jolt
silver moat
#

Oh I see what you mean

grand jolt
#

🙂

grand jolt
#

@silver moat this is what I was aiming for. Thanks for trying to help. Much appreciated.

silver moat
#

Pretty neat

meager pelican
#

The normal is the pixel location relative to the center. So take one world-space location and subtract the other, depending what direction you want the vector to point. (Inside or outside). Normalize it.
float3 theNormal = normalize(WSCenter - WSPixelLocation);

#

Or the other way around.

vagrant fossil
#

Hello

#

I need help with a shader which I need to be self-illuminated and there is no way to make it self-illuminated.

meager pelican
#

None of that is what I said. Nor what you asked about before.

#

You asked for a normal. I repeat:
The normal is the pixel location relative to the center. So take one world-space location and subtract the other, depending what direction you want the vector to point. (Inside or outside). Normalize it.

float3 theNormal = normalize(WSCenter - WSPixelLocation);

Or the other way around.

rare charm
#

I know almost exactly nothing about shaders so bear with me. I have a UI Panel that I want to use as a filter so everything I see through it is black/white. But I can put stuff between it and the camera and it won't be black/white. Kind of like looking through a monochrome window. Is that the right way to do it and what do I do to make a shader that accomplishes it?

#

The panel will always cover the whole camera, so I expect I'll start with a grab pass, but after that I'm lost.

meager pelican
#

What pipeline are you using?

rare charm
#

With pixel art I don't have to think about thi stuff lol

#

Whatever the default is, and if there isn't a default i don't know

#

but I'm happy to find out

meager pelican
#

So I assume standard pipeline. So, good, you can do that grabpass you were talking about.

#

To output the B/W color, there's a formula. I think there's a macro for it too.

#

But the code goes something like:

rare charm
#

Do I use a standard surface shader?

meager pelican
#

IDK off the top of my head for UI, probably something UI-ish.

#

You should research, because I'm going to bed. :p

rare charm
#

I made a few shaders ages ago in Blender but everything is much different than 10 years ago

meager pelican
#

Google it please, it will save me the effort. There will be links.

#

So find a UI shader.

#

Then:

#
  1. Do your grabpass
#
  1. Apply the B/W formula to the background you got from the grabpass.
#

Unless UI already gives you a background, but I don't remember that. I don't do too many UI shaders.

#

The formula is (looking, sec):

rare charm
#

wait I forgot shader graph is a thing

meager pelican
#
inline half Luminance(half3 rgb)
{
    return dot(rgb, unity_ColorSpaceLuminance.rgb);
}

// Convert rgb to luminance
// with rgb in linear space with sRGB primaries and D65 white point
half LinearRgbToLuminance(half3 linearRgb)
{
    return dot(linearRgb, half3(0.2126729f,  0.7151522f, 0.0721750f));
}

These are in UnityCG.cginc (may vary on your version).
Note that it is different for linear color space vs gamma space

#

Then do it with nodes if you use SRP/SG.

#

I think there might be a node for that already.

rotund flame
#

Hello all. I am working on a game using 2Dlights and 2d sprite lit and unlit shaders. When i cook the game for playstation 4 and test the game on the console, all my shaders appears as purple boxes, and i cant see the 2d lights either.`I added the 2Drenderer to my universalrender pipeline, but i don't know if i miss something. Someone has info about it?

clever saddle
#

Hey,I just started to learn shader,but I knocked into a problem on the first day

#

Why I click the plus button but it doesnt work?

vocal narwhal
#

ShaderGraph currently only functions with URP and HDRP, so you need to have either of those installed and configured in a project

indigo frost
#

Is it possibleto achive something like per face shading?

grand jolt
#

Greetings, I'm experimenting with the position node from shader graph and I'm not sure if this is intended but the texture that I want on my object is being tiled heavily, it's a large texture 2048 and also tried 4096 but both tile beyond my screen resolution which seems strange, appreciate the help

#

I tried all the different settings under the position node and World seems to behave somewhat like I expected aside from the tiling issue

hearty stump
#

@indigo frost you might want to start with a triplaner shader and expand on it.
It will require a lot of calculation from the vertex to fragment but if you are familiar with matrix calculation it will help you out.
Because for each face you will need to get the verts that's making that face and color it based on those verts

meager pelican
#

@grand joltYou don't usually feed position into the texture mapping routines, you feed the UV coordinates.
Try deleting the Position node and letting it default to UV0.
Then the tiling and offset variables will control...well...tiling and offset.

#

Position is the object's position in some-space. Such as world-space location in the game world.

#

Unless you're trying to map textures to worldspace.

grand jolt
#

@meager pelican Thanks for the reply, the reason I was going this direction is due to damage I want to project onto the surface, this needs to have the same section of image otherwise it looks really bad, previously I was able to mask using some python code but I've moved from metallic surface to fabric and the same approach isn't viable

#

Here is an illustration of what I'm trying to achieve and the result so far (I change the projection color a bit for example purpose)

meager pelican
meager pelican
grand jolt
#

No I want to remove the tiling hehe

meager pelican
#

Did you try deleting the Position node?

grand jolt
#

Without it looks like this

grand jolt
#

Which is to be expected since now I have a large surface and small one each with the same texture

indigo frost
#

i did look it up and i landed on this little thing

#

but i'm not exactly sure the math behind it

meager pelican
#

Triangle normals from derivatives! Good. Cool. That'll work.

#

It's taking the DDX and DDY (change in x and y position) of the triangle, and doing a cross product and transform of them to build a normal vector relative to the pixel. Basically DDX and DDY come "for free" because the GPU tracks that stuff to figure out mip-mapping and stuff.

#

So it "knows" the adjacent pixel's results and the current pixel and can tell "the slope".

indigo frost
#

I still don't think i understand it just from this

#

Maybe something visual to help me paint the picture would be better

#

but that is besides the point here. we got it to work, even though i don't understand it fully, but it still doesn't really look like i want it to.
I know i am asking for a lot but, can you maybe give me a few pointers on how i can get my result to look like the thing i want?

#

This is mine:

#

and this is my goal:

meager pelican
#

Hmmm

#

The top one (yours)...I can see wrinkles in it. Is that due to the normals you calced?

#

The bottom one (goal)...is more like overlapping blended triangles.

#

Not really normals.

indigo frost
#

I'm not sure about the bottom one, i have no idea how it is achived

#

i just looked it up on google and decided it looked cool and i wanted to basically remake it for some UI stuff

#

i wanted it to feel alive so here is what i did

low lichen
#

@indigo frost Is this closer to what you want?

indigo frost
indigo frost
#

the mesh i made in blender

#

and did some random transform on the verts

#

Again, i'm new to shaders and this stuff in general

meager pelican
#

The goal-one is layered. If that's what you want.

indigo frost
#

so i do appreciate all your help

#

like alpha blended?

meager pelican
#

Like that. IDK how they did it exactly. Maybe with 20 different examples we could figure it out.

#

But it doesn't matter.

#

You want something that you like the looks of ("Looks cool").

#

Do you want it to dynamically change based on lighting?

#

Like changes when it moves, or the light moves?

indigo frost
#

I'm not sure about lighting

#

it's not necesarry

#

it's main goal is to serve as a UI background

#

Basically either is fine

#

But mostly, yes. Something that has vertex displacement and looks dope

meager pelican
#

Is the texture available (not copyrighted?, or you don't care if it's not commercial project or you're just messing around?)

#

You could just use that texture as the background directly.

indigo frost
#

texture?

meager pelican
#

The pic you just posted (the goal pic).

indigo frost
#

There is no texture here....

meager pelican
#

That's a texture.

indigo frost
#

It's just a random google serach image

meager pelican
#

Yeah. texture. 😉

indigo frost
#

Basically something simular

#

not a 1 t o 1 copy

meager pelican
#

I mean, you can make a texture in a graphics editor and map it to your BG

#

It all depends. If you don't care about lighting...why modify verts and do calcs?

#

Do you want it to move or change?

indigo frost
#

I don't want it to be static

#

i want to "move"

#

not in x,y or z

#

but basically up and down, so the lighting on each face changes and so does the color accordingly

#

that was my approach

#

this

meager pelican
#

OK, so you DO care about lighting!
See the image @low lichenposted above?

indigo frost
#

mhm

meager pelican
#

OK.

indigo frost
#

Like i said

meager pelican
#

The first one you posted (goal) was layered.
This one you showed is moving.

#

Not layered.

indigo frost
#

i used lighting because i HAD to

#

not that i need it

#

i just had to use it to achive that effect

meager pelican
#

I get that. But there's either layers or not.

#

Let's start with one layer.

indigo frost
#

ok

meager pelican
#

Then we could theoretically add more layers on top. And blend

indigo frost
#

Mhm

meager pelican
#

So you want to do your vert displacement like you're doing, based on some displacement texture. And you're going to change the offsets of the displacement over time, scaled by some rate. Or recalc the displacement somehow.

#

Then you can use the lighting calc to get the lighting value per triangle.

indigo frost
#

Ok

meager pelican
#

I can't quite make out the displacement stuff in your graph. But generally you can multiply the displacement by some scalar value to give it a displacement-strength. You might want to add that so your "wrinkles" get higher.

indigo frost
#

Brb

meager pelican
#

Me too. AFK.

#

Back

indigo frost
#

M2

#

I'm not sure what you mean by scalar value

meager pelican
#

A float.

indigo frost
#

Well but that would mean that they are static and not moving

meager pelican
#

Scale. Height.

#

The movement comes from tiling/offset...later.

#

Different from scaled height.

#

So add a variable that scales the height strength (the offsets). So it could be 1x for normal (what you have now) or 2x for twice as much, or .5 for half as much displacement.

indigo frost
#

So from what i am understand is that you want me to control the factor of how much each vertex is displaced

meager pelican
#

So you can see it. It's very faint right now.

indigo frost
#

If that is the case, i can just add a float multiplied by the vector3 i want to add to the vertex's position

#

like this?

#

I'm wrong, arent' i?

meager pelican
#

Not necessarily, depending on values you have. Usually, you displace a vert along the normal direction in cases like this. But the object's normal is "up" for you if you don't rotate the plane. Does that make sense?

#

So you're adding to the object-space Y value some scaled displacement from the Veroni texture.

indigo frost
#

well i only want to displace it in the objects Y dir

meager pelican
#

So it depends on what that vector3 comes in as on the left. If it is (0, 1, 0) you're gold.

indigo frost
#

Actually for whatever reason

#

i just noticed after you pointed it out, but it's (0,0,1)

#

And it looks as it should, but if i change it to (0,1,0)

#

it breaks

meager pelican
#

That might be some UI thing. Oy.

#

OK, so keep it 0,0,1

indigo frost
#

Anyway, yeah

meager pelican
#

But scale it. Did it make the wrinkles better? Higher?

indigo frost
#

it tried tweaking the displacement factor

#

it looks like am monster

#

shadows are kind of going all over the place

meager pelican
#

That's OK, we can see the polygons now at least.

#

So it scaled. 🙂

#

One step at a time.

indigo frost
#

i just want to point out that that was a displacement factor of 35

#

and this is of 1

meager pelican
#

Well the 1 is not too bad, but it doesn't look like the pic you posted the first time.

indigo frost
#

What i am trying to say is that besides the shadows, it's acutally not all that different ~ it's not what i expected

meager pelican
indigo frost
#

Anyway yeah, back to 35 we go. The main problem that i see right now is that i am super dependant on the directional light tht i am using

#

if i tweak the angle just a bit

#

the difference shift in almost everything is immense

meager pelican
#

How could you not be?
But you could use a different light just for this if you want.
We'll check your lighting calc next.

indigo frost
#

Here are my light settings

#

and htis is the directional light

indigo frost
meager pelican
#

Sure? I mean, that's up to you. You're using a lit-graph, right?

indigo frost
#

For the shader? Yes

meager pelican
#

So it "knows" about that light.

#

Adds code in.

#

By itself. Behind the scenes. Ish.

indigo frost
#

I removed "Cast shadows" from the mesh's mesh renderer

meager pelican
#

Or you could just pass a direction vector and calc something yourself.

#

The thing is you may want your own light for this, in case you want it to change and "move" and not be the same as the scene lighting. IDK, up to you.

#

But in that case you'd want an unlit graph and decouple it from the scene lighting. IMO

indigo frost
#

So just for context

#

this is aimed to be a background for the main menu of a game

#

the camera is going to be looking at it and nothing more

#

when a level is loaded, this wont be there

meager pelican
#

OK. You might want to up the ambient light level in the lighting settings to make it smoothed out.

indigo frost
#

Hum

meager pelican
#

So to make it move, you need to add tiling and offset to your texture read of the voronoi vert texture. Probably based on time, or some other xy values you pass from C#.

indigo frost
#

No wait, it's already moving

#

i have that...

#

the vets arre moving up and down

#

Is this what your talking about, or am i missing something here

meager pelican
#

Yeah, fine, if it's moving it's moving.

#

I couldn't really read the "big" one it was too blurry.

#

For me

#

So if that's working, fine.

#

So are we closer now?

indigo frost
#

Yeah

#

I think everything is mostly done

#

i just need to figure out the lighting and make i layered

#

but i can't seem to put my finger on it... it looks kind of wrong if i do up the ambient light

meager pelican
#

I'd have like 3 different layers and some color tints.

indigo frost
#

I was planing to do gradients with the UV

#

like this