UPDATE (Sep 1)
The reason I was attempting to resize the position points buffer was to allow me to increase the resolution of the Normal Map and to add more detail.
I have since found an easier way to add detail in the first example of the TSL Guide which discussed adding a detail texture to the diffuse texture Although I wasn’t able to get the get the example in the Guide to work, I was able to create a “detail texture” by adding a command to make the texture repeat 32x. I then combined the “detail texture” with the lower resolution diffuse texture using the “mul” command. The result is a diffuse texture that has good detail.
After making the original post, I realized there were a couple of problems with my post. First, as noted below, the “error” shown in the picture was not an error, but an expected result of my not interpolating the position values when resizing the position buffer. Second, I had forgotten that my Normal Map shader was already resizing the texture.
In conclusion, the shader below may actually be a good way to resize a buffer. But, if you are simply trying to add more detail to a texture, there are easier ways to do that.
Thanks to every who participated in this discussion..
ORIGINAL POST
I am trying to resize a series of points that are saved in vec4 texture format
Thus, if the source texture is 12,22,37 … and the destination texture is 2x larger, I would expect that the destination values are 12,12,22,22,37,37 … This is something like a simple pixel resizer.
I am using this wgsl shader to perform that action.
this.compBigr = wgslFn(`
fn computeWGSL(
u_tsiz: f32, // size of destination
r_disp: texture_2d<f32>, // source
w_bigr: texture_storage_2d<rgba32float,write>, // destination
u_indx: u32,
u_mult: u32 // multiplier
) -> void {
// Compute vUv (special)
var posX = f32(u_indx) % u_tsiz; // width - destination
var posY = f32(u_indx) / u_tsiz; // height - destination
var idxD = vec2i(i32(posX),i32(posY)); // index - destination
var idxS = vec2i(i32(posX)/i32(u_mult),i32(posY)/i32(u_mult)); // index - source
//
var input = textureLoad(r_disp,idxS,0);
textureStore(w_bigr,idxD,input);
}
`);
The resized values are then fed to a normal shader which computes the normal values, which I expect to be 2x bigger.
However, instead of smooth values, I am getting a series of little squares, like this:
The problem could be with the normal shader. But since this resizing should be a simple exercise, I want to first make sure that my resize shader looks correct.
Any suggestions?
