mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Name the aircraft icons' 76 device-pixel image switch, and give it in CSS pixels
The draw contract measures an icon's imageLod switch in CSS pixels; the aircraft layers' GPU icons switch to their near image past 76 device (drawing-buffer) pixels. iconAtlas now names that switch, which the icon shader reads, and nearImageSwitchPx(pixelRatio) gives it in CSS pixels for a layer moving onto the draw port: 76 over the scene's pixel ratio, the one the quality port's frame signals report. On the default renderer that is its pixelRatio setting, or 1 while that is browser-recommended; devicePixelRatio does not enter it, so the default is 1.
This commit is contained in:
1 parent
87395bb733
commit
2cc226c1f9
3 files changed
+61
-5
No files matched your search
@@ -9,6 +9,29 @@
|
||||
* each slot's texture rectangle from `rects`.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Drawn width in device pixels (the drawing buffer's) past which an icon
|
||||
* row with no switch of its own draws its near image: the aircraft layers'
|
||||
* switch.
|
||||
*/
|
||||
export const NEAR_IMAGE_DEVICE_PX = 76;
|
||||
|
||||
/**
|
||||
* `NEAR_IMAGE_DEVICE_PX` in CSS pixels, for an icon item's
|
||||
* `imageLod.switchPx`, which the draw contract measures in CSS pixels: the
|
||||
* device switch divided by the drawing buffer's pixels per CSS pixel. That
|
||||
* is the scene's pixel ratio, which the quality port's frame signals report
|
||||
* as `pixelRatio`: on the default renderer its `pixelRatio` setting, or 1
|
||||
* while that is 0 (browser recommended). `devicePixelRatio` does not enter
|
||||
* it. A layer drawing through the port passes the ratio its frames report
|
||||
* and rewrites its rows' switch when that changes.
|
||||
* @param {number} [pixelRatio] Drawing-buffer pixels per CSS pixel (1).
|
||||
*/
|
||||
export function nearImageSwitchPx(pixelRatio = 1) {
|
||||
const ratio = Number.isFinite(pixelRatio) && pixelRatio > 0 ? pixelRatio : 1;
|
||||
return NEAR_IMAGE_DEVICE_PX / ratio;
|
||||
}
|
||||
|
||||
/** Slots a renderer can address (one vec4 uniform each). */
|
||||
export const MAX_ICON_SLOTS = 64;
|
||||
|
||||
|
||||
@@ -17,15 +17,16 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { ICON_SEGMENT_GLSL, SEGMENT_STRIDE } from './iconSegment.js';
|
||||
import { ICON_CULL_HEIGHT_M, ICON_CULL_LIFT, STYLE_STRIDE } from './iconSet.js';
|
||||
import { iconAtlas, MAX_ICON_SLOTS } from './iconAtlas.js';
|
||||
import {
|
||||
iconAtlas,
|
||||
MAX_ICON_SLOTS,
|
||||
NEAR_IMAGE_DEVICE_PX,
|
||||
} from './iconAtlas.js';
|
||||
import {
|
||||
cameraLimbDistanceM,
|
||||
getAircraftRecessionParams,
|
||||
} from './aircraftRecession.js';
|
||||
|
||||
/** On-screen device pixels above which a row draws its near (large) image. */
|
||||
const NEAR_IMAGE_PX = 76;
|
||||
|
||||
const ATTRIBUTE_LOCATIONS = Object.freeze({
|
||||
corner: 0,
|
||||
seg0: 1,
|
||||
@@ -139,7 +140,7 @@ void main() {
|
||||
float glyphPx = style0.x * scale * distanceScale * czm_pixelRatio;
|
||||
bool nearImage = style3.x > 0.0
|
||||
? glyphPx / czm_pixelRatio > style3.x
|
||||
: glyphPx > ${NEAR_IMAGE_PX.toFixed(1)};
|
||||
: glyphPx > ${NEAR_IMAGE_DEVICE_PX.toFixed(1)};
|
||||
float slot = nearImage ? style1.y : style1.x;
|
||||
if (slot < 0.0) return; // no image set
|
||||
vec4 rect = u_slots[int(slot)];
|
||||
|
||||
Reference in new issue
Block a user