Closed m3taphysics closed 1 year ago
Made a test on the average frame-time at 100,100 coordinates, while changing the renderqueue position on the Skybox material. On my laptop with i7-12800H, 16Gb of RAM and an RTX 3070ti, I got the following results:
renderqueue 2445 (at the end of the Opaque pass as Unity suggested in their review) Average frame time: 11.3082 ms renderqueue 2000 (at the beginning of the Opaque pass) Average frame time: 11.5851 ms renderqueue 2998 (as it is now) Average frame time: 12.96443 ms
Made another test on the average frame-time at 100,100 coordinates, to calculate the average frametime (120 seconds) difference between dev and the branch where I made small shader improvements. On my laptop with i7-12800H, 16Gb of RAM and an RTX 3070ti, I got the following results:
dev branch: 13.42076 ms shader branch: 12.65271 ms
With this we may be gaining at least ~0.5 ms on frame time.
Conclusions about the shader: The skybox shadergraph shader "S_Skybox02" use multiple subshaders, that in turn use other subshaders too. I have split the subshader "SG_Sky03BasicLayer" into two subshaders called "SG_Sky03BasicLayer_CubemapInput" and "SG_Sky03BasicLayer_TexInput". With this split, I stripped out from the main shader and respective subshaders Texture inputs and texture mappings parts that were not used but made anyway some computation.
The shader and subshader need a deep refactoring from an expert. Moving some calculations from inside the shader/subshaders to C# code can be beneficial.
The PR with small shader improvements has been merged to dev.
The PR where the Skybox camera should have been merged is on hold because the Main Camera has a maximum draw distance of 500. This renders the skybox correctly, but not the infinite floor, which is rendered up until the max distance (set in the option by the user), and is not blending with the skybox (watch attached video).
Set the camera draw distance fixed to 3000 (this will permit to draw the infinite floor on the skybox layer up until horizon and blend it correctly with the skybox)
Develop a LayerCullingOverrideController
to change the culling distance for any given layer.
Change the "draw distance" option we have in the graphical settings menu to manipulate the culling distance of layer[0] instead of the Camera draw distance of the frustum. (this way, we are setting the draw distance only for the default Layer 0, which contains all the world objects)
The LayerCullingOverrideController
should be based on this Unity's Camera.layerCullDistances documented here
Unity's documentation is not super explicative but adapting their example to our needs:
distances[0] = 500;
will set the Default layer 0 to render up to a distance of 500.
Bonus: with that system in place, we can decide on some granular rendering options on different layers for different graphic levels
Closing, moved to shape up
Description
The skybox in the game is currently being rendered by a separate camera and is using an extremely complex shader-graph based shader and has overheads due to it being on a completely separate camera.
Deliverables
Notes
See unity review: https://drive.google.com/file/d/1hob-9c4MCTZRFKMGj9bMcQTAQyQL8lq7/view