Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken Converter #35

Open
HAced opened this issue Mar 22, 2021 · 1 comment
Open

Broken Converter #35

HAced opened this issue Mar 22, 2021 · 1 comment

Comments

@HAced
Copy link

HAced commented Mar 22, 2021

I heard a lot about this converter not working correctly anymore, and it not working for me too, so here's the shader I want to be converted.
#define t iTime
mat2 m(float a){float c=cos(a), s=sin(a);return mat2(c,-s,s,c);}
float map(vec3 p){
p.xz*= m(t0.4);p.xy= m(t0.3);
vec3 q = p
2.+t;
return length(p+vec3(sin(t*0.7)))*log(length(p)+1.) + sin(q.x+sin(q.z+sin(q.y)))*5.5 - 1.;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord ){
vec2 p = fragCoord.xy/iResolution.y - vec2(.9,.5);
vec3 cl = vec3(0.);
float d = .9;
for(int i=0; i<=5; i++) {
vec3 p = vec3(0,0,5.) + normalize(vec3(p, -1.))d;
float rz = map(p);
float f = clamp((rz - map(p+.1))0.5, -.1, 1. );
vec3 l = vec3(.32, .24, .49) + vec3(.53, .48, .61)f;
cl = cl
l + (1.-smoothstep(0., 2.5, rz))
.7
l;
d += min(rz, 1.);
}
fragColor = vec4(cl, 1.);
}
Original website: https://www.shadertoy.com/view/wdjSRc

@smkplus
Copy link
Owner

smkplus commented Mar 24, 2021

Hi I tried to convert the shader

image

    Shader "ShaderMan/MyShader"
	{
	Properties{
	
	}
	SubShader
	{
	Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
	Pass
	{
	ZWrite Off
	Blend SrcAlpha OneMinusSrcAlpha
	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#include "UnityCG.cginc"
			
    

    float4 vec4(float x,float y,float z,float w){return float4(x,y,z,w);}
    float4 vec4(float x){return float4(x,x,x,x);}
    float4 vec4(float2 x,float2 y){return float4(float2(x.x,x.y),float2(y.x,y.y));}
    float4 vec4(float3 x,float y){return float4(float3(x.x,x.y,x.z),y);}


    float3 vec3(float x,float y,float z){return float3(x,y,z);}
    float3 vec3(float x){return float3(x,x,x);}
    float3 vec3(float2 x,float y){return float3(float2(x.x,x.y),y);}

    float2 vec2(float x,float y){return float2(x,y);}
    float2 vec2(float x){return float2(x,x);}

    float vec(float x){return float(x);}
    
    

	struct VertexInput {
    float4 vertex : POSITION;
	float2 uv:TEXCOORD0;
    float4 tangent : TANGENT;
    float3 normal : NORMAL;
	//VertexInput
	};
	struct VertexOutput {
	float4 pos : SV_POSITION;
	float2 uv:TEXCOORD0;
	//VertexOutput
	};
	
	
	VertexOutput vert (VertexInput v)
	{
	VertexOutput o;
	o.pos = UnityObjectToClipPos (v.vertex);
	o.uv = v.uv;
	//VertexFactory
	return o;
	}
    
    // FORKED FROM Ether by nimitz (twitter: @stormoid)
// https://www.shadertoy.com/view/MsjSW3

#define t _Time.y
fixed2x2 m(float a){float c=cos(a), s=sin(a);return fixed2x2(c,-s,s,c);}
float map(float3 p){
    p.xz = mul(p.xz,m(t*0.4));p.xy= mul(p.xy,m(t*0.3));
    float3 q = p*2.+t;
    return length(p+vec3(sin(t*0.7)))*log(length(p)+1.) + sin(q.x+sin(q.z+sin(q.y)))*5.5 - 1.;
}


    
    
	fixed4 frag(VertexOutput vertex_output) : SV_Target
	{
		
	float2 p = vertex_output.uv/1 - vec2(.9,.5);
    float3 cl = vec3(0.);
    float d = .9;
    [unroll(100)]
for(int i=0; i<=5; i++)	{
		float3 pp = vec3(0,0,5.) + normalize(vec3(p, -1.))*d;
        float rz = map(pp);
		float f =  clamp((rz - map(pp+.1))*0.5, -.1, 1. );
        float3 l = vec3(0.1,0.3,.4) + vec3(5., 2.5, 3.)*f;
        cl = cl*l + (1.-smoothstep(0., 2.5, rz))*.7*l;
		d += min(rz, 1.);
	}
    return vec4(cl, 1.);

	}
	ENDCG
	}
  }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants