Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mradfo21 · Jan 02, 2014 at 05:56 PM · shaderscgfragmentshadinggeneral

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

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HappyMoo · Jan 02, 2014 at 07:47 PM 0
Share

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?

avatar image mradfo21 · Jan 02, 2014 at 09:24 PM 0
Share

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

avatar image HappyMoo · Jan 03, 2014 at 01:40 AM 0
Share

That's nice... you're making me want to have some more fun with shaders..

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges