10 bits per channel rgb

This commit is contained in:
Matthieu Baumann
2021-03-12 13:51:06 +01:00
parent f56978d55f
commit a6eac3f81f
6 changed files with 22 additions and 26 deletions

View File

@@ -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));

View File

@@ -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));

View File

@@ -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));

View File

@@ -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));

View File

@@ -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));

View File

@@ -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));