Comments (6)
Thanks for writing this up! I'm curious how you're setting these, I tried to repro this, but when everything is sized right, it does seem to be behaving as expected!
I did have a moment where C# was coercing byte
s and ushort
s into int
s, and tripping up my generic code. It did look a little similar to what you have here, is it possible you've got some of that going on?
My test was two textures of each format, red 4px grid, one at 32x32, and one at 42x32.
Code for this image is over here: https://github.com/StereoKit/StereoKit/blob/develop/Examples/StereoKitTest/Tests/TestTextures.cs
from stereokit.
I'm using the example given there : https://stereokit.net/Pages/StereoKit/Tex/SetColors.html but I changed the size from 128 to 138
let width = 138;
let height = 138;
let mut raw_dots128 = Vec::new();
let mut raw_dots_byte = Vec::new();
let mut raw_dots_u16 = Vec::new();
let mut raw_dots_u32 = Vec::new();
for y in 0..height {
for x in 0..width {
if x % 128 == 0
|| (x + 1) % 128 == 0
|| (x - 1) % 128 == 0
|| y % 128 == 0
|| (y + 1) % 128 == 0
|| (y - 1) % 128 == 0
{
raw_dots.push(line_color);
raw_dots128.push(line_color128);
raw_dots_byte.push(220);
raw_dots_u16.push(1220);
raw_dots_u32.push(1220);
} else if x % 64 == 0 || y % 64 == 0 {
raw_dots.push(sub_line_color);
raw_dots128.push(sub_line_color128);
raw_dots_byte.push(0);
raw_dots_u16.push(30000);
raw_dots_u32.push(12200);
} else {
raw_dots.push(base_color);
raw_dots128.push(base_color128);
raw_dots_byte.push(50);
raw_dots_u16.push(64000);
raw_dots_u32.push(256 * 256 * 256 * 250);
}
}
}
let color_dots = raw_dots.as_slice();
let color_dots128 = raw_dots128.as_slice();
let color_dots_byte = raw_dots_byte.as_slice();
let color_dots_u16 = raw_dots_u16.as_slice();
let color_dots_u32 = raw_dots_u32.as_slice();
from stereokit.
it works when the size is 2^x but not with 42 or other values.
And with a size of 17 I also have the problem with R16. Very odd.
WidthXHeight 16x17 works well but 17x16 don't. The problem seems to be around the width value.
from stereokit.
Translating your code into C# and adding some random colors, I get this:
Only real change I made was that R32 needs to be a float, and not a u32. I tried with a couple of other weird sizes, but still couldn't get any of the weird stuff you're seeing!
Right now I'm guessing this is either some rust syntax thing, or a rust binding issue?
Here's my C# code, which I slotted into the TestTexture.cs file.
Color line_color128 = Color.HSV(0.6f, 0.05f, 1);
Color sub_line_color128 = Color.HSV(0.6f, 0.05f, 0.6f);
Color base_color128 = Color.HSV(0.6f, 0.1f, 0.25f);
Color32 line_color = line_color128;
Color32 sub_line_color = sub_line_color128;
Color32 base_color = base_color128;
int width = 138;
int height = 138;
List<Color32>raw_dots = new();
List<Color> raw_dots128 = new();
List<byte> raw_dots_byte = new();
List<ushort> raw_dots_u16 = new();
List<float> raw_dots_f32 = new();
for (int y=0; y<height; y+=1) {
for (int x=0; x<width; x+=1) {
if (x % 128 == 0
|| (x + 1) % 128 == 0
|| (x - 1) % 128 == 0
|| y % 128 == 0
|| (y + 1) % 128 == 0
|| (y - 1) % 128 == 0)
{
raw_dots .Add(line_color);
raw_dots128 .Add(line_color128);
raw_dots_byte.Add(220);
raw_dots_u16 .Add(1220);
raw_dots_f32 .Add(.2f);
}
else if (x % 64 == 0 || y % 64 == 0) {
raw_dots .Add(sub_line_color);
raw_dots128 .Add(sub_line_color128);
raw_dots_byte.Add(0);
raw_dots_u16 .Add(30000);
raw_dots_f32 .Add(.2f);
}
else
{
raw_dots .Add(base_color);
raw_dots128 .Add(base_color128);
raw_dots_byte.Add(50);
raw_dots_u16 .Add(64000);
raw_dots_f32 .Add(1);
}
}
}
Tex t = new Tex(TexType.Image, TexFormat.Rgba32);
t.SetColors(width, height, raw_dots.ToArray());
Material m = Material.Default.Copy();
m[MatParamName.DiffuseTex] = t;
testTextures.Add(new FormatTest { format = t.Format, mat = m, tex = t });
t = new Tex(TexType.Image, TexFormat.Rgba128);
t.SetColors(width, height, raw_dots128.ToArray());
m = Material.Default.Copy();
m[MatParamName.DiffuseTex] = t;
testTextures.Add(new FormatTest { format = t.Format, mat = m, tex = t });
t = new Tex(TexType.Image, TexFormat.R8);
t.SetColors(width, height, raw_dots_byte.ToArray());
m = Material.Default.Copy();
m[MatParamName.DiffuseTex] = t;
testTextures.Add(new FormatTest { format = t.Format, mat = m, tex = t });
t = new Tex(TexType.Image, TexFormat.R16);
t.SetColors(width, height, raw_dots_u16.ToArray());
m = Material.Default.Copy();
m[MatParamName.DiffuseTex] = t;
testTextures.Add(new FormatTest { format = t.Format, mat = m, tex = t });
t = new Tex(TexType.Image, TexFormat.R32);
t.SetColors(width, height, raw_dots_f32.ToArray());
m = Material.Default.Copy();
m[MatParamName.DiffuseTex] = t;
testTextures.Add(new FormatTest { format = t.Format, mat = m, tex = t });
from stereokit.
Yeah, actually, when you say this in rust
let mut raw_dots_byte = Vec::new();
let mut raw_dots_u16 = Vec::new();
Can you verify that it's ending up the correct type? I see no explicit mention of type anywhere in your code. From what I can read there, I'd expect it to be a 32 bit int.
from stereokit.
R16 is working well with the right type now, Thanks
Rust is managing inference so well that you don't have to import most of the type you're using. I'm using a middle function that decides of the value contained by the array then the value of the Vec.
I declared the type as you said but R8 is still having this strange behaviour, R16 only for 17x16 and R32 works well now.
from stereokit.
Related Issues (20)
- Unable to trigger sphere_point_contains and bounds_point_contains HOT 2
- Is there a built-in way to make a window follow you? HOT 1
- Add overload to Model Ray intersection to return the relevant ModelNode
- Texture formats on Quest
- Update partial rect of `Tex`
- OriginMode strange behavior on Quest HOT 6
- Why does Stereokit not have a gesture model on Snapdragon Spaces HOT 2
- Hyphens in directory name not handled well by dotnet new HOT 2
- `Renderer.RenderTo` results in y-inverted image with Android HOT 2
- How Stereokit interacts with Unity?
- Need some way of loading a GLSL shader directly instead of converting from HLSL, or a binding in skshaderc for GLSL samplerExternalOES HOT 4
- Platform.ReadFileBytes(filename) and Assets dir HOT 4
- Unicode rendering missing character in Linux simulator HOT 2
- How to use Stereokit to develop overlay applications?How Stereokit interacts with OpenXL?
- UIButton:How to change the background color of a button to an custom image, and how to change the window background to transparent? HOT 1
- Hand tracking problems when piching to grab an object HOT 3
- Segfault when reading gltf using EXT_meshopt_compression / ... HOT 1
- Add Window UIMove mode: face user, but rotate around Y only HOT 3
- How to instantly switch between VST and VR modes
- Ready Player Me GLTFs pack data in a way SK doesn't recognize
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stereokit.