Skip to content

Instantly share code, notes, and snippets.

@yumayanagisawa
Created July 3, 2017 17:15
Show Gist options
  • Save yumayanagisawa/2dad04f9341836d6102e8fcab6c7f51c to your computer and use it in GitHub Desktop.
Save yumayanagisawa/2dad04f9341836d6102e8fcab6c7f51c to your computer and use it in GitHub Desktop.
Convert GLSL Sandbox to Unity ShaderLab
Shader "Custom/template" {
Properties {
/*
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
*/
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass {
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
fixed4 frag(v2f_img i) : SV_Target
{
fixed2 resolution = _ScreenParams;
fixed2 position = (i.uv * resolution / resolution.xy);
float time = _Time * 30;
fixed color = 0.0;
color += sin(position.x * cos(time / 15.0) * 80.0) + cos(position.y * cos(time / 15.0) * 10.0);
color += sin(position.y * sin(time / 10.0) * 40.0) + cos(position.x * sin(time / 25.0) * 40.0);
color += sin(position.x * sin(time / 5.0) * 10.0) + sin(position.y * sin(time / 35.0) * 80.0);
color *= sin(time / 10.0) * 0.5;
return fixed4(color, color * 0.5, sin(color + time / 3.0) * 0.75, 1.0);
}
ENDCG
}
}
FallBack "Diffuse"
}
/*
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_OES_standard_derivatives : enable
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / resolution.xy ) + mouse / 4.0;
float color = 0.0;
color += sin( position.x * cos( time / 15.0 ) * 80.0 ) + cos( position.y * cos( time / 15.0 ) * 10.0 );
color += sin( position.y * sin( time / 10.0 ) * 40.0 ) + cos( position.x * sin( time / 25.0 ) * 40.0 );
color += sin( position.x * sin( time / 5.0 ) * 10.0 ) + sin( position.y * sin( time / 35.0 ) * 80.0 );
color *= sin( time / 10.0 ) * 0.5;
gl_FragColor = vec4( vec3( color, color * 0.5, sin( color + time / 3.0 ) * 0.75 ), 1.0 );
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment