Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gpu_shader_smoke_frag.glsl « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b57bd5b6a3775701a61aa1145152207a013ed780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

in vec3 coords;
out vec4 fragColor;

uniform vec3 active_color;
uniform float step_size;
uniform float density_scale;

uniform sampler3D soot_texture;
uniform sampler3D shadow_texture;

#ifdef USE_COBA
uniform sampler1D transfer_texture;
uniform sampler3D color_band_texture;
#endif

void main()
{
	/* compute color and density from volume texture */
	vec4 soot = texture(soot_texture, coords);

#ifndef USE_COBA
	vec3 soot_color;
	if (soot.a != 0) {
		soot_color = active_color * soot.rgb / soot.a;
	}
	else {
		soot_color = vec3(0);
	}
	float soot_density = density_scale * soot.a;

	/* compute transmittance and alpha */
	float soot_transmittance = pow(2.71828182846, -soot_density * step_size);
	float soot_alpha = 1.0 - soot_transmittance;

	/* shade */
	float shadow = texture(shadow_texture, coords).r;
	soot_color *= soot_transmittance * shadow;

	/* premultiply alpha */
	fragColor = vec4(soot_alpha * soot_color, soot_alpha);
#else
	float color_band = texture(color_band_texture, coords).r;
	vec4 transfer_function = texture(transfer_texture, color_band);
	fragColor = transfer_function * density_scale;
#endif
}