- Home /
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);
}
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.
Oh, and I don't believe there are any restrictions for shaders in Unity free vs pro.
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
Follow this Question
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