+3 votes

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!

in Engine by (20 points)
edited by

+1 This will be extremely powerful in 2D, if anyone has any resources on this, please share as this type of information is barely available if any at all.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.