#archived-shaders
1 messages ยท Page 125 of 1
but if you're using a cutout shader, only the bush area should be writing to normals in the first place
but I think unity's outline system just uses its own default shader on everything to create the outlines so
Well I say 'cutout' but maybe I'm using the wrong terminology.
I'm using a custom outline shader
And for the 'cutout' I used shader graph
Basically I'm plugging the alpha value of the bush texture into the alpha slot
And then also using a slider value for alpha cutoff
yeah, that should cull the pixels outside the cutoff range and thus not write to depth normals there
you just have to do that cutout in your outline shader too, if that's not in SG
Well if you look at the first row of images in the picture I shared, that's kind of my issue Right, that color and depth are being culled but normals are not
And yeah outline shader is not shader graph
yeah so would have to see what you're doing in your outline shader code. Are you using discarding the pixel in the fragment function using discard; or clip(alpha - _Cutoff); ? (either are fine)
Will check later, not 100% sure
I'd like to mention too that I'm using the outline shader within a renderer feature in URP
There is no
outline material applied to the bush or something
like, it replaces the outline function for everything ?
Umm yeah it draws an outline over everything using depth/normals and color textures it gets from the scene camera
Or well active camera rather
ok well it should work then, the shader graph shader should only be writing the non-clipped pixels to the depth buffer, so not sure what's wrong. If the shader wasn't culling the depth write of those pixels, then the leaves in further behind the culled areas wouldn't be seen since they'd be depth culled
But only the non clipped pixels are writing to the depth buffer right?
It's normals that's the issue
yes only the non-clipped pixels should be writing to the depth buffer if your shader is alphatested/opaque and clipped pixels, not transparent
so i feel like there's an issue elsewhere
I am generating the normals texture myself since URP does not provide it
You think that's the issue? That there is no link between the cutout shader and my normals texture?
So everything is just written to my normals texture, even the pixels that should be clipped
yeah that would be an issue, as I guess you're not outputting to that render target with your shadergraph version
Ah right that would make sense
Might have to bind an RT and create a custom node you can use to write normals to it from your shader graphs. Could implement the new keyword functionality to only have the shader path in editor
Yeah I think I know what you mean
Either that or, for all selected objects, render them all manually using a replacement material/shader in one call which has _MainTex and _Cutoff and renders the normals to a texture in post process for you to draw outlines with
Will give it a try
Thank you for the input, it has been very helpful and enriching
No problem, hope you manage to work it out!
Trying to get shadows on this vertex animated shader, but shadows don't follow the vertex animation, anyone able to help?
are you using a surface shader?
if so, you need to add addshadow to the #pragma surface surf line to generate a shadow pass from your code instead of a default one. Otherwise you'll have to write your own shadow pass that uses the vertex modifications. @floral blade
It's a fragment shader, maybe that's why having trouble, should I just do another pass for shadowcaster and copy paste the vertex modifying code or is there another way?
actually got it going thanks @still carbon ๐
hi. I am having an issue with shader graph. Using 2019.3.0b5 with SG & HDRP 7.12
I am unable to set surface options such as surface type (opague vs transparent). I mean - I am setting it on master node in SG but in the inspector of material created with that shader the changes isn't reflected. Is there a bug somewhere or maybe I am doing something wrong?
@hoary sonnet When you say "I am setting" does it means you just change the parameter in shader graph ? Cause you need to save the graph to see change in the editor
yeah, I am saving the asset itself after setting it in master node
@hoary sonnet oh ๐ฆ sorry then I don't know =/
Hello. I am playing around with shader graph and made it bend based on location of a player, I would like to make it work with other gameobjects too. Any suggestions how to do it? Currently I am setting player position using global variable.
@young kestrel How many objects do you want this to work with? You can always just define multiple position variables and use all of them in the shader.
would be great to have more than 10, but having that many position values sounds a bit complicated
@young kestrel Shader Graph doesn't support vector arrays, does it?
no support for vector arrays
for foliage to move away when player and enemies walk around
Hmm looks like its possible to create a custom node which can be coded. I'll look around there might be a chance to do it
@low lichen they should be able to support vector arrays in a custom function node
Hey guys - if I wanted to switch the shader that is being used to render a gameObject in a script, should I be doing it by:
- Somehow changing the shader within the material that is applied to the gameObject (is this even possible?)
OR - Having an entire extra material with the other shader already applied, and changing the material of the gameObject?
The shader is the very first option in the inspector when you select the material. If you know for sure you want everything that uses that mat to use your shader then you can choose not to make a new material. I would just make a new material though
thank ya
Anyone know how to create a shader/shader graph for HDRP, that would do the following: Be invisible, not render anything behind it. Use is for AR, where we want to put a 3d object in front/behind a plane from the camera, and need invisible objects occluding the 3d render.
I'd imagine you'd need bit more low level access to things than what shaders expose to make that happen
like, you could render the blocking object to stencil buffer and then use special shaders for the objects that take that into account
In recent HDRP, you could use the custom pass volume to render the object before everything, and only write in the Zbuffer
Can't believe that Unity doesn't have a "double-sided" checkbox for their cutout and transparent rendering modes by default...
Or that most posts say that the best solution is to duplicate the geometry and flip the normals in the 3d editing software
That said... I have no idea how to make a double sided material where the normal map works on the backfaces too ๐
So quick question about shader graph
Uh, how should I put this...
Is it supposed to work with any pipeline?
Because I heard a few weeks back that it was only compatible with the lightweight render pipeline
But now I'm watching a thing about them from Unite Copenhagen that seems to imply that it should be compatible with everything
And uh... it shows a lot of features that I can't see in there, so I was wondering if what they're showing is not actually rolled out
Even though it doesn't seem like that's what they're saying
@woven loom It works with the scriptable render pipelines, so lightweight/universal and HD. But not the built-in renderer.
Lightweight is getting renamed to Universal for 2019.3
Oooh I see
Also uh
There's mention of a version 7.1.1 for ShaderGraph but the latest I can see in the package manager is 6.9.1
Some version will only be available to the latest beta version of Unity. Which version are you on?
Ah I see
I'm on the latest stable version
I'll add the 2019.3 beta version and see what I get from there
@woven loom 7.x is for 2019.3
Hm
Oh there was also another thing... Is it possible to remove fog distance entirely?
Turns out something about it might be messing with my shader
Remove fog itself?
Yeah, I think
Does Shader Graph still have the bug where if you make a new exposed variable then rename it you cant edit anything until you save and exit then reopen?
not in latest 2019.3 betas
ok cool so they fixed it, ill wait for the main release then
i'm trying to import a few precompiled shaders into my project, however all of them give me a Parse error: syntax error, unexpected TVAL_ID, expecting TOK_SETTEXTURE or '}' error at line 18. is there a specific cause for this? pastebin to one of the shaders: https://pastebin.com/W36iYxNw
@junior wave that shader is written in GLSL which is not commonly used in Unity. there are ways to make GLSL work in unity but I don't know the specifics, another option is to convert it to CG or HLSL
i figured as much, however i read that unity does support glsl
is there an efficient way to convert from glsl to cg/hlsl?
I've only ever converted things manually, there might be an easy way I don't know of. unity does support it but the exact formatting may be off, and some people say you might need to force unity to launch in OpenGL mode to use it
not really looking forward to converting this manually 
thank you for your help
i'll see what i can find
you could try looking for a program. unity itself converts HLSL to GLSL internally when it runs on OpenGL so it should be possible
i found out that i could just rename "Program" to "GLSLRPOGRAM", just confirms how unexperienced i am with shaders. the shader still does not work however, it now renders completely black, the errors are gone tho... @real basin
is there any way to flip a texture along an axis in shader graph
like on only one axis
essentially i want to flip a texture in shader graph along the z plane
to fix the problem of the x position
its just a basic texture so its just to flip it along the z
but i dont know how to in shader graph
Just multiply the UV coordinate by -1
x or y depending on which one corresponds to that
the UV is just 2 values so it's only passing the XY values from Multiply to UV, Z isn't doing anything. try switching the -1 to X or Y and see which works
so just use a regular UV or positon? not to great with shaders
I'm not familiar with shadergraph myself, but I think on the multiply node you just need to change X or Y to -1 instead of Z
yea, i did that and neither worked lol, its showing up blank so it must be something else, unless i code something separate to flip it before it enters
or it might be you need to do UV.x = 1 - UV.x if this isn't a repeating texture
its an orthographic camera projection mapped onto a render texture
but its faced upwards so its x rotation is a bit different
oh okay then yeah it should be 1 - UV.x so the values stay within the 0 to 1 range. multiplying by -1 only works with repeating textures
soo use the one minus node?
probably? I've never used nodes
Ah
were getting somewhere
ok
so the x works now the y isnt
so i guess i just have to one minus the x
alone lol
AHHH boieee
we gucci
hooray
is there a way to use a texture to displace verts
like am i doing something wrong or..
basically taking a depth texture and modifying the mesh to displace verts along the y axis
ideally the transform node at the right will go into position however its not allowing me to which means somethings not right
you need the sample texture 2d lod node for vertex stage
alright, this is what i have so far
but i have 2 problems with it
essentially, i want that white rounded bevel image in the bottom middle, to have the white space replaced with the gradient im generating
and this works for the most part, except it ignores the black border and the natural soft gradient/bevel on the image
and for some reason, it ignores the mask in my scene
as you can see, the part that has the material, just renders regardless of the mask that removes the text
i think you have to multiply the mask by the gradient and then have that as the color
so you want the gradient to be where the white mask is and the inverted mask to..?
no, when i put it in scene, it is in an element that has a mask on it
and the material is just ignoring this mask
in the picture i posted, the other elements like text stop rendering when they leave the mask, but for some reason the material doesnt stop rendering until all of it has left the mask
You can't create proper UI shaders that have all the stencil features (e.g. clip masks) with ShaderGraph right now
I'm not so good in shaders but can't you lerp your alpha with the model y coordinate?
I also have my own question: Looking at the build-in shader file UnityShaderVariables.cginc I can see that the stereo matrices are defined in a constant buffer:
GLOBAL_CBUFFER_START(UnityStereoGlobals)
float4x4 unity_StereoMatrixP[2];
float4x4 unity_StereoMatrixV[2];
float4x4 unity_StereoMatrixInvV[2];
float4x4 unity_StereoMatrixVP[2];
float4x4 unity_StereoCameraProjection[2];
float4x4 unity_StereoCameraInvProjection[2];
float4x4 unity_StereoWorldToCamera[2];
float4x4 unity_StereoCameraToWorld[2];
float3 unity_StereoWorldSpaceCameraPos[2];
float4 unity_StereoScaleOffset[2];
GLOBAL_CBUFFER_END
However, I have no idea what the difference is between unity_StereoMatrixP and unity_StereoCameraProjection. Same with unity_StereoMatrixV and unity_StereoWorldToCamera. Shouldn't those do the exact same thing?
Hello,I am a beginner at shaders and especially shader graph as there is less tutorials about it with various effect as compared to the old renderer in unity. I would like to get help in changing the v.normal given below to v.vertex in shader graph v.vertex.xyz += v.normal * _Height;// scale vertices along normal.
Its from the MinionArts
@gilded lichen you said you cant make UI shaders that follow stencils, but is there a better way to create gradients in runtime? i would love to not use shaders, but from what i could tell this was my best option
essentially, should i continue trying down this route, and just open the code that the graph generates and add stencils there, or just try something else
(and if i continue down this route, is there a way to make the shader not just black without putting a camera on the UI)
@dusk tapir depending on your shader skills best way is to grab a copy of the built-in shaders, find the UI shader and make a copy of that to modify
currently, i have 0 shader skills, just learned bout em yesterday, but i shall try!
At some point I think either Unity or an Assetstore publisher will create a proper UI shader master node for ShaderGraph (and maybe it exists already and I just don't know)
But trying is good for learning :)
i was now about to say doesnt shader graph support both 2d and 3d environments
from what i can tell, it supports 2D environments, but only if its an actual scene, and not just a canvas for a UI
it has to have a camera on it
check this video at the 44 min mark
https://www.youtube.com/watch?v=NsWNRLD-FEI
March 21, 10:45am (San Francisco) - Andy Touch demonstrates how you can easily create shaders using the graph framework. Shader Graph enables you to build yo...
dont know if this might help
https://www.youtube.com/watch?v=Nbvqi8cfnrc
Tutorial about using a Shader graph material to render on a UI image and a number of errors and bugs you might have when doing so. the bugs/errors are: 1. Th...
i watched the second one, thats why i was saying you need a camera
Hey guys, I'm working on a project that will use a tile map, I don't want to use the built in tilemap functionality as I find it clunky, so what I've done is use shaders to render my tilemap onto a single quad using shaders with a lookup texture for handling the data and a tileset for the actual images.
However I have some friends who have suggested that the tileset should be on a texturearray instead of a texture atlas but the documentation for this is quite sparse and so I'm hoping one of you may know a good document or video explaining texturearray use in unity
is it just me or is the latest URP + Unity beta 2019.3.0b5 shader graph completly broken?
Shader error in 'Shader Graphs/Test': redefinition of 'unity_Builtins2Array' /Unity/DiggingGame/Library/PackageCache/com.unity.render-pipelines.universal@7.1.2/ShaderLibrary/UnityInput.hlsl(114) (on d3d11)
all packages latest version
and any ideas how to fix it? I can not use an completely empty shader graph without this error, existing shaders also broken, default shaders are working
try uninstalling and reinstalling that package? maybe some garbage got left behind in an upgrade
you think I'd lose shaders in the process?
Doubt it, but never hurts to have a backup
just uninstalling might not get rid of the garbage, so you should also delete that directory under PackageCache after uninstalling
Looks like that PackageCache folder is the actual package code, I would not have called that folder a Cache personally
Library\PackageCache
Library\PlayerDataCache
Library\ScriptAssemblies
Library\ShaderCache
Library\StateCache
Library\TempArtifacts
Library\UIElements
Library\webgl_cache
Library\APIUpdater
Library\Artifacts
Library\il2cpp_cache
Library\metadata
which of these folders can I safely empty you think?
is there a way to invalidate all cache for Unity?
is it GI Cache?
looks like it's due to GPU Instancing
I have Library in my .gitignore, so I assume you can just delete all of it
really, wow good to know
(and I didn't write that .gitignore myself)
thanks I think I will just delete that folder then on every upgrade!
I think the "You do" there should be "You don't", otherwise none of that makes any sense
looks like my project indeed has a problem (this is after starting after deleting that folder)
I'm going to chech that manifest they mention
there are a lot of Unity problems that go away on one or more restarts...
my guess the upgrade path for LWRP to URP is not flawless
that is very likely
looks normal to me
I will compare it to a fresh project
I'm just documenting this in case somebody has the same problem sorry for the spam
wow, did not expect this, my best guess: I had Visual Studio Code open. That has some kind of IntelliSense server running indexing these .tmp files and locking it for the package manager
@drifting edge that error "redefinition of 'unity_Builtins2Array'" is gone now? In my experience it's related to VR rendering and/or having "GPU Instancing" enabled on materials. I have a bug report open about that
Unity is starting now, let me check
yeah did not fix anything
well seems this project is on halt until they manage to fix it
try adding "com.unity.render-pipelines.core": "7.1.2" to your manifest
it looks like something went wrong and it wasn't able to upgrade the dependency
might fix it /shrug
it is as herbst said, "redefinition of 'unity_Builtins2Array"
anybody care to explain why Shader Graph has Vector1, 2, 3, 4 types... when it's generating HLSL that uses float, float2, 3, 4 ?
not to mention the same float types that Unity.Mathematics lib uses
Hi peeps, does HDRP have issues with alpha clipping?
I'm trying to create a alpha-mask-clipped version of the normal HDRP Lit-shader, and it appears to look okay in Shader Graph
I've only had issues with alpha clipping in the editor if I've had texture streaming enabled
and even then it's random
But in the editor just fades the alpha instead
^You can see the mask working, it just doesn't clip. :/
However
The preview looks fine?
yeah, that should work
... wait
wtf
It works properly if I don't have anything else beneath it?
wtaf
So should I just file this as a bug report or something?
I wish the OVR (Oculus Integration) came with shaders that actually worked in the Universal Rendering Pipeline..
i swear, im almost done with this shader, my (hopefully) final problem, is transparency
for some reason, while it gradates through the color, it changes transparency
(oh also just realized it isnt letting me input my texture...)
its over 700 lines, so i cant send all of it, but if anyone is willing to help, tell me where/when such a thing could occur
You can link to it via a service like hastebin
I'm trying to make a 2D flag-waving shader for sprites that uses a mask to control what verts on the rendered sprite wave. I was able to do this in a shaderlab shader, but can't seem to make the same concept work in Shadergraph. Can anyone tell what I might be doing wrong?
ive narrowed down the first problem, im 90% sure it comes from this line Blend SrcAlpha OneMinusSrcAlpha
i was following a tutorial, and they didnt explain why use those values, so i dont understand what it does, only that they said to put it in SubShader, but not in Pass
Hey friends! I'm curious if this technique they used in Below to skew the geometry is within the purview of shader graph?
In this 2017 talk, Capybara Games' Colin Weick explores the techniques used to achieve high visual fidelity in the context of the simplified yet dense aesthe...
The skewing method starts at 23ish mins
Does anybody know how to guarantee a color is removed from an image when using either color mask or replace color in shader graph, I am doing it on a render texture where the camera background is hot pink so it doesn't cause conflicts with any palettes used in the game. I keep getting slight jagged artifacts of hot pink showing around the edge of my character though, only small but somewhat noticeable
figured it out, I had mipmaps turned on in the render texture - it was causing bleeding
@remote osprey what are you trying to use to tell the shader which verts to move? the sampled texture? or the X and Y? because to me it looks like none of them, you should multiply the wind with the mask, not substract
and what is X and Y?
and do the multiplication before you do the addition to the original vert position
Hey folks. I don't suppose anybody has any advice on using passes in Shaders?
I'm trying to split my shader into different passes, and I'm getting the error,
Parse error: syntax error, unexpected TOK_PASS, expecting TOK_SeTTEXTURE or '}' at line etc...
well without code we can't tell you where you made the parsing error
or is this a graph?
I'm happy to provide code - it's not a graph.
One moment...
(As Unity is booting - it's a grass shader, but I also need it to have triplanar, dissolve and outline qualities. I've got triplanar working, but the code was starting to look squirrely, so I figured I'd tidy it into different passes)
@cosmic prairie - code can be found here: https://pastebin.com/NddZy5uT
@cosmic prairie I'm using a sample texture to determine what verts are allowed to move (so a mask), and the x and y to determine the strength that they will be allowed to move. Of course there's not time nodes on there or anything yet to move them over time, so I'm setting the X and Y in the Material to test things, and rather than just the masked vertices moving, the entire sprite mesh moves its position.
I got a simple shader but it won't work with colors, will only render black, why is that?
Shader "GLDebug/GLlineZOn" {
SubShader {
Pass {
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull Off
BindChannels {
Bind "vertex", vertex
Bind "color", color
}
}
}
}
ok nvm, was something else
Sorry to bump, folks, still trying to work out passes within shaders. I think that my problems may stem from my StandardShader block, but have nothing conclusive. If anybody has shader experience, would appreciate some advice...!
You have a surface shader there. Surface shaders expand into multiple passes internally
If you want a multipass surface shader it's actually easy but hacky and totally undocumented - just have multiple surface shaders below each other, no need to have "Pass" anywhere
They'll all expand into right passes (e.g. shadow collector, motion vectors, forward, ...)
How I can fix colors being burnt behind using Scene Color node in Lit shader?
Hello @gilded lichen - I'm fairly new at shader programming, so I may have the wrong end of the stick on this. The shader is initially a vertex shader (causing the models to move around like billowing grass), with the surface shader applying the texturing and colours to the model...
I'm not really trying to get a second surface shader on the object - after this piece, I want to apply an outer glow to the objects, followed by a dissolve effect.
In order to get these implemented cleanly, I'm trying to organise them with passes - somewhat for my own mental health.
I appreciate the advice to just do things with multiple surface shaders, but I'd currently prefer to learn how to do stuff 'correctly' with multiple passes.
Apologies if this sounds like I'm picking a fight here, just trying to understand the right way of doing things...!
If you want to manually do custom passes you'll have to get rid of the surface shader and go lower level.
Also, while it's a good idea to organize things passes don't quite work as what you're trying to achieve
"passes" in shader terminology refer to drawing the same object multiple times with different settings - each is just drawing on top of the previous one with limited control over blending
"fullscreen passes" is commonly used as term for global Postprocessing effects that get applied to the whole screen buffer after rendering objects
What you want to do is better suited for having several functions that operate on the fragment shader level (or surface shader if you stick with that), but it's still one "pass" - one time rendering the object
That was sort of what I was thinking. I was going to do the vertex shader first, then clip pieces with the dissolve texture, then texture the object with triplanar, then apply a surrounding glow.
Hmmm.
Okay!
So I got completely the wrong end of the stick there...!
Yeah I think just a mixup of terminology
Thanks man. Okay, so I need to just try and organise things inside the surface shader, I think.
I don't suppose you know of any examples of this that I could look at?
I can highly recommend using something like Amplify (node based shader editor) for complex stuff
Always good to know the basics but that makes life easier
Yeah, I think that might be something for the next project... but right now, I gotsta grind it out, line by line. =D I have most of the logic, but just need to get it all working in place...
Without wanting to sound dismissive, most of these seem like relatively simple shaders, with a single purpose per shader.
You've helped me a lot, so feel no obligation - but if you happen to know of an example of a multi-function shader example, that would be amazing. =)
Well, you could look at the Amplify examples, there's some pretty complex ones. Also, you'll find that especially contour changing effects (e.g. the outer glow you mentioned) are hard and need good preplanning. Some will only work as postfx, others might work with some tricks (e.g. inverse culling + normal offset + fresnel transparency)
Yeah, I was looking at the latter. I've just got dissolve working, so I just need to get the outline up and running and I'm (mostly) set.
At the moment I'm trying to adapt this to my shader: http://www.shaderslab.com/demo-19---outline-3d-model.html
That shader is a good example of what I was talking about (it has a Pass at the top, and then the surface shader comes below without explicit pass as it unrolls into multiple passes)
...Ohh, so I can do separate passes at the top?
Yep sure, sorry if I wasn't clear about that. You can have passes above/below surface shaders - think of a surface shader as just a block of N passes getting generated for you. Doesn't affect other passes around it.
Gotcha, okay, okay...
@gilded lichen ... any chance you could take a look at my current shader as I'm still a bit confused over the order these blocks are supposed to be assembled...
Whenever I try to add the pass at the top of my shader, I get a syntax error that claims I have an extra '{'...
does any one know if unity supports RWBuffer in compute shaders
@quaint grotto That's supported
No, I'm not sure
๐
How do I enable height map displacement in Shader Graph for HDRP?
@quaint grotto define "weird behavior" in this context.
Also, interesting discussion here:
https://www.gamedev.net/forums/topic/678018-rwbuffer-vs-rwstructuredbuffer-or-rwbyteaddressbuffer/
Also what hardware and what DX level and what data type? May be implementation/device specific problems. Not saying it is, but maybe.
Hey Guys, Recently, I have looked through some piece of shader code, and found out one piece of shader resource object I havent really looked into it. That is RWBuffer. Ive been using RWStructuredBuffer, RWTextureXD, and even RWByteAddressBuffer for awhile, and think there is...
@meager pelican weird as in when i set the buffer as RWBuffer the data is zero or just random, when its RWStructured buffer or Buffer then it seems valid
i assumed therefor that SetData does not apply to RWBuffer for unity
but i can't be sure of that
but its the only explanation i can think of so far
Huh. Do you need to set it frequently, or is it a one-time thing? Because you could create a compute pass to set it in the shader, like copy it from a texture or RWStructuredBuffer to the RWBuffer via shader, but you wouldn't want to do that every pass.
I'm out of ideas. The compression thing and performance thing was interesting in that article though.
no but structured buffers are slower than regular buffers
because they are for generics
Right, which is why if it's not frequent that could be a work-around. Sorry I can't be of more help, haven't run into that.
tis a pain if they dont support it
because im trying to get my algorithm down below .6 ms
Yeah, but like I said, if you only initialize it once, big deal. If you know RWSB works, use that the one time to initialize the RWBuffer.
But if you need to initialize it from the C# side each frame, IDK what to tell you. Maybe someone else has the answer. Good luck.
According to https://docs.unity3d.com/Manual/GPUInstancing.html
" Standard and StandardSpecular Shaders are already modified to have instancing support, but with no per-instance properties defined other than the transforms"
I don't understand, so it's modified to have instancing support, but has no instance properties? How is that different from not having instancing support?
In addition, suppose I do want to support _Color as a per-instanced property. Is there a way I can set the color per object in the inspector on the material itself, or do I have to add a script to do that?
is the code for the standard shader somewhere so I can fiddle around with it?
found it
or better I found the zip download of a ll shaders
has anyone a tut on how a normal maps?
Lesson: How to use the Normal Mapping feature. Subscribe! It's Free! FACEBOOK: http://www.facebook.com/SalokinGames WEBSITE: www.salokingames.com
Support me on Patreon โ https://www.patreon.com/DanMoran Follow me on the Twittersphere โ https://twitter.com/DanielJMoran Get the Assets for this Video here...
@pine lily
thx I've watched that already
got the code but now I have to figure out how to get the normal working with an texture/albedo map
gonna watch: https://www.youtube.com/watch?v=C0uJ4sZelio and hope it helps
Make sure to SUBSCRIBE so you don't miss a video! Download the complete project: http://quill18.com/unity_tutorials/ Also, please feel free to ask lots of qu...
getting a normal map to scroll is really hard T_T
@remote osprey sorry for the late reply, so basically you need to multiply the X and Y values first with the mask, then do the addition to the original verts and get rid of the substract nodes
meh tut didn't help at all
I'm kinda stuck non of the tuts I find uses/ explains how to use several maps like albedo + normal. Does anyone know something where I can learn this? I've tried taking a look into the standard shader code but that one seems to use some advanced method I don't understand.
what I want to do is what this guy is discussing here: https://www.youtube.com/watch?v=8rCRsOLiO7k
Let's dive into Super Mario Galaxy 2, and explore how a small team at Nintendo pushed simple developer techniques to their limits to make something that stil...
I tried doing this with the standard shader via sript but that didn't work. I'd like to do this as a shader but I've already put 1 week into learning shaders but I can't seem to work this out.
hi, what is the difference between sampler2D and sampler2D_float?
@median shore Adding the _float will ensure that you'll always have float precision when sampling the texture. On lower end devices, it will use lower precision if you use just sampler2D.
ok so sampler2D is dynamic depending on the device?
Yes, it might only give you fixed or half precision and you'll get banding
nice, thanks
So I'm trying to draw the normals of my scene through post processing but _CameraDepthNormalsTexture seems to be empty (resulting image is plain grey)
@median shore Are you using the built-in renderer and have you enabled depth normals texture on the camera you're using?
You're trying to cast it to a float rather than a float4. It should be like this:
float4 color = tex2D(_CameraDepthNormalsTexture, i.uv);
oof
missed this when i removed stuff
my original frag function was this:
fixed4 frag (v2f i) : SV_Target
{
float depth;
fixed3 normals;
DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture, i.uv), depth, normals);
fixed4 color = fixed4(1, 1, 1, 1);
//color.rgb = Linear01Depth(depth);
color.rgb = normals;
return color;
}
and output is still grey after using float4 instead of float
You can use the Frame Debugger to make sure that _CameraDepthNormalsTexture is valid
What is the difference between UNITY_DEFINE_INSTANCED_PROP and [PerRendererData]
wait what now it's working
i touched nothing, beside pressing play
which i already tried a lot before
im legit getting trolled haha
@full kestrel I don't think that attribute does anything except hide the property in the material inspector
thanks anyway
@low lichen I think you are right, thanks
If I want to adjust the strength of a normal map do I just multiply the b channel by a constant, then normalize?
Haya
I was wondering about something
https://youtu.be/DOLE4nrK97g I was watching that conference, and one of the more interesting part was creating a lambert subgraph for use in getting light information for stylized shaders
Learn how to write a custom lighting shader for a stylized look that can easily be shared across multiple assets. Speaker: Ciro Continisio - Unity More about...
So I've been trying to remake that subgraph in my project, with only a few things removed from the subgraphs so that I have what I need for my thing
And honestly it works really well
Apart from one thing
There's added code for adding cast shadows
And the "resolution" for them is... pretty terrible
I wanna figure out if it's possible to increase that resolution thing
@woven loom That's not a shader issue, but the shadow map
Shadow map resolution is in Project Settings > Quality, I think
Ooo
Aight hang on
Hmm
There isn't a shadowmap setting in there but it also says that some settings are hidden since I'm using a scriptable render pipeline
Oh, then it's in the scriptable renderpipeline asset
Ooooh aight
That looks much better
I uh... think...
Still looks jagged, but way less than before
Is there a way to increase the lightmap/shadowmap resolution on a per object basis?
No
Because it takes up more pixels in the shadow texture
I see
I'd go for just increasing the scale on everything but at the same time I feel like that's just asking for performance issues
Then again pretty much everything is static so I could just bake these
Anyway, that's good, that means I just need to make the additional lights cast shadows and I'd have my shader complete
working on some terrain blending shader again, this time came up with depth offset with dithering which actually gets pretty nice result, the only thing is pretty visible dithering, is there a way I could smooth that out or made it so it runs before antialiasing?
closer look to it
I have a scene with thousands of objects, but only 2 materials. But I still have thousands of passes. Is that because some objects have submeshes?
@full kestrel Are the objects set to static?
Yes
Not counting the skybox, 3 materials, everything static, about 300 game objects. Not sure why so many passes other than that some of the game objects have submeshes with multiple materails?
@full kestrel Each submesh is its own pass
@low lichen If i understand correctly, that means if I have 4 identical objects with 2 submeshes, then it can't batch and that would be 8 passes total? If those two submeshes had the same material, would it now be one pass?
I'm not sure how batching works with submeshes
I can't tell, are the "thousands of objects" all the same mesh? If so, you could try using instancing not batching. In that case, don't mark them static. Static batching has priority over instancing.
@merry rose I dont understand much about that, but have you tried increasing the size of the dithering texture ?
Basically I have just simple dithering which offsets the depth in rendering meaning I get some of the stuff behind the actuall mesh, the problem cames with that its either 0 or 1, so I am looking on how could I blur it to get nice gradient from one texture to another.
But I dont rly mind it now as its not rly noticable its just perfection which one day It might get ๐ now just hoping for tesselation for unity's terrain ๐
i just fixed the render pipeline problem, but i found that the shadows are pixelated
can anyone tell me whats the problem ?
I think the pipelines have different config files, make sure you have smooth shadows activated there maybe ?
not shader config, render pipeline config asset I think, I dont remember the name correctly
Iโm trying to create a digital glitch effect on my camera in a 2D game using LWRP. Iโve found a lot of examples using a script to apply a shader to the camera, but I havenโt gotten any of them to change the rendered image. I feel like my issue is related to using the LWRP stuff (in order to get 2D lights), but I donโt know enough about shaders yet to figure out where this is falling apart.
Is there a good resource I should start with to get a better grasp on this stuff?
@merry rose youre having trouble with unity tesselation too??
Cause i cant get it to work with out it having wierd tint and bad displacement
I would love to have displacement on new Unity's terrain caus the shader does not support it for now, and its been long time since I tried to make my own but might give it a try
what weird tint do you mean?
@merry rose well the entire texture gets a white overlay. The color is just not right
Thats pretty weird, are you using HDRP?
Yes
Its really wierd. And annoying. I love using substance designer but tesselation in unity doesnt work at all. Not terrain or objects
yeah I got what you mean
So I used layeredLitTessellation shader on terrain to get tesselation only thing is that I cant use any of the height amplitude parameters which is pretty bad hmm
@merry rose dither with MSAA + Alpha to Coverage isn't implemented yet, talked to the team at Unite and they said "they have it on the roadmap" which I'd say translates to "don't hold your breath"
@merry rose thats a very intresting result. Is posible you can maybe help me out with how you got this working some time today
As long is it work woth hdrp
Thanks for info, so in 2030 got ya ๐ค ๐
Yes of course, I am doing some experimenting for our future project but we are pretty on hold becase we want to use DOTS netcode and all of that stuff
Exactly what im doing. Trying to make work arounds for stuff i need to work for the production of the game
Yeah, like there is so much not done that its easier to do a work around and get the result you want, before I made like own grass shader but then they changed the naming so it stopped working, but they talked about some new system basically for details, hopefully next GDC they might give some insight to that
Why doesnt this animate?
It should animate just fine, does it animate in the scene / game view?
do u have enabled animated materials?
I just activated that, it does nothing ๐ญ
Yeah you're not in Play mode in the Game View and you don't seem to have the Animated materials box ticked in the Scene view
Just try to remake the graph from scratch and see if it was just bugged or something
@merry rose here ima add you as a friend. Im active almost all the time and always working. Hmu
Oki
@grand jolt connect the graph to to sine time not time in the end
should fix the issue
@merry rose is it possible i can get some help with tesselation?
I am not actually making tesselation just using the LitTessellation shader that comes with HDRP, for now custom tessellation is not rly possible only with custom coding
i know that. but its acting wierd on my terrain
im probably going to make a tesselation shader soon if unity doesnt
I'm confused on what is happening on the shaders.
if I go with cutoff, then the models is correct, but quality is lowered.
but if I go with sprite default, the quality is correct, but the model goes off model.
Does anyone have a tutorial for adding pixel displacement to a HDRP Lit master node in shader graph?
Use parallax occlusiom mapping node
Anyone got an idea why I cant lerp between two different parallax UVs? working on terrain shader and I can lerp albedo, normal but the parallax UV first one always, I can bump lerp value to hundred and nothing changes
Making continued progress in this shader but not quite there yet. This is meant to be a sprite shader that waves a flag by moving the vertices, and uses a mask to determine how much weight to put on verts (so with the mask in this image, the top doesn't move at all, and the bottom waves freely - so a hanging banner). With this current setup, the bottom moves left and right - but so does the top, only the top doesn't move as much, and the mesh becomes VERY TINY. So it's CLOSE. I think I need to add a Position node, but I haven't figured out the right configuration yet, as whenever I add in the Position node and the mesh becomes the correct size - but then the entire mesh moves left and right and ignores the mask.
Thanks for all the help so far - a little more help and I think I'll understand what's needed here. Thank you!
hi guys, i would like to know how to add some refraction to my surface shader, any ideas? (im not using hdrp)
@merry rose try and multiply the height of the shader
@remote osprey an easy way is to use a LERP where the T is your mask where black = no movement then in the A just feed it the position node (set to object) then in the B feed it the wavy math you have.
@lament sorrel looks like it's a sorting issue, if everything is kind of on the same rendering plane, the regular blend mode can get confused and sort weird, where clip just sorts better with things so close on the same layer
anyone know why my camera is not cleared when running this code two times in one frame: https://hastebin.com/bevibuqeva.cs
I have a simple unlit shader and I'm trying to use it in a particle system
but several properties like 'color' in the particle system inspector now don't affect my particles
how can I make it so that the particle effect inspector still works?
aah found the issue
I need to use vertex color node
@rough stump basically this is my setup and I cant multiply height because it takes Texture2D as input, so I should be able to do it after wards but it does not work, even whe I use it instantly at textures it will still use the first Parallax UVs and it will ignore the second one
Aaah! I see that's messed up!
Yeah, think so too, like why would they do that grr
Hey guys, I've been trying to figure this out myself but google and youtube yielded me no results. Might be that I just dont know what to look for, though.
I'm going for a cel shaded look and want that on my terrain as well. I want to use built in unity terrain for the ease of use and efficiency. Is there a way I can set up a shader graph for it? And can it take in lighting information?
Why is this red so dark but it shows as full red on the right side
@robust drift The lighting in the scene is dimmer, probably
Can I add like a sun?
@robust drift Sure, also called a Directional Light
Oh ye that worked thanks
hello. I have a quick question. I'm using LWRP and I've made a simple shader graph material and applied it to objects in the scene. On Android (and in editor) it works fine (materials have the color I choose), but for some reason I'm getting this on iOS (tested on 2 devices with iOS 12).
I have no clue what to do - any help would be appriciated.
It should be like this.
anyone knows why it throws an error? I am using correct hlsl code but custom function node is throwing error that it "cannot inplicitly convert from 'Texture2D<float4>' to 'sampler2D' "
HeightMap must not be a sampler2D then
but I have to use UVs how can I do that if it would be float?
like this code worked with shader forge custom nodes, so its weird that its not working here, I found that pretty much same error was in older UE4 version
Where is HeightMap defined? Is it something that Shader Graph just gives you?
Surprisingly hard to find examples of custom nodes, but here's a thread I found that samples a texture in a custom node.
https://forum.unity.com/threads/samplerstate-in-custom-shader-graph-node.647128/
It didnt helped at all, like he even said it, like the documentation is now reworked but there isnt any showcase of how to use textures in it
Hi! What are people their thoughts in here about Shader Graph vs writing shaders? ๐
For example, do you think Shader Graph is better than writing shaders your self, does one have a much tougher learning curve, is one over the other better for performance?
I'm trying to figure out which of the 2 I want to learn about.
I've found this course on Udemy about shaders. Perhaps that their might be people in here which bought that course, if so is it a good one?
https://www.udemy.com/course/unity-shaders/
@south topaz Writing shaders has a longer learning curve. You can easily get the same performance with either. Shader Graph is more limiting, but you won't find those limits until you're doing something advanced.
What would you consider as something advanced if I may ask? ๐
well ive always kinda been intrested in ray marching. cant understand it though
btw : comenting on the video
@south topaz Maybe advanced is the wrong word. There are certain features missing from Shader Graph, such as tessellation. Features like that will likely be added later.
@low lichen tesselation is mising from unity in general to be honest. the current one sucks and its hard to make a good one
even quixel failed at it for unity
@south topaz I learned shaders by watching this and making a bunch of shaders
https://www.youtube.com/watch?v=T-HXmQAMhG0
Another video/tutorial thing. This time about shaders. Still trying to find my voice and my style for future videos. Let me know what you guys think. Get the...
But if I understand you correctly, some things are still missing in Shader Graph. Which isn't too surprising since it's not very old, but in general I should be able to still do a lot with it?
@south topaz Learn both. Watch what one does to learn the other. It's not a binary choice. :2cents:
shader graph is still in preview. this argument is pointless
shader graph is only in preview for 2018 versions
- wont be final till 2020 i think
no, shader graph is not in preview versions for 2019
really? doesnt make sense
hdrp is still in preview. i cant see shader graph being final yet until the actually SRP it runs on is
might be wrong i guess.
shader graph runs on any SRP, both universal and HD
universal is not in preview anymore
that said, there are features and functionality that aren't yet "out of the box" for shader graph but a lot of them are things we're aware of and working towards
Why else do they have the Unity Staff role, or did I totally miss the point of that role? x)
๐
๐
when spara said we're i checked the role. and then noticed how stupid i was even trying to argue with some one who works there. they definataly would know if a feature is done or not,etc.....
but im kinda disapointed about one thing. as a 3d env artist i always make textures in Substance Designer. but i cant really every use them like i was to since tesselation is so not focused on in unity. we dont have terrain tesselation and even normal tesselation isnt really that great. + hdrp doesnt support grass which i made a work around for and wind doesnt really work either for some reason or thats at least for me and my team.
I think I'm going to give the course I found a shot, if it doesn't work out for me at least I tried. And if it does work out I'll be a step further, thanks all for responding! ๐
If you're looking into toon shading, this is amazing https://www.youtube.com/watch?v=DOLE4nrK97g&t=2352s
Learn how to write a custom lighting shader for a stylized look that can easily be shared across multiple assets. Speaker: Ciro Continisio - Unity More about...
It also tackles some fundamentals of lighting very well and it explains why things work. Really great vid
Guys, I have the water height on UV2, I want to add waves, any suggestion into how one would do it? Flow map on UV3 perhaps?
@south topaz IIRC that course is for the standard/traditional pipeline. But it will teach you about shaders, just not the URP/HDRP specifics.
@fast acorn
Guys, I have the water height on UV2, I want to add waves, any suggestion into how one would do it? Flow map on UV3 perhaps?
I'd use another texture or 3, not the UVs on the meshes. Scrolling textures, offset from each other, or something.
@meager pelican Well, itโs still a start ๐
Yeah, it's a good/great start. And...it's much more well documented.
@fast acorn if it's procedural, can you just calculate the offsets in a vertex shader?
@meager pelican offset to what exactly?
The color or the vertex (waves). Depends on what you're doing to make a "water shader" (there's all types and styles). What were you going to stuff into UV3 and update each frame? (Ouch!)
Oh, yes, I could indeed use the vertex color for that
What? Not what I was saying.........
Besides you can generate textures procedurally too....like with perlin noise.
Why in the world would you want to have to update the UVs or colors on the mesh, and re-upload the mesh each frame? Yikes! You want to upload the mesh once, and then dynamically update it in a vertex shader to alter the base with an offset that you calc some other way so you don't have to update the mesh each frame.
Ohh..
No, I wanted to use the uv just to save overall what will flow to where (statically), and use noises with textures to actually make the action processed on top of that.
The problem with procedural texture (at least for me), is that the planet is a sphere, so wrapping it can be a bit troublesome programmatically
I would rather use textures tbh, but my concern in order to make the flow map with textures is regarding the sphere wrapping and because I kind of already have the info on the UVs
OK, but you said "flow map on UV3" and that will kill you.
flow map as delta-offset to your UV2 is what I'm thinking. And that flow map can be procedurally generated into/from a texture.
At least that's what I'm thinking. Have you seen Unity's water shader? You look like you want ocean type waves, and really maybe just reflections from X miles up. But my only point is that you don't want to modify the mesh UVs each frame, IMHO.
I agree, I don't intend to modify the uv each frame, nor any texture input, just scrolling textures in function of time in the actual shader. But I need something telling that the waves are going from the deep towards shallow waters
this is the piece of information that I'm not sure how I'll pass to the shader
Oh! You want a directional vector field mapped onto your planet for the water flow direction.
yes
Sorry, I thought you were talking about the wave offsets in general.
oh, OK
np
the problem with procedural texture (the problem for me, since I don't know how to solve) is to wrap it into a planet, if it was just a plane I could create a 2d map
for a planet I would have to "translate" the information to a texture to be then picked by the UV1 or through a world position technique
that's why I thought about using UV3 for that, since I already have the information about how deep is the water in the UV2
I guess that the pixels UV data will be the interpolation between nearby vertexes
if I do that
Well, if you had a scrolling wave height, and a directional field for wave-flow-direction, it's just a matter of combining the two or maybe you can even get away with one. I would think. Haven't tried it. So your lookup into the height would be modified by the direction vector at that location * some cycling time * some scale. Basically you want to distort the moving height field by the flow vectors. My head hurts, I think I'd have to try it before I walk away in shame typing more here. Maybe someone else has done both of those things at once from 250 miles up.
yes, that's exactly what I want to do
Yeah, if that doesn't change and it's static, you could put some direction into UV3 as long as you don't have to update each frame. ๐
not sure if there are other approaches since that's not quite an usual problem
Yeah Oceans are weird that way, waves. I mean on the Great Lakes or other things, you get wind-driven waves and they pretty much follow the local wind direction. So there's some back and forth on the windward side, but more lapping on the down-wind side. And then you could just color each shore with some foam or something and have it all be a single direction and call it a day. But on the Ocean, I think all coasts get waves.
Not that, from your pic above, you'd actually see waves lapping from 250 miles up or anything....
they are mini-planets and it kind of need more information to make clear that there is water in there, since I'm going for a toon look, I can't rely much on the normals, so this is the reason why I wanted some waves, I'll try this approach and I'll share the results in here.
What unity water does is use two or more textures in different "sizes" and ->scrolling in different directions <-. So that might still work to make your wave-coloring offsets.
yeah
This is a really cool video BTW...as long as I'm thinking of it.
https://www.youtube.com/watch?v=8rCRsOLiO7k
Let's dive into Super Mario Galaxy 2, and explore how a small team at Nintendo pushed simple developer techniques to their limits to make something that stil...
that's awesome, thanks, just saved on my watch later stuff
first thing that I'll do once I get home
hi, wondering if there is a way to hook into rect transform data in a shader (like how you would get scale or position from an object), or if that is something for the near future?
You mean shader graph? Position is part of the normal shader info, I think scale is in the transformation matrix too. You'll want to research the transformations that go into shader programming to understand. But it takes a local position and scale and rotation and does matrix math to get the world position then camera and screen view... that's the MVP type of thing.
yeah, shader graph, doing some UI materials and I wanted them to update based on the change in the rect transform of the ui element (image, panel, etc).
I got it to work but I have to feed the local scale of the changed UI elements rect transform and feed it into the shader as a parameter in script
Rect transform positions are actually world positions too
You can manipulate it like that
They are in the world, rect transform is a layer on top of transform
You will probably have to send information regarding the width and height manually through a script though
Which is fine
yeah, I got it to work doing the the parameter/script method, but wanted to know if there was a node that would get that information in real time like Object, Object didn't seem to react to any rect transform changes
In the end I made just simple parallax mapping, which can be easily controlled, only thing I am missing rn is height blending which wont take that long, so what everyone can take from this is that current version custom function node (HDRP 7.1.2) does not allow you to modify texture data as it cannot load Texture2D properly giving an error. Hopefully they will fix it as unreal did, they had it working already in UE3 but then they had to redone it in UE4 same as Unity is doing now basically.
@fast acorn I just remembered this guy did some procedural mini planets, and although he may or may not have a water solution you like, you may find it interesting. I worked through this 'tut' for fun a few months ago and it was neat. There's like 6 bite-sized chunks in the series.
https://www.youtube.com/watch?v=QN39W020LqU
In this series we'll be creating a system for procedurally generating simple, but diverse planets. Get the project files for this episode: http://github.com/...
@meager pelican thanks :D
actually my planet generation algo is based on this series
I've added a bunch of things to it afterwards though
I've added a cool stamp system (which I don't use on this type of planet, just for moons as yet), but it was quite fun
Neat. ๐
that video that you've suggested earlier is awesome btw @meager pelican
this one is a nice one too, have you ever seen it?
https://youtu.be/YPy2hytwDLM
In this 2013 GDC session, Blizzard Entertainment's Julian Love discusses the implementation of visual effects in Blizzard's Diablo franchise. Register for GD...
they also use a lot the same type of technique
I'm trying to create a shader to make an inside border of a sprite; currently the sprite is a white square, if it matters.
I tried to do that by checking the texcoord together with an offset variable, and if it's <= 0.0f or >= 1.0f, I use the border border.
It works, but I'm having a problem when scaling. When scaling, I want the border size to still be the same size as it was before the. That is,
I want a screen-size border size rather than texture-size border size. How do I achieve that?
@rustic dragon Thanks for the tip! Though didn't quite seem to do it... Check out the following 2 images. The first shows the updated material. There are 2 banner sprites here. Both are in the exact same location. One has this shader applied, the other has the default Sprite shader applied. The one with the new shader I'm making is super small and offset to the side (the entire thing still moves left / right when animating). The second image is the updated shader graph...
When working with this from straight shaderlab scripts, I recall that we needed to do some math so that the shader pretended like the sprite was a full texture, allowing it to act 1:1 with the positioning on the mask image... otherwise it tried to just get the same pixel positions as the sprite, but on the mask.... might that be something needed here as well?
Okay forget that. I'm REALLY close now...
Left is the shader in the graph image. Right is the standard sprite. Everything is just a little too small, and the bottom moves a little bit rather then being rigid. It's almost like everything is just slightly offset still... but close!
heya guys
is there a way to draw geometry infront of everything using the Shader Graph?
i know you need to use the ZBuffer
but i dont think you can change that through the graph
you can modify the resulting shader (right click on master node, copy code, paste into new shader file and modify as needed)
Iirc the only way to change the way object are drawn is by making a renderer asset
Hello everyone
Is it possible for a shader to check the layer of a gameobject at a certain position? im thinking about making a shader for a minimap material which sets each pixel depending on whether it is a wall or floor (i want the minimap image to be abstract not simple a camera looking down on the scene)
No, the shader has no knowledge of the layer
You might be able to do something based on distance with your models and a shader on them that will display the models in the stylized way you want. You just set the distance so far you never see it in regular gameplay, but your minimap camera you make really far away so it draws the LOD shader part and renders that to a texture. You could probably do something similar with just an LOD system on the models too.
but then again you could just use layer masks with the map cam for that ๐
yeah i think i might just make a second tilemap with abstract tiles that only renders on the minimap cam,doesnt feel as clean as potentially using shaders though
random other question - im playing with shadergraph with URP and trying to do a grabpass-like effect, seems like it's the Scene Color node that I need to use.. but how do I actually use the output? just seems to output grey always
well you could just include the abstract tiles with the real tiles in the same prefab, just set them to another layer that the map camera will only see
that way you wouldn't have to make 2 separate maps
@bitter vessel This shader trick actually does work, it's just a distance calc between the camera and the models and used in a lerp, the green objects are what the main gameplay camera sees, and the camera box on the bottom right is what the map renderer sees, here I just have it go red for the map camera.
if you get the distances right, you will never see the red during gameplay, and 'only' see the red with the map render cam
Hmm I'm a little confused by the Texel Size node, does it not return 1/textureWidth on width and 1/textureHeight on height?
Oh ok it just returns width and height it seems
Yo guys, Im working on a toon shader and Ive got custom nodes to get the main directional light and additional lights. The additional lights now not only give off light but also add their respective color, though only that of the last detected light that shines on a certain object. Is there a way to seperate all detected light colors rather than saving and outputting them seperately?
Would save a serious pain in setting up the nodes if I wouldnt have to replicate the setup for extra lights like 5 times or more
Hey everyone! Is it not possible to create&use global variables in shader graph? I couldn't find it for a long time and had to ask. Using hdrp.
Unity has global variables? ๐ค Never knew that.
@ebon trench shaders does right? I mean like Shader.SetGlobalFloat. But I can't define one inside shader graph I think... I wonder if it's a hdrp thing ๐ค
You sure that isnt just part of unity's code?
I think it might be part of the core HDRP package
What would you need them for? If you need visible variables on materials just use the blackboard.
globals let you set&sync variables of multiple materials using same shader at once. I used to use it a lot before but can't seem to find it in shader graph. thought it might be a hdrp limitation or something.
Im not sure if you can reset it on already made materials, but the default value of blackboarded variables is usable for syncing a base value?
default values won't help as instanced materials will override them. also can't set/change default values in code etc.
Figured, cant help you then Im afraid.
thanks a lot anyway @ebon trench ๐
Yw, if you find a way to pull it off please do let me know
I will! as I said I think they simply doesn't work in hdrp or something. I'm just doing it in a little hacky way at the moment, finding all necessary materials, setting variables individually etc.
@fast acorn
I hadn't seen it. That was great, loved those scrolling multiplied textures.
this one is a nice one too, have you ever seen it?
@meager pelican
yeah, they manage to get some interesting results with it, I also liked a lot the nintendo one, I'm waiting for the other ones from the series that he said it would be
The blend-add thing was a good tip too if you haven't seen it before.
@lost prairie I think you just define one in your shader, make it unexposed, make the reference into something readable like _GlobalAmbient orvwhatever you want it to be called and call setglobalfloat() on that _GlobalAmbient
it is definitely a thing, I just dont remember how I did it, but I think this is the way
Its getting somewhereโข
pretty happy with the progress for it being my first shader ๐
tho I cant figure out for the life of me how to make the additional lights cast shadows
cause I cant reverse engineer the code used for the main light for it, sadly :/
Also does anyone know why blue light doesnt give off light? edit: fixed it
hey any unity ewangelist here?
im a little bit confused atm
unity is acualy offering few rendering modes
when u make your game do you use the light rendering presets etc or still use the standard rendering path?
is this new rendering preset a standard?
With LWRP two cameras no longer works for rendering the world view and view model seperatly.
When i posed this question in another discord i was sent here, beeing told you guys might know a way.
(Keep in mind, im completely new to shaders)
@silent dew look at https://github.com/Unity-Technologies/UniversalRenderingExamples
Oh wow! Thanks @thick fulcrum ! ๐
@urban oxide I'd advise sticking with the standard rendering path for now until the newer pipelines are MUCH more stable and feature complete.
ok, so using SRP/SGT actually is meaningless?
Anybody have any ideas how one can achieve a fog of war in HDRP?? I've done it in regular Unity versions with Render textures, but it's apparently not gonna work in HDRP with that method as you can't use depth cameras.
i mean, even i create the shaders with shader graph i need to use the new rendering pipeline
Feel free to use URP if you understand what restrictions that has and feel the need to use Shader Graph
so im unable to use my light shader with the standard rendering path
"light performance shaders"
shadergraph does not work with standard renderer
URP/LWRP are out of preview so it's pretty production ready
Just look at the feature table and see whether there's something you definitely need that it doesn't have https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.1/manual/universalrp-builtin-feature-comparison.html
amplify I believe works with all rendering modes, so you could use standard.
@vocal narwhal last I checked was still some issues which require manually adjusting shader code to get them to work. Guess it depends on your view of "production ready", personally I don't like having to manually make changes, which may need adjusting each new version.
I'm using LWRP without issue in my current project
anyone seen this before? Shader error in 'GAP_SG/GlowElectricity 2': redefinition of 'unity_Builtins2Array' at /Library/PackageCache/com.unity.render-pipelines.universal@7.1.1/ShaderLibrary/UnityInput.hlsl(114) (on d3d11) it was just a ShaderGraph built in an earlier version and i have no idea how to narrow down which aspect of it is apparently no longer supported. Opening in ShaderGraph and re-saving doesn't fix it ๐ฆ
@haughty canyon also seeing this. I think it's downright broken. This also prevents builds
heya @gilded lichen , so i started rebuilding my shader node by node, got half way through and no issues. But as soon as i enabled GPU instancing on a material that was using it, the error appears. Disabling GPU instancing doesn't make the error go away so i'm not sure how to you can revert one that has already been corrupted in this way.
Yes that's similar to my findings. In fact I did a PR earlier today to the SRP repo with a unit test for Shader Graph + GPU Instancing:
https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/4802
So, anyone experienced with making water/glass shaders for HDRP - can someone help me with scene color node? Everything behind the material looks darkened and I don't know how to fix it.
in shader graph could someone explain to me when I should use a subgraph and when a custom node?
Custom nodes let you implement code into your shadergraph, allowing for more functionality.
Subgraphs are saved custom nodes consisting of other nodes internally, allowing you to save setups you use more often.
You can also save a custom function node as a subgraph to allow for easy access to it from the node menu.
yeah I know what both do, but like
if I have a certain set of nodes I use frequently
just convert them to subgraph?
and use custom nodes for things I can't achieve with the built in nodes?
because both a subgraph and a custom node can achieve the goal of saving space
I think I should only use custom nodes for things I can't achieve with a combination of the built in nodes
or like a long arithmetic operation
I mean, use whichever you want in what way works for you Id say
I dont think theres any real data on performance impacts either may have yet
I cant find it easily, anyway
There shouldn't be any performance impact, subgraphs reduce work when u get tired of repeatedly making certain node combos
I guess it could be an interesting test to take a complex graph, write it as custom hlsl nodes and compare instruction counts
Is it possible to create volumetrics with shader graph
my approach would be to find the distance until the next face with normal away from view but there doesn't seem to be a node for that or anythign
anyone knows how to make a shader for an object, where the object has a red outline which is always visible but the main texture not?
@civic finch for that method you would first render the volume back faces' positions to texture, then in a second pass render front faces & sample that rendertexture, so you have the ray start and end position for a fragment. Then sample along that vector in thevolume
Ah ok
implemented terrain holes into my custom terrain shader, does anyone have an Idea why I cannot take textures from terrain, i use correct _variableNames but for some reason I cannot get splatmap, heightmap, only thing for now what I tested and is working is terrainHolesMap so I have holes now ๐
@merry rose How did you do the dithered terrain blending on your modules?
You can use Dither node and plug it into DepthOffset, before you can remap it to get wanted result
To blend object of same type use Heightmap and multiply dither with heightmap, that will give some randomness which will result in same object blending together
By Dither node do you mean in ShaderGraph?
Do you have a visual example of the graph?
Is there a way to override the lighting output strength of a LWRP PBR shadergraph material? I'm working on a scene that has some underwater and above water sections and I'm trying to implement a area specific fog that will fade objects to lower light levels depending on how far away they are.
@grand jolt this is my node setup, yes its shadergraph
Really, I need some way of applying a function to the PBR pixel. everything in the scene after it's rendered based on it's world space position.
added some waves to my water shader for procedural planets
So any shader gurus here?
I have been attempting to... err... essentially hack in LWRP support for the Vita.
I almost have it "working" as far as errors go.
everything up to this final piece
Compiling Fragment program
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF3 SHADER_API_MOBILE UNITY_COLORSPACE_GAMMA UNITY_LIGHTMAP_RGBM_ENCODING```
So in the other cases, this was easily resolved as it was disabling d3d11_9x, which was throwing an error for the Vita
well, scratch that, seems that wasn't the issue
they are all erroring again
ok, this doesn't even make sense anymore.
Reports a similar error as above for line 18 for a different shader, but loading it in VS shows this at line 18:
#pragma exclude_renderers d3d11_9x
Go to the next error, another "did you forget" for line 23, but there is nothing there. the errors don't match the issues they report in the first place.
I give up on this.
Does anybody know how to make this water wall effect with shader graph? https://www.youtube.com/watch?v=luxsRWWME6U
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Probably a grab pass with two panning displacement textures
Anyone know an easy way with Shader Graph to make a bevel or emboss effect on a sprite?
this may be a stupid question but i upgraded a project and shaders are all broken, and i am stupid dumb with graphical stuff, much better with coding. do i have to somehow re-acquire and map these same shader properties (ambient occlusions, bloom, what have you) or can i upgrade them without losing them (i have like a dozen post processing profiles)
@grand jolt Probably one of the LODs has a missing or invalid material
i habe no idea im not a unity dev, im just desining the scene
is it possible for me to turn off the LOD
@grand jolt Try disabling the LOD Group component on the prefab
Trying to make caustics shader using scene depth, but I have absolutely no idea how to do it correctly.
Tried making a Sprite Lit based shader graph, but it seems to disappear in play mode - works fine outside of play mode
Any ideas?
Tried that didint work
they missing material
Should I try to reinstall
if not then contract the guy
nvm i got it
thank you guys tho ๐
howd u fix
So I'm back in Unity compatibility heck
I can't use shader graph without creating a render pipeline asset
if anything i want to use URP
but post processing doesn't work with URP
so
oh ok i found a blog post
Unity do like their approach of firehosing useful information over a number of different sources
wait so
i can't get URP on 2019.2
but post processing is broken on 2019.2 URP
is 2019.2 an unsupported version
like non LTS or whatever the equivalent is
Post does work with URP. It has its own implementation of it though.
Anyone know of a way to render to the stencil buffer while using deferred in Unity?
they say there's one free bit, and it would be useful if i could write to it
maybe i just have the syntax wrong?
Stencil
{
Ref[_StencilRef]
WriteMask[_StencilRef]
Comp Always
Pass Replace
}```
what i really want is to just write the one bit mask
frame debugger shows it has the reference i set but not the writemask,
oh wait, nevermind this IS working
Could anyone spare me a couple mins to check why this disappears in play mode? it's a 2d lit graph
ok I'm even more confused as even this is turning invisible on play:
Is it possible to use angles in shaders?
Im trying to convert an integer from 0-360 to a normalized vector direction in my shader
Yep
thanks ๐
Anyone knows how could I get terrain layers textures in my custom terrain shader? I am able to get the terrain holes map but other than that I cannot figure out how to get Albedo, Normal or mask map
Check the source of the default terrain shader
The names of your properties are probably wrong
I named them the same as when I see in debug inspector of terrainLit material
okay found out why its not working
Why not?
because none of it is exposed, all of the textures are made in custom functions, and then just transfered to main shader to be seen, you cannot rly access it without going into code and customize it to your own will
-.-
Is it not possible to use pi in shader graphs?
Make a constant node with 3.14159265359 as value
pi isn't a builtin thing in shaders
Well I kinda need it to be exact
3.14159265358979323846264338327950288420 have 39 digits
That should be enough to calculate the circumference of the universe to the width of a single hydrogen atom
(you don't have enough precision to represent that number though)
Im bending the entire world into a sphere and im pretty sure there will be a visible cut where it connects back
Because in my experience there is always a cut in the rendering/collisions unless its perfect
Go and try and see
@civic finch Post doesn't work in VR on 2019.2, and in some configurations also not on desktop. If you're feeling adventurous there's a branch in SRP repo for postfx fixes
Anyone else having the issue where shader graph sprite shaders turn invisible in play mode?
anyone had any luck with getting projectors or decals to work with the LWRP?
hey if you guys have any doubts or wanna try out cell shading i recently published my asset on the store! with cartoon water shader!!
Anyone got the dithered crossfade working on HDRP?
@plucky bone figured it out, it's streamer mode
if you have streamer mode on you @ people without the # afterwards
How can I animate a custom post-processing shader over time in LWRP?
as trying to use _Time does not work
how do i make the edges of the mesh glow? fresnel does not work for hard edges, only curved like a sphere
@upbeat topaz Try using _TimeParameters, that's what the SRP now prefers
Hi.
Where to find good tutorials for beginner to understand Spherical Harmonics and Unity lighting.
I had searched and couldn't find some tutorials/explanations to start with.
I think
- I need to understand Spherical Harmonics
- How light is converted to SH and how it is used in Unity.
@upper kite I couldn't get the _TimeParams to work, but it seems I just have applied the regular _Time wrong earlier, as it did work in this configuration
Hey everyone
Anyone here good with Shader Graph? I'm trying to get something to work and I'm not sure if its even possible
Or if I'm going about it the wrong way
try saying what that is, as then it will be easier to find the right person for ya
So, I've made a 2D water shader
That I'm scrolling using the offset to make it look like it is moving
Now, unfortunately this means that any other 2D GameObjects that sit in front of it look like they're floating above the water (because there water just scrolls right underneath it)
What I want (if possible) is to be able to get the underlying plane with the shader to be aware of the things rendering in front of it, and draw a border around the images to make them look like they're interacting with the water
I have an idea how to do this with a 3D mesh when the two objects intersect, but because the island is only rendered in front of water I don't know if I can do what I want
@upbeat topaz your variable name is wrong
speed over time would be s/t
it should be named distance
not sure why you couldn't get _Time param to work what were you trying
you likely meant to use:
unity_DeltaTime float4 Delta time: (dt, 1/dt, smoothDt, 1/smoothDt).
_Time is time since level load.
@upbeat topaz
it worked with the level load, but delta time will prob be more useful
and thank you for the advice
howdy! when using normal displacement and a noise gen, it tends to rip and tear the faces apart, is there a way to avoid this ?
hmm the mesh is smoothed
"we can fix the seams using object space for the noise instead of UV space"
that's from a vertex displacement tutorial by Unity
but i am using object space added to the mix
If it were smoothed you wouldn't have duplicate vertices
Which would solve the issue
that actually sounds similar to my problem, I'm trying to do inverted hull outlines but where there's seams between objects cracks form and I was wondering if there's a way to prevent this?
https://github.com/ronja-tutorials/ShaderTutorials/blob/master/Assets/020_Inverted_Hull/UnlitOutlines.shader this is the shader I'm using
and a weird peculiarity with certain faces not seeming to invert as if they're being culled? like this finger here I feel the outline should follow down the side where his finger is but it just kinda cuts off as if it's a plane formed on top of the hand
@jaunty lichen I guess all of your normals aren't smoothed, and in some scenarios they shouldn't be, you can however use other inputs for displacement, like you could bake vertex colors to be the smoothed normals, but I guess you are already using those, so you could try uv map 2 and 3, or just have a separate 3d model for the outline
Yeah it's started to dawn on me that the issue is the model itself, which sucks cause i've been trying shader after shader trying to get a particular feel for days now xD
well, just import into blender, smooth the normals and import back to unity
Anyone has idea how to replicate this in shader? https://twitter.com/klemen_lozar/status/952219112796598272
You can use the depth buffer with a bump offset function to map textures to the geometry in your scene. Very handy for dynamic UI elements, character damage effects, etc...#UE4 #gamedev #indiedev https://t.co/6KFjpo7vwA
323
1663
@burnt ether It'll be similar to how deferred g-buffer decals work
idk how the bump offset works, but here is a working shader I made that you can use to achieve a similar effect, it basically reconstructs the world position from depth, works in the forward renderer too https://drive.google.com/file/d/1lIkuq8PM5HKRfUYw63iY5Mw6LmSFqKJA/view?usp=drivesdk
@burnt ether
@cosmic prairie Thanks, but now how to use it?
Inputing this to uv node of texture doesn't work, results are crazy.
@burnt ether Oh, you're doing this in Shader Graph? Can't you try to copy the UE4 node setup?
https://twitter.com/klemen_lozar/status/952255581233889280
@burnt ether check you have enabled the depth texture, I believe it's disabled by default. In urp render settings.
@burnt ether I'm not sure if it's possible with shader graph alone yet, I know of some asset store decals for lwrp / urp. I was just looking back in forums, "on the roadmap" is general gist.
Is there a roadmap for Shader Graph?
of that I'm certain, publicly visible.. unlikely
Is there by any chance a way to convert a .fx (HLSL i believe) shader to a unity supported .shader easily?
hmm the subshadergraph worked for me, maybe it's gpu specific?
@burnt ether I'll send the built project with a 3d-ish voronoi example, please confirm that this is what you see or not:
you can look around similarly to blender with the middle mouse button and by holding leftshift
if you move around the textures should not shift around
How do you connect the node to texture's uv?
just plug it into PBR node's color and see if that works fine first
The demo works good.
btw are you trying to reconstruct from the main camera or the shadow map? because shadow map is a different story
yes, but since you are trying to sample a 2d thing with a 3d thing it will look wonky:
is this similar to what you see in your own project?
do the textures shift around when you move your camera around?
Yes, they can't stay in place.
maybe? never used HDRP, but doesn't HDRP have world coordinates by default?
It has. Show me how you connect the graph with it.
The multiplication is just to make it look better, does nothing special
This is the one with the voronoi example
Idk what happens now, I guess it's HDRP doing something differently with depth stuff.
yeah maybe its that
btw I have no clue why my subgraph even functions, there is a part in it that I made accidentally that made it work
Thanks for help anyway.
would raymarching be doable with the shader graph?
Working on making some water for my game and I accidently made 2d water somehow
But so after an hour, I've managed to make the waves work in the way I want. Now I can focus on the other parts of the water shader
Hello! I'm new to this server and I'm not entirely sure where to go, is this an okay place to seek some help with compute shaders?
Uhhh
yes
@winter acorn probably, I think you'd have to use the custom node to handle the for loop
@winter acorn it works, I've ported some raymarching from shadertoy and done object space volumetric shapes etc. but as @uncut karma said you need custom node to handle some bits.
hmm. thanks
I have a problem understanding something...
Let's say that I have a function, defined somewhere in the CGINCLUDES block.
How can I figure out from which pass it is called (e.g. deferred write, shadowcaster pass, etc.) if no defines actually work there (since CGINCLUDE block must always be higher than the preprocessor define block)?
You've tried using defines in the function without success?
But how can I? The same exact function must be used in all of the passes. I cannot make a definition inside them.
And because functions and cgincludes must be present before the call, I cannot possibly process that definition, because it was not defined yet
I can just dupe the function and include it into all of the passes, but that'll become a maintenance hell.
As I understand includes, all its doing is pasting the code you include into the shader before compiling it. So I don't see why defines wouldn't work like in any other function.
Yeah, that's if we're talking about the includes.
But what about the raw code inside that same shader file?
I don't think I'm understanding what you're trying to do
I have a function in a shader, defined somewhere above the passes or inside a CGINCLUDE shader block (not the cginc file). How can I achieve the exact same behavior here as with defines + cginc files?
It's just a hypothetical question
I don't know. Doesn't sound possible. Why not use cginc files? More duplicate code to include it in every pass?
It was just a curiosity of mine.
But yeah, I understand why cginc files are better for this
ok so i downloaded this assethttps://assetstore.unity.com/packages/essentials/tutorial-projects/unity-particle-pack-127325?cid=1011l6DoIzYL
and i'm new in general to unity and everything surrounding
so my question is how do you spawn a particle effect prefab
and have it happen once
@slate patrol could a forward declared function help in your situation?
It's basically a function defined without the body first, then later anywhere in the file it is redefined (so it avoids the compiler thinking it is missing)
Could anyone give me some help on this? It happens anytime I try to do any shadergraph
That looks like a shader graph bug, it is in control of any includes, did u check if SG and URP are same version?
I also see this pop up very often, seems to be a bug in the async shader compiler
how do i spawn in particles
I have a question. I'm trying to make water similar to the witness, and I'm have a lot of trouble with having the water reflect the world. I've tried a few different ways, but it usually ends in my editor crashing.
how big a concern is overdraw with transparent effects? I've got this shield effect rendering to a quad, but there's a lot of unused space.. should I find a better way to do this?
@full sail It's a big concern for mobile hardware. Desktop and console, not as much.
@low lichen cool, any insight into a better way to render 2d effects? or does this approach seem acceptable?
@full sail You could reduce the overdraw by making sure the quad doesn't extend much further than the texture. You could also place the quad behind the ships (?), so you're not drawing transparent pixels on top of the ship.
@low lichen I'm using "clip" to discard the majority of the shape currently. Are you saying pixels are automatically discarded if they sit behind other objects from the camera?
Yes, it's called early Z rejection and it's an optimization that the GPU uses so it doesn't have to draw pixels that won't be visible anyway because other objects are in front of it.
clip and discard are really bad for mobile GPUs, you should not use it if this is for mobile
For desktop and console, it's absolutely fine.
thanks for the info @low lichen
So, I've been having an interesting time with Unity's compute shaders. I've been working on an audio visualization project involving real time fluid simulation. After doing a lot of research and reading a lot of papers, I stumbled across this code found here: https://github.com/Scrawk/GPU-GEMS-3D-Fluid-Simulation. The thing is that I had tried to adapt this code to work with rendertextures, as in this code it's implemented using compute buffers. When I had finished my changes, I went to test it, and it's simply not behaving the way it should. I've double checked everything and made sure that all the math is correct. Also, my rather messy code that I wrote can be found here https://github.com/AsherBearce/AudioVisualizer. I also have code that is the directly modified version of Scrawk's implementation that I can provide if necessary, however I'm too lazy to post it to github at this moment. Also, the directly modified code, and the code found on my github behave in exactly the same way. I'm not entirely sure what I'm doing wrong, so if someone with more experience than me could lend a hand, I'd be very grateful.
I'd ensure that your textures are linear color space, your project settings are set to gamma space, so I think textures will be sRGB unless specified directly, but not sure if that's the issue, it only displays a small circular blob for me
That's the behavior I'm experiencing as well. I'll try changing the color space to see if that works
Actually, how do I change it? Lol I can't find it in the project settings
Ah, nevermind found it
Oh and you're only copying slice 0 of the texture
It isn't required to use texture 3d, I'd just use rendertexture for both
Yeah, I realized that pretty quickly
But I just haven't gotten around to fixing it. I'll try that now
I don't have any specific advice but if you aren't familiar with keijiro's work he has made a lot of audio visualization plugins and effects that might be helpful https://github.com/keijiro?tab=repositories
Thanks! I'll definitely give that a look. I do have a solution to my problem, but it kind of ignores why I'm having this problem, and I think this would be a good learning experience to fix it.
In shader graph has anyone been able to get transform nodes to behave correctly going between object and world space? I seem to have them working after a bunch of tweaking and then they seem to change their functionality? I am still on 19.1 so it could just be versions but my cursory search of the issues database didn't seem to turn up anything.
Alright, I seem to be missing something crucial
How do I render the motion vectors? e.g., I have some vertex displacement and I need to write motion vector data by multiplying the previous matrix.
But as far as I can see, no internal shaders do that. They don't calculate motion vectors and I can't see where they write em.
So, how do I write the vector motion data?
I know that there is a "MotionVectors" LightMode, but that one requires its own pass in order to render, which is absolutely not acceptable.
Anyone?
@slate patrol which renderer?
Default one, of course
I mean, the legacy one
You get which one I'm talking about
Is it really necessary that I need a separate pass to render custom motion vectors?
I ask because for the old renderer, there's this sample on PP stack v1: https://github.com/Unity-Technologies/PostProcessing/tree/v1/PostProcessing/Utilities/CustomMotionTexture
that sample is overriding the motion vectors
but should give you ideas how to do other things
there's visualization shader too if i remember right
Yeah, I snooped around in it, but it does require its own separate pass to render the motion vectors.
yes
ah, you said that already
I dunno how else you could write there unless you do it on some pass
But how does the standard shader do it without a separate pass?
Is it just a hardware quirk that basically says "if you don't do vertex manipulation I can write correct motion vectors for you automatically"?
there isn't some internal pass? I wouldn't know
you could probably see these with some frame debugger
There is none. No internal shaders have a dedicated MotionVector pass
And I don't. I can debug motion vectors written by a separate pass, but not the ones that are written as a part of the main fragment shaders. They do get written though.
What is more dealbreaking for me is that MotionVectors pass doesn't seem to support instancing, so all of the meshes are rendered separately.
When converting from Shadertoy to Unity Shaders, what would be the equivalent to iChannel1?
freqs[1] = texture(iChannel1, vec2(0.07, 0.25)).x;
Like in the above example
Probably a normal texture input
Would you be able to assist me in converting? I'm pretty new to shaders, but just wanted to see a shader I found on Shadertoy in Unity
This is a good tutorial:
https://www.youtube.com/watch?v=CzORVWFvZ28
Twitter: @The_ArtOfCode Facebook: https://www.facebook.com/groups/theartofcode/ Patreon: https://www.patreon.com/TheArtOfCode Ever wondered how to get a shad...
float freqs[4];
void surf(Input IN, inout SurfaceOutputStandard o)
{
freqs[0] = tex2D(iChannel1, float2(0.01, 0.25)).x;
freqs[1] = tex2D(iChannel1, float2(0.07, 0.25)).x;
freqs[2] = tex2D(iChannel1, float2(0.15, 0.25)).x;
freqs[3] = tex2D(iChannel1, float2(0.30, 0.25)).x;```
I've watched that
The problem is he glosses over iChannel1
iChannel1 is just a texture input. You have to define a texture property in the start of the shader, then sample it with tex2D, like you're doing in that snippet.
so basically the input for the user?
There is "_MainTex("Albedo (RGB)", 2D) = "white" {}" already, which I assume could be used here?
Yeah, replace iChannel1 with _MainTex
I think the tutorial goes over fragCoord
Hm.
I'd have to watch again then.
The line is:
float2 uv = fragCoord.xy / iResolution.xy;
He already mentioned that, since it's on a 3D object then resolution doesn't really matter
But question is if the UV float does because it's used somewhere else in the computation
What that line is doing is converting pixel coordinates to uv coordinates.
Right.
The tutorial definitely goes over this
I'll try and watch again then
@void bobcat Here's the timestamp
https://youtu.be/CzORVWFvZ28?t=686
Twitter: @The_ArtOfCode Facebook: https://www.facebook.com/groups/theartofcode/ Patreon: https://www.patreon.com/TheArtOfCode Ever wondered how to get a shad...
Oh, thank you. I was skimming to look through.
Hm
I don't quite understand his fragColor cheatsheet
He just seems to return a float4
Is that right?
@void bobcat Yeah, in shadertoy the main function is a void, but outputs by setting the out parameter fragColor. In Unity, the frag function returns a float4 instead.
Wait...this is a void function. I can't return anything from it.
So I'd have to write to the "SurfaceOutputStandard"
Ah, I picked surface shader
Rather than unlit shader
Okay
The result was not exactly as on shadertoy.... xD
https://www.shadertoy.com/view/4dXGR4 This is the shadertoy version
I'm making a gif for the unity version I just converted
iChannel1 is an audio stream, not a texture. Could have pointed that out.
huh? ๐ค
This is an audio reactive shader. Do you want to convert that part, too?