#archived-shaders

1 messages · Page 54 of 1

tight phoenix
#

I think my problem is that voronoi cells get distance from their center, but I need distance from the edges?

#

because the edges are not all uniformly the same value, they're all over the place, its only the centers the same value, so I am not able to mask the edges

#

but like, this person 100% is getting the edges

#

but I can't seem to parse their code

regal stag
#

The "Out" preview on the NewVoronoi node looks like distance to edges, but also looks like regular voronoi not the Chebyshev one

fluid salmon
#

im using a blend node in overwrite mode to overlay an image with transparency (overlayImg) onto another texture. How can I make it so that this step doesnt happen if overlayImg is empty? At the moment, if it's empty, the overwrite turns the output fully white.

Would this be a branch node or something?

tight phoenix
#

This only makes this harder, my comprehension sucks no matter how many hours I put into it, it feels like nothing ever becomes clear

regal stag
fluid salmon
regal stag
tight phoenix
tight phoenix
regal stag
#

Chebyshev Voronoi Edges

tight phoenix
#

my scene looks dramatically different in build compared to game view of the editor

#

how can I debug whats occuring here?

#

I cant click on and inspect any of the assets in the build version, and those are the ones I need info about

#

I have the debug profiler hooked

#

but how do I find that sepcific thing?

tight phoenix
#

I found the specific thing 🤔 through manual experimentation with what I figured it might be

#

Not sure how to fix it yet though

#

the problem is that I'm running this: ``` matPropBlock.SetFloat("_GlobalBrightness", value);

#

that value is getting set to 0 in build but not in editor

#

I dont know how that is possible because nothing in the scene is even scripted to do that

#

and its default value is 1

#

do MaterialPropertyBlock work differently between editor and build?

tight phoenix
#

ah, found the deeper actual problem

#

I am writing barycentric coordinate data to triangles, but the method that does this can't run at build runtime

#

the shader needs that data to be visible, thus why it was vanishing

raven hamlet
#

Can someone help me understand why this code isn't getting me a fragment's OS position?

                // clipspace frag position
                float u = IN.vertex.x * 2.0 / _ScreenParams.x - 1.0;
                float v = IN.vertex.y * 2.0 / _ScreenParams.y - 1.0;
                float4 ro = float4(u, v, -1, 1); 

                // obj space frag position
                ro = mul(UNITY_MATRIX_IT_MV, mul(unity_CameraInvProjection, ro));
frigid jay
raven hamlet
#

SV_Position is screen position right? e.g. in 1920x1080 space yeah?

frigid jay
raven hamlet
#

"... the SV_Position semantic (when used in the context of a pixel shader) specifies screen space coordinates (offset by 0.5)"

frigid jay
#
struct v2p
{
  float4 pos: POSITION;
  float3 objectSpacePos: TEXCOORD0;
};

v2p vs(float3 vertex: POSITION)
{
  v2p o;
  o.pos = UnityObjectToClipPos(vertex);
  o.objectSpacePos = vertex;
}

float4 ps(v2p i): COLOR0
{
  //  i.objectSpacePos is your object space position in pixel shader
  return float4(i.objectSpacePos, 1);
}
#

Something like that

raven hamlet
#

ah ok

#

So the space we're in in the fragment shader is clipspace

#

I'm not sure how unity handles the nearplane, I've tried both 0 and -1 which afaik are the standard options

near fable
#

Hi, I just imported an asset I got from the asset store and the materials are all pink. I had a look and they're using custom shaders. I'm also getting this issue:

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)```
Unity version 2021.2.8f1, and using URP
raven hamlet
#

I'm trying to get the position of of the fragment in object space for the origin of a raymarching ray. I have the position of the object in object space (the hit of the ray) no problem

junior iris
#

Why is the UV Coordinate node in Shader Graph a Vec4? What do the ZW channels represent?

#

I thought UV Coords are just Vec2?

safe ravine
#

I noticed that some packages show which rendering pipelines are supported. But it is not shown in the web page for my asset. How can I fix this?

frigid leaf
#

Hey everyone. I have a standard set of shader VFX I need to apply to all my models (like glow, fresnel, changing its albedo color). Every model will have the same pack of effects. I remember that it's generally not recommended to put multiple materials into a single mesh. Also, our game will have mods and that probably will include adding user VFX. How do I do this right? Do I have to combine both my surface shader and VFX into a single material or can I split them into multiple separate materials? What are drawbacks? (I'm using HDRP)

fossil cedar
fossil cedar
fossil cedar
fossil cedar
# raven hamlet I'm trying to get the position of of the fragment in object space for the origin...

fortunately, there's a number of raymarching tutorials and examples out there for unity. i recommend to follow one of these or at least examine their code as a frame of reference https://youtube.com/playlist?list=PL3POsQzaCw53iK_EhOYR39h1J9Lvg-m-g
https://youtu.be/S8AWd66hoCo

In this video we'll code a ray marcher inside of a shader in Unity that allows you to render 3d objects on the surface of other 3d objects, like a hologram!

Twitter: @The_ArtOfCode
Facebook: https://www.facebook.com/groups/theartofcode/
Patreon: https://www.patreon.com/TheArtOfCode
ShaderToy: https://www.shadertoy.com/user/BigWIngs
PayPal Dona...

▶ Play video
raven hamlet
#

I got it figured out

raven hamlet
#

transposing the matrix multiplication to go from camera space to object space ended up fixing the issue

                float4 ro = float4(u, v, -1, 1);
                float4 camSpace = mul(unity_CameraInvProjection, ro);

                // obj space frag position;
                ro = mul(camSpace, UNITY_MATRIX_IT_MV);
smoky widget
#

Is there a way I can make a camera render red and green in a normal way, but get only the minimum of the blue channel?

#

Like from all the colors that are affecting a certain pixel, get the minimum of all

shadow locust
#

if all your objects use a shader that takes the scene color and mins it with its own blue channel for example

frigid jay
#

For “RG” channels you will need separate pass. You can use alpha channel as imaginary “B” channel. Alpha channel blending can be configured separately from RBG

frigid jay
smoky widget
#

If its not too much, could you write somd pseudo code for how it would look like?

#

I think i understand the B channel thing, but not the RG

rare wren
smoky widget
frigid jay
smoky widget
#

Okay, so for example, how can I get the Youngest in front sort mode of particles to work on a custom shader¿

frigid jay
frigid jay
frigid jay
smoky widget
#

This using a default unlit shader

#

And this is using the default particle shader

smoky widget
#

Now, what I understand is that, i need to create a custom shader that will have first a pass that blends and gets the minimum of blue, then a second pass that renders Red and green and somehow get the blue from previous pass, (not super sure how) and then defined the remaining fields that would be needed to keep that particle working too

frigid jay
#

So, you need two-pass shader. First pass will calculate minimum in R channel. Options for this pass: “ColorMask B”, “BlendOp Min”, “Blend One One”
Second pass will have just one additional property: “ColorMask RG”

smoky widget
#

Ah! Disabling the Zwrite fixes that problem i had with the sorting!

#

Not sure how to remove the yellowish thing

#

Aha! changing it so that the first pass only returns the blue channel removes the yellow

#

Ah, not that's what I thought, but not really removing it

#

that's because blue also needs to be transparent with alpha

#

is that possible?

frigid jay
smoky widget
frigid jay
#

I am not sure that it what you need, but alpha premultiply can help you: outColor.b *= outColor.a;

smoky widget
#

Ah, multiplying wasn't working because where the texture was transparent i was getting a value of zero on the blue channel, where I actually needed a 1 there, the solution was

return float4(0,0,col.b+(1-col.a),0);
#

Now the result of all particles becomes this texture, which is what I wanted

karmic hatch
#

Maybe the scaling is different, it should be identical if world space and object space are the same (i.e. no rotation, no scaling, no offset)

clear veldt
#

Idk how to, I’ve been stuck for a little bit

mighty fiber
#

hey y'all, i'm having a little problem with some assets i downloaded. I'm working in Unity 5.6 because i'm modding a game but i tried importing assets made for unity 2020 after using the built in converter to make them usable with legacy shaders. However, something about the shaders or the code isn't working and is producing this conondrum. Please let me know if you have any suggestions.

vale salmon
#

made a shader graph called "scanned"

#

tried to make a mateiral from it but its just blank on the right side

#

tthere are no options for me to change anything like i have made the variables in the actually shader you can see on the left

#

the base color and fresnel power.

#

but i have no options for those in the inspector after creating a material from the shader graph

#

nvm i fixed it

#

didnt save asset

#

hm, but still have some problems. the shader isn't working as intended

#

the main preview is completely blank, and even after chaning settings in the material i create from the shader, nothing changes

#

nvm fixed

idle copper
#

Hello, is there a way to set the normal of a pixel being rendered in a surface shader? I want all pixels to be rendered with the same normal (therefore being lit the same way) regardless of the mesh. I also need shadows so I can't use an unlit material.

I did try setting the normal of the SurfaceOutputStandard, but that doesn't seem to work. Half of the mesh is rendered (kind of) normally while some faces are all black.

shadow locust
idle copper
#

It would basically be like an unlit material that casts and receives shadows

shadow locust
#

but with faces that are not facing the light can't he object itself be casting a shadow on itself?

idle copper
idle copper
#

Do objects cast shadows on themselves in Unity?

shadow locust
#

yeah

#

i think so

idle copper
#

Is there a way to disable that?

idle copper
#

Nvm, I found a shader online.

shadow locust
#

the concept is sound. I've seen it done before

#

maybe just an issue with your implementation

lyric tiger
karmic hatch
frigid jay
green peak
#
  Shader "Example/TestShader" 
  { 
    SubShader {
      Tags { "RenderType" = "Opaque" }
      
      CGPROGRAM
      #pragma surface surf Lambert
      
      struct Input {
          float4 color : COLOR;
      };
      
      void surf (Input IN, inout SurfaceOutput o) {
          o.Albedo = 1;
      }
      
      ENDCG
    }
    Fallback "Diffuse"
  }

why is it pink... I pulled this straight from unity

#

Figured it out, it needed a default Cull front

green peak
#

Nvm, it doest work

#
  Shader "Example/TestShader" 
  { 
    SubShader {
      Tags { "RenderType" = "Opaque" }
      
      CGPROGRAM
      
      Cull Front // this line is suppose to be before CGPROGRAM

      #pragma surface surf Lambert

      struct Input {
          float4 color : COLOR;
      };
      
      void surf (Input IN, inout SurfaceOutput o) {
          o.Albedo = 1;
      }
      
      ENDCG
    }
    Fallback "Diffuse"
  }

when I do this, the sprite works

#

although the code is wrong

#
  { 
    SubShader {
      Tags { "RenderType" = "Opaque" }
      
      Cull Front // this line is suppose to be before CGPROGRAM
      
      CGPROGRAM
      

      #pragma surface surf Lambert

      struct Input {
          float4 color : COLOR;
      };
      
      void surf (Input IN, inout SurfaceOutput o) {
          o.Albedo = 1;
      }
      
      ENDCG
    }
    Fallback "Diffuse"
  }

If i do this, the shader is back to purple

I have tested this with both Cull Front/Back/Off

what is GOING ON!!

regal stag
green peak
#

O

regal stag
#

Then yeah, not supported. That's why it's magenta. It's usually recommened to use Shader Graph instead

green peak
regal stag
# green peak I figured shader graph would be limiting in the long run...is that the case?

Hmm perhaps? There are some things shader graph can't do. Depends what you need the shader to do.
Can generate code from a graph (though that tends to be pretty unreadable). Could also copy one of the shaders under the URP package as a basis then edit if you really want a code one.
But it is easier with a graph and less likely for the shader to break with updates to the pipeline.

green peak
#

I see

neat horizon
#

Why is it taking so long, I don't have a shader that I created myself, I use it from the assets that everyone uses and not much

green peak
#

is ur code running?

#

is it paused at a break point?

#

post shader

#

you can click on material and click edit to see shader code

neat horizon
green peak
#

the assets themselves should have shader code

neat horizon
# green peak click it and send us code

There are 20 shaders in the project. I don't know which one is wrong and it doesn't show. If it gives an error after the build is finished, I will post it here

green peak
#

hmm

#

there is no point waiting

#

just restart, if it didnt work in 3 hours sure as hell wont work in 6

#

even if it does take 6 hours to work

#

its no sensible because everytime you make changes are you really gonna wait 6 hours?

neat horizon
#

ok how do i find it now

green peak
#

find what?

neat horizon
#

why is it taking so long regarding shaders?

green peak
#

could be anything really

#

No one understands the nature of ur program

neat horizon
#
public static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scaleBias, Material material, int pass)
        {
            s_PropertyBlock.SetVector(BlitShaderIDs._BlitScaleBias, scaleBias);
            s_PropertyBlock.SetTexture(BlitShaderIDs._BlitTexture, source);
            DrawTriangle(cmd, material, pass);
        }

this is the error code
s_PropertyBlock.SetTexture(BlitShaderIDs._BlitTexture, source);

clear veldt
green peak
#

any1 know why my materials arent matching?

#
 struct appdata {
                float4 vertex : POSITION;
                float4 color : COLOR; // Assuming the colors are provided as float4 in the C# script
                float2 uv : TEXCOORD0;
            };

            struct v2f {
                float4 pos : SV_POSITION;
                float4 color : COLOR;
                float2 uv : TEXCOORD0;
            };

            v2f vert(appdata v) {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.color = v.color;
                o.uv = v.uv;
                return o;
            }

            // Fragment shader
            // This shader simply passes through the color to the output

            fixed4 frag(v2f i) : SV_Target {
            
                fixed4 col = tex2D(_MainTex, i.uv);
               // col *= _Color;
                return col;
            }
karmic hatch
# clear veldt So what am I supposed to do then? I’ve pretty much tried everything

I think if you have something that roughly does

worldPos = worldPos - vec3(0,1,0)*(worldPos.x * worldPos.x / x_radius + worldPos.z * worldPos.z / z_radius)

where worldPos is the world-space vertex position, then it should create the desired effect. (If the object has triangles about as large or larger than min(x_radius, z_radius), you will have issues). There should not be any dependence on rotation or scaling with this. (You can switch the Vertex node to take a world-space position so you don't need to do any transformations yourself)

clear veldt
#

I may have a script for something like this, I’ll try it

karmic hatch
green peak
#

Not sure, still learning 🙂

green peak
karmic hatch
# green peak how can I verify

If you do col = fixed4(uv, 0, 0); it should show the UVs and it should be black in one corner, yellow in the opposite corner, and then green and red in the two remaining corners

green peak
#

I am creating a procedural mesh

karmic hatch
karmic hatch
green peak
karmic hatch
# green peak what do I set it too?

if you don't want the texture stretched and it's aligned perpendicular to z, we can define d = max((max(vertices.x) - min(vertices.x)), (max(vertices.y) - min(vertices.y))) as the size of your mesh, and then you want your uvs to be Vector2((vertex.x - min(vertices.x))/d, (vertex.y - min(vertices.y))/d) where vertex is the particular vertex for that element in the array. (note that max(vertices.y) is not valid, if you don't a priori know the maximum size of your mesh, you will have to loop over the array. You probably do know how big the mesh is though since you're making it with code so it should be fine)

green peak
#

What is the best way to add depth to my meshes

#

Using different materials has its limits

grave vortex
#

How can I use Nsight's shader profiler with Unity?
I can't seem to get a build to include shader symbols

clear veldt
neat horizon
#

Shader error in 'Universal Render Pipeline/Lit': maximum ps_4_0 sampler register index (16) exceeded at INVALID_UTF8_STRING(9) (on d3d11)

I am getting this error after getting build

clear veldt
#

I made a shader graph that curves world but objects that have rotation have this weird offset and float around. I still haven't been able to fix this after a few days

neat horizon
reef turret
#

Hey, is there any possible way to use a graphics shader with a compute shader? I'm trying to use the Raymarching technique to blend meshes together to simulate a fluid like effect, I'm using URP

lucid geyser
#

Does anyone know of a great source for making unity shaders? I want to create 2d effects on a cimple circled. is something like this possible in unity ? https://www.youtube.com/watch?v=f4s1h2YETNY

In this tutorial, I explore the fascinating realm of shader art coding and aim to offer helpful insights and guidance to assist you in beginning your own creative journey. I hope to share my passion with you along the way!

Final shader: https://www.shadertoy.com/view/mtyGWy

Resources presented in the video:
• Shadertoy: https://www.shadertoy.c...

▶ Play video
#

like can this be applied to a basic white circle sprite?

#

@karmic hatch do you know of any good sources for this ^^^

fossil cedar
fossil cedar
# lucid geyser Does anyone know of a great source for making unity shaders? I want to create 2d...

you can also look up general GLSL to HLSL resources like this which are also helpful. the languages are very similar in structure. https://learn.microsoft.com/en-us/windows/uwp/gaming/glsl-to-hlsl-reference

fossil cedar
fossil cedar
# reef turret Hey, is there any possible way to use a graphics shader with a compute shader? I...

yes, you can execute compute shaders that write to a graphicsbuffer or computebuffer or texture, and then read those buffers or textures in traditional "graphics" shaders i.e. vertex or pixel shaders. all told this can be quite an endeavor but there are some examples out there. here is one with links in the video's description to example code and also some assets that are further developed and more efficient https://www.youtube.com/watch?v=eisCx-pC0oo

fossil cedar
# reef turret thx

np. there's also screenspace fluid rendering, and isosurface mesh generation like marching cubes, dual contouring, or surface nets. just to give you some other techniques to look into.

lucid geyser
#

Why is my sprite showing up as this color? what

#

the green should be transparent and the yellow should be white

fossil cedar
fossil cedar
#

can you screenshot that, and the texture format listed below the inspector preview

#

there's weird texture formats sometimes

lucid geyser
#

it's doing it with every sprite that i use

#

it's doing it with this sprite

fossil cedar
#

even the built in sprites?

kindred cradle
#

I've now followed two separate tutorials for some water shaders and both times after applying the shader to an object my unity editor Scene tab is very choppy.
The game runs fine and if I RMB and move around in the Scene it runs smooth.
Is this a normal issue?

lucid geyser
#

this is a built in circle sprite

fossil cedar
# lucid geyser yes ^

wild, is it only in shadergraph? or does it look yellow and green in the game and scene view also?

lucid geyser
#

in scene as well

#

i got the transparent part to disapear but the white is yellow

#

this is scene^

fossil cedar
#

not exactly sure but unless i'm missing something, i feel like it could either be a unity bug, or a bug or error with your gpu or the gpu drivers

#

it even happens when you create a new shadergraph?

lucid geyser
#

is it possible that i'm using the wrong shader ? i'm totally new to shader stuff. just doing tuts

#

I also changed my pipeline asset to a custom 2D URP

#

here are the pipleine assets

fossil cedar
#

maybe sprite textures are weird, i haven't used them with shadergraph

#

i know they aren't regular textures exactly

#

that's why the texture importer has an option for sprites, because they are unique in some way

lucid geyser
#

I'm also new to game development so... ya i probably effed something up somewhere.. what would you double check first?

#

instead of using a sprite... what would you use?

fossil cedar
# clear veldt I made a shader graph that curves world but objects that have rotation have this...

this is a few years old but there might be a special shader graph type for sprites https://kylewbanks.com/blog/sprite-shader-effects-with-unity-and-shader-graph-part-1-getting-started

lucid geyser
#

i literally just want to make effects using a circlular png or sprite whatever

#

i don't need to use sprites

clear veldt
fossil cedar
#

but yeah you could also not use what unity considers sprites, just a regular 2d texture on a quad / rectangle which is what i usually do but i work mostly in 3d

fossil cedar
clear veldt
#

In the shader graph

fossil cedar
#

but in the "old days" have the alpha mask be baked into an rgb texture as bright green or magenta, etc was common

#

so that's what i'm wondering but just guessing

lucid geyser
#

Check this out. so all tuts have showed something similar to this when creating a brand new mater shader. the only different is this whole "fragment" and "vertex" thing is't included. i'm thinking i might be using the wrong kind of shader as a starting point?

#

the tuts show somthing like a "sprite lit master" which i don't have

#

notice i'm plugging a v4 color into a base color 3 and taking the alphga and pluggin gthe alpha 1. that seemed to resolve the greeen parts of the sprite.. but i'm thinking the yellow issue has something to do with the weird fragment and vertex starting point

fossil cedar
#

sorry for linking to an old article

#

i'm testing something quick

lucid geyser
#

ahhh wait... do i just need to plug in a color node into the base color 3?

#

i think this is working

fossil cedar
#

@lucid geyser i was going to say try this on the texture import settings

#

change from sprite to default

#

but that's just a guess

lucid geyser
#

ok i got it to work...

fossil cedar
# fossil cedar change from sprite to default

it maybe makes no difference, maybe sprite is just another way to tell the editor you want have the option to edit the texture pixel by pixel but doesn't change the texture format, so more to the point of what @clear veldt was saying.

clear veldt
#

notlikethis wdymmmmmmmm

fossil cedar
#

i haven't done much 2D sorry for going on with some wild guesses

fossil cedar
#

anyway, sorry off topic

clear veldt
fossil cedar
#

@lucid geyser even though you worked around the issue the yellow green seems strange. i would try restarting unity or restarting your computer at some point, and try updating the GPU driver to see if it persists or goes away. not exactly the same issue just little dots but bright yellow and green. the person updated their GPU driver software and it went away https://forum.unity.com/threads/weird-green-and-yellow-pixels-appears-on-textures.386844/

fossil cedar
# clear veldt But I’m working on 3d

oh yeah true, well i haven't worked with sprites in the sense of unity's texture type either and they seem geared towards "(2D or UI)" according to the dropdown. so i guess that could be UI in 3d game. also is think particlesystem uses sprite type? but i mostly use vfx graph for particles and "default" texture type

clear veldt
#

Ok

tranquil jackal
#

thank you I will try to do that. I am using Memory profiler, and checking what it says.

fossil cedar
# kindred cradle I've now followed two separate tutorials for some water shaders and both times a...

this sounds likes normal default behavior in scene view in edit mode. unity tries to optimize some things in the editor to not run unless you are interacting with them. there are a few things you can do, enter play mode, and/r make sure "always refresh" is enabled in scene mode setttings, it's in a drop down that looks like a sparkle for "effects." there are also some editor scripts to force the editor to repaint every frame but they aren't really officially supported so might have strange results

fossil cedar
# clear veldt I made a shader graph that curves world but objects that have rotation have this...

i had a response to you about this already but i lost it i have to retype it lol. i was going to say, i'm not sure what your goal is, but it *looks *like you are (rail) "road building" and in that case i recommend using the Unity Spline tool package for this "road / world bending" on the CPU / in C# script land which will have fewer bugs and weirdness down the road (literally) than doing large movements of the game world "en masse" via on the GPU in shader land.

vertex position offset shaders like this should generally only be used for small movements like leaves blow in the wind, or MAYBE for some large movements that are only visual effects in the background like a thousand birds flying in the background that you never touch or electricity beams or sparks that fly right through you but you don't have any game logic attached to them. or maybe a weird world bending cinematic.. even then i would probably use the Mesh API and a script or compute shader instead of a vertex shader

assuming splines are the way here i think #🔀┃art-asset-workflow is the place to discuss the Unity Spline Tool further, i can see people have discussed it there.
https://blog.unity.com/engine-platform/building-better-paths-with-splines-in-2022-2
https://www.youtube.com/watch?v=CyN8Rw18_zw
https://www.youtube.com/watch?v=kNMu83sU948

clear veldt
#

My worlds already bends, some objects just float around

fossil cedar
#

@clear veldt ohh because it's endless runner, the world coming at you is 3D but the player only interacts what's essentially a 2D plane. so it doesn't matter gameplay wise if the world bends in front of you with a shader. sorry for misunderstanding.

#

@clear veldt in this case i noticed a few months ago Unity released an official endless runner game example. i looked it up and it says it includes a "curved world shader". perhaps we can use this shader or at least cross reference it to your shader graph to help resolve the issue. https://assetstore.unity.com/packages/templates/tutorials/endless-runner-sample-game-87901
this tutorial related to the example says "The files to examine to see how this works are WorldCurver.cs, and CurvedCode.cginc"
https://learn.unity.com/tutorial/mobile-development-techniques#5c7f8528edbc2a002053b4ab

lucid geyser
#

How can i make my shader sprite render behind other sprites?

lucid geyser
#

yes, it doesn't behave the same as othe rsprites

fossil cedar
#

there's a number of ways. i think that doc lists all of them

lucid geyser
#

this doesn't help.

#

I want to speak with a person about it.

fossil cedar
#

i'm a person lol but i don't work for Unity. it's just a community forum

#

responding immediately with "this doesn't help" means you didn't even try. (or if you did find and try these methods earlier, i guess you aren't saying what happened or why it didn't seem to work?)

#

i recommend trying the first two methods in the doc. either put the sprite in a sorting layer and rearrange the layers so yours is in the back, or set the render queue for that renderer to a number lower than the other renderers

  1. Sorting Layer and Order in Layer
  2. Specify Render Queue
#

there's screenshots in there for how the sorting layers work even

lucid geyser
#

Does anyone know how to have multiple objects use the same shader but behave indipendantly of one another?

uncut inlet
#

why do my textures look like this after sampling

vocal narwhal
shadow locust
vale spruce
#

is there any performance cost of Shader.SetGlobalMatrix rather then setting them one by one ?

#

this tutorial telling me to use two kind of struct v2f, and for some reasons it works, but I don't understand how

green peak
#

structs are just objects

#

you can have multiple

vale spruce
#
InterpolatorsVertex MyVertexProgram (VertexData v) {
    InterpolatorsVertex i;
    UNITY_INITIALIZE_OUTPUT(Interpolators, i);
    UNITY_SETUP_INSTANCE_ID(v);
    UNITY_TRANSFER_INSTANCE_ID(v, i);

    i.pos = UnityObjectToClipPos(v.vertex);
    i.worldPos.xyz = mul(unity_ObjectToWorld, v.vertex);
// rest of code
}
vale spruce
#

both struct variable name is i

green peak
#

doesnt look like it

#
InterpolatorsVertex MyVertexProgram (VertexData v) {
    InterpolatorsVertex i; // <----- I see only one!!!!
    UNITY_INITIALIZE_OUTPUT(Interpolators, i);
    UNITY_SETUP_INSTANCE_ID(v);
    UNITY_TRANSFER_INSTANCE_ID(v, i);

    i.pos = UnityObjectToClipPos(v.vertex);
    i.worldPos.xyz = mul(unity_ObjectToWorld, v.vertex);
// rest of code
}
vale spruce
green peak
#
 UNITY_INITIALIZE_OUTPUT(Interpolators, i);

what does that function do, i would guess your answers lies there

vale spruce
#

oh... now that I look at it seems like the turtorial actually split the v2f vert (appdata v){} into multiple function

green peak
#

hahaha, catlike coding is it?

#

He does that, gives you the answer before the question and ur left guessing unless you read along

#

I recommend you do a quick read of the full page, then come along a second time

vale spruce
#

I see... thanks, I guess I need to reread it again

green peak
#

Anytime soldier, we are all in this battle together!

karmic hatch
karmic hatch
green peak
#

not a shader question but,
you already did?

stable cove
#

i'm sorry wrong channale

frail violet
#

Greetings. I'm using standard pipeline on Unity 2020.
I'm trying to make a shader for a material on a cube.

I want the top face to be a certain texture, and I want the side faces to be a different texture.

I want it to tile based on x and z scale (but only on the top face).

I want the textures to be emissive. I want to be able to control the color, and intensity (values greater than 0).

I found some examples online, but they were all based on world position, and couldn't figure out how to do it just based on the local normals and scale of the cube.

shadow locust
# frail violet Greetings. I'm using standard pipeline on Unity 2020. I'm trying to make a shade...

YOu can do this with:

  • multiple materials (requires your mesh is broken into submeshes)
  • UV mapping (you will need to UV map your mesh such that each face uses a separate UV coordinate section)

With the UV mapping approach you can either combine all your textures into one, or do a mapping in your code where you figure out which UV section the fragment is in and then normalize the UV to fully map it to one of the input textures

frank sparrow
#

can anyone give me some advice, i am trying to make a shader graph that is just turns a plane into a moving sine wave. ive experimented a load and i just cant seem to do it and cant figure it out. i have been told this is a relatively simple vertex shader but all i end up doing is changing the position of the entire plane or scaling the plane so I cant figure out how to individually change the vertexes to map to the sine wave. any pointers would be appreciated thank you

fluid salmon
#

hey everyone! I have a beach shoreline inspired by Cyanilux's animal crossing twitter thread.

I have the waves flowing like in the first image in time. I'm using the second image as a mask to make it seem like the waves start off separate and combine to form one. However, I'd like to make it so there is variance. I dont want all the waves to start off as the same size. Does anyone have ideas as to how i could do this?

shadow locust
#

basically somethinbg like this is what you want to express in the graph, as an example:

vertex.pos.y = vertex.pos.y + Sin(time + vertex.pos.x)```
#

