-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
GPUComputationRenderer: fix createTexture and disable depthBuffer #13766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@vlucendo What is your use case for calling this method with args different from gpuCompute.createTexture( sizeXTexture, sizeYTexture );... and does your application work correctly when you do that? |
AFAIK, it is not needed. |
My use case is to create a texture with the same height but different width to store some data that won't be used in a variable but would be passed as a uniform instead. After looking for createTexture on the three.js codebase it never gets called with params, so I supposed the reason for it to have them is to be able to use it as a helper function sometimes. const texture = gpuCompute.createTexture( 64 ); |
|
I think this is a design flaw or bug, and the size should be hardwired to be the same as the /ping @yomboprime |
I don't fully understand this statement.
That is correct, it is a utility function as it is
The parameters are there because usually you create and manipulate textures when using the There was a try to refactor the So for me the change is suitable (and also the z-buffer disabling), even though I don't fully understand the use case. |
|
My use case is not very relevant, I'm making instanced gpgpu meshlines. In the width of the texture are stored the different path positions of the lines, and every pixel of height is a different line. Only the first point of the path gets the position updated and the rest just copy the data of the previous one. This makes a texture with a size of 128 (path points) * 1024 (number of lines) for example. To set the initial position of the lines (or to reset it when their life reaches 0) I need a texture of different size (1 pixel per line, 1024px in total) with the initial positions because I only care about the first point of the path. const computation = new GPUComputationRenderer(pathPoints, linesNum, this.renderer);
const positionsTexture = computation.createTexture();
const positionsVariable = computation.addVariable('tPositions', fragment, positionsTexture);
computation.setVariableDependencies(positionsVariable, [positionsVariable]);
//create initial positions texture
const initialPositions = computation.createTexture(1);
//fill values
const data = initialPositions.image.data;
for(let i = 0; i < data.length; i += 4)
{
//set x, y, z
}
//pass the texture to the variable as a uniform
positionsVariable.material.uniforms.initialPositions = { value: initialPositions };
const error = computation.init();I could have done it manually, but |
|
That makes sense. |
I would change the signature. this.createTexture = function() {This is how it is intended to be used in the context of |
|
Ok then, changed! |
|
Thanks! |
The size params this function passes to THREE.DataTexture were wrong. Also fixed the indentation 🌈
Edit: disabled depthBuffer on another commit too, it isn't needed by GPUComputationRenderer right?