mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-01-05 09:40:02 -08:00
10 bits per channel rgb
This commit is contained in:
@@ -75,7 +75,7 @@ use web_sys::{Request, RequestInit, RequestMode, Response};
|
||||
use wasm_bindgen::JsValue;
|
||||
use std::mem;
|
||||
use crate::renderable::projection::Aitoff;
|
||||
fn generate_position<P: Projection>() -> Vec<u16> {
|
||||
fn generate_position<P: Projection>() -> Vec<u32> {
|
||||
let (w, h) = (2048.0, 2048.0);
|
||||
let mut data = vec![];
|
||||
for y in 0..(h as u32) {
|
||||
@@ -87,14 +87,15 @@ fn generate_position<P: Projection>() -> Vec<u16> {
|
||||
true,
|
||||
) {
|
||||
let pos = pos.truncate().normalize();
|
||||
let mut d: u32 = 0;
|
||||
d |= 3 << 30;
|
||||
d |= (((pos.z * 0.5 + 0.5) * (1024.0 as f64)) as u32) << 20;
|
||||
d |= (((pos.y * 0.5 + 0.5) * (1024.0 as f64)) as u32) << 10;
|
||||
d |= ((pos.x * 0.5 + 0.5) * (1024.0 as f64)) as u32;
|
||||
|
||||
data.push(((pos.x * 0.5 + 0.5) * (std::u16::MAX as f64)) as u16);
|
||||
data.push(((pos.y * 0.5 + 0.5) * (std::u16::MAX as f64)) as u16);
|
||||
data.push(((pos.z * 0.5 + 0.5) * (std::u16::MAX as f64)) as u16);
|
||||
data.push(d);
|
||||
} else {
|
||||
data.push(std::u16::MAX);
|
||||
data.push(std::u16::MAX);
|
||||
data.push(std::u16::MAX);
|
||||
data.push(!0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,12 +211,12 @@ impl RayTracer {
|
||||
WebGl2RenderingContext::CLAMP_TO_EDGE,
|
||||
),
|
||||
],
|
||||
WebGl2RenderingContext::RGB16UI as i32, // internal format
|
||||
WebGl2RenderingContext::RGB_INTEGER, // format
|
||||
WebGl2RenderingContext::UNSIGNED_SHORT, // type
|
||||
WebGl2RenderingContext::RGB10_A2 as i32, // internal format
|
||||
WebGl2RenderingContext::RGBA, // format
|
||||
WebGl2RenderingContext::UNSIGNED_INT_2_10_10_10_REV, // type
|
||||
).unwrap();
|
||||
|
||||
let buf_data = unsafe { js_sys::Uint16Array::view(&data) };
|
||||
let buf_data = unsafe { js_sys::Uint32Array::view(&data) };
|
||||
position_tex
|
||||
.bind()
|
||||
.tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_array_buffer_view(0, 0, 2048, 2048, Some(&buf_data));
|
||||
|
||||
@@ -59,12 +59,11 @@ TileColor get_tile_color(vec3 pos) {
|
||||
const float duration = 500.f; // 500ms
|
||||
uniform int max_depth; // max depth of the HiPS
|
||||
|
||||
uniform usampler2D position_tex;
|
||||
uniform sampler2D position_tex;
|
||||
uniform mat4 model;
|
||||
void main() {
|
||||
vec2 uv = out_clip_pos * 0.5 + 0.5;
|
||||
uvec3 o = texture(position_tex, uv).rgb;
|
||||
vec3 n = vec3(float(o.x)/65535.0, float(o.y)/65535.0, float(o.z)/65535.0) * 2.0 - 1.0;
|
||||
vec3 n = texture(position_tex, uv).rgb * 2.0 - 1.0;
|
||||
|
||||
vec3 frag_pos = vec3(model * vec4(n, 1.0));
|
||||
|
||||
|
||||
@@ -56,12 +56,11 @@ TileColor get_tile_color(vec3 pos) {
|
||||
const float duration = 500.f; // 500ms
|
||||
uniform int max_depth; // max depth of the HiPS
|
||||
|
||||
uniform usampler2D position_tex;
|
||||
uniform sampler2D position_tex;
|
||||
uniform mat4 model;
|
||||
void main() {
|
||||
vec2 uv = out_clip_pos * 0.5 + 0.5;
|
||||
uvec3 o = texture(position_tex, uv).rgb;
|
||||
vec3 n = vec3(float(o.x)/65535.0, float(o.y)/65535.0, float(o.z)/65535.0) * 2.0 - 1.0;
|
||||
vec3 n = texture(position_tex, uv).rgb * 2.0 - 1.0;
|
||||
|
||||
vec3 frag_pos = vec3(model * vec4(n, 1.0));
|
||||
|
||||
|
||||
@@ -56,12 +56,11 @@ TileColor get_tile_color(vec3 pos) {
|
||||
const float duration = 500.f; // 500ms
|
||||
uniform int max_depth; // max depth of the HiPS
|
||||
|
||||
uniform usampler2D position_tex;
|
||||
uniform sampler2D position_tex;
|
||||
uniform mat4 model;
|
||||
void main() {
|
||||
vec2 uv = out_clip_pos * 0.5 + 0.5;
|
||||
uvec3 o = texture(position_tex, uv).rgb;
|
||||
vec3 n = vec3(float(o.x)/65535.0, float(o.y)/65535.0, float(o.z)/65535.0) * 2.0 - 1.0;
|
||||
vec3 n = texture(position_tex, uv).rgb * 2.0 - 1.0;
|
||||
|
||||
vec3 frag_pos = vec3(model * vec4(n, 1.0));
|
||||
|
||||
|
||||
@@ -56,12 +56,11 @@ TileColor get_tile_color(vec3 pos) {
|
||||
const float duration = 500.f; // 500ms
|
||||
uniform int max_depth; // max depth of the HiPS
|
||||
|
||||
uniform usampler2D position_tex;
|
||||
uniform sampler2D position_tex;
|
||||
uniform mat4 model;
|
||||
void main() {
|
||||
vec2 uv = out_clip_pos * 0.5 + 0.5;
|
||||
uvec3 o = texture(position_tex, uv).rgb;
|
||||
vec3 n = vec3(float(o.x)/65535.0, float(o.y)/65535.0, float(o.z)/65535.0) * 2.0 - 1.0;
|
||||
vec3 n = texture(position_tex, uv).rgb * 2.0 - 1.0;
|
||||
|
||||
vec3 frag_pos = vec3(model * vec4(n, 1.0));
|
||||
|
||||
|
||||
@@ -57,12 +57,11 @@ TileColor get_tile_color(vec3 pos) {
|
||||
const float duration = 500.f; // 500ms
|
||||
uniform int max_depth; // max depth of the HiPS
|
||||
|
||||
uniform usampler2D position_tex;
|
||||
uniform sampler2D position_tex;
|
||||
uniform mat4 model;
|
||||
void main() {
|
||||
vec2 uv = out_clip_pos * 0.5 + 0.5;
|
||||
uvec3 o = texture(position_tex, uv).rgb;
|
||||
vec3 n = vec3(float(o.x)/65535.0, float(o.y)/65535.0, float(o.z)/65535.0) * 2.0 - 1.0;
|
||||
vec3 n = texture(position_tex, uv).rgb * 2.0 - 1.0;
|
||||
|
||||
vec3 frag_pos = vec3(model * vec4(n, 1.0));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user