forked from StudioInfinity/dyna3
Ray-caster: pass the sphere count as a uniform
In the process, start exploring array size limits of various kinds.
This commit is contained in:
parent
c5fe725b1b
commit
85db7b9be0
2 changed files with 29 additions and 10 deletions
|
@ -101,7 +101,7 @@ fn main() {
|
|||
|
||||
on_mount(move || {
|
||||
// list construction elements
|
||||
const SPHERE_MAX: usize = 256;
|
||||
const SPHERE_MAX: usize = 12;
|
||||
let mut sphere_vec = Vec::<DVector<f64>>::new();
|
||||
|
||||
// get the display canvas
|
||||
|
@ -142,14 +142,32 @@ fn main() {
|
|||
console::log_1(&JsValue::from(link_msg));
|
||||
ctx.use_program(Some(&program));
|
||||
|
||||
/* DEBUG */
|
||||
// print the maximum number of vectors that can be passed as
|
||||
// uniforms to a fragment shader. the OpenGL ES 3.0 standard
|
||||
// requires this maximum to be at least 224, as discussed in the
|
||||
// documentation of the GL_MAX_FRAGMENT_UNIFORM_VECTORS parameter
|
||||
// here:
|
||||
//
|
||||
// https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glGet.xhtml
|
||||
//
|
||||
// there are also other size limits. for example, on Aaron's
|
||||
// machine, the the length of a float or genType array seems to be
|
||||
// capped at 1024 elements
|
||||
console::log_2(
|
||||
&ctx.get_parameter(WebGl2RenderingContext::MAX_FRAGMENT_UNIFORM_VECTORS).unwrap(),
|
||||
&JsValue::from("uniform vectors available")
|
||||
);
|
||||
|
||||
// find indices of vertex attributes and uniforms
|
||||
let position_index = ctx.get_attrib_location(&program, "position") as u32;
|
||||
let sphere_cnt_loc = ctx.get_uniform_location(&program, "sphere_cnt");
|
||||
let sphere_sp_locs = get_uniform_array_locations::<SPHERE_MAX>(
|
||||
&ctx, &program, "sphere_list", "sp"
|
||||
);
|
||||
let sphere_lt_locs = get_uniform_array_locations::<SPHERE_MAX>(
|
||||
&ctx, &program, "sphere_list", "lt"
|
||||
);
|
||||
let position_index = ctx.get_attrib_location(&program, "position") as u32;
|
||||
let resolution_loc = ctx.get_uniform_location(&program, "resolution");
|
||||
let shortdim_loc = ctx.get_uniform_location(&program, "shortdim");
|
||||
let ctrl_loc = ctx.get_uniform_location(&program, "ctrl"); /* DEBUG */
|
||||
|
@ -192,6 +210,7 @@ fn main() {
|
|||
ctx.uniform1f(shortdim_loc.as_ref(), width.min(height));
|
||||
|
||||
// pass the construction
|
||||
ctx.uniform1i(sphere_cnt_loc.as_ref(), sphere_vec.len() as i32);
|
||||
for n in 0..sphere_vec.len() {
|
||||
let v = &sphere_vec[n];
|
||||
ctx.uniform3f(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue