@@ -67,18 +67,26 @@ public class PanoramaRendererUtility {
6767 .withLocation (Animatium .location ("pipeline/basic_texture" ))
6868 .build ();
6969
70- // To be called after ``cubeMap.render``
70+ /**
71+ * In PanoramaRenderer, before ``cubeMap.render``, set viewPort to (0, 0, 256, 256)
72+ * then call this method after ``cubeMap.render``
73+ *
74+ * @param matrix The GUI matrix
75+ * @param textureView The texture we are drawing to
76+ * @param width Screen width
77+ * @param height Screen Height
78+ */
7179 public void render (Matrix3x2f matrix , GlTextureView textureView , int width , int height ) {
7280 final RenderTarget renderTarget = Minecraft .getInstance ().getMainRenderTarget ();
73- for (int i = 0 ; i < 6 ; ++i ) {
74- PanoramaRendererUtility . writeAndBlitBlurTexture (matrix , renderTarget , textureView , width , height );
81+ for (int i = 0 ; i < 7 ; ++i ) {
82+ writeAndBlitBlurTexture (matrix , renderTarget , textureView , width , height );
7583 }
7684
77- PanoramaRendererUtility . renderFinalTexture (renderTarget , textureView , width , height );
85+ renderFinalTexture (renderTarget , textureView , width , height );
7886 }
7987
80- public void writeAndBlitBlurTexture (Matrix3x2f matrix , RenderTarget renderTarget , GlTextureView texture , int width , int height ) {
81- texture .texture ().setTextureFilter (FilterMode .LINEAR , false );
88+ private void writeAndBlitBlurTexture (Matrix3x2f matrix , RenderTarget renderTarget , GlTextureView texture , int width , int height ) {
89+ texture .texture ().setTextureFilter (FilterMode .LINEAR , FilterMode . LINEAR , false );
8290 // Ensures enough width/height for it to not crash when window is resized
8391 if (renderTarget .width >= 256 && renderTarget .height >= 256 ) {
8492 RenderSystem .getDevice ().createCommandEncoder ().copyTextureToTexture (
@@ -103,13 +111,19 @@ public void writeAndBlitBlurTexture(Matrix3x2f matrix, RenderTarget renderTarget
103111 bufferBuilder .addVertexWith2DPose (matrix , 0.0F , height ).setUv (0.0F + growth , 0.0F ).setColor (color );
104112 }
105113
106- RenderUtils .drawBuffer (pipeline , renderTarget , bufferBuilder .buildOrThrow (), (pass ) -> {
107- pass .bindSampler ("Sampler0" , texture );
108- });
114+ RenderUtils .drawBuffer (pipeline , renderTarget , bufferBuilder .buildOrThrow (), (pass ) -> pass .bindSampler ("Sampler0" , texture ));
109115 }
110116 }
111117
112- public void renderFinalTexture (RenderTarget renderTarget , GlTextureView texture , int width , int height ) {
118+ /**
119+ * Renders the final full image to the screen
120+ *
121+ * @param renderTarget The render target we are drawing to
122+ * @param texture The temporary texture
123+ * @param width Screen width
124+ * @param height Screen height
125+ */
126+ private void renderFinalTexture (RenderTarget renderTarget , GlTextureView texture , int width , int height ) {
113127 float aspect = 120.0F / (float ) (Math .max (width , height ));
114128 float sw = (float ) width * aspect / 256.0F ;
115129 float sh = (float ) height * aspect / 256.0F ;
@@ -121,9 +135,7 @@ public void renderFinalTexture(RenderTarget renderTarget, GlTextureView texture,
121135 bufferBuilder .addVertex (width , height , 0.0F ).setUv (0.5F - sh , 0.5F - sw ).setColor (color );
122136 bufferBuilder .addVertex (width , 0.0F , 0.0F ).setUv (0.5F + sh , 0.5F - sw ).setColor (color );
123137 bufferBuilder .addVertex (0.0F , 0.0F , 0.0F ).setUv (0.5F + sh , 0.5F + sw ).setColor (color );
124- RenderUtils .drawBuffer (pipeline , renderTarget , bufferBuilder .buildOrThrow (), (pass ) -> {
125- pass .bindSampler ("Sampler0" , texture );
126- });
138+ RenderUtils .drawBuffer (pipeline , renderTarget , bufferBuilder .buildOrThrow (), (pass ) -> pass .bindSampler ("Sampler0" , texture ));
127139 }
128140 }
129141}
0 commit comments