-
Notifications
You must be signed in to change notification settings - Fork 4
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
Window Size as an uniform. #28
Comments
We have already worked on an option to allow custom passing on window sizes (in WGPUCanvas.jl and WGPUgfx.jl) Can you better point us in this issue? |
Yes. We need to avoid stretching. |
Our Edit: we need to pass window size as uniform if we would like to update camera projection matrix in shader. Since our camera projection matrix is updated in CPU, setting |
Could you point us to the file we should start looking into for the shader stuff. Will we have to look into other repos as well or WGPUgfx is enough. |
Here aspect ratio needs to be set based on window width and height. Also perspective matrix needs to be updated with change in height and width. I am not sure about perspective matrix update. But aspect ratio is good start. We may not have to update shader code. Looks like we can update perspective matrix through aspect ratio and width and height. WGPUgfx.jl/src/primitives/camera.jl Line 292 in e751a2e
WGPUgfx.jl/src/primitives/camera.jl Lines 366 to 376 in e751a2e
|
updating aspect ratio field of camera object directly on event may work out of the box. |
|
wgpu1.webmI wrote the code to update the aspect ratio on every resize with function attachWindowSizeCallback(scene, camera)
callback = (_, w, h) -> begin
@info w,h,scene.canvas.size
camera.aspectRatio *= w/scene.canvas.size[1]
camera.aspectRatio *= scene.canvas.size[2]/h
scene.canvas.size = (w,h)
WGPUCore.determineSize(scene.canvas.context)
end
GLFW.SetWindowSizeCallback(scene.canvas.windowRef[], callback)
end and i ran the tri.jl example , is this desirable ? |
looks like |
I really appreciate you. There are many such trivial things that can be improved. |
WGPUgfx.jl/src/primitives/camera.jl Lines 118 to 130 in e751a2e
setting I don't see other issues with this code. But, we might still need to pass window size as uniform since we don't know what users want. So you can raise a separate issue like preserve |
@ut112002 summary: Raise separate issue and make a PR if you would like to. You take your time and submit PR. Passing window uniform is slightly involved. Right now camera projection matrix is updated on CPU and Camera buffer is set. Another approach would be update camera projection matrix on GPU with change in window height and width. This would mean significant change in camera.jl and other shader code. In cases where we have multiple cameras, CPU version could have an overhead on buffer updates. This argument needs backing with experimentation. |
Currently all window sizes are (500, 500). Its hardcoded somewhere.
For that to change we need to change to some shader code. Pass window size as an uniform as window size changes. Window uniform needs to be updated with window Events.The text was updated successfully, but these errors were encountered: