#archived-shaders

1 messages ยท Page 16 of 1

leaden turret
#

when you say dynamic objects move - i guess what remains to be clarified is; if my entire scene is static, just the only thing moving is - myself i.e. the player / the camera controller moving around the scene, is that what you call a static scene which CAN be reflected from-any-angle to-any-angle with reflection probes on the cheap, and it will look correct even for a moving camera? or if the camera is moving around the scene at all - all bets are off, baked reflection probes is not the way to go. instead we must use the other solutions like spreading out updating reflection probes over multiple frames, or probes are not the way to go altogether just all-out planar reflections

#

i did in fact make a scene pretty close to what you're describing at that github link - lemme know if you ever get around to giving it a spin, either to see where i went wrong or if you can show a little bit of how to correctly implement what you're describing

#

and thanks i appreciate the time & advice/explanations ๐Ÿ‘ ๐Ÿ™Œ

rigid sandal
#

Could anyone help me with this errors? i cannot figure it out

#

It works in editor but not on console itself

tight phoenix
#

im struggling, im really really really really struggling to produce this appearance

#

no matter what combination of noise I use, I cant solve it

#

the key critical thing that never works is smudging

#

its easy to make cells that roughly look like the above

#

but they -always- have soft gradient peaks from edge to top

#

i need desperately to have the secret to smudge those peaks

#

nothing ive tried has worked

#

closest ive managed and its completely shit and wrong

#

how do I smudge the white peaks closer to the dark valleys?

#

everything ive tried has failed to achieve this

regal stag
tight phoenix
#

yeah its not enough to just flatten it, I want to smudge the peaks away from the perfect center of each voronoi cell

#

but I cant find a way to change the voronoi cell center

#

like this is pretty good, but its missing that critical step of smuding the peaks

#

no matter how much I distort the UVs, the peaks are always dead center because thats just how voronoi works

karmic hatch
tight phoenix
#

hmm that has sorta worked ๐Ÿค” its quite messy but maybe if I tweak the values a bit

karmic hatch
visual mesa
#

Anyone have any examples on how I can use DrawMeshInstancedProcedural to draw thousands of mesh instances in different positions? I can't seem to get it to work

shadow locust
visual mesa
#

Yes, that would be helpful! Thank you. From what I understand DrawMeshInstancedProcedural is basically a wrapper for DrawMeshInstancedIndirect that you can call from C# scripts if you know the number of instances to draw

#

I could be wrong though

shadow locust
#

but I'm not sure your characterization of the methods is quite correct.

distant sparrow
#

importing the toon fantasy nature pack and all the materials turn pink with this error

last sable
distant sparrow
#

yeah, this is the standard first person sample project

#

which is URP

last sable
#

Was there a separate URP package that you need to install? There often is.

distant sparrow
#

oh yeah, found and it worked

visual mesa
#

I see you can use Bounds.IntersectRay(Ray ray), but you would need to know the bounds for each instance. I'm a bit confused on if DrawMeshInstanceIndirect just draws "one mesh" broken up into mulitple pieces. Or if all of the cubes I'm seeing in scene are in fact separate meshes. I'm a bit new to shaders and draw calls ๐Ÿ™‚

shadow locust
#

They are drawing the quad hundreds of thousands of times

#

the quad is the entire mesh

#

it's not broken up

#

you could replace the quad with a mesh of the statue of david

visual mesa
#

So is there no way then to detect intersection with a specific cube?

shadow locust
#

and you'd have 100,000 little stars of david

shadow locust
visual mesa
#

Yeah, but I'm trying to avoid GameObjects due to performance ๐Ÿ˜ฆ

shadow locust
#

You have to realize that DrawMesh, in all its incarnations, is just a way of drawing things

visual mesa
#

I basically need what GameObject colliders do, but without them ๐Ÿ˜„

shadow locust
#

it doesn't create anything in or interact with the hierarchy at all

visual mesa
#

For improved performance

shadow locust
#

you certainly can't use Unity's Physics engine(s) which are CPU based

#

the example I shared has a primitive implementation of such a thing though

visual mesa
#

Yeah, I don't need Physics at all. My use case is I have thousands of cubes that need their positions moved programmatically. Users can not move or manipulate the objects (no physics needed). However, I do need to be able to detect if a user points at a specific cube (and mimic a selection interaction)

shadow locust
#

If you look at the last animation on the page you can see a manipulation in a similar vein to what you're talking about perhaps

visual mesa
#

Could I achieve that with a custom compute shader?

shadow locust
#

maybe? I'm not sure I fully understand the nature of what you're asking

#

I'd just say look at the last animation on the page and see if it's in the same realm of stuff as you're talking about

visual mesa
#

Yeah, I'll take a look. Thanks!

#

@shadow locust To give a better idea of what I'd like to do.... these cubes are all moving and I'd like to detect which specific cube my raycast is intersecting with

#

I followed the example here to create the scene in the picture

tight phoenix
#

what is the formula to mask out a specific range of values, with falloff?

#

desired end result is putting in a value for time and the falloff range returning just those bits

#

my attempt here is flawed though, it isnt behaving

#

better example - here ive manually adjusted all the values to get just the vales between that range

#

but I need the formula so automatically determine those 4 values from just the two values of range and time

#

certain formulas work at very specific values
but stop working as soon as those values change

#

ideal outcome is that as the time value changes, the range value does not need compensating adjustments, the range value falls off from where time is

#

if it was working, time at 0.5 and range at 0.1 would give me 1/10th of the values from the exact center of the 256 value range a color has

tight phoenix
#

I know I will need a values time +/- range , but then how do I use those it isolate a thin band

cosmic prairie
#

if thats what you're after

#

this will have falloff both ways, I'm too sleepy to understand what you're after exactly, hopefully this was it, goodnight ๐Ÿ˜ด

#

one more thing - if you want the smoothness off the falloff do 1 - min(1, pow(abs(threshold - input) * falloff), smoothness)

#

(couldn't go to sleep with this retained information)

tight phoenix
#

one subtrating the minmum of 1 and the absolute of the threshold minus input, multiplied by falloff?

#

oh I was using Range for both threshold and falloff

#

but after fixing that, its still not working

#

so im definitely still making a pemdas error

#

got it working, turned out I did have the right maths, it was my values that were not working

#

turned it into a custom node though to be sure pedmas was correct

#

๐Ÿ‘

tight phoenix
#

Does anyone have a link to a resource / tutorial that talks about how normals are calculated?
I don't want to fully replace the Lit behaviour, but I do want to add a simple blinn phong (?) specular highlight to a height map

#

I want to calculate 'normals' from this height, butI still want to use the actual Lit normals

#

but I am not sure how normals interact with manually calculated view direction spec / fresnel

#

I guess im trying to google normals for lighting for an unlit shader? Toon shader normal maps? yes im aware there is no light in the unlit shader but I just need to use that data for another purpose

#

oh looks like it might be covered in here

rare charm
#

I know just the basics about shaders. Is there a way to make a shader for a quad that makes the edges of the quad distorted?

meager pelican
#
  half3 h = normalize (lightDir + viewDir);
  half diff = max (0, dot (s.Normal, lightDir));

  float nh = max (0, dot (s.Normal, h));
  float spec = pow (nh, 48.0);

  half4 c;
  c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
  c.a = s.Alpha;
  return c;
}```
from here: https://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html
#

@tight phoenix

meager pelican
kind juniper
#

Assuming the mesh is properly uv-mapped.

long moat
#

Hello! is it possible to give a stencil shader different cutout shape? instead of the mesh shape. For example adding star shaped cutout texture will create a star shaped stencil in whatever it cuts through

meager pelican
long moat
#

currently my stencil simply replaces every shader that has:

            Ref 1
            Comp notequal
            Pass keep
        }```
#

This is the entire stencil shader right now:

Shader "Custom/Stencil"
{
    SubShader
    {
        Tags { "RenderType"="Opaque" "Queue"="Geometry-1" }
        ColorMask 0
        ZWrite off
        
        Stencil
        {
            Ref 1
            Comp always
            Pass replace
        }
        
        Pass
        {
            Cull Back
            ZTest Less
        
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            
            struct appdata
            {
                float4 vertex : POSITION;
            };
            struct v2f
            {
                float4 pos : SV_POSITION;
            };
            v2f vert(appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                return o;
            }
            half4 frag(v2f i) : COLOR
            {
                return half4(1,1,0,1);
            }
            
            ENDCG
        }
    } 
}
regal stag
long moat
# regal stag You'd use something like `clip(shapeTexSample.a - _AlphaClipThreshold)` in the f...

something like this?

{
    Properties
    {
        _MainTex("Albedo", 2D) = "white" {}
    }
    
    SubShader
    {
        Tags { "RenderType"="Opaque" "Queue"="Geometry-1" }
        ColorMask 0
        ZWrite off
        
        Stencil
        {
            Ref 1
            Comp always
            Pass replace
        }
        
        Pass
        {
            Cull Back
            ZTest Less
        
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
        
            sampler2D _MainTex;
            
            struct appdata
            {
                float4 vertex : POSITION;
            };
            struct v2f
            {
                float4 pos : SV_POSITION;
            };
            v2f vert(appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                return o;
            }
            half4 frag(v2f i) : COLOR
            {
                return clip(_MainTex.a - _AlphaClipThreshold);
                //return half4(1,1,0,1);
            }
            
            ENDCG
        }
    } 
}```
#

forgive me if i make noobish mistakes ๐Ÿ˜… im still learning how to handle with shaders..

regal stag
# long moat something like this? ```Shader "Custom/Stencil" { Properties { _...

You need to sample the texture. The clip function also shouldn't be used for the return. It discards the pixel if the parameter passed in is less than 0. You'd still need to return your colour for the other pixels.

half4 frag(v2f i) : COLOR {
    float4 mainTexSample = tex2D(_MainTex, uv);
    clip(mainTexSample.a - _AlphaClipThreshold);
    return half4(1,1,0,1);
}

Also either change _AlphaClipThreshold to a hardcoded value (0.5 maybe), or provide a Float property as an input.

long moat
#

oh so its not something that exists as a parameter in this shader, alright

regal stag
#

Would also need float2 uv : TEXCOORD0; in appdata and v2f, and o.uv = TRANSFORM_TEX(v.uv, _MainTex); in the vertex shader to pass the uv through

long moat
# regal stag Would also need `float2 uv : TEXCOORD0;` in appdata and v2f, and `o.uv = TRANSFO...

so um like this?

{
    Properties
    {
        _MainTex("Albedo", 2D) = "white" {}
        _AlphaClipThreshold("Alpha Threshold", Range(0, 1)) = 0.5
    }
    
    SubShader
    {
        Tags { "RenderType"="Opaque" "Queue"="Geometry-1" }
        ColorMask 0
        ZWrite off
        
        Stencil
        {
            Ref 1
            Comp always
            Pass replace
        }
        
        Pass
        {
            Cull Back
            ZTest Less
        
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
        
            sampler2D _MainTex;
            
            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };
            struct v2f
            {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
            };
            v2f vert(appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }
            half4 frag(v2f i) : COLOR
            {
                float4 mainTexSample = tex2D(_MainTex, uv);
                clip(mainTexSample.a - _AlphaClipThreshold);
                return half4(1,1,0,1);
            }
            
            ENDCG
        }
    } 
}```
#

i mostly got to play with surface shaders, not with vert/frag shaders ๐Ÿ˜…

#

mmm i believe i did everything correct but it throws me this error:

meager pelican
#

Looks like you're missing an include that defines the TRANSFORM_TEX macro

#

Like UnityCG.cginc

#

let me get you the syntax

long moat
#

Oh yep now I see it

#

I missed the unityCG

meager pelican
#

Put
#include "UnityCG.cginc" in there after the pragmas

#
float4 _MainTex_ST;```
long moat
#

now it throws me this error:

#

not sure how the clip supposed to work..

#

here is the updated script:

{
    Properties
    {
        _MainTex("Albedo", 2D) = "white" {}
        _AlphaClipThreshold("Alpha Threshold", Range(0, 1)) = 0.5
    }
    
    SubShader
    {
        Tags { "RenderType"="Opaque" "Queue"="Geometry-1" }
        ColorMask 0
        ZWrite off
        
        Stencil
        {
            Ref 1
            Comp always
            Pass replace
        }
        
        Pass
        {
            Cull Back
            ZTest Less
        
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"
            
            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };
            struct v2f
            {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            
            v2f vert(appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }
            half4 frag(v2f i) : COLOR
            {
                float4 mainTexSample = tex2D(_MainTex, i.uv);
                clip(mainTexSample.a - _AlphaClipThreshold);
                return half4(1,1,0,1);
            }
            
            ENDCG
        }
    } 
}```
meager pelican
#

The param is a float.
If it is < 0, the fragment is discarded. So the math expression is written by you such that it returns a negative value for discarded pixels.

long moat
#

but, no how is it possible?

meager pelican
#

Change this line to:
_AlphaClipThreshold("Alpha Threshold", Range(0, 1.0)) = 0.5
and see if it helps. Explain later if it works.

long moat
#

nope, still the same error:

#

i changed the range to Float earlier but that did not help either

regal stag
#

You need float _AlphaClipThreshold; somewhere in the hlsl portion, outside the function scope. e.g. after the float4 _MainTex_ST; line

meager pelican
#

Oh, yeah, he didn't define it. ๐Ÿ˜‰

#

The Properties don't do the defines.

long moat
#

yes now it works! Thank you so much @regal stag and @meager pelican ๐Ÿ˜

eternal walrus
#

im having an error on my shader graphs, how can i fix it. note: i upgraded my project from built in to hdrp

long moat
zenith heron
#

Hello, I made a shader for post-processing effects which most of my sprites use. One of these effects is a brightness effect which can range from -100 to 100, where -100 turns it completely dark and 100 completely white. However, changing the brightness value for one sprite does it for the others. I think I know why this happens, but I'm not sure what it's called, or how it can be prevented. Can anyone help me define this? Thank you very much for your time.

bold breach
#

hello, im new to untiy and im wondering how to create a cartoony outline effect like the image i attatched, if anyone could provide any tips or support that would be much appreciated
thanks

grand jolt
#

I am following a tutorial for a water shader but the water waves basically flash flood the entire map, my first instinct was to change the scale of the noise but that didn't do anything other than change the speed of the waves

#

It's a single big cube but I need it to be a single big cube for other reasons so is there a way to make the waves smaller

#

tried to fix with a tiling node

#

but it's 2D

rare charm
#

Why am I getting this weird effect on my alpha? The preview shows it the alpha is completely transparent but the scene view shows something completely different

grand jolt
#

pls

karmic hatch
karmic hatch
# grand jolt anyone

Before adding the waves to the position, multiply by a new wave height property.

karmic hatch
grand jolt
#

also

meager pelican
bold breach
grand jolt
#

that's a mountain btw

karmic hatch
grand jolt
karmic hatch
grand jolt
#

and what am I gonna do with the scale of the mesh if the scale doesn't make the waves smaller

karmic hatch
#

How are you generating your mesh?

#

Actually just rather than feeding a UV or something into the noise, feed in the position

grand jolt
karmic hatch
#

A cube only has vertices at the corners, so you won't be displacing much

#

you'll just move the four corners around

grand jolt
karmic hatch
#

Indeed

grand jolt
#

just made it a little bit laggier

karmic hatch
#

you want your subdivisions to be the same size as the waves or smaller

grand jolt
#

still floods

#

I'ma send the whole shader

#

anything about it

bold breach
karmic hatch
grand jolt
karmic hatch
grand jolt
karmic hatch
#

In your tiling and offset node, in place of UV0 put in the position

grand jolt
#

ok

grand jolt
#

these are my settings btw

rare charm
karmic hatch
grand jolt
karmic hatch
#

The output from the noise

grand jolt
#

ok

karmic hatch
#

(Since you're multiplying both together, it's mathematically equivalent, but in one it has to do three multiplications while the noise is just a float so one multiplication. Very minor performance difference but might as well take it)

grand jolt
#

partially fixed it, the waves aren't like spread out but instead a very very subtle and unnoticeable unless on the shore kind of wave

karmic hatch
#

What happens as you change the wave height property?

grand jolt
#

had to set it to 0.05 to get something noticeable that respects the map

karmic hatch
#

Oh also after the noise (but before the multiplication) subtract 0.5

#

Then the water shouldn't rise up

grand jolt
#

aaaand I ran into a problem that I saw coming but chose to ignore

#

it's a water shader

#

made for a plane

#

applied to a cube

#

so stuff like this happens

grand jolt
#

ykw I might as well just leave it with the waves it already have

#

at least you can see it on the shore

karmic hatch
karmic hatch
#

If you subtract 0.5 from the noise, the waves should grow without the water overall rising

grand jolt
#

and yes, I subdivided it

#

a lot

karmic hatch
#

Did you swap the UV for the position in the tiling and offset node?

#

And for the tiling vector2, put in a float property for wave scale

karmic hatch
#

Swap the space from object to world

#

That should do it

karmic hatch
#

going into the noise node

grand jolt
#

what the fuck

karmic hatch
#

just realised, instead of just position, either use a swizzle node or split + vector 2 and take the (x, z) components

grand jolt
#

whatever that is

karmic hatch
#

Swizzling is just playing with the components of a float1/2/3/4

grand jolt
#

what do I input tho

#

the position?

karmic hatch
#

yes position in, and for the mask do xz

grand jolt
#

so this

karmic hatch
#

yes

grand jolt
#

ok

#

this IS cube compatible right

#

I am using one

karmic hatch
#

multiply the normal by (0,1,0)

#

(that'll stop the sides from shifting)

grand jolt
karmic hatch
#

And then just play around with the properties until it is good

grand jolt
#

better

grand jolt
#

IT WORKS

#

TYSM

#

wo'a

karmic hatch
grand jolt
#

wo'a

#

what does that mean

#

wo'a

#

like woah?

#

wait

#

. . .

#

I get it now

#

water

meager pelican
#

#archived-shaders message
CC: @amber saffron ^^
Basically, @leaden turret, because you're using a lit shader and a metallic surface, you're using the reflection probe method. The only way around that is to do your own lighting and "manual vert/frag" type of thing if you want to avoid using probes.

#

Unity is auto-generating the lighting calcs.

grand jolt
#

the only other one is scene depth

#

and it doesn't look like this

karmic hatch
#

Seems to be an Unreal engine node

grand jolt
#

it's on unity tho

karmic hatch
#

maybe there's a package for it or something; or maybe they made a custom node

grand jolt
#

it was on sub graphs

#

on the video

#

it was under sub graphs

karmic hatch
#

Ok so they made a sub graph for it ig

grand jolt
karmic hatch
# grand jolt ok but then how do I get the node

I think if you subtract length(fragment position <view space>) from (depth <eye>)/(normalize(view direction <view space>).b) it should give the distance between the water surface and the background

grand jolt
#

in the nodes

karmic hatch
#

all of those functions are nodes

grand jolt
#

and how did you know that's what the node did

karmic hatch
#

I'm assuming it's the distance between water surface and background.

#

If it's not, it's certainly a function of that

karmic hatch
#

For foam you just check when that distance is small, then paint the surface white

grand jolt
#

but something like this right?

karmic hatch
#

yes

#

then there's a depth node and you want to divide that by the z component (aka b component) of the normalized view space view direction

#

(it might actually be a multiply instead of a divide, now i think of it. I just remember the depth itself being biased depending on the view direction)

karmic hatch
#

yes, but swap scene depth from linear 01 to eye

grand jolt
#

and if it is

#

how do I paint it white actually

karmic hatch
grand jolt
karmic hatch
#

(and a similar branch for alpha)

grand jolt
karmic hatch
#

At the moment it'll just look like straight lines

#

Then you can add noise to the distance and then it'll make it look better

karmic hatch
grand jolt
#

I add a noise

#

got i

#

it

#

and after the branch a noise texture

karmic hatch
#

I would put the caustics with the blue color before the branch, rather than adding them afterwards

#

also it seems you're adding the base color to itself?

karmic hatch
#

in the bottom image, take the output of the addition node on the far left, and then put that into the false on the branch

karmic hatch
#

yes

grand jolt
#

turned white

karmic hatch
#

you're adding the simple noise after the branch, so you're just adding on average light grey to all of the water

grand jolt
#

so I add the noise if it is true

#

and that would go on the true?

#

like

#

in between the true

#

I put the add

karmic hatch
#

you could put the noise in the bottom part of the comparison

grand jolt
#

and that would do it?

karmic hatch
#

you want the noise to be affecting the comparison though, not the final color

karmic hatch
#

try negating the b component of normalized view direction

grand jolt
karmic hatch
#

swap the inputs to the subtract node

grand jolt
#

that doesn't change anything

#

right?

#

aand everything's white again

karmic hatch
grand jolt
karmic hatch
#

can you just put the output of the subtract into emission color, remove everything going into base color and set base to black?

#

(debug)

karmic hatch
#

you are putting a float into the emission output, yes?

#

the line starts out as blue?

grand jolt
#

I think

grand jolt
karmic hatch
#

the lines connecting nodes in shadergraph are colored depending on what type of struct it is. Float1 is blue, float2 is green, float3 is yellow, and float4 is pink.

#

Bool is purple

grand jolt
#

wait

#

nvm

#

it starts out blue

#

so what do I do now

karmic hatch
#

is the water still green?

grand jolt
#

yes

karmic hatch
#

that is... genuinely baffling. It's a float, it should be greyscale

karmic hatch
#

that subtract then goes into emission right?

karmic hatch
#

and you set base color to black?

grand jolt
#

yes

karmic hatch
#

can you set alpha to 1

grand jolt
#

ok

#

still green

#

what is my shader just

#

cursed or smthn

#

(joking)

karmic hatch
#

can you set emission to black too?

#

if it's still green then that's probably something other than the shader being very weird

grand jolt
#

but then what will I assign the emission to

#

I mean

#

the substract

#

base color?

karmic hatch
#

just assign like base color set it to black

grand jolt
#

ok

#

saved it

#

it's still green

#

as base color

karmic hatch
#

i mean set both emission and base color to black, have nothing going into the fragment node

#

could even go all the way and set the shader to be unlit

karmic hatch
#

very strange

grand jolt
#

so

#

what do I do about it

karmic hatch
#

Can you try making the shader unlit and setting the base color to black and alpha to 1

grand jolt
#

still green

#

looks like my shader is just cursed

karmic hatch
#

any post processing effects or something?

grand jolt
#

looks black here tho

grand jolt
karmic hatch
#

can you turn those off just to check

grand jolt
karmic hatch
#

when the camera is underwater?

grand jolt
#

yes

karmic hatch
#

ah

#

ok i don't know why it's green but let's get back on track and hope it's just adding on or something

grand jolt
#

ok

#

alright so

#

it's all white

karmic hatch
# grand jolt

can you try putting the output of the divide here into the color node

karmic hatch
#

and move the camera close to shallow water

grand jolt
#

wait on the base color?

#

ok

#

also it's green

karmic hatch
#

still dark green?

grand jolt
karmic hatch
#

ok try negating it first then

#

(or remove the negate node in there)

grand jolt
#

now it's white

karmic hatch
#

does it turn grey if you get very close to shallow water?

agile mango
#

Quick question, do I need to us a URP or HDRP project to use PBR stuff? It's been a hot minute since I've messed with that stuff.

#

Or is it just something I can import to an existing project?

karmic hatch
grand jolt
#

do you mean shallow as if it's like the shore

karmic hatch
#

yes

grand jolt
#

if so

#

then no

#

no it doesn't

karmic hatch
#

can you try dividing by 10 or something

grand jolt
karmic hatch
#

the result of everything that's going into the color output

grand jolt
#

ok

#

like this right?

karmic hatch
#

yes

grand jolt
#

when do you get to the part where I get done with the foam so I can finally finish stuff up and prepare the build

#

don't want to rush things up but

#

I've been like 1hr on this

#

alright I'ma check it now

karmic hatch
#

there are certainly tutorials online

grand jolt
#

yes

#

it gets gray

karmic hatch
#

does it change as you get nearer or further away?

grand jolt
#

yes

karmic hatch
# grand jolt

back to this then, if you just remove the negate node on the bottom, does it go dark near the shore?

grand jolt
#

it becomes black

#

always black

#

it's kinda spooky actually

karmic hatch
#

if you negate the output, does it change?

#

(specifically, does it go back near the shore, and white elsewhere)

grand jolt
#

yes but it turns gray

#

not black

karmic hatch
#

at the very very edge of the shore does it turn black?

#

also does it change color as you move the camera or change the direction you're looking in?

grand jolt
#

still gray

karmic hatch
#

ok that's good at least

#

anyway so then you can just plug that into the comparison node, maybe just branch between 1 and 0 for now and see what that looks like

grand jolt
#

already there

karmic hatch
#

actually you can just put the bool from the comparison into the color directly

grand jolt
#

like this

#

ok

karmic hatch
#

yes

grand jolt
#

can't plug the comparison to the color

karmic hatch
#

ah ok thought you could

#

sad

grand jolt
#

so

#

what do I do now

karmic hatch
#

same as branch with 1 and 0 so just do that

grand jolt
#

ok

#

it remains white now

karmic hatch
#

any specks of black at the shore?

grand jolt
#

no

karmic hatch
#

try adding 1 to the noise

grand jolt
#

nothin

#

@karmic hatch

karmic hatch
#

if you set the bottom of the comparison to 10, still nothing?

grand jolt
#

yep

#

still nothing

karmic hatch
#

going to try to whack something together on my end and will send it if/when it works

grand jolt
#

it looks good already

#

and I want to get this done today

#

been working on it too long atp

karmic hatch
#

good luck

grand jolt
#

thanks

#

you can still try tho

#

and if it works then I'll add it back

karmic hatch
#

i will dw

long moat
grand jolt
#

did you notice

long moat
#

just stay hidden from nintendo ๐Ÿ˜…

grand jolt
#

at least not at this stage

#

of development

#

mayybe when I have more flexibility over it

grand jolt
#

anything yet @karmic hatch

karmic hatch
#

yep

#

just getting it so it looks like water now

grand jolt
#

ok

karmic hatch
#

here's the bit that does the foam check, the bool then goes into a branch

grand jolt
#

alr

#

and the bool goes into a branch, which has white on the true port

#

and the normal water color in the false color

#

and then I add it to the other color

#

and that should be it

#

right?

#

@karmic hatch

karmic hatch
hearty obsidian
#

Using unlit sprite graphs for some UI images. Had to update to 2021 LTS for some unrelated reason, now half of the UI shaders render as fully white. Can't seem to pinpoint the issue. Same nodes are reused across both working and non working shaders. Any idea?

#

The issue occurs on iOS exclusively

meager pelican
#

@leaden turret CC: @amber saffron
Just for fun, I've played around with driving a single real-time reflection probe via script. It costs about 15 frames/second and that's on a medium desktop card. This might vary, though, due to scene rendering time. Because if the underlying scene isn't efficient, neither is the probe rendering. It's a catch-22, even at low probe resolution. Turning off vegetation helped a lot so there's some optimization that can be done in the test-scene to get closer to real benchmarks.
I've got it set to only refresh the probe if the player moves some set distance from last-known-position.

I'm doubting it is practical for low-end mobile, but I can't really test it unless I build and load it and I'll leave that to you, @leaden turret, if you want to experiment I can post more.

Such a technique makes accurate reflections.
Next thing I'll do, though, is go back to your baked probes and see if I can adjust them to not have the doubling effect and to be every X world-units apart so they don't glitch so much.

grand jolt
#

don't know why that's so performance intensive

meager pelican
# grand jolt don't know why that's so performance intensive

Well, there's no such thing as a "mini camera", it's a scene camera (but I take your point that it is low resolution) rendering a cube map. The thing is it has to re-render the entire scene, or whatever layers are applicable. That takes time. Time to re-submit all scene objects, render them....and it does it SIX TIMES, the way I did it is one side of the cube map per frame, and it actually spreads it across 14 frames somehow (on the individual sides per frame setting).

So it tries to reduce the costs, but there are costs. And if your scene is inefficient, so is the reflection probe rendering.

There are other techniques, such as screen-space reflections that can basically use screenshots. But reflection probes are re-rendering. And we're in a discussion about experimenting with different techniques.

leaden turret
meager pelican
#

They were doubled up for some reason, and not precise. But they did move somehow. Still not right though. But I haven't really played with that yet, it's my next step (see post above) after finishing the real-time test (for fun).

leaden turret
#

ahh right right yes same here, they do seem a bit overlapping/duplicated (maybe that's the blending interpolation between multiple probes at play?) and yes they kinda do slide along a bit... but it's reeeally kinda not close to satisfactory... and from certain angles it's really horribly completely wrong and off

meager pelican
#

Yeah. Right now you've got them in two columns near the center (for testing of course) but their active-area boxes are all the same and cover the entire water.

What I was going to do next was to make a "grid" of probes, say every 10 meters, low res like you have them....and have their boxes be about 20 meters large so they over lap (or maybe 15). And have them be baked probes. And then try having the player move through them.

The thing about realtime is that there's only one reflection probe at the play position. But it costs to update it. With baked, they're baked, but you chew up memory having them available even if the engine only passes one or two during any given frame.

leaden turret
# meager pelican <@252562676520058880> CC: <@532477925250039820> Just for fun, I've played around...

Such a technique makes accurate reflections.
You mean the technique of to only refresh the probe if the player moves some set distance from last-known-position ? cool! def wanna test that on the low end mobile

Next thing I'll do, though, is go back to your baked probes and see if I can adjust them to not have the doubling effect and to be every X world-units apart so they don't glitch so much. ๐Ÿ™ awesome! thanks! much looking forward & staying tuned for any developments about that

meager pelican
#

I mean the real-time technique. The "only update when moving" is an optimization, admittedly with only a little payoff.

leaden turret
meager pelican
#

Maybe you can mess with them from the description and see if it gets any better. IDK, I haven't really experimented with reflections on low-end mobile, I mostly play with desktop stuff so this is a fun experiment for me and why I'm engaged.

I thought you were looking at doing some form of screen-space reflection, maybe. But if you're using the lit shaders, you'll get reflections from probes automatically as the lit shaders generate/contain that code already.

#

Incidentally, just as a test, since you have the metallic and smoothness at 1.0, I overrode the render queue to be opaque on the material settings, and it upped the frame rate since it didn't have to draw the ocean bottom area and then blend.

leaden turret
# meager pelican Maybe you can mess with them from the description and see if it gets any better....

i was considering screen space at some point, but i fear the limitations of frustum angle might really make things quite fugly... it can happen fairly often that a player is looking kinda downward towards the water and not including the distant landmasses, possibly making it really jarring between yes seeing / not seeing those reflections based on how low the camera angle aims towards the water...

#

so at this point i limited myself to - either finding a workable solution with baked probes, or - no choice, all out planar reflection

#

(but ๐Ÿคทโ€โ™‚๏ธ i could still be convinced otherwise heh... if it makes sense somehow to still try screen space...)

leaden turret
# meager pelican Incidentally, just as a test, since you have the metallic and smoothness at 1.0,...

TBH i'm always messing/playing with those numbers, hardly knowing what i'm doing and not sure i'm fully satisfied with the effect as-is in the demo project. One annoyance i've noticed is; if I turn metallic all the way up, then the reflections are more colorful which is desirable, but the sun specular reflections are totally blue tinted which i find not ideal... if i turn metallic down the sun specular is nice and white as desired, but island reflections are very washed out. i wish i had also bright white specular AND colorful water reflections of islands/landmass

#

but very cool to know about that optimization if indeed i dont care for deep water visibility... good do know ๐Ÿ‘Œ

meager pelican
#

Here's the script for driving the real-time reflection probe. No warranties, I just threw it together to test. Put it on a game object that is a child of the real time reflection probe. Set the public references properly to the camera object and set a move distance.

leaden turret
#

๐Ÿ‘ ๐Ÿ™Œ awesome, thanks much!! will take this straight to the lab

meager pelican
#

Ooops got some message text in there at the top...lol

leaden turret
#

np

#

noted

#

i also do wanna try a bit what you described about grid of probes. Still not sure i fully understood how to do it right (how big should each probe box be / cover? and other questions) so will still be looking out for if you happen to play around with that and get any interesting results, but ye i'll be trying to play with that a bit

meager pelican
# leaden turret TBH i'm always messing/playing with those numbers, hardly knowing what i'm doing...

Yeah, the editor really screws with your timing, so always time with the stats window showing in maximized mode, so the editor window overhead doesn't mess with your data.

Also the UI scrips seem to be taking quite a bit of CPU side stuff, and the veg stuff I disabled to get it out of the metrics. Still only got about 80 FPS ish on mid-end desktop hardware, and I suspect the terrain system is part of the reason. But could be my system settings too.

leaden turret
#

aside from that i'm gonna be trying to develop further the test/demo project; a few more vegetation types (trees / grass etc), making a GameObject version of the scene, an ECS SubScenes version of the scene, each version with a 1-piece terrain mesh version of the scene and a 16x16 subdivided terrain mesh version of the scene to see if any occlusion culling makes a significant difference or not (maybe i'll try another version putting each 16x16 chunk with its vegetation in another subscene, a-la MegaCity kind of optimizations...) and a camera "on rails" sequence loop to demo various rendering conditions ex. narrow "corridors" of the map with limited visibility vs. large landscape views with long distances etc. so it can be profiled on mobile for lack of a proper mobile DOTS character controller

meager pelican
#

I'd try every 10 meters, so you'll have a grid of N x N probes, box sizes about 15 meters each so they overlap...play with that value. You know you can select them all and edit that size all at once so it isn't too bad.

leaden turret
#

ah cool right ๐Ÿ‘Œ

grand jolt
#

the false is the normal water texture and the output went into the base color

#

is this correct

leaden turret
#

@meager pelican also just to confirm - am I on the right track that it only makes sense to go Box projection? Not regular non-box-projection probes?

grand jolt
#

@karmic hatch

leaden turret
#

or maybe it can make sense to use non-box-projection, if each probe box is like you say a smaller 15x15 area or something...

grand jolt
#

regedit and carpefunsoftware be writing a paragraph

leaden turret
meager pelican
grand jolt
leaden turret
grand jolt
#

I think he got offline

meager pelican
#

@grand jolt Sorry, we should really be using a thread for all this, and much if it isn't about writing shaders, yet, it's about how stock shaders react. I'm about ready to bail out for the day.

grand jolt
#

he hasn't come back anyways

leaden turret
meager pelican
leaden turret
#

aha ok i'll try, no idea really - maybe 100x100 probes does make sense ๐Ÿคทโ€โ™‚๏ธ truly have no clue and wondering what might be best idea to use here..

meager pelican
#

Going to bale out for the night. Catch up with you later.

grand jolt
#

I'ma ping once more just to make sure

#

@karmic hatch

leaden turret
# meager pelican Yeah, the editor really screws with your timing, so always time with the stats w...

re. terrain system; yes i was made aware that unity terrain is not most performant and especially not a good idea for mobile, which is why in fact i use this asset plugin https://assetstore.unity.com/packages/tools/terrain/terrain-to-mesh-2021-195349 to convert the terrain to mesh with its own splatmap shaders & stuff (which had their own complications about moving variables to CBUFFER if you remember... which still dont work on mobile for some reason..) i've been starting to try messing with making terrain meshes in blender, still working on that (no success yet...)

grand jolt
#

yep he's offline

#

in that case

grand jolt
grand jolt
leaden turret
#

is this about a water shader?

grand jolt
#

stylized water shader

#

I'm trying to get the foam

leaden turret
#

which one? custom? or from the asset store

grand jolt
#

or at least put some work into them

#

well it's from a tutorial

#

but I did it manually

leaden turret
#

ah cool, which tutorial?

grand jolt
#

the thing is the node this guy used doesn't exist for some reason so we had to come up with an idea to get around it

leaden turret
#

i'm kinda looking around for a good water solution for my project too, ideally performant & lightweight but with certain effects

grand jolt
#

and since it got complicated I decided to just not have foam and he told me he was gonna try to get it to work for himself and then send it

leaden turret
#

been trying to follow some tutorials myself, totally newb to shaders

grand jolt
#

so he sent it

#

I did it and it doesn't work because it wasn't the full thing, so I just guessed some stuff

leaden turret
#

hey our hero is here ๐Ÿคฉ

karmic hatch
# grand jolt

you're remapping the noise to be almost exactly 0.5 at all times, the In Min Max(2) should be 0, 1 since that's the range the noise covers

grand jolt
# leaden turret maybe look at how some other guys do it? ex. https://assetstore.unity.com/packag...

In this video I showed you how to make a water shader that has foams in it. It is one of my most requested video so far.

In this video you will learn how to make a simple or cartoon water shader and a Dynamic FOAM shader that you can apply to any water shader or can work as a base for adding foams in your water.

I have tried to explain everyt...

โ–ถ Play video
grand jolt
#

and is the foam visible from the editor

karmic hatch
#

Should be

grand jolt
#

ok

#

nothing

grand jolt
karmic hatch
#

My clamp was on another branch, bc i was using an exponential and didn't want it to get mad

grand jolt
#

ok

karmic hatch
#

or actually you might use it if you're using it for the color

#

but you don't need it for the foam

grand jolt
karmic hatch
grand jolt
#

as the uv right?

karmic hatch
#

yes

grand jolt
#

alr

grand jolt
#

uh the material icon turned red-ish orange

karmic hatch
#

strange

grand jolt
#

and this happened

karmic hatch
#

for the FoamNoise&Thickness property, make sure both values are >0

grand jolt
karmic hatch
#

yes

grand jolt
#

ok

#

it did this but it's the wrong color + it's just a line basically

karmic hatch
#

if you make the g value larger than the r value the noise should start doing its thing

karmic hatch
#

it's a vector2, it has an r and g component (x and y)

grand jolt
#

oh

#

so if x if bigger than y it will look randomized

karmic hatch
#

if they're different, it doesn't actually matter which is larger

grand jolt
#

almost

#

but the dots are stretched

karmic hatch
#

what did you put in for the UV?

grand jolt
#

is it object

karmic hatch
#

yeah you want the x,z components; this currently does xy by default but the y is vertical so it doesn't see any change

grand jolt
karmic hatch
#

swizzle

grand jolt
#

it gives them separately

#

oh

karmic hatch
#

(also there is a combine node)

grand jolt
#

which one r g b or a

karmic hatch
#

just put the position into the swizzle

grand jolt
karmic hatch
#

a float doesn't have a z component, that's why it's mad

grand jolt
#

but it's not white it's

#

green-ish(?)

karmic hatch
#

yeah currently i think you were setting it to black and then for whatever reason that gets greenified

#

in the branch, just lead it to a color node with white

#

or a float node with 1

grand jolt
#

the final

#

test

#

IT WORKSSSSSSSSSS

karmic hatch
#

:)

grand jolt
#

TYSM @karmic hatch

karmic hatch
#

np

#

good luck and good night :)

grand jolt
#

tyty

gray quail
#

trying to make a toon shader with a scribble effect on shadows. right now it uses GetMainLight().shadowAttenuation as a mask for the screen space scribble texture. what I want to do next (and where I'm stumped) is adding some noise to the shadow edge so the jaggies are not so noticeable. I want to avoid upping the shadow resolution itself. any suggestions?

brisk epoch
#

I was wondering how I could hide the backface with this shader?

meager pelican
# gray quail trying to make a toon shader with a scribble effect on shadows. right now it use...

Suggestions? Just off the top of my head....
Although you're doing screen-space shadows, you could distort the UV with some noise based on world-space xz location or some such. World space so that static objects would have the same distortion value every time. It would change for moving objects of course, but so does screen space.

Then there's just the scale of the textures themselves...might reduce the "jaggies".

meager pelican
grizzled bolt
karmic hatch
regal stag
restive lava
#

hey guys, i'm wondering, how would i be able to make an object be rendered directional, that is, no matter where you go the object is still in the same place, pretty much like a skybox

grand jolt
#

Hey, how would one make something in shadergraph that "stretches" a tunnel

#

as in the tunnel looks short from the outside but it takes longer to get through it than it seems from the outside

grand jolt
#

but what about warping a tunnel around you at the same time ๐Ÿค”

restive lava
#

i think you could do that by adding a mesh and making the mesh a camera render of another place and if you walk in the tunnel you get seamlessly teleported to that place

#

but in shadergraph i don't really know a lot about shaders

proven stirrup
#

can i use Shader.Find() for Shadergraphs somehow?
if i try Shader.Find(MyShadergraph.shadergraph) it returns null

regal stag
proven stirrup
#

yeah, i didnt think that i have to add the "Shader Graphs/"

#

with the Shader Graphs/ infront of the name it works. Thanks for the answer tho!

#

i added them to the always include shader list in the project settings

hearty obsidian
#

Halp, the screen position node output seems to have its y component negated when rendered via an overlay camera. Behaves fine with a base camera. Any workaround to retain the same behaviour across both types of cameras?

#

this is in 2021 LTS, iirc was fine with 2020 lts

gray quail
karmic hatch
restive lava
# karmic hatch can you not just use a skybox?

the reason why i wanted to use that was for a moon (i use BiRP) and the way i saw some people do it was just making a sprite move, one downside is you can go behind it, but you may think that you could just make the sprite move with you, but then the moon would render first than say a tree, and you could also say, use a lens flare but lens flares work weirdly, they disappear instantly, but i want them to be able to be seen just a little bit if you're behind a tree or something

karmic hatch
#

you could create another camera that doesn't move around, and then use that as the background

restive lava
karmic hatch
# restive lava could you explain it a bit more? like how to do it etc.

I haven't done it before myself, here's a tutorial https://www.youtube.com/watch?v=OmCjPctKkjw&ab_channel=Unity

In this video we're going to take a look at Camera Stacking with the Universal Render Pipeline, in short URP, using Unity! Using Camera Stacking you can layer game UI in Unity very quickly, and author high quality user experience.

Download the Cockpit demo, along with other URP example projects here!
https://on.unity.com/3jUFeQm

More info on...

โ–ถ Play video
tight phoenix
#

'Error unexpected token 'float3' at line 1'
I am not seeing its problem, can you?

#

float3 works just fine in other custom node hlsls

#

ah there was a missing , further down the line

tight phoenix
#

the problem cannot be the code so it must be one of the inputs

#

what space should the world light direction and view direction be in to calculate specular?

karmic hatch
regal stag
#

Yeah, use the Transform node, Tangent to World, Direction mode

tight phoenix
#

first time using world space normals

#

hmm interesting

#

there is a difference between when I built it from nodes vs. when I did it from a single custom node

#

The custom one must be right since its the original code

#

but as far as I can tell I didnt make any mistakes in the non-custom one

#

ah wait I think I found it

#

Yeah fixed it, the mistake was normal got used twice but I only set it to world space on one of them, not both of them

open quarry
#

does anyone have any examples of modifying the normal buffer in AFterOpaqueDepthAndNormal?
whenever i try to do it, it just returns a solid white texture

tight phoenix
#

texture proccessing question:

  • Noise looks real nice for making a procedural texture
  • The same noise however makes for a normal map full of very hard edges

Is there a way to like, lightly blur it to reduce the intensity of those edges?

karmic hatch
#

Inigo Quilez has some stuff on smooth voronoi noise

#

@tight phoenix

tight phoenix
tight phoenix
#

What is a Hash2f ๐Ÿค” I tried googling it but no dice

#

source: Inigo Quilez's smooth voronoi

#

google only has 8 results for hash2f and none are shader related

regal stag
#

I believe it's a function returning a random vector. Can see IQ's implementation in the shadertoy example : https://www.shadertoy.com/view/ldB3zc

vec2  hash2( vec2  p ) { p = vec2( dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3)) ); return fract(sin(p)*43758.5453); }
tight phoenix
#

Oooh you're right you're right

#

that made it click in my brain I have it (renamed) in another custom voronoi based on IQ's work

regal stag
#

Yeah that's the method Unity uses in their Voronoi node. Either will likely work

tropic sluice
#

Does anyone know how I would go about a planar projection of a texture onto another object so that it's written into it's render texture? I know it's possible to raycast onto an object and then draw a sprite at the hits UV coordinate, but that means it's dependent on the UV mapping... so it would be different sizes depending how the object has been UV mapped... I'm looking for a way to do the same but within world space to keep the sizing consistent between objects

meager pelican
tropic sluice
#

Sorry, I'm really struggling to describe it myself.

#

But yes I think so.

#

So I'm after what you might get in Blender when you're painting, or Substance Painter

#

Right now I have a version that raycasts, gives me the UV of the hit, I feed that into a shader

meager pelican
#

Right! You want to "paint" (or whatever) onto an object.

tropic sluice
#

And I draw a sprite there, but if I try it across two different objects

#

Then the size changes, so I assume this is where it needs to be in world space, or something like that

#

Exactly

#

I want to be able to paint across two objects keeping the size consistent

meager pelican
#

Please excuse this question, but why would you draw it on two different objects?

tropic sluice
#

If there is one object in the world, you might want to paint on that... then walk around a bit and paint on something else

#

Or maybe it's a modular level and you want to paint across modular sections

#

I already spent a couple of years working on a paint system, and I model everything with all it's issues in mind

#

But I'm basically trying to refine it so it's less dependent on how objects are UV mapped

#

So I can just use whatever objects I like

meager pelican
#

Let's say we have one 1-meter cube, two 2-meter spheres and three 3-meter capsules in "our world".
You want to be able to apply your paint decal and not have it change size?

#

And further

#

You want to set a modular template for all capsules?

tropic sluice
#

Sort of a decal, I need it written into the render texture that's on the object

#

But yes not changing size is the aim here

#

As you can see from the link I sent I already have a pretty robust paint system but if two objects are UV mapped differently it results in different sizes

meager pelican
#

hmmmm

#

If you didn't have to "stamp" it onto other objects, the answer is easy, as you know. You have unique render textures for each object.

#

Nice link/vid BTW ๐Ÿ™‚

tropic sluice
#

This is really hard to talk about.. I think that's half the problem, thanks

#

So the easiest way to really describe it is imagine if you had a projector

#

You load an image into it

meager pelican
#

So you're thinking you want to translate object1-uv-space to world space, and then world-space to object2-uv-space if it fits at all.

tropic sluice
#

You fire it at an object, or even two... and however the image lands on the object, I want that to be written into the texture

#

I think so yes

#

But I'm just struggling to fully comprehend whats involved\

meager pelican
tropic sluice
#

Yup

#

So in the video I sent there are actually two walls, theyre basically just quads, theyre side by side... and because they have the same UV maps, it works

#

WIth some trickery

#

But I'm wondering if there's a way I can do it across objects when the UV mapping isn't identicle

#

The wall in the video is actually 3 walls wide, with a render texture for each

meager pelican
# tropic sluice You fire it at an object, or even two... and however the image lands on the obje...

OK, one more question (at least).
Let's say we're projecting onto a screen-space sphere. What happens to the "backside" of the sphere that isn't visible? So I "splat" a bullet hole at some sphere and it hits at the side relative to the view direction, so only 1/2 the bullet hole actually shows. What should the render texture contain? See? Did the paint "miss" or did it wrap around the undrawn back side? Or is this not an issue?

tropic sluice
#

I basically don't care about the back side

#

Because it's just not a concern

meager pelican
#

OK, so you only have to map to visible areas

#

at the moment.

tropic sluice
#

Like in the video, those are just planes, they don't even have a back face

meager pelican
#

Fine.

#

Just checking

tropic sluice
#

And you can't get behind the walls

meager pelican
#

UV's are already size relative.

#

BUT....you need to know on a pixel by pixel basis, what the UV value is regardless of size.

#

IDK if I'm making sense, let's see.

#

If I had a projector and it projected a "star" onto a wall, and another one onto another wall that is beside it but bigger.

tropic sluice
#

That's where I'm at, I think I'm a little too stupid to comprehend whats involved

meager pelican
#

You don't want to have the same UV coordinates....and you wouldn't if you can somehow take the projection and map that to world-space UV results. Which is what you were asking to start with and now I'm getting it.

#

Do you by chance use a color index scheme, or are you using all three rgb channels to hold color?

tropic sluice
#

I'm using channels

#

So they're not set colours (indexed)

#

Does that make a big difference?

meager pelican
#

I was trying to cheat.
If you could free up two channels to store the uv values that ended up being used as it was interpolated across each polygon, you could get at them easier. Each pixel would know it's UV value ON READ.

#

If you project onto a "wall" whatever pixels you had projected onto would "know" their own uv's.

tight phoenix
#

Question, I have this dark spot in my height map, you can see its quite rounded.
I'd like it to be more steeply deep, but I havent been able to figure out how to multiply the values just in that specific range without affecting the steepness of the rest of the overall height map

meager pelican
tight phoenix
#

you can see in its hight map its pretty flat

tropic sluice
#

Sorry for being slow, still here, just thinking

meager pelican
#

NP, me too. I'm thinking about how we do it when we know the geometry because it is stored in a buffer for the shader to access. Let me think for a bit. AFK.

tropic sluice
#

Okay ๐Ÿ™‚

meager pelican
#

@tropic sluiceOK, I'm the one that's slow. ๐Ÿ˜‰
So I THINK you're already doing what you need to do. By that I mean:

How are you, now, casing your ray such that you decide on where to paint? I mean, with just one wall?

#

Somehow, you're projecting a ray onto a wall and calculating where to splat, right? And updating a render texture. Just one wall....

tropic sluice
#

Yes

meager pelican
#

And if that one wall happens to be a "small wall" it works. And if that one wall happens to be a "big wall" it works.

tropic sluice
#

I just use Physics.Raycast, the RaycastHit gives me a UV coordinate, I then have a custom shader that I use with Graphics.Blit to draw a sprite at that UV coordinate

#

I feed the UV coordinate of the hit into the material I use to blit

#

And also the distance of the raycast which I use to scale how big the splat is

#

But it means very little because it's dependent on the UV map scale at the end of the day

#

And yes if the walls have difference scaled UV maps, the splat is of an inconsistent size

meager pelican
#

Ha!
you can go backwards from that.

tropic sluice
#

Because it's drawn in UV space

#

That's exactly what I'm wondering

#

I can't work out how to do inverse UV space conversions and such

meager pelican
#

You want UV-Space to world-space (which is exactly what you asked, I'm just dense).

tropic sluice
#

Yeah that sounds about right to me

#

But I think I'm stretching my poor brain a bit too much ๐Ÿ˜‰

meager pelican
#

This crap is never considered "easy", just "experienced".

#

It's sounding more and more like a world-space projector to me.

tropic sluice
#

Yes

#

So if you've seen the projector thing in Unity... I basically want something like that which can actually write what it's projecting into the target objects render texture

meager pelican
#

Now if I knew off the top of my head the formula, we'd be all set. But I don't. Others might.

The thing is, you basically need to rasterize your bounding box if you can get it in world space, by the UV values, and map that rasterization to world-space interpolation onto another object probably regardless of orientation.

It might just be adjusting 2D height/width ratios. Come to think of it.

If I paint a splat onto a 1x1 wall, and then want to copy it to a 2x2 wall, I've got to cut the uv's in half and then locate an orientation/offset point.

#
newUV.x = rt1.width/rt2.width * spat.uv.x + spatUVOffset.x;
newUV.y = rt1.height/rt2.height * spat.uv.y + spatUVOffset.y;```
#

Of course you'd pre-calc with width/height stuff so as to not do it every time.

tropic sluice
#

I guess but the whole uvmap couldnt vary in density

#

Imagine how you UV map things, some areas take up more of the UV space

#

So the scaling might even vary across the UV map. nevermind between two different uv maps

#

That make sense?

meager pelican
#

Yeah, OK, so you need it to adjust to the new-uv-map however it is mapped.

#

So we're back to "how do you do it for wall 1"?
Can you "just" ray cast to wall 2 and get UV info? no? I mean, if you spat a circle onto wall 1, you can hit several triangles in one spat, and they could be uv mapped anywhere, right?

tropic sluice
#

Yes the raycasts give you back a UV coordinate

meager pelican
#

Do you basically ray-cast each pixel?

tropic sluice
#

Yes they could be uv mapped in any crazy way

#

So most of my objects are actually perfect squares, ie, they match uv space perfectly ๐Ÿ˜‰

#

No crazy stuff

#

No I raycast once, feed that into a shader, and then I turn every pixel that's within a certain range of that UV location white

#

it draws a circle

#

If raycasting were performant that would definitely be an option

#

But it's a lot of pixels and a lot of raycasts ๐Ÿ˜‰

meager pelican
#

But if you cross a triangle boundary, the uv maps COULD be split anywhere in the texture, conceptually, although they'd share at least one point.

tropic sluice
#

Exactly yes

#

That's one issue

#

Or maybe the UV mapping is distorted

meager pelican
#

BBIAB, AFK for a min

tropic sluice
#

So you paint, it gets drawn onto the uvmap as a perfect circle if you're actually looking at it in uv space, but once it's mapped onto the object it's distorted

#

I think it's because I need to draw somehow from within world space, and then transform it so that it fits into the UV space

meager pelican
#

This is for wall 1. Only one wall. Right?

tropic sluice
#

If I could work out how to do it with one, I'd spend time working out how to do it to two later ๐Ÿ˜‰

meager pelican
#

OK, I thought it was already working on wall 1, and you "just" had a problem with wall 2.

tropic sluice
#

Nope, that game is done.. it works

#

But it has the limitation that my objects basically have to be square planes

#

If you think of it like this... I'm casting a ray, it gives me a UV coord, I open up the texture and draw a perfect circle.... But if the uvmapping is all wonky, it wont look like a circle back in the world

#

I need to be able to project from world space, and convert it into the UV space so its wonky in the wonky uv space

#

Rather than the other way around

#

If you go into blender for example, and have your cat do the uv mapping of an object for you...

#

And then try to paint on it, it'll see look kind of okay

meager pelican
#

Right, that's what I'm worried about.
But can't you "rig the system"? In other workds, no weird UV mapping allowed?

But OK, let's project it into non-wonky uv space. By that I mean since we have a render texture of known size that we write into, and we know world space locations of ray hits...

tropic sluice
#

It'll look silly in the uv map view though

meager pelican
#

I mean, you're talking about rectangles, right?

#

Always rectangles that you paint?

tropic sluice
#

Currently I only know the world space location of the single ray hit

#

squares

meager pelican
#

OK, squares.

#

But that's all you need I think for non-wonky-uv-space

tropic sluice
#

Squares map perfectly to uv space ๐Ÿ™‚

meager pelican
#

So do rectangles.

#

But no matter.

#

We know the world-space locations of the corners of the quad.
We know the ray-hit location. We know the spalt size.

#

Yes?

tropic sluice
#

Yes

meager pelican
#

Non-wonky UV space is "just" the % across the quad in each direction.

#

So let's say we use UV set 4 for non-wonky uv space.

#

UV0 can still be whatever it is for texturing base albedo.

tropic sluice
#

ok

#

I'll make a little video of exactly what I'm getting at, few mins

meager pelican
#

So the quad's uv locations range from
x-start-WS at UV.x=0 to x-end-WS at uv=1
And similar for y.

#

And the splat is somewhere in the middle of all that, conceptually.
So the spat uv for the center is
uv.x = (splat-WS.x - quad-start-WS.x)/quad-width-WS

#

uv.y = (splat-WS.y - quad-start-WS.y)/quad-height-WS

tropic sluice
#

This basically demonstrates what I'm doing wrong vs what I want to do

#

And yes the UV map is intentionally very wonky ๐Ÿ˜‰

#

What I'm currently doing is like when I draw into the UV map

#

What I want to do is like when I draw onto the 3D object

meager pelican
#

I see.

#

OK, the thing is that raycast.rayhit is done on the C# side, right?

#

Then you pass it into the shader

tropic sluice
#

Correct

#

Yes using setfloat

meager pelican
#

OK, the C# side knows the whole mesh, and there's a c++ routine backing the function call, that is basically going through all the mesh data, figuring out what polygon the ray hit, and then knowing all 3 verts, it calculates where the UV's for that polygon were hit by the ray.

tropic sluice
#

ok

#

so you can get the uv coordinates for that polygon?

#

where those vertices lay in uv space?

meager pelican
#

Yeah, there are ray-triangle intersection tests....

#

If you want to wamp through the mesh on the C# side

#

But oy...

tropic sluice
#

Sounds like it could be slow

meager pelican
#

yeah.

#

But IDK why you want to do that. Just use another non-wonky uv set, like uv4

#

No wonky, no problemy

#

Assuming you're drawing on flat planes

tropic sluice
#

I think you have a point, maybe it will sink in soon

#

So it's basically just use another uvmap for paint only

meager pelican
#

Winner winner chicken dinner!

#

So let UV0 be the normal texturing, no paint. UV4 be the paint uvs

tropic sluice
#

So I have artists that just do whatever the hell they want

#

Then I go create a really simple planar uvpmap or something

meager pelican
#

Yeah

tropic sluice
#

In the other UV slot and use that

meager pelican
#

๐Ÿ™‚

tropic sluice
#

That makes a lot of sense

meager pelican
#

But you'll still have "challenges" if it's not planar objects. But for walls, or flat stuff, no problem.

#

There's probably other ways, storing decals instead. So you're painting on some invisible quad that gets projected onto the non-planar object, and you'd have to distort the paint to map back to the quad, and IDK how to do that exactly.

#

But for planes/quads no problem.

tropic sluice
#

Yeah I like the idea that things distort if you're not painting head on

#

It distorts from the spray cans perspective

#

Because that's how it would work if you were doing it in real life

#

But it's not the end of the world

#

As a trade off for a much simpler soluation

meager pelican
#

Well, again, I'm confused as to if we're talking about planes-only or not

#

Because if not...decal system should be thoroughly investigated.

#

Using projection.

tropic sluice
#

im still trying to work out the requirements

#

but basically planar projection should suffice

#

i think your idea of just doing a planar projection uv map is a good one

#

what blender and substance can do is very cool, and required because people are painting to non-planar objects a lot

#

most of my objects side of a train, a wall, etc

#

so some aren't truly planar, but they're near enough it wont matter

#

@meager pelican thanks for all your help

meager pelican
#

Yep, or you drive it all from C#, mostly. And then just "paint the result" using a shader.

Glad to help (and I hope I didn't confuse it).

serene creek
#

Hello, how can I use more than 16 sampler2D slots in my shader?
Thanks for any help!

kind juniper
#

Or rather samplers.

serene creek
#

Custom shader with different configurations, usually not all of them are active at the same time but the compiler still throw errors I guess when compiling all variants

kind juniper
#

What are the textures for? Can you not use a texture array instead?

#

Or an atlas with multiple textures in one.

serene creek
#

Has 3 albedo, 3 normal, 2 metallic and 1 occlussion, 1 emission, 1 parallax, 1 height, 1 cutoff, 1 SSS, and some other slots for Special effects like wetness, snow, dissolve, etc

#

I can't use an atlas because some textures are already 8k textures needed for a high end human skin render

kind juniper
#

Albedo could be put in one texture array

#

And normals

serene creek
#

WOuld you help me understand the concept of texture array?

kind juniper
#

But really, it feels like you're putting too much work on 1 shader.

kind juniper
serene creek
#

yeah but I know there are limitations from what I am reading because the GPU sees them as a single object

#

Im concerned they all need to have the exact same attributes

#

not all albedo are 8k textures

#

they also need to be able to set independently at runtime, not sure if this is a limitation

#

Im also concerned a texture array has the same source, meaning if I have x4 8k textures into an array that would be a 16k texture and is not supported I think

#

Anyhow, because I dont think textureArrays are an option and going back to the original question, forgetting the reason of why I need it, Is there any way I can I use more than 16 sampler2D sots?

kind juniper
# serene creek not all albedo are 8k textures

They are of the same size, yes. But you could sample only within the bounds of the actual texture size(handle that in the shader).
You can set them at runtime.
And I don't think Tex array size is calculated as a sum of its texture elements.

kind juniper
tight phoenix
#

Im having trouble remapping a very shallow range of values into a deep spike of values

#

the plateau is so samey that using stuff like power exponents isnt working

#

it keeps turning into a punch out

#

discord bot wont allow me to post a gif because apparently its explicit

#

the whole thing gets pushed in instead of gradiently pushed in

wanton grove
#

Why is my compute shader creating a bunch of memory use with repeated uses when recreating a buffer everytime I use it? I release the buffer and I don't think theres anything referencing it so why it the memory adding up?

kind juniper
wanton grove
#

Also this is in the editor

kind juniper
wanton grove
#

Oh sry

kind juniper
#

Just a note, but compute buffer is allocating VRAM. Not RAM.

wanton grove
#

Because I temporarily disabled it and it worked

kind juniper
#

What worked?

wanton grove
#

I constructed the compute buffer only once, but then my mesh wouldn't modify even if I re-set it to the shader.

#

I also tried using set data to clear it each time but that didn't work either

kind juniper
wanton grove
kind juniper
#

Also, you should probably use the profiler instead of task manager

wanton grove
#

Let me see if I can find any other references to the buffer

kind juniper
#

It's not the buffer...๐Ÿ˜…

wanton grove
#

Oh, ok

#

Could it be because I'm setting buffers/textures over and over again?

#

(not creating them, the SetBuffer() function)

kind juniper
#

Need to see your code to tell for sure.

wanton grove
#

Ok, I have two potential culprits, I'll send them really quick.

#

Also any general pointers for how to optimize this would be nice too cause I don't know how compute shaders work to well, specifically managing the buffers and stuff

kind juniper
wanton grove
#

First one is used at runtime aswell, second one is just editor.

#

The Bulge function is what causes it over time when I try to raycast it through the editor script

tight phoenix
kind juniper
kind juniper
wanton grove
#

Ok, here's what I got

#

I think the memory buildup was slower this time

kind juniper
# wanton grove

You should be able to see what exactly is occupying how much memory. I think it was supposed to be in the profiler Memory module details. There's also a dedicated memory profiler, although it needs to be installed via the package manager.

kind juniper
wanton grove
kind juniper
#

That could be from before the changes. Did you restart the editor?

wanton grove
#

I'm in the detailed part of the memory profiler and I'm looking for it now

kind juniper
# wanton grove no

Then you still have the leaked meshes in memory.๐Ÿคทโ€โ™‚๏ธ

kind juniper
#

Most likely

wanton grove
#

I do call new Mesh() quite a bit I think

#

but nothing references it

kind juniper
#

Did you read my message about mesh/shared mesh?