depending on what effect you want you may include the z position in there somehow too, or not

frank sparrow
#

alright, is there a node to access vertex position? i presume it isnt vertex id/color

shadow locust
#

yep, the Position node

frank sparrow
frank sparrow
shadow locust
#

I'm not familiar with gerstner waves but there seem to be many videos about that online

frank sparrow
shadow locust
#

we want a vertex shader here

frank sparrow
#

im feeding it into the Postion bit on the Vertex

#

okay ill try test around more, ive been using the object position node before so ill see what i can do

frank sparrow
shadow locust
#

even when I "open in browser"

frank sparrow
#

oh sorry

#

let me get a better screenshot

#

any better?

shadow locust
#

try adding just x

frank sparrow
#

oh crap yeah

#

is that just a single node or something else?

frank sparrow
#

does that mean i could select any two of those and they would be equal to x and y since the vector position is less than four inputs?

#

not any two actually, the first two and that would be X and Y

regal stag
#

The position is a Vector3, so there's also a Z component (aka B). RGBA=XYZW

frank sparrow
#

what would the W component be?

#

oh my god its so beautiful

regal stag
#

In this case, for the Split it should just be 0 as there is no w component for a Vector3.

frank sparrow
#

ah okay thats good

#

thank you soo much PraetorBlue and Cyan, i have done it, now for some minor adjustments

