Origins (Fabric)

Origins (Fabric)

15M Downloads

Brightness condition not functioning properly with shader power type

Alluysl opened this issue ยท 3 comments

commented

(This has ripple effects onto exposed_to_sun)

Important findings at the bottom too!

Brightness condition is always evaluated as higher than 0.5 (I checked by reversing the comparison and using different shaders) for the shader power type.

Affected example:

Notice how weakness is properly applied but the shader is applied even when it shouldn't:
image
image

Data for that example:

{
	"type": "origins:multiple",

	"comparison_power_meant_to_show_that_things_are_triggered_properly_for_this_power_type": {
		"type": "origins:stacking_status_effect",
		"min_stacks": 0,
		"max_stacks": 1,
		"duration_per_stack": 20,
		"effects": [
			{
				"effect": "minecraft:weakness",
				"is_ambient": true,
				"show_particles": false,
				"show_icon": true
			}
		],
		"condition": {
			"type": "origins:brightness",
			"comparison": ">",
			"compare_to": 0.5
		}
	},

	"shader_power_that_has_the_issue": {
		"type": "origins:shader",
		"shader": "minecraft:shaders/post/pencil.json",
		"condition": {
			"type": "origins:brightness",
			"comparison": ">",
			"compare_to": 0.5
		}
	},

	"tell_whether_brightness_condition_is_fullfilled_every_second_for_reference": {
		"type": "origins:action_over_time",
		"entity_action": {
			"type": "origins:if_else",
			"condition": {
				"type": "origins:brightness",
				"comparison": ">",
				"compare_to": 0.5
			},
			"if_action": {
				"type": "origins:execute_command",
				"command": "say true"
			},
			"else_action": {
				"type": "origins:execute_command",
				"command": "say false"
			}
		},
		"interval": 20
	}
}

The shader is also active at both noon and midnight instead of deactivating at midnight in the case of a dark one:
image
This excludes the hypothesis that brightness depends on the post-processed image for shader power types.

When changing ">" to "<":
image

Reference test (for comparison):

{
	"type": "origins:multiple",

	"comparison_power_meant_to_show_that_things_are_triggered_properly_for_this_power_type": {
		"type": "origins:stacking_status_effect",
		"min_stacks": 0,
		"max_stacks": 1,
		"duration_per_stack": 20,
		"effects": [
			{
				"effect": "minecraft:weakness",
				"is_ambient": true,
				"show_particles": false,
				"show_icon": true
			}
		],
		"condition": {
			"type": "origins:on_block",
			"block_condition": {
				"type": "origins:block",
				"block": "minecraft:grass_block"
			}
		}
	},

	"shader_power_that_has_the_issue": {
		"type": "origins:shader",
		"shader": "minecraft:shaders/post/pencil.json",
		"condition": {
			"type": "origins:on_block",
			"block_condition": {
				"type": "origins:block",
				"block": "minecraft:grass_block"
			}
		}
	}
}

In this test everything goes as expected and the player gets weakness if and only if the shader effect is applied, meaning the shader deactivates and activates properly. I also tested with exposed_to_sky, yielding the same results.

IMPORTANT FINDINGS

Now, changing from "> 0.5" to "== 1" gives us interesting results:

At noon:

Not exposed:
image
Exposed:
image

At midnight:

Not exposed:
image
Exposed:
image

It seems the brightness value is somehow offset due to the shader. I would like to do more research but it's 3:30 AM so that will be it for now.

Naturally I'm using Origins version 0.7.1.

commented

Judging by the code, the issue seems to be from the game itself. Maybe it can be patched though.

commented

For reference, the following has the expected behavior:

{
	"type": "origins:multiple",

	"is_exposed": {
		"type": "origins:resource",
		"min": 0,
		"max": 1,
		"start_value": 0,
		"hud_render": {
			"should_render": false
		}
	},

	"update_exposed": {
		"type": "origins:action_over_time",
		"entity_action": {
			"type":"origins:if_else",
			"condition": {
				"type": "origins:exposed_to_sun"
			},
			"if_action": {
				"type": "origins:execute_command",
				"command": "resource set @s alluyslorigins:test_is_exposed 1"
			},
			"else_action": {
				"type": "origins:execute_command",
				"command": "resource set @s alluyslorigins:test_is_exposed 0"
			}
		},
		"interval": 20
	},

	"comparison_power_meant_to_show_that_things_are_triggered_properly_for_this_power_type": {
		"type": "origins:stacking_status_effect",
		"min_stacks": 0,
		"max_stacks": 1,
		"duration_per_stack": 20,
		"effects": [
			{
				"effect": "minecraft:weakness",
				"is_ambient": true,
				"show_particles": false,
				"show_icon": true
			}
		],
		"condition": {
			"type": "origins:resource",
			"resource": "alluyslorigins:test_is_exposed",
			"comparison": "==",
			"compare_to": 1
		}
	},

	"shader_power_that_has_the_issue": {
		"type": "origins:shader",
		"shader": "minecraft:shaders/post/pencil.json",
		"condition": {
			"type": "origins:resource",
			"resource": "alluyslorigins:test_is_exposed",
			"comparison": "==",
			"compare_to": 1
		}
	},

	"tell_whether_brightness_condition_is_fullfilled_every_second_for_reference": {
		"type": "origins:action_over_time",
		"entity_action": {
			"type": "origins:if_else",
			"condition": {
				"type": "origins:resource",
				"resource": "alluyslorigins:test_is_exposed",
				"comparison": "==",
				"compare_to": 1
			},
			"if_action": {
				"type": "origins:execute_command",
				"command": "say true"
			},
			"else_action": {
				"type": "origins:execute_command",
				"command": "say false"
			}
		},
		"interval": 20
	}
}
commented

I should mention I'm using Sodium, actually.