- Home /
General question about shading in unity
A large gameplay feature of my game is the ability to see through walls. imagine an RTS but where you can toggle through different levels of buildings.
So I've got how to do it all worked out and I've created the feature using a fragment shader's discard feature (input height H. if world position of frag is > inputHeight, discard = simple!). I'm still creating a prototype so my focus is not on art at the moment. Now when I made this shader I just wrote a basic diffuse and specular lighting into it. I'm not intimidated by shader writing, though I'm not an expert. My question is this:
if your implementing a gameplay feature geared around a fragment shader effect, is it a good idea to modify unity's built in shaders or start from scratch with your own lighting models?
There is just something that bugs me about wanting to implement just a single feature, which is in total 4 lines of code, but then having to disregard ALL of unity's built in shaders. Now are Unity's shaders actually doing something cool that would make me want to keep them? If I switch to my own shader for every surface in my game am i playing with fire? Is there a reason not to do that - aka some kind of incredible optimization for different platforms that unity handles behind the scenes?
What are your thoughts? I'm just looking for advice, because my re-invent the wheel senses are going off when im writing my own custom cg shader for every surface of the game.
thanks for any advice!
Matt
I only dabbled in shader writing, but my thoughts are that custom shaders are being written all over the place and there are also a lot of shaders in the asset store, so if you can create a $$anonymous$$imal shader that works on all platforms you need and does what you need, go for it...
However, you may want some of the more advanced features later and then you'll have to recreate them... or copy'n'paste in or copy and adapt etc..
Regarding the effect you are trying to create... isn't it a problem that this actually wouldn't create geometry for the cut, so you would see that the wall is just a thin face?
you are correct that i dont fill in the geometry somehow (doing geometry booleans is a bit over my head). But i dont really think it'll be that bed, especially because i can put a cool emissive effect over a thin line around where it cuts in.
heres a post from a while ago where i was figuring out how to do it:
http://answers.unity3d.com/questions/560429/raycast-with-transparent-shader.html
That's nice... you're making me want to have some more fun with shaders..
Answer by tanoshimi · Jan 02, 2014 at 07:57 PM
There's nothing special about Unity's built-in shaders - feel free to use your own instead ;)
The only thing of note is that they are mostly written using Unity's own "surface shader" template, so you won't be able to modify them by adding your own custom fragment function - you'd have to write the complete vert/frag shader from scratch, but it's not so hard.
Answer by mradfo21 · Jan 02, 2014 at 09:22 PM
ok cool! I'll just write my own vert/frag shader. just wanted to check!
thanks guys!
Your answer
Follow this Question
Related Questions
Access to svPosition in fragment shader 1 Answer
GrabPass twirl shader not centering correctly 0 Answers
_LightMatrix0 and Directional Light 1 Answer
Is it more qualitative to calculate light direction manually or using WorldSpaceLightDir(vertex)? 1 Answer
Spherical Hamonics - ShadeSH9 and Surface Shader issue 0 Answers