regal stag
# frank sparrow

Also to add to Praetor's suggestion, you might want the result of the Sine here to only offset vertices along the vertical/Y axis. Can put it into a Vector3 node before adding to the original position to do that.
Though something to keep in mind for later, when doing actual Gerstner wave calculations they usually have some horizontal/XZ offset too.

frank sparrow
#

i didnt know i could store them in vector3 variables, thank you very much. gonna be much easiser now i think

grave vortex
# grave vortex How can I use Nsight's shader profiler with Unity? I can't seem to get a build ...

Just bumping my previous question

Clearly using Nsight to profile unity shaders is possible, as evidenced by this video, but I haven't been able to find any information on how to export shader symbols with a build

https://www.youtube.com/watch?v=l_LiE1vAFhM

Unity's High Definition Render Pipeline (HDRP) makes it possible for developers to unleash their application's full potential using a custom renderer. With this great power, comes great responsibility; more than ever you need to ensure that your application maintains optimal performance so your users can have the best experience possible. Learn ...

▶ Play video
fluid salmon
# regal stag Also to add to Praetor's suggestion, you might want the result of the Sine here ...

hey Cyan! In your old animal crossing shoreline shader (https://twitter.com/Cyanilux/status/1251899743644549122) you have the waves starting off separated and combining as they get closer to the shore. I assume you're using a mask like the one i've attached. How would you make it so that the distance between these separated waves varies? So that the waves dont all combine at the same time?
I'm thinking offsetting the Y coordinate of that texture based on some randomness?

regal stag
drowsy coral
#

Hey everybody, this is with built-in rendering pipeline.

#

I'm trying to set fog colors from a dictionary.

#

Setting the fog color beforehand in the editor and not modifying it in code comes out fine:

#

But as soon as I set it in code, look what happens, no matter what setting I change.

#

The fog is pure white, and I can't even go change it in editor! (Granted, it's because I'm changing it once per frame in an update function, but still).

#

But it comes out as white.

#

Also I start getting depth errors with my billboarded sprites, but that's a whole nother issue.

celest citrus
#

Hi! I need to create a shader using shader graph that will procedurally generate a space background with stars. The main problem is that I have to use sprites of stars for this.

I will be glad if somebody could explain how to do this or where to search for guides.
Thanks!

polar ruin
wary axle
#

I want to write shader in unity, but it does not create an error in unity, but it gives an error through visual studio, how do I solve it (visual studio is defined in unity)

clear veldt
karmic hatch
karmic hatch
#

If the vertex position input is still set to object space in the node inspector it's going to break everything when object space isn't world space (i.e. when something rotates) but if everything is in world space it should work

frank sparrow
#

is there any reason I cannot connect these nodes

#

they have been connected in the past and now I cant reconnect them

regal stag
frank sparrow
#

is there a way I can take the height of the vertexes used in a shader graph and use them in a script?

regal stag
frank sparrow
#

thank you

#

i have decided i hate gerstner waves too

ebon moss
#

Hey, I have a wind effect shader graph and I'm trying to turn it into a wind vignette (wind effect around the edges of the screen), any ideas how I coulod do this

kindred crystal
#

hey there

#

having an issue with a custom character shader, on mac it doesn't cast shadows and ambient occlusion draws on top of the character. on windows it's fine. seems like something going on with the camera depth buffer? anyone ever seen a thing like that?

kindred cradle
#

Anyone know why my exposed shader graph properties aren't editable from the Unity UI?
In the image I have selected "Size" which shows it is "Exposed" from the Inspector but in the material everything is grayed out except for the Colors.

kind juniper
kindred cradle
kind juniper
kindred cradle
#

I tested this on a Core RP converted to URP and a brand new URP project, saved in different areas so idk whats going on man! 😂

regal stag
kindred cradle
kind juniper
#

Aha, so it was a "default asset". Didn't know that the shader graph creates a material for you now.

split thorn
#

anyone know if it is possible to get a shader range property min value and max value?

kindred crystal
#

set on the material e.g. material.SetFloat

#

as soon as i reference any of those uniforms, the depth pass for this material gets dropped. not in the framedebugger.

vale spruce
#

Anyone could think a better way to write this?

float xCoordsColor = i.customShadowCoords.x > 1 ? 0 :  i.customShadowCoords.x < 0 ? 0 : 1;
float yCoordsColor = i.customShadowCoords.y > 1 ? 0 :  i.customShadowCoords.y < 0 ? 0 : 1;
return xCoordsColor * yCoordsColor;
#

I just want it when i.customShadowCoords.x and i.customShadowCoords.y both value is between 0 to 1, it will give me 1 as value, else it will give me 0

kind juniper
#

Clamp..?

vale spruce
kind juniper
#

Nvm. Misread the code.

vocal narwhal
vale spruce
#

yeah... looks more expensive probably no 😅

vocal narwhal
#

I doubt it's more expensive, it's branchless 😄

vale spruce
#

hmm... maybe you are right

vocal narwhal
#

1 - saturate(abs(floor(x))) also an option for the equation.
You can have a play around with something like graphtoy and see if you can get it any better

vale spruce
#

I see... thanks

vale spruce
#

float result = 1 - saturate(abs(floor(i.customShadowCoords.x)) + abs(floor(i.customShadowCoords.y)))
ok found the answer

amber saffron
#

An other way ? 🙂

float2 t = uv;
t = step( abs(t-0.5), 0.5);
float result = min(t.x, t.y);
vocal narwhal
#

I was trying to avoid step. but there are lots of ways 😄

amber saffron
#

Any reason why ?

#

Similar without step :

float2 t = abs( uv - 0.5 );
float r = max(t.x, t.y);
r = 1.0-floor(r*2.0);
vocal narwhal
#

🤷 min(step(0, x), step(x, 1)) just chain a whole bunch of steps together, then you have the same solution has the first one but with a fancy function instead

frank sparrow
#

In the position node, what does the Object and World actually correlate to?

vocal narwhal
frank sparrow
vocal narwhal
frank sparrow
#

ah alright ill give it a read thank you

#

okay i think i get it thanks

civic oxide
#

Does anyone know of a free dynamic culling system I can use that works with hdrp?

amber saffron
civic oxide
#

yup

civic oxide
#

I need it to be bakable during runtime and the only free solution I've found so far is onot compatible with hdrp

amber saffron
#

Okay. Well I don't know any runtime solutions, sorry

frigid jay
#

Can give you insights maybe

kindred crystal
# kindred crystal as soon as i reference any of those uniforms, the depth pass for this material g...

sorry to be a bother, this issue is driving me crazy. i set up a windows dev environment to see what the frame debugger looks like on that side. i boiled down the shadowcaster to something minimially reproducible (well, in our project anyways):

Pass {
    // -- options --
    Tags {
        "LightMode" = "ShadowCaster"
    }

    // -- program --
    CGPROGRAM
    #pragma vertex DrawVert
    #pragma fragment DrawFrag
    #pragma multi_compile_shadowcaster

    // -- includes --
    #include "UnityCG.cginc"

    // -- props --
    float1 _Distortion_Intensity;

    // -- types --
    struct FragIn {
        V2F_SHADOW_CASTER;
    };

    FragIn DrawVert(appdata_base v) {
        FragIn o;
        TRANSFER_SHADOW_CASTER_NORMALOFFSET(o);
        o.pos.y += _Distortion_Intensity;
        return o;
    }

    float4 DrawFrag(FragIn IN) : SV_Target {
        SHADOW_CASTER_FRAGMENT(IN);
    }
    ENDCG
}
#

on windows, the camera depth pass for this material appears in the frame debugger, the shader property is bound correctly

#

on mac, w/ the same exact code, this DrawMesh frame is missing from the depth pass unless i remove the reference to _Distortion_Intensity

grave vortex
frigid jay
grave vortex
#

I was using Vulkan for Nsight GPU trace, as it doesn't support D3D11

grave vortex
lone crow
#

Why isn't the material with emission on isn't emitting any light onto surrouding objects?

frigid jay
# lone crow Why isn't the material with emission on isn't emitting any light onto surrouding...

Emission materials by default represent materials that not follow to light energy conseravtion principle. I.e. those materials can reflect more light energy then recevie from all surrounding light sources. Those materials are not light sources. For more realistic look with multiple light energy bounces (in other words light energy emitted from object is applied to surrounding environment) you need some form of Global Illumination (GI)

lone crow
#

So If I add a mild light source and raise the intensity value of the color on the material, that should make the material emit green light right? Or it woudl appear that way

#

small amount of light falling on the material which doesnt affect the cube much but the material will reflect more light than what is being received because of high emission intensity

#

is this how it works?

shadow locust
#

in other words

#

baked lighting

#

and it's generally not going to be realtime

lone crow
#

I have realtime global illumination on

shadow locust
#

I think to receive realtime lighting from this, you probably need light probes?

#

In this video, we talk about 2 ways to use emissive materials inside of Unity! Learn both how to bake emissive lights for static objects and a method to simulate emissive light in real time!

LINKS
UNITY EMISSIVE MATERIAL DOCUMENTATION
https://docs.unity3d.com/Manual/lighting-emissive-materials.html

UNITY ASSET STORE
http://www.therealtimeessen...

▶ Play video
#

even in this video he uses a point light i think to get it to actually work in realtime

lone crow
#

Now its clear

kindred crystal
# kindred crystal on mac, w/ the same exact code, this `DrawMesh` frame is missing from the depth ...

can confirm after inspecting the compiled output for d3d and metal and they both include a shadowcaster pass compiled for the same set of keywords. on mac, the shader inspector lists "Cast shadows" as no. and if i log the number of passes in the shader, on mac in reports 1 and on windows it reports 2:

Debug.Log($"[shader] {shader} subshader {shader.subshaderCount} pass {shader.GetPassCountInSubshader(0)}");
#

wish unity were open source

kindred crystal
#

pretty much at the end of anything i can imagine trying, running into the brick wall of whatever is happening behind the c# <> native shader bindings. no idea why unity is dropping the shadowcaster pass on mac.

split oyster
#

How do I render 1 milion of 2D circle sprites facing always the player?

lunar valley
#

indirect gpu instance 1 million quads and make them face the player inside the vertex shader

split oyster
#

I have a problem with indirect gpu instance... I was following a guy tutorial but I didn't understand a thing
for set vertex positions... have I to use a matrix?

struct appdata_t {
                float4 vertex   : POSITION;
                float4 color    : COLOR;
            };

            struct v2f {
                float4 vertex   : SV_POSITION;
                fixed4 color    : COLOR;
            }; 

            struct MeshProperties {
                float4x4 mat;
                float4 color;
            };

            StructuredBuffer<MeshProperties> _Properties;

            v2f vert(appdata_t i, uint instanceID: SV_InstanceID) {
                v2f o;

                float4 pos = mul(_Properties[instanceID].mat, i.vertex);
                o.vertex = UnityObjectToClipPos(pos);
                o.color = _Properties[instanceID].color;

                return o;
            }
#

I wanna use a float3 instead of matrix and float4 stuff... is it possible? I heard that float for vertex is necessary for not break the rendering... so is there a way to efficiently convert float3 to float4 in shaders?

tacit hearth
#

does anyone happen to know of a shader graph node that will let me colorize an inputted texture? i want to be able to colorize images white but multiplying by the color white obviously just uses the original color from the image

kind juniper
tacit hearth
kind juniper
#

If you change all the colors to white, you'll get a completely white texture though...🤔

tacit hearth
#

or shades of

kind juniper
#

Do you have a specific example of it from an image editor?

tacit hearth
#

well colorizing in image editors does different shades according to the strength of the color, so i suppose its similar to trying to create a heightmap from a color texture

#

but ill screenshot 1 sec

#

original:

#

colorized white / grey:

kind juniper
#

I think that's just decreasing the saturation of the image.

tacit hearth
#

ah really? ill try a saturate node then, cheers

kind juniper
#

No, saturate in shaders is a different thing afaik. It just normalizes the values.

tacit hearth
#

ah

#

hmm, not sure which node would fit the bill....ill look about

kind juniper
#

I think you can use Colorspace conversion node to convert to HSV, then set the S(saturation) to 0 and convert back to rgb.

tacit hearth
#

this mayhaps?

kind juniper
#

Ah wait, there's actually a "Saturation" node as well

tacit hearth
#

aha!

#

that may be it

kind juniper
# tacit hearth

This just replaces the colors. I'm not sure that's what you want.

kind juniper
tacit hearth
#

thanks, i knew saturate existed....but not saturation XD

#

this opens up wild possibilities 😛

vale spruce
#

so I'm getting baked shadow by doing

indirectLight.diffuse = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.lightmapUV));

but what I actually want is toon like shadow, so... is there a away to bake like toon shadow (without any gradient)?

amber saffron
tight phoenix
#

in shader, is there any way to get/lerp over an objects bounds? As in like, have a shader effect isolated to its worldspace min/max bounds?

#

Ideally without passing in vector3s through a material property block UnityChanThink I can do that, but I was hoping the shader has access to the bounds directly?

#

oh object node has bounds 👀

#

how do I "get" the bounds in object space?

#

i guess i could do two transform nodes for min and max

#

i feel this a more basic math function could achieve this however

#

the output is pure white, but I am expecting a gradient from min to max

#

what am I misunderstanding?

#

are min and max bounds broken? or straight up just don't do anything? I am not understanding why the output is a solid color

#

yeah im starting to think these just don't output anything of any kind, nothing I do produces any values, useless and broken, actively misleading, poorly documented may as well be flat out lying by claiming to exist and offer this thing

#

the distance between min and max bounds is not 1 at every fragment so this obviously 100% is completely broken

#

how do I get bounds in shader? The object node is broken and returns nothing usable

#

like am I just stupid? how can this return 1 for every fragment, that makes no sense

grizzled bolt
#

I don't recall if it was local space or world space but the distance would always be 1 nonetheless

tight phoenix
#

why would it be always 1?

#

I dont understand what I am doing wrong, I just want to have an effect isolated to the bounds of the mesh, no matter what bounds the mesh is

#

distance = destination - origin, but when I use min max bounds, I am not getting any distance

#

finally getting something, I still dont know why min max bounds isnt working or producing the result I expect

grizzled bolt
#

Like, they are points, not coordinate spaces

#

I may have something about this somewhere

tight phoenix
#

thats immensely confusing, how can the world space coordinates of min and max not produce distance? like, its positions in world space, ergo distance between those positions would differ per fragment???

#

I'm starting to think that I am the stupid one, that it does exactly what it does but im too dumb to understand how to use it

grizzled bolt
#

The distance of example bounds points -0.5,-0.5,-0.5 and 0.5,0.5,0.5 remains the same regardless of when or where you measure that distance

tight phoenix
#

that should introduce spacial coordinates if it doesnt already have that, right?

#

I mean obviously I am wrong because its not working but I dont understand why thats wrong

#

UnityChanThink it also behaves completely different when done in world space coordinates instead of object space, which also makes no sense to me

#

world and object space coordinates are synonymous as far as I knew, the same calculation done in all world should return the same as done in all object space

#

I dont know why this is agitating me so severely and my agitation is only making it harder to comprehen

grizzled bolt
#

Hey I understood this before and now I don't!

tight phoenix
#

trying to show myself empathy and not get mad at myself for not understanding

grizzled bolt
# tight phoenix yeah <:UnityChanThink:885169594560544800>

I think it should be something like this, for a vertical 0-1 gradient
We just want the world position "stretched" between the lowest bounds point and the highest bounds point using remap
But something's wrong here because the gradient changes around even when rotating a sphere

#

It looks mostly right but when rotating a sphere the bounds positions shouldn't change at all, but it seems like they do

tight phoenix
#

the output of mine

#

Ah yeah Bounds is in world space with no rotation

#

meaning bounds grows as it rotates, its size changes 🤔

tight phoenix
#

the bounds of a sphere do not change by rotating it (in theory) so that's pretty wtf

grizzled bolt
#

Totally!

tight phoenix
#

that its treating bounds more like object space box collider even though it says its a world space min max

grizzled bolt
#

That explains the value change, and it's not incorrect that the coordinates themselves are in world space
But I didn't know that bounding boxes could rotate at all

tight phoenix
#

Yeah me either UnityChanThink shaders can get the rotation, maybe we can do some kind of matrix multiplication to remove rotation before the calculation takes place?

grizzled bolt
#

I guess the reason is it refers Renderer.localBounds instead of Renderer.bounds

tight phoenix
grizzled bolt
#

Oof
I'd find some lazier workaround
Or live with localbounds
It technically works anyway

tight phoenix
#

but I am not sure what kind of matrix multiplication I have to do to get all these values in the same space irregardless of any rotation or scale

#

i know matrix mults must be done, but not sure what matrix, and what elements, and when in the calculation

#

this looks close

grizzled bolt
#

@tight phoenix I think you can use this if you want a -1 to 1 space within your bounds on all axes, used in place of world/object position

#

So any noise nodes and such would be using these coordinates, not within placed among these nodes

tight phoenix
#

I am getting broken texture and pure white output from your logic there

grizzled bolt
amber saffron
#

Using world position and bounds, you can do a simple remap yourself :
remapedvalue = (pos - boundMin)/(boundMax - boundMin)

tight phoenix
#

im also realizing that I cant use the position node at all because the position node has no concept of bounds, its just a value where 000 is the mesh dead center UnityChanThink

tight phoenix
#

I am trying to get box bounds of any mesh, regardless of scale, rotation, position
in manhattan distance values so that there is no visible 'sphere' to the distance

#

where 0 is one corner and 1 is the other

amber saffron
#

The preview is broken, but what about the scene view ?

tight phoenix
amber saffron
#

BTW, if I'm not wrong, the manhattan distance should be the sum of XYZ of the divide node.

amber saffron
#

Yes

tight phoenix
#

I think the problem is that its in world space coordinates, and I need local object maybe?

amber saffron
#

Here's what I got :
The last divide it to normalize the gradient over the bounds (else the diagonal length is > 1)

tight phoenix
#

ill try matrix convert after the divide because its still a vec3 there

amber saffron
tight phoenix
#

this broke it, so this was not the answer

tight phoenix
amber saffron
#

The local bounds is a bouding box aligned with the object rotation, and the world bounds is a box containing all the local bounds corners, aligned with the world axes

tight phoenix
#

if world bounds min max change when the object rotates, can't you just do some kind of matrix multiply to remove that rotation before doing the calculation?

#

since world bounds and object bounds are the same if the object isnt rotated

amber saffron
tight phoenix
amber saffron
#

And it should work :

tight phoenix
#

I don't know how to get rotation in shader, net says complex things about matrix multiplication

amber saffron
#

Yes, transform node accounts for rotation

tight phoenix
#

okay, trying that now

amber saffron
#

Now, it really only works arount the 0 rotation, you get axes inversion and other weird stuff happening when you rotate :/

tight phoenix
#

yeah I think the problem is that the world bounds are physically getting larger as it rotates

#

so it cant just be multiplied out since its bounds got bigger and not just changed spacial position

amber saffron
tight phoenix
#

so I guess the sollution is.. don't rotate the mesh UnityChanThink which is not ideal

amber saffron
#

Just grab the local bounds from script and send them to the shader

tight phoenix
#

yeah I guess Ill have to do that

#

I am making use of a lot of material property blocks in my shaders and Im getting concerned that when all of this is in a scene together that performance might tank

#

but maybe it wont and my worries are unfounded

#

now I just have to figure out which iof these 5 attempts is made to make use of the correct bounds

#

and then make use of those bounds correctly

#

well that works for scale and rotate, but not distance UnityChanThink

stable nexus
#

Is there a way to get screen depth in standard render pipeline?

tight phoenix
#

I have min max bounds positions in world or object space now, but I can't figure out how to get back to where I was to get the manhattan distance 😬

#

immensely frustrated

#

frustrated to the point that I know I cannot solve this without help

#

and in knowing that, its basically prophesizing and becomes true because I wont solve it without help, I cant, Ill stop myself

#

or something

#

anyways ill just take lunch

amber saffron
tight phoenix
# amber saffron If you have the min and max bounds in object space, it should be hard to get the...
    private void PassBounds()
    {
        if (meshFilter != null && meshFilter.sharedMesh != null)
        {
            Bounds bounds = meshFilter.sharedMesh.bounds;

            // Object to World space.
            Vector3 cornerMin = transform.TransformPoint(bounds.center + Vector3.Scale(bounds.extents, new Vector3(-1, -1, -1)));
            Vector3 cornerMax = transform.TransformPoint(bounds.center + Vector3.Scale(bounds.extents, new Vector3(1, 1, 1)));

            // Object space;
            //Vector3 corner1 = bounds.center + Vector3.Scale(bounds.extents, new Vector3(-1, -1, -1));
            //Vector3 corner2 = bounds.center + Vector3.Scale(bounds.extents, new Vector3(1, 1, 1));

            matBlock.SetVector("_BoundsMin", cornerMin);
            matBlock.SetVector("_BoundsMax", cornerMax);
            Renderer renderer = GetComponent<Renderer>();
            renderer.SetPropertyBlock(matBlock);
        }
    }```
amber saffron
#

You'd better go to pass the bounds "raw" value and do the math in shader in object space

devout coral
#

anyone wanted outline for 2d sprite? How its made

grizzled bolt
tight phoenix
#
    {
        if (meshFilter != null && meshFilter.sharedMesh != null)
        {
            Bounds bounds = meshFilter.sharedMesh.bounds;
            matBlock.SetVector("_BoundsMin", bounds.min);
            matBlock.SetVector("_BoundsMax", bounds.max);
            Renderer renderer = GetComponent<Renderer>();
            renderer.SetPropertyBlock(matBlock);
        }
    }```
In this version, https://docs.unity3d.com/ScriptReference/Bounds.html per this, what 'space' are min and max in?
#

the math performed in transform.TransformPoint(bounds.center + Vector3.Scale(bounds.extents, new Vector3(-1, -1, -1)));
is a black box to me

#

I dont know what those values are or how to replicate them in-shader, I could guess based on their names but I wouldn't be able to debug that if it didnt just work

amber saffron
tight phoenix
#

even the term box implies space, my brain is short circuiting trying to comprehend of a box that has no space

amber saffron
tight phoenix
#

its not a box, its just two coordinate positions that a box could be extrapolated from?

amber saffron
#

Renderer.bounds -> world space
Renderer.localBounds -> local space
Mesh.bounds -> relative to the mesh coordinates space

#

But all of them a just a bounds data struct

tight phoenix
tight phoenix
#

I now have this, which allegedly is the bounds, in object space, fixed to the size of the bounds no matter its position, rotation, or scale

#

does that look right to you?

amber saffron
#

I think so.
Should give you local positions in the range -1;1

tight phoenix
#

seems correct yes UnityChanThink pictured: stepping the output

#

okay now to get the manhattan distance from it somehow

#

I know to get manhattan distance I need corner to corner, and if the output is -1 to 1, I just need to add/subtract then manhattan those I think UnityChanThink

amber saffron
#

From the center ? abs(position) and sum x+y+z

tight phoenix
#

why is this wrong?

#

why would the distance be always exactly the same no matter what fragment I evalulate if I am evaluating from positions that have been offset?

#

the problem is the offset positions were all offset by exactly 1 and -1.. so the difference didnt change?

#

But then how do you offset not all ofit by all of it?

amber saffron
#

What is happening in this custom function ?

tight phoenix
#

manhattan distance

tight phoenix
amber saffron
#

Oh, wow, that's a lot of math for something simple 😅

tight phoenix
#

thats the result I got when I googled the formula for manhattan distance

#

how am I supposed to know its wrong :/

#

no where on the page said 'hey guess what this is actually wrong'

amber saffron
#

It is technically correct, but could be written in a more optimized manner

tight phoenix
#

Sorry Ill try to stop being snippy

#

optimized or not its still outputting a single value no matter what the fragment is

#

and I dont know why

#

unless the reason is because I am adding / subtracting to every value, this no change is created

amber saffron
#

Hum, you node setup would just output abs(range)*3 as manhattan distance here

tight phoenix
#

but then how am I supposed to add only to some fragments but not others

tight phoenix
#

normal distance is also a single solid value with no distance

amber saffron
#

What manhattan distance are you trying to get here ?

tight phoenix
#

min to max bounds extents

#

I wish I knew what I was doing, I wish this was easier :/

#

I wish I didnt have to rely on others to explain every single basic vector math 101

amber saffron
tight phoenix
#

am I?

#

I have no idea wthat that means

#

is that the mathimatical formula that represents min to max bounds distance?

#

What is X in this case? Min, Max, and ?

#

I guess x is the fragment

amber saffron
#

I'm just trying to explain what is happening in the lasts nodes setup you've shared, and why it is a constant value

amber saffron
#

Again, what is the distance that you are trying to calculate.
From where to where ?

tight phoenix
tight phoenix
tight phoenix
#

vector +111 to vector-111, or whatever values are the min and max bounds

amber saffron
tight phoenix
#

how can the distance between the furest point and closest point be constant

#

its a box

#

boxes are not constant width

#

This is so incredibly confusing, I have absolutely no idea why or how a box doesnt just have dimensions, a box is a 3d shape

#

I dont have comprehension

#

I dont have understanding

#

a box physically cannot NOT have dimensions, box by definition is a 3d shape, just like square is a 2d shape

#

Im sorry this must be frustrating that I don't understand

amber saffron
tight phoenix
#

you may as well be speaking darmok and jilad at tenagra, I understand each individual word but the do not add up to understanding to me

#

the box.. is bounds? bounds is a box? size? is constant?

#

How can size be constant

amber saffron
#

Bounds, also know as "bounding box"

tight phoenix
#

a box is a 3d volume, size and constantness dont even exist in 3d space in that sense

amber saffron
#

Bounds : a 3D box, aligned to some coordinates system, that encloses a mesh vertices

tight phoenix
#

Right, yes

#

and distance is also a trivial formula

amber saffron
#

Yes

tight phoenix
#

so why is this basically impossible

amber saffron
#

It is not

tight phoenix
#

then why havent we solved it already

grizzled bolt
tight phoenix
#

if its not hard, why has it been hours

#

Sorry, I should stop whining, you're trying to help me

amber saffron
#

But in you node setup you're not calculating any valid distance, and you were unable to explain what distance you are trying to calculate

tight phoenix
#

unable to explain what distance you are trying to calculate
bounds is a box
boxes have dimensions
I want the distance from the minimum positino of the box bounds to the maximum

#

I dont understand why you keep asking me to explain what I want or saying I cant explain it

#

I want an output of values that go from 0 to 1 across the box from the min to the max of the bounds, in object space, also known as the distance

amber saffron
tight phoenix
#

that doesnt make any sense, this is where you're losing me

amber saffron
tight phoenix
#

I think the problem is you are telling me the exact literal answer to my question, and NOT telling me what I ACTAULLY want to know

#

but I cant ask you what I actually want to know because I'm too stupid to even know myself and if I knew i wouldnt be here

#

im sorry im inexperienced

amber saffron
# tight phoenix I want an output of values that go from 0 to 1 across the box from the min to th...

I'll ellaborate on this one.
You already have the normalized position. In the range [-1;1]
You just have to transform it to the range [0;1].
A simple remap node or value = value * 0.5 + 0.5 will do the trick.

Then, from this, calculate the manhatan position (values are already all positive, so it is just x+y+z)

It will give a result that ranges from 0 to 3, so finish by dividing by 3 to normalize the value

tight phoenix
#

You were giving me the exact symantic answer my question, but my question itself was wrong, the words I was using to explain my queston were not the right words, but in my mind they were the right words because I had no possible way to know that I was not asking the question I was asking

amber saffron
#

I have an additional question : why the manhattan distance specifically ?

tight phoenix
#

because I want the values to act as a mask to an effect to resolve in all directions linearly rather than across the true distance where point to point is the furthest real distance

#

which, is also wrong, and dont listen to what I just said

#

because I do not have the language to explain what I want in words

#

and the words I just spoke do not represent what I want

#

I will draw it instead

#

because drawings are a language we both speak

#

that is manhattan distance, correct?

amber saffron
amber saffron
tight phoenix
#

ffs

#

then is it Chebyshev distance

amber saffron
#

But you can do it with min nodes.
result = min(x, min( y, z ) );

tight phoenix
#

okay so the whole time I wanted Chebyshev and not Manhattan

#

every time I used the word manhattan, I meant Chebyshev

amber saffron
tight phoenix
#

yeah I dont evne know how to say that kind of distance without using its 'official' name

amber saffron
#

Note that your gradient in the picture goes from white to black.
If it was the other way around, you'd want do use max instead

tight phoenix
#

distance where every direction is the same distance? distance where.. diagonals are not normalized?

#

like I cant even describe it, its just 'chebyshev distance'

tight phoenix
amber saffron
tight phoenix
#

except what I just said above is ALSO wrong isnt it?

#

I didnt mean its 3D world position to opposite, I meant the fragment's position on the mesh... <something something something related to the two corners>

tight phoenix
#

I feel like the problem was ultimately not that I didn't understand, the problem is that I couldn't explain what I wanted correctly

#

the words I kept using were describing something different from what I meant to be asking for

#

unless thats wrong too

amber saffron
tight phoenix
#

because at this point im pretty much settled that im always wrong and know nothing

tight phoenix
#

here is why my brain doesnt understand

#

a box has physical dimensions

#

I can touch two places on the box

#

ergo there can be a min and max

amber saffron
#

It's just terms and definitions.
Extents is the half diagonal of the bounds -> a dimension
min and max are positions

tight phoenix
#

the min being the lowest possible spot on the box, and the max being the highest possible spot

#

for a line its easy to visualize because lines have a start and an end, so for a 3D volume of a box its like rotating a diamond

amber saffron
tight phoenix
#

in this picture, is this picture depicting the min, the max, and the center?

amber saffron
#

Figure them as the corner with the lowest values in all dimensions, and the corner with the highest values in all dimensions

tight phoenix
#

which is 'extents' ?

tight phoenix
amber saffron
tight phoenix
#

What I am not understanding is why did it take this must time and effort to get to this point

#

like, It feels like we agree on everything, but then I go 'then x = x?' and then you go 'no, x = apple'

#

and I am just not grasping

#

thank you for your patience with putting up with me as well

#

min and max, lets pretend they're world coordinates, are (000) and (111)

amber saffron
#

Because there is so many weird stuff that is possible to do with shaders that if you don't state clearly the intend, it can easilly be misinterpretted

tight phoenix
tight phoenix
#

I should stop trying to 'understand' it for now and just get on with it

tight phoenix
amber saffron
amber saffron
# tight phoenix min and max, lets pretend they're world coordinates, are (000) and (111)

I'm trying to explain why all that confusion.
Taking you example, min=(0,0,0) and max = (1,1,1).
Quoting you previously :

I want the distance from the minimum positino of the box bounds to the maximum

Well, to my reading, that's distance between min and max, so a constant square root of 3 🤷

The importand point was this :

I want an output of values that go from 0 to 1 across the box from the min to the max of the bounds, in object space, also known as the distance

Because the thing that is displayed across the box is the curent pixel, which is the element that has a variable position value.

amber saffron
#

So, are we all good now ? 🙂

tight phoenix
#

🫠 almost

#

I cant help but notice that after all that work, the outcome looks suspiciously like object position

#

is object space position ALREADY values 0 to 1 of the bounding box? did I just waste hours on something I already had?

amber saffron
tight phoenix
#

like this cylinder for example

#

huh interesting that its bounds corner is here

#

I guess it makes sense the bounds would be on the mesh and not on the box bounds?

#

or am I dumb and this entire time I wanted object position

amber saffron
tight phoenix
#

ooh yeah you're right

#

yeah this is exactly what I wanted

amber saffron
tight phoenix
#

bounds-normalized, so to speak?

amber saffron
#

Yes 🙂

#

Saying that now, it could have been done with a single remap node 😅

#

Well, if remap was working for Vector3

#

Anyway, you got it working, now up to you to do something with this gradient

tight phoenix
#

yess

tight phoenix
amber saffron
#

remaping the object position

tight phoenix
#

since 'bounds space' doesnt real

#

is it this bounds size value

amber saffron
#

sorry, by "object position", I mean "position node, object space"

tight phoenix
#

to get the same result?

#

since it sounds like if I can remap it in a single step that will be much more performant than passing bounds in through material property blocks

#

and then doing a shitload of math

amber saffron
#

You still need the bounds data, but it can be done with fewer nodes

tight phoenix
#

oh okay

#

the property block is the slowest bit so in that case nothing really changes

amber saffron
#

result = (position - min) / (max - min)

And that was my initial answer when I joined the conversation 😅

tight phoenix
#

and the only reason it didnt work was because we were using the min max from the object node, instead of its real min max from its real bounds

amber saffron
#

Yep

tight phoenix
#

Okay, the fact that I was able to understand why that was the case is reassuring

tight phoenix
#

okay going with the optimized vesion, ill keep the old version as a backup just in case

amber saffron
#

Why the multiply by 0.5 after it ?

tight phoenix
#

Thanks for all the help, I know it wasnt easy to get through to me

tight phoenix
#

Is this not the expected output?

amber saffron
#

No, it should just range from 0 to 1

tight phoenix
#

maybe because object space starts centered?

#

granted I had to do the *0.5 even before using object space

amber saffron
#

Can you post a readable screenshot of the rest of the connected nodes ?

tight phoenix
#

Yup 1 sec

tight phoenix
#

both required the 0.5 mult going into Split

#

original pre object space method output without 0.5 mult

amber saffron
#

Hum, nodes seems correct, so the only source of error I can think of are the bounds min and max values.
Did you change the code ?

tight phoenix
#

that code runs OnValidate and Start so its up-to-date

amber saffron
#

Oo.
This is somehow unexpected.
For a defautl cube, it does display -0.5,-0.5,- 0.5 and 0.5,0.5,0.5 right ?

tight phoenix
#

erm

#

mnaybe?

#

in the picture, that is a default cube

amber saffron
tight phoenix
#

or do you mean in the script?

#

in the script I didnt set any default values at all

amber saffron
#

IDK, both, I'm confused, if the script is working properly it shouldn't display like this XD

tight phoenix
#

the script says this is bounds min and max

amber saffron
#

Hum, max is clearly wrong here

#

should be 0.5,0.5,0.5

#

this is the issue

tight phoenix
#

the issue is actually that I wrote BOUND without the s awkwardsweat

amber saffron
#

HAha

tight phoenix
#

as usual, pebcak

amber saffron
#

Happens

tight phoenix
#

yep works now without mult

amber saffron
#

There should be an error logged in the console when the property does not exist

#

Nice, finally all fixed and working properly, now go do what you want with this gradient 😄

lone crow
#

Wanted to know how this works

#

We are multiplying position of a vertex by its normal?

tight phoenix
#

iunno why im even posting this

#

i am miserable and cant stop feeling imposter syndrome

#

spoke too soon, its actually working exactly as desired right now

final rampart
#

wow

tight phoenix
#

I'm just so burnt out I can't even feel joy that I got it 🪹

final rampart
#

How can I make one of this that has the unity those squares

tight phoenix
final rampart
#

from the publisher

tight phoenix
#

hm the janked up edge appears to be occuring due to floating point problems, bounds to shader says its a weird shape

#

ill work on this more later because im too burnt out to know why anything is anything

final rampart
#

I mean that because of how square it looks

tame topaz
#

Your question doesn't make sense?

uneven schooner
#

So I've seen these before, know what they are for, have used them before, but was wondering.. does anyone know what these would be called?

#

can give context if needed

grizzled bolt
uneven schooner
#

it's basically three images in one, red is one image, green is another, and blue is another.

#

you would get each different image by getting the different color values

regal stag
#

Would be called something along the lines of channel-packed masks I guess

uneven schooner
#

ohh

#

yeah that makes sense

#

https://youtu.be/jlKNOirh66E?t=267
Found a video containing a better explanation if needed (timestamp)

It’s shading time. Watch me try to make a shader that renders real-time 3D in the hand drawn style of Moebius. There be crosshatch, outlines, sobel filters, we’re in for a bumpy ride.

Support the channel on Patreon to get extra content, and access to the Discord server and to the source code of every project!
https://www.patreon.com/UselessGame...

▶ Play video
uneven schooner
#

I know what it's used for but was curious as to what it's actually called

uneven schooner
#

anyone know what this means?

#

only seems to happen if I input a Vector4 in UV.

#

but it still happens if I switch UV from Vector2 to Vector4

#

and this is the subgraph

#

and finally, this is line 58

#

just noticed these errors

low lichen
# uneven schooner anyone know what this means?

If you replace the Texture.Sample with Texture.SampleLevel and specify a mip level like 0, then the first error should not occur, which means the compiler won't unsuccessfully try to unroll the loops.

steel drift
#

Hi guys, can you help me with this URP shader? I have a URP Lit material, and my goal is to change the tile value of the '_DetailAlbedoMap' in runtime. I've implemented the following code to achieve this:
internal void SetTexture(Texture texture, int tileSize = 10) {
baseMaterial.SetTexture(detailAlbedoMap, texture);
var tilingScale = new Vector2(tileSize, tileSize);
baseMaterial.SetTextureScale(detailAlbedoMap, tilingScale);
skinnedMeshRenderer.materials[0] = baseMaterial;
Debug.Log(baseMaterial.name);
}

The problem I'm facing is that although the value gets updated, the changes are not being reflected in the game's renderer (mesh) until I make some small changes in the editor. Is this a bug, or am I doing something wrong?

vale spruce
#

how to override a function in hlsl?

#

like let's say I want to override BRDF3_Unity_PBS, only in one specific .cginc file is possible to do so?

rare wren
#

I am working on custom lighting/shadows in URP unlit shader graph. I have it working with the directional lights and point lights (I think point lights don't have this issue since the shadows are cast in 6 directions).

Spotlights give horrible shadow artifacts when the shadow is at the edge of the light's bounding box. Does someone know the reason for this and how to solve it maybe?

void AdditionalShadows_half (half3 WorldPosition, out half ShadowAtten){
    ShadowAtten = 1;
    #ifdef SHADERGRAPH_PREVIEW
        ShadowAtten = 1;
    #else
 
    uint pixelLightCount = GetAdditionalLightsCount();
    uint meshRenderingLayers = GetMeshRenderingLayer();
 
    // For Foward+ the LIGHT_LOOP_BEGIN macro will use inputData.normalizedScreenSpaceUV, inputData.positionWS, so create that:
    InputData inputData = (InputData)0;
    half4 screenPos = ComputeScreenPos(TransformWorldToHClip(WorldPosition));
    inputData.normalizedScreenSpaceUV = screenPos.xy / screenPos.w;
    inputData.positionWS = WorldPosition;
 
    LIGHT_LOOP_BEGIN(pixelLightCount)
        Light light = GetAdditionalLight(lightIndex, WorldPosition, half4(1,1,1,1));
    #ifdef _LIGHT_LAYERS
    if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
    #endif
        {
            ShadowAtten *= light.shadowAttenuation;
        }
    LIGHT_LOOP_END
    #endif
}
scarlet pulsar
#

I have problem with setting Color to my shader. It doesn't changing.

var materialProperty = new MaterialPropertyBlock();
materialProperty.SetColor("_SelectColor",new Color(1,1,1,0.95f));
_lastMeshRenderer.SetPropertyBlock(materialProperty);

Changing for example SunlightLevel work fine.

vale spruce
#

why my cutout shadow caster? anyone got an idea?

vale spruce
#

how to make real time cutout shadow?

meager pelican
# vale spruce how to make real time cutout shadow?

shadows are cast in a special pass that is rendered from the perspective of each light into a shadow map. Specifics might vary a bit by pipeline.

So you'd have to have the SHADOWCASTER pass render your object not as it's default, but as its cutout. So you can't use a default shadow caster pass, you have to include one in your shader. If using SG, you'd have to do that by hand, editing the resulting code-generated file, as I don't know of a way to do it in the tool (I think). That's why you're getting a quad, because that pass isn't doing the cutout calcs.

#

Custom geometry mods/discards are always a problem with shadows.

vale spruce
# meager pelican shadows are cast in a special pass that is rendered from the perspective of each...

I do have them in that shader code, here the frag

float4 MyShadowFragmentProgram (Interpolators i) : SV_TARGET{
    UNITY_SETUP_INSTANCE_ID(i);
    #if defined(LOD_FADE_CROSSFADE)
        UnityApplyDitherCrossFade(i.vpos);
    #endif

    float alpha = GetAlpha(i);

    #if defined(_RENDERING_CUTOUT)
        clip(alpha - _AlphaCutoff);
    #endif

    #if SHADOWS_SEMITRANSPARENT
        float dither = tex3D(_DitherMaskLOD, float3(i.vpos.xy * 0.25, alpha * 0.9375)).a;
        clip(dither - 0.01);
    #endif

    #if defined(SHADOWS_CUBE)
        float depth = length(i.lightVec) + unity_LightShadowBias.x;
        depth *= _LightPositionRange.w;
        return UnityEncodeCubeShadowDepth(depth);
    #else
        return 0;
    #endif
}

The important part is just the clip(alpha - _AlphaCutoff); right? for this? but it didn't work for me on real time, but it does work on baked

meager pelican
#

Hmmm...IDK. Verify the pass name. What pass is that code in?

vale spruce
#
Pass
{
    Tags
    {
        "LightMode" = "ShadowCaster"
    }
#

that?

meager pelican
#

yes the clip

#

yes that

vale spruce
#

Unity standard shader can do this on real time, but I can't really understand what my code lacking

meager pelican
#

IDK off the top of my head. But if you're getting that quad, I'm thinking that some other condition needs that clip function call. Or "dither" doesn't have the value you think it does at the time.

#

You could try returning something else, like 0 instead of clip, but I"d assume 0 is the default.
GTG....work calls. 😉

vale spruce
#

damn... I'm dumb

#

_Cutoff ("Alpha Cutoff", Range(0, 1)) = 0.5
I forgot I changed my _Cutoff name

#

took me 2 hours I want to cri

vale spruce
#

is it possible to clamp the slider between 0 and 1 but if I want to I can still type like value of 5 manually?

barren stratus
#

Hey I have a question

#

so im trying to make a blend slider to slide between textures and Im having a bit of a problem

#

I tried making a frenel effect with the texture that'll be slided in and for now defaulted it to a normal color

#

for the slide in I used a Uv node and split it to take out it's Y axis value to perform the slide along the Y axis then connected that to the opacity of the blend node

#

it's having weird blending outputs. the blend mode is set to Overwrite so I have no idea why that is

#

I tried using normalise but it's still not working right

#

can I send a picture because I feel like that'll better explain it

barren stratus
vale spruce
vale spruce
barren stratus
#

yh

#

one sec

#

i want the new texture to slide in like it's showing on the multiply and normalize nodes

#

but it's not

#

im currently just using the color blue to represent the texture

vale spruce
#

I don't really understand what you mean by slide in

barren stratus
#

Ive nv used blend node, literally just heard about it and wanted to play around with it

barren stratus
#

tnks though, I'lljust learn something else

#

I think I'll wait for cyan to come on or something because thinking about the things I could do with that, my desire to learn it is peak rn

amber saffron
vale spruce
#

is there no way to force gpu instancing to take more than 2 pass?? :/

hollow wolf
#

does creating heartrate using shader worth the effort (performance wise) than creating it using particle?

rare wren
hollow wolf
#

guess i need to learn math again lol sadok

rare wren
#

Shaders if written properly are very efficient.
I don't think a heartbeat will be too demanding

#

But for now I'd say pick which is better for now. Unless you do something crazy both won't kill performance probably

reef mango
amber saffron
reef mango
#

thats the million dollar question. it makes no sense. how can greatestHeight not be the same number for every value of index?

amber saffron
reef mango
#

let me clarify. when i write the output to a texture then i get different values at the different uvs passed in _ArrayCoordinatesOfSplats

amber saffron
#

Oh, or maybe you were expecting that greatestHeightAtSpotLocations is a common variable shared between all the pixels ?

reef mango
#

yes. isnt it common to all index values?

woeful breach
#

does this look like clouds or more like water ?

hollow wolf
#

i dont know about the view when you near to it tho

amber saffron
woeful breach
hollow wolf
amber saffron
# reef mango yes. isnt it common to all index values?

What I REALLY don't understand is how you know that greatestHeightAtSpotLocations changes for each index, since you can really read the value only after the loop executed.
And how do you do to debug it in an output texture ?

reef mango
amber saffron
#

And so, the RT is not a solid color, the value varies for each pixel, even though the array coordinates are constant ?

reef mango
#

i see now something strange is happening when i blit the RT to a temporary RT and then that temporay one back to the RT

amber saffron
#

?

reef mango
#

when i draw red pixels to the RT and then blit that RT to a temp and from the temp back to the RT those pixels arent red anymore. They're grayscale.

tight phoenix
#

How do I get world space values that will allow me to lerp between top and bottom in world space from its bounding box in shader?

#

the space I thought I needed it in proved to be wrong :/ so now im back to square zero

#

i still can't wrap my head around the fact that min and max are not points in space and I can't just lerp between the two points in space

#

is there some way I could just write a subgraph to MAKE them points in space so that I can do this

#

because every single time I go to use them, I need them to be points in space I can lerp between but they arent so I cant

#

i can feel my distress already rachetting up because I need this done, I need this solved, I need it solved yesterday but I am no closer to a sollution and I can't do it on my own but I need to get it done so I am a failure who has to rely on others to help me and if I can't get help, im fucked

reef mango
#

@Remy it looks like it has to do with color formats

#

should i srgb on any of my texutres or must i stick with UNORM?

amber saffron
amber saffron
amber saffron
tight phoenix
#

this didnt return a value between 0 and 1 from top to bottom, the masking didnt 'scale' it was still linear

reef mango
#

@amber saffron when i blit the source heightmap to the RT then the colors display correctly. But when i blit from RT to temp and the from temp to RT all the colors are grayscale.

amber saffron
tight phoenix
#

I want world bounds this time, I was wrong yesterday, local doesnt work atll for what I need

amber saffron
tight phoenix
#

I spent the entire day wasting everyones time and being a failure and ultimately the result wasnt even what I needed because as usual I am too stupid to even know what I need b

reef mango
#

@amber saffron i use R8G8B8A8_UNorm on all RTs and UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_UNorm on the temp RT

tight phoenix
#

I am in crisis and I cant handle this but I HAVE to immerse myself in this agonizing acid because its my job

#

sorry

tight phoenix
#

i should shut up

#

i cant handle being a failure but game dev every 15 minutes you're failing at something

amber saffron
# tight phoenix i should shut up

Are you expecting the gradient to go from black to white from the lowest vertex/pixel to the highest one, independtly of the rotation of the object ?

tight phoenix
#

I want a float value where 0 stepped is fully masked out top to bottom, and 1 is fully masked in top to bottom

amber saffron
# tight phoenix Yes

Won't happen then unless you recalculate the bounds yourself each time the object is rotated then.

tight phoenix
#

no matter what size or rotation the mesh is at

#

okay so I can pass in that bounds again from the script, except per frame instead of once

tight phoenix
#

what why?

amber saffron
#

Let me try to sum up this :

  • You want the world minimum and maximum Y of the mesh, whatever the rotation and scale
  • You can not use either the local nor the world bounds, as :
    • The local bounds will outshoot minimum and maximum when the object is rotated
    • The world bounds mush encapsulate the local bounds, and will also always outshoot

So you need to calculate world bounds (or min and max Y at least) each time the object is scaled/rotated, by taking in acount all the vertices world position

#

And this can prove quite costly if you have a lot of objects with complex meshes

tight phoenix
#

😰

#

I don't understand why its so difficult or costly, its frustrating because in real life its incredibly simple to say 'here is the top and bottom of something'

like I am not trying to write code for it to identify what is or isnt a bird in a picture, I just want the top and bottom

#

trying not to panic

amber saffron
# tight phoenix I don't understand why its so difficult or costly, its frustrating because in re...

Because cpu and gpus don't work like you brain, and realtime rendering needs as fast as possible (so as simple as possible) calculations.
The mesh bounds is calculated once, when the mesh is imported.
It then can be summed up to 8 points : the corners of the bouding box
The world bounds is calculated in realtime by quickly calculating a box aligned with the world coordinates that includes those 8 points.

This is very fast, compared to having a more precise bounds for meshes that coulds contain million of vertices