procedural flame shader
Asked Answered
D

5

0

found this flame shader on shadertoy>

https://www.shadertoy.com/view/XsXSWS
looks really usefull
i have no clue on how to convert it to a godot one tho.

Diego answered 4/12, 2022 at 18:46 Comment(0)
D
0

Looks like standard GLSL, so you could basically copy and paste it with a few changes, but please look at if there is a license.

Diomedes answered 4/12, 2022 at 19:30 Comment(0)
D
0

Diomedes i dont see any license
i tried copy pasting it but im getting alot of errors i cant resolve. my shading knowledge is bad 🙁

Diego answered 4/12, 2022 at 19:39 Comment(0)
D
0

Here, I just ported it, but don't blame me if you get sued, lol.

shader_type canvas_item;

vec2 hash( vec2 p ) {
	p = vec2( dot(p,vec2(127.1,311.7)),
			 dot(p,vec2(269.5,183.3)) );
	return -1.0 + 2.0*fract(sin(p)*43758.5453123);
}

float noise( in vec2 p ) {
	const float K1 = 0.366025404;
	const float K2 = 0.211324865;
	vec2 i = floor( p + (p.x+p.y)*K1 );
	vec2 a = p - i + (i.x+i.y)*K2;
	vec2 o = (a.x>a.y) ? vec2(1.0,0.0) : vec2(0.0,1.0);
	vec2 b = a - o + K2;
	vec2 c = a - 1.0 + 2.0*K2;
	vec3 h = max( 0.5-vec3(dot(a,a), dot(b,b), dot(c,c) ), 0.0 );
	vec3 n = h*h*h*h*vec3( dot(a,hash(i+0.0)), dot(b,hash(i+o)), dot(c,hash(i+1.0)));
	
	return dot( n, vec3(70.0) );
}

float fbm(vec2 uv) {
	float f;
	mat2 m = mat2(vec2(1.6,  1.2), vec2(-1.2,  1.6));
	f  = 0.5000*noise( uv ); uv = m*uv;
	f += 0.2500*noise( uv ); uv = m*uv;
	f += 0.1250*noise( uv ); uv = m*uv;
	f += 0.0625*noise( uv ); uv = m*uv;
	f = 0.5 + 0.5*f;
	return f;
}

void fragment() {
	vec2 uv = vec2(UV.s, -UV.t + 1.0);
	vec2 q = uv;
	q.x *= 5.;
	q.y *= 2.;
	float strength = floor(q.x+1.);
	float T3 = max(3.,1.25*strength)*TIME;
	q.x = mod(q.x,1.)-0.5;
	q.y -= 0.25;
	float n = fbm(strength*q - vec2(0,T3));
	float c = 1. - 16. * pow( max( 0., length(q*vec2(1.8+q.y*1.5,.75) ) - n * max( 0., q.y+.25 ) ),1.2 );
	float c1 = n * c * (1.5-pow(2.50*uv.y,4.));
	c1=clamp(c1,0.,1.);
	vec3 col = vec3(1.5*c1, 1.5*c1*c1*c1, c1*c1*c1*c1*c1*c1);
	float a = c * (1.-pow(uv.y,3.));
	
	COLOR = vec4( mix(vec3(0.),col,a), 1.0);
}
Diomedes answered 4/12, 2022 at 19:45 Comment(0)
D
0

Diomedes what? that quick?
i m trying to use it as a particle shader, doesnt compile then.
how do i check if there is a license? dont see any on shadertoy

Diego answered 4/12, 2022 at 19:50 Comment(0)
D
0

It's a canvas item shader. You can put it on a ColorRect to test it in a new project.

I haven't worked with particle shaders, so I'd have to look into that later.

Diomedes answered 4/12, 2022 at 20:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.