• 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 Squishy8 · Jun 27, 2016 at 02:53 PM · shadershadersglassconfusedrefraction

Light Refraction, Glass, and Marbles

I am building a project that needs marbles, the kind children play with. Colorful round pretty marbles that are not rendering the way i want them to. The marbles aren't important. It's the glass that concerns me. If you look at the glass shader in blender it has an IOR (Index of Refraction) value that essentially determines how distorted things are when you look at them through the glass. Anyone who knows blender well should know what I'm talking about. I would like to reproduce this effect using the shaders in unity, the problem is I'm not sure how to go about it. I poked around the internet and there are things about writing your own shaders and there is shader code that i don't quite understand. From what i do understand this is something you need unity pro for? To be honest i don't really understand.

What would be absolutely wonderful is if somebody could point me in the right direction here. Do i need to write my own shader because I'm willing to learn how, assuming there's something i can learn from. Is light refraction something i can do with the shaders I have in the free version of unity or do I need unity pro? If so is there a way around this? All I want is glass the refracts light. I'm open to suggestions. any help is appreciated

Comment
Add comment
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

2 Replies

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

Answer by Eno-Khaon · Jun 30, 2016 at 05:25 AM

Is this something more along the lines of what you're looking for?

https://en.wikibooks.org/wiki/Cg_Programming/Unity/Curved_Glass

That shader should be able to be used as-is, so you should be able to create a material and apply that shader. Then, ideally, it should do what you're hoping for.

Comment
Add comment · Show 4 · 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 Squishy8 · Jun 30, 2016 at 06:40 PM 0
Share

This shader is awesome! It is very close to what I want if I can figure out how to generate a cubemap for it. The thing now is though, can i get it to "see" things that are inside the glass. (as in inside the mesh) it's sort of essential to making what i want to happen happen. If i can get it to do that it'll be perfect.

You see the whole point of this is recreating a marble I made in blender in unity. In blender it looks like this

alt text

Yeah it's a little rough and that isn't the best render, but it stilll looks better than it does in unity because in Unity it looks like a ball with an orange wafer in it... Let's be honest that's because it IS a ball with an orange wafer in it the difference being that in blender it's a refractive glass ball that warps light with a wafer in it, and in unity it's a plain transparent ball that doesn't warp light with an orange wafer in it.

I suppose what i'm asking for is a shader that warps light so that whatever is inside looks warped. I wouldn't $$anonymous$$d it having a reflection but maybe not one quite as pro$$anonymous$$ent as your curved glass shader. (you can see in the picture that it reflects the softlight too heavily which sort of makes it look dull, my mistake)

avatar image tanoshimi Squishy8 · Jun 30, 2016 at 06:50 PM 0
Share

And the reason for that is that Unity -being a game engine- is doing simplified lighting calculations in realtime, while Blender -being a 3D rendering program- can take as much sweet time as it wants... :)

avatar image Asgardr tanoshimi · Jun 30, 2016 at 06:52 PM 0
Share

To be precise, Blender uses raytraced transparency in its renderer.

Show more comments
avatar image
2

Answer by tanoshimi · Jun 27, 2016 at 03:20 PM

  • No, you don't need Unity Pro (since Unity 5.x, there are no differences between the engine features in Pro and Personal).

  • Yes you need a shader that accounts for refraction.

  • Fortunately, Unity comes with one. Assets -> Import Package -> Effects -> Glass Refraction and try the material there.

Comment
Add comment · Show 2 · 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 Squishy8 · Jun 29, 2016 at 10:00 PM 0
Share

The glass in the glass refraction package doesn't quite look the way that I want it to. I'm going for more of a warping effect like this: https://www.shadertoy.com/view/XsSGDh

I know I can write my own shaders (I even watched an hour long unite talk about it) but I have no idea how to make this work.

avatar image Asgardr Squishy8 · Jun 30, 2016 at 06:45 PM 0
Share

The link you provided is indeed very pretty, but for a reason. It's raytraced. And I wouldn't rely on raytracing in this case. Plus, knowing how to write shaders is very far from knowing the complex mathematics of light propagation.

I'd reconsider looking at the Glass Refraction that Unity provides, I'm afraid.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Refractive glass shader 1 Answer

Glass Refraction Shader 2 Answers

how to bring a refraction effect in unity? 0 Answers

Need help rendering beer glass in unity... 0 Answers

Refraction Shader Problem 1 Answer


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