Spatial shader, multiple Omni light problem
Asked Answered
W

6

0

Hey there, if somebody had the same issue:
i'm building my own lit spatial shader with the visual shader graph,
here the graph, (i tested with an expression as well i still have a problem)

here the issue :
when i test with multiple light, for example here with two omni , they are not blending very well in the engine.

Somebody have a way to fix it ?
thanks a lot

Waistband answered 24/10, 2023 at 15:35 Comment(0)
S
0

Waistband What happens if you disable shadow casting?

Stallworth answered 24/10, 2023 at 18:5 Comment(0)
W
0

Stallworth
yes i tested that, both shadow on the materials flags and omni light are disable.
Maybe it's a limitation with the actual engine state ?

Waistband answered 24/10, 2023 at 20:45 Comment(0)
S
1

Waistband More likely it's your shader. Can you post the shader code? (Click on "show generated shader code" icon in the shader editor toolbar and copy paste the code)

Stallworth answered 24/10, 2023 at 20:50 Comment(0)
W
0

Stallworth
Sure !
here the code

shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_lambert, specular_schlick_ggx, shadows_disabled, debug_shadow_splits;

global uniform vec4 Subscene_Darker_color : source_color;



void fragment() {
// ColorParameter:2
	vec4 n_out2p0 = Subscene_Darker_color;


// Output:0
	ALBEDO = vec3(n_out2p0.xyz);


}

void light() {
// Input:51
	vec3 n_out51p0 = NORMAL;


// Input:60
	vec3 n_out60p0 = LIGHT;


// DotProduct:58
	float n_out58p0 = dot(n_out51p0, n_out60p0);


// Clamp:56
	float n_in56p1 = 0.00000;
	float n_in56p2 = 1.00000;
	float n_out56p0 = clamp(n_out58p0, n_in56p1, n_in56p2);


// Input:57
	float n_out57p0 = ATTENUATION;


// VectorOp:59
	vec3 n_out59p0 = vec3(n_out56p0) * vec3(n_out57p0);


// Output:0
	SPECULAR_LIGHT = n_out59p0;


}
Waistband answered 25/10, 2023 at 10:0 Comment(0)
S
1

Waistband Each light pass should add to existing light value. That way the light contribution from each source accumulates properly. So you need to add the calculated value to existing value when assigning to output.

SPECULAR_LIGHT = SPECULAR_LIGHT + contribution_from_this_pass;
Stallworth answered 25/10, 2023 at 13:10 Comment(0)
W
0

Stallworth

Thanks again ! : ) that's working, just need to convert my visual shader and do the += need there.
Will try to do it keeping the visual shader as well and share it here when i will

Waistband answered 25/10, 2023 at 13:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.