aboutsummaryrefslogtreecommitdiff
path: root/client/shaders/shadow_shaders/pass1_trans_fragment.glsl
blob: b267c221480b434fcddabf2eb35ed61bc332e5a2 (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
uniform sampler2D ColorMapSampler;
varying vec4 tPos;

#ifdef COLORED_SHADOWS
varying vec3 varColor;

// c_precision of 128 fits within 7 base-10 digits
const float c_precision = 128.0;
const float c_precisionp1 = c_precision + 1.0;

float packColor(vec3 color)
{
	return floor(color.b * c_precision + 0.5)
		+ floor(color.g * c_precision + 0.5) * c_precisionp1
		+ floor(color.r * c_precision + 0.5) * c_precisionp1 * c_precisionp1;
}

const vec3 black = vec3(0.0);
#endif

void main()
{
	vec4 col = texture2D(ColorMapSampler, gl_TexCoord[0].st);
#ifndef COLORED_SHADOWS
	if (col.a < 0.5)
		discard;
#endif

	float depth = 0.5 + tPos.z * 0.5;
	// ToDo: Liso: Apply movement on waving plants
	// depth in [0, 1] for texture

	//col.rgb = col.a == 1.0 ? vec3(1.0) : col.rgb;
#ifdef COLORED_SHADOWS
	col.rgb *= varColor.rgb;
	// premultiply color alpha (see-through side)
	float packedColor = packColor(col.rgb * (1.0 - col.a));
	gl_FragColor = vec4(depth, packedColor, 0.0,1.0);
#else
	gl_FragColor = vec4(depth, 0.0, 0.0, 1.0);
#endif
}
ref='#n85'>85 86 87 88
-- Registering some dummy items and recipes for the crafting tests

minetest.register_craftitem("unittests:torch", {
	description = "Crafting Test Item: Torch",
	inventory_image = "unittests_torch.png",

	groups = { dummy = 1 },
})
minetest.register_craftitem("unittests:coal_lump", {
	description = "Crafting Test Item: Coal Lump",
	inventory_image = "unittests_coal_lump.png",

	groups = { dummy = 1 },
})
minetest.register_craftitem("unittests:stick", {
	description = "Crafting Test Item: Stick",
	inventory_image = "unittests_stick.png",

	groups = { dummy = 1 },
})
minetest.register_craftitem("unittests:iron_lump", {
	description = "Crafting Test Item: Iron Lump",
	inventory_image = "unittests_iron_lump.png",

	groups = { dummy = 1 },
})
minetest.register_craftitem("unittests:steel_ingot", {
	description = "Crafting Test Item: Steel Ingot",
	inventory_image = "unittests_steel_ingot.png",

	groups = { dummy = 1 },
})

-- Recipes for tests: Normal crafting, cooking and fuel

minetest.register_craft({
	output = 'unittests:torch 4',
	recipe = {
		{'unittests:coal_lump'},
		{'unittests:stick'},
	}
})

minetest.register_craft({
	type = "cooking",
	output = "unittests:steel_ingot",
	recipe = "unittests:iron_lump",
})

minetest.register_craft({
	type = "fuel",
	recipe = "unittests:coal_lump",
	burntime = 40,
})

-- Test tool repair
minetest.register_craft({
	type = "toolrepair",
	additional_wear = -0.05,
})

-- Test the disable_repair=1 group
minetest.register_tool("unittests:unrepairable_tool", {
	description = "Crafting Test Item: Unrepairable Tool",
	inventory_image = "unittests_unrepairable_tool.png",
	tool_capabilities = {
		groupcaps = {
			cracky = {
				times = {3, 2, 1},
			}
		}
	},
	groups = { disable_repair = 1, dummy = 1 }
})

minetest.register_tool("unittests:repairable_tool", {
	description = "Crafting Test Item: Repairable Tool",
	inventory_image = "unittests_repairable_tool.png",
	tool_capabilities = {
		groupcaps = {
			cracky = {
				times = {3, 2, 1},
			}
		}
	},

	groups = { dummy = 1 },
})