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 Sytto · Jan 30, 2013 at 12:18 AM · shadersshaderlabcghlslglsl

Can this shader run in unity?

Hello! First of all, I have no idea about shaders. I would like to run this shader inside Unity ( http://glsl.heroku.com/e#6303.3 )

I read it should be in a language called CG but I have no idea how to convert it to CG.

can anyone provide me the appropriate shader code? Also. Would it run in Unity Basic?

Thanks!

edit: shader code

 #ifdef GL_ES
 precision mediump float;
 #endif
 
 uniform float time;
 uniform vec2 mouse;
 uniform vec2 resolution;
 
 void main( void ) {
     
     vec3 color;
     float sum = 0.0;
     float size = 25.0;
     float r = 2.0;
     float g = 1.0;
     for (int i = 0; i < 3; ++i) {
         vec2 position = resolution / 2.0;
         position.x += sin(time + 10.0 * float(i)) * 50.0;
         position.y += cos(time+ 5.0 * float(i)) * 50.0;
         
         float dist = length(gl_FragCoord.xy - position);
 
         sum += size / pow(dist, g);
     }
     
     if (sum > r) color = vec3(1,1,1);
     
     gl_FragColor = vec4(color, 1);
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Julien-Lynge · Jan 30, 2013 at 02:48 AM

First of all, apologies, but I'm not going to allow scripts on a random site link, so I can't see the shader you're referring to. Can you copy over the code if this doesn't answer your question?

Second, the link says "GLSL," so I'm going to assume it's a GLSL shader. GLSL is a language used to write shaders, and Unity does support it. If you'd like to know how to work with GLSL in Unity, I suggest you check out the great Wikibooks tutorials at http://en.wikibooks.org/wiki/GLSL_Programming/Unity, as well as the Unity shader reference (try http://docs.unity3d.com/Documentation/Components/SL-GLSLShaderPrograms.html), and check out the numerous other questions people have asked on GLSL here (http://answers.unity3d.com/questions/topics/glsl.html) - one of them probably answers your question.

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 Julien-Lynge · Jan 30, 2013 at 02:49 AM 0
Share

Oh, and I don't believe there are any restrictions for shaders in Unity free vs pro.

avatar image Sytto · Jan 30, 2013 at 12:11 PM 0
Share

thanks for your answer. I updated my question so you can see the code, however in the link you can see how it looks, thats why I put the link rather than just the code

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

10 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

Related Questions

what would you choose to write unity shaders GLSL, HLSL/CG or Surface lang? 1 Answer

Can a CG shader fail to work on hardware? 1 Answer

Shader Variable Types 2 Answers

Porting from ShaderToy(GLSL) to shaderlab(HLSL/CG) unity not giving me the desired result. 2 Answers

Grabpass refraction masking 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