sun and dynamic light?

Posted By: 3run

sun and dynamic light? - 10/29/14 11:27

I wonder is there any way to get brightness of the surface affected by dynamic light and sun light. F.e. if I trace below player and then check for tex_light (or hit) I can see then, if player is hiding in the shadow or not (lightmap), this could be used to make view entity darker or brighter depending on the surface below player (lets call this fake lightning). I remember one guy from Russian gamestudio community (jd_frost) used view entities for weapons, and via some tricks he was able to get dynamic lights with their colors (sun light as well) affect on view entity, and he didn't use shaders for those, only a trace, some stuff that I do not remember, and he changed view entities colors (I remember this one for sure). The sad thing is, that Russian community webpage is down.. maybe some of you guys have an idea how to return color and brightness of surface affected by dynamic light?

thanks in advance, greets
Posted By: Superku

Re: sun and dynamic light? - 10/29/14 17:04

You could try to iterate over the level enemies (ent_next), find those who have light_range != 0 or whatever it is called, then perform a c_trace every frame or multiple times per second from the camera to those entities (distance checks/ updates every frame, they are relatively cheap) and try to adapt the view entity color that way.
You could either use a shader or use a simple and old school MATERIAL where you set material.ambient_red, material.emissive_red and so on manually. I'm not too sure about the correct formula right now but for a start try to set the emissive_blue vector to zero each frame, then add the light (ent.blue ?) of each visible dynamic light source to said material vector but scale it prior to that with some factor like the following:

factor = clamp(1-vec_dist(camera.x,light.x)/light.light_range,0,1);
Posted By: 3run

Re: sun and dynamic light? - 10/29/14 21:19

well, I've got your idea. thank you, Superku.
Posted By: sivan

Re: sun and dynamic light? - 10/30/14 10:56

wouldn't it be better to use normal models for weapons placed farer than clip_near instead of view entities? you could get much quality, just by using a bit longer 1st person arm model, and weapon model with adjusted scale; and another different model, if you want to switch to 3rd person view.
Posted By: MasterQ32

Re: sun and dynamic light? - 10/30/14 11:36

You can even use only one model for first and third person. It works pretty fine and has some really cool dynamics as the weapon is animated through the player model.
Also you could see your feet wink
Posted By: sivan

Re: sun and dynamic light? - 10/30/14 11:48

yeah and because of shadows cast by player character it is better... if close clipping issues are solved.
Posted By: 3run

Re: sun and dynamic light? - 10/30/14 13:54

I'm doing this for testing purposes, not because I prefer view entities over world entities for weapons, or so. And I don't really need anyone to tell about what looks better, cause we all do have our own tastes tongue
Originally Posted By: MasterQ32
Also you could see your feet wink
This doesn't make your approach better, cause if you won't have good animated models, it will look terrible (I've already told you this before, when you've showed me one of your projects WIP). In my situation, I have no good models, and I'm not the one who can create good ones, so tongue

Greets
Posted By: MasterQ32

Re: sun and dynamic light? - 10/30/14 14:09

Quote:
This doesn't make your approach better, cause if you won't have good animated models

Doesn't this also apply on view models as you can see the models in third person (as the player you see your enemies)
So imho it doesn't matter if i see "one more" bad animation if most of the animation is bad.
Posted By: 3run

Re: sun and dynamic light? - 10/30/14 14:11

Originally Posted By: MasterQ32
Doesn't this also apply on view models
It doesn't, simply cause I use animated sprites instead of models tongue
And there are tons of pretty nice animated (old-school) sprites out there!
Posted By: MasterQ32

Re: sun and dynamic light? - 10/30/14 14:59

Why not use a PANEL with the animated weapon sprite and color it dynamically with LIGHT flag and use this instead of a view model?
Should look pretty cool if the NOFILTER flag is set
Posted By: Wjbender

Re: sun and dynamic light? - 10/30/14 19:40

in the manual under "engine" sub section "lighting engine" is a lot of information .

one states that you can read the PRV values of
the current watched (debug) entity but according
to what I understand PRV being pre calculated
light values ,come from static lighting ,so that won't
help you .

However ,also according with my understanding
dynamic lighting calculates from the diffuse specular and emissive values of entities ,
therefore you could
create an entity which you could read it's material
values from and apply the calculation to it ,then apply that to your view entity ?,but
I do not know how good a transition would look like.

if you need an entity to only be affected by dynamic
lights the manual states , set it's UNLIT flag but do not assign mat_unlit .

for affecting it only with PRV , assign mat_unlit
but do not set UNLIT flag ..

I guess you could also read a single vertex (totally unsure) for calculating the light ...

but for PVR the hit.blue/green/red represent
the lightmap ,so that won't help for dynamic lights..

i think the closest i got is ,have a look at , vecLight and vecLightColor

jb
Posted By: 3run

Re: sun and dynamic light? - 10/31/14 08:22

Originally Posted By: MasterQ32
Why not use a PANEL with the animated weapon sprite and color it dynamically with LIGHT flag and use this instead of a view model?
Should look pretty cool if the NOFILTER flag is set
Still, this doesn't help me to get dynamic lights affect on PANELs you suggest. tired


Originally Posted By: Wjbender
in the manual under "engine" sub section "lighting engine" is a lot of information .

one states that you can read the PRV values of
the current watched (debug) entity but according
to what I understand PRV being pre calculated
light values ,come from static lighting ,so that won't
help you .
Yes, I've already got static light on the view entity (as I've described in my first post).
Originally Posted By: Wjbender
However ,also according with my understanding
dynamic lighting calculates from the diffuse specular and emissive values of entities ,
therefore you could
create an entity which you could read it's material
values from and apply the calculation to it ,then apply that to your view entity ?,but
I do not know how good a transition would look like.
If only I knew, how to return this values of the specific entity frown
Originally Posted By: Wjbender
if you need an entity to only be affected by dynamic
lights the manual states , set it's UNLIT flag but do not assign mat_unlit .

for affecting it only with PRV , assign mat_unlit
but do not set UNLIT flag ..
UNLIT flag doesn't help in this situation.. smirk
I can't say it doesn't affect view entities, cause after setting it, I'm not able to change view entities colors.
Originally Posted By: Wjbender
I guess you could also read a single vertex (totally unsure) for calculating the light ...

but for PVR the hit.blue/green/red represent
the lightmap ,so that won't help for dynamic lights..

i think the closest i got is ,have a look at , vecLight and vecLightColor

jb
I'm not familiar with shaders unfortunately, otherways maybe I could use vecLightPos and vecLightColor frown

Thank you all for ideas so far, but yet question is still unanswered.
I could cycle throw all entities to check if they have lightrange > 0, or only specific type of entities (fire, enemies), but this is not an option for me, cause it will be too slow and tricky.. I want to recreate solution which was made by that jd_frost dude, so I could only use a single trace for this. So please, this in this direction, so all together we'll be able (hopefully) to recreate this solution (let this be some kind of a challenge for your knowledge tongue ).

Greets
Posted By: Wjbender

Re: sun and dynamic light? - 10/31/14 12:38

okay ... shadow_range sets a limit for the range which
dynamic shadows are displayed ..

set this value so that the shadow wil not
be displayed when it is out of range of a dynamic
light , the engine would determine the distance
calculations for you .

use a trace and if you find the shadow in there ,it
would mean to apply brightness to your view entity,
else set it dark .
I do not know if it would work for only decal shadows
or what .

view_to_light is another option to access ,the
variables of the closest to furthest 8 lights .

not a problem I would like to make my own , good luck

© 2024 lite-C Forums