Hello, Im new with shader graph and I'm trying to get color via script. I tried with material.GetColor("_Color") or just material.Color but unity says that shader do not constain _Color parameter. How can I get color from master node?
It has just some hours since I started to play with ShaderGraph, but I would say the issue for you is that your Shader does not have a property called: "_Color"
But that "Color(3) input" (as far as I know) is only the port where the Master Node will receive everything you did in order to show the final result of the shader, which could be a color (yellow, pink, red, etc..) or a texture with a lot of complex pixels changes. What specifically would you like to do with that info in your code?
I need a color generated by a noise in shader. Im arleady using mathf.perlinnoise and some other plugin with noise from github but it starting to be very heavy if I need a lot of values from noises. I thing noise generaded in shader (so by gpu) would be much faster.
I'm not an expert in Shaders and didn't understand exactly what you want to do with the noise result, but if you want to provide more details, I can try to help while another experienced person comes to help you.
I would use one of the Shader Graph Noise nodes, there are three: Gradient Noise Simple Noise Voronoi Gradient is Perlin. That will give you a single floating point value, so you will probably want three generators one for each color. Then play around with the parameters until you get the amount of noise or smoothed noise you want for your effect. You may need to combine the three outputs from the Noise nodes into one vector 3 before passing it to the color, which can be done with the Combine node. Let me know how this works out for you.
Yes, it work for me but the problem is that I don't know how to get that color or other value in my script from shader. In shader graph I can set only input parameter like vector, color etc but there is nothing like output parameter. For example if I want to create mesh plane with vertices height depends on noise from shader. But I can nothing get from shader what shader generated.
The output is the whole shader result. So you can try to search how to Bake your shader result into a Texture to be used in real-time to do whatever you need Some links: - https://forum.unity.com/threads/save-texture-generated-by-a-shader.326561/ - https://gamedev.stackexchange.com/q...te-from-shader-to-a-texture-to-a-png-in-unity - https://www.ronja-tutorials.com/post/030-baking-shaders/
A Shader Graph shader is intended for producing a camera rendered output with two parts a vertex shader for your mesh, first, and a fragment shader for rendered pixel colors, last. Those are the outputs for shader graph, but the end result is a texture of the render. You could set up a camera, put the material with the shader on a quad or whatever in front of the camera to a render texture than save off that result if you wanted a map of the end results. However, this seems like a complicated approach to something that might be simple. If you just want the GPU to calculate some values, see Compute Shaders (not Shader Graph). You are also talking about color and then about a mesh. So first I think it would be best to understand what you are trying to accomplish overall and then I can give you some direction. For instance, if you just want to randomly displace the mesh for a plane, that would be with the vertex shader outputs. Let me know what you are trying to do.