- Home /
Refer from Shader to C# code?
Hi there! I am working on a match3 game and I have to make the items from the game render only inside a certain space, but I don't know much about shaders. For example, when I spwan new items, they appear on top of the 1st row of my items matrix and then fall to their position. So I searched for a solution and I think the best solution would be to use a VERTEX AND FRAGMENT shader to prevent the items to be drawn outside the game matrix. The thing is that in a match3 game there are also levels where item slots are missing, aka there are empty places in the matrix where the items must not be drawn. The question: is there a way to reference the positions of these empty slots to the shader?
you can get one million X better answers if you just post a quick screen shot of what you are doing. click Edit and use the "photo" button on the editor
Answer by Fattie · Jan 12, 2016 at 06:05 PM
Good news,
It's almost certainly the case that this has nothing to do with shaders, whatsoever, and you should not touch or worry about shaders in any way!
Good news right! :)
Simply try turning the renderer on and off, in the Editor. Next, learn how to do that in code - it's very simple (search on here if you have trouble).
Finally note that if you want to have a "frame" which covers like half an object as it say falls in ... just do that! Add a frame on top (i.e. closer to the camera).
I suggest mastering these very simple techniques before worrying about shaders, and I hope it helps!
Thanks for the reply. The first method would be useful and very simple, but i was looking for a cooler transition of the elements. In this way, they will pop in and dissappear. The second one is not possible in a match 3 game and no one would use it, taking into account that there is a huge number of possibilities to make a level,with missing slots. So my question question still stands up. I would be greatful if someone could help.
Your answer
Follow this Question
Related Questions
Screen shaders that alter geometry at runtime or through camera 1 Answer
separate vert and frag shader functions in two distinct URP Render Features 0 Answers
Uniform Texture, Rendering Problem 0 Answers
Dynamic Batching not working even adhering to all rules 3 Answers
Can I unpack normal / tangent / uv information in the vertex function in a surface shader? 1 Answer