From ae119f29cf9ab0b2ad5dd8382195e9b41c3154cf Mon Sep 17 00:00:00 2001 From: Fahim Imaduddin Dalvi <dalvifahim@gmail.com> Date: Sat, 4 Sep 2021 13:41:02 +0300 Subject: [PATCH] Fixed FOV side effect on light sprite size. The light sprite diminished to zero size as the FOV was decreased (in sim zoom), and increased considerably as the FOV was increased. This commit fixed this by taking the FOV into account to keep the light sprite size roughly constant across the valid FOV range. --- Effects/scenery-lights.eff | 6 ++++++ Shaders/scenery-lights.vert | 12 ++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Effects/scenery-lights.eff b/Effects/scenery-lights.eff index b805837d6..86d6debf0 100644 --- a/Effects/scenery-lights.eff +++ b/Effects/scenery-lights.eff @@ -15,6 +15,7 @@ <use_night_vision><use>/sim/rendering/als-filters/use-night-vision</use></use_night_vision> <use_IR_vision><use>/sim/rendering/als-filters/use-IR-vision</use></use_IR_vision> <sun_angle><use>/sim/time/sun-angle-rad</use></sun_angle> + <fov><use>/sim/current-view/field-of-view</use></fov> </parameters> <technique n="10"> @@ -123,6 +124,11 @@ <type>float</type> <value><use>sun_angle</use></value> </uniform> + <uniform> + <name>fov</name> + <type>float</type> + <value><use>fov</use></value> + </uniform> <uniform> <name>texture</name> <type>sampler-2d</type> diff --git a/Shaders/scenery-lights.vert b/Shaders/scenery-lights.vert index b31add3f0..aa6be6c08 100644 --- a/Shaders/scenery-lights.vert +++ b/Shaders/scenery-lights.vert @@ -24,6 +24,7 @@ uniform float osg_SimulationTime; uniform float avisibility; uniform float sun_angle; +uniform float fov; varying vec3 relativePosition; varying vec2 rawPosition; @@ -184,19 +185,14 @@ void main() lightSize = lightParams.x; lightIntensity = lightParams.y; - /******* - * TODOs: - * Might need to take into account FOV - */ - /******** * Each light is made up of a base circle, a circular-ish halo around the base and a bunch of * star-like rays * baseLightSize is tuned using reference objects of sizes 10cm, 50cm, 100cm, 500cm and 1000cm - * under the assumption that the "bright center" part of the light will be the same size as - * the light itself + * under the assumption that the "bright center" part of the light will be the approximately the + * same size as the light itself */ - float baseLightSize = lightSize / (dist/80); + float baseLightSize = lightSize / (dist/80) * 60/fov; /********