+1 vote

Hi There,

I've been banging my head with this problem for a few days now.

I want to check in shader if a light is "lower" in Y position in relation to the object (i have it's Y position in a shader param)

If the light is bellow object, it proceeds, if not the light is 0.

At first i thought i could do this:

float light_y = current_world_position.y + LIGHT_VEC.y
if(light_y > object_y){
    LIGHT = LIGHT;
} else {
    LIGHT =  vec4(0.0);
}

but then it hit me, that the LIGHT_VEC is probably normalized.

So what i want is: find the global position for the current fragment, and the global position of the light (or distance vector to the light, so i can sum it's Y component to the position and find the light)

Is that possible as of now?
If so, how could i go about it? (FRAGMENTCOORD returns strange values, and POSITION is not available) Tested using Godot 3.0.2 and 3.0.3 rc1

Thanks in advance!

asked Jun 11 in Engine by raphaelkox (18 points)
edited Jun 11 by raphaelkox

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.