55import btw .lowercase .optiboxes .utils .CommonUtils ;
66import btw .lowercase .optiboxes .utils .IrisUtil ;
77import btw .lowercase .optiboxes .utils .UVRange ;
8+ import btw .lowercase .optiboxes .utils .components .Blend ;
89import com .mojang .blaze3d .buffers .GpuBuffer ;
910import com .mojang .blaze3d .pipeline .RenderTarget ;
1011import com .mojang .blaze3d .systems .RenderPass ;
@@ -56,10 +57,11 @@ private void buildSky() {
5657 skyBufferIndexCount = meshData .drawState ().indexCount ();
5758 skyBuffer = RenderSystem .getDevice ().createBuffer (
5859 () -> "OptiFine Skybox" ,
59- //? >=1.21.6
60- /*GpuBuffer.USAGE_COPY_DST,*/
61- //? =1.21.5
62- com .mojang .blaze3d .buffers .BufferType .VERTICES , com .mojang .blaze3d .buffers .BufferUsage .STATIC_WRITE ,
60+ //? >=1.21.6 {
61+ GpuBuffer .USAGE_COPY_DST ,
62+ //?} else {
63+ /*com.mojang.blaze3d.buffers.BufferType.VERTICES, com.mojang.blaze3d.buffers.BufferUsage.STATIC_WRITE,
64+ */ //?}
6365 meshData .vertexBuffer ()
6466 );
6567 }
@@ -68,15 +70,15 @@ private void buildSky() {
6870 //? >=1.21.5 {
6971 private final Map <ResourceLocation , com .mojang .blaze3d .pipeline .RenderPipeline > renderPipelineCache = new HashMap <>();
7072
71- public static com .mojang .blaze3d .pipeline .RenderPipeline getSkyboxPipeline (@ Nullable com . mojang . blaze3d . pipeline .BlendFunction blendFunction ) {
73+ public static com .mojang .blaze3d .pipeline .RenderPipeline getSkyboxPipeline (@ Nullable btw . lowercase . optiboxes . utils .BlendFunction blendFunction ) {
7274 com .mojang .blaze3d .pipeline .RenderPipeline .Builder builder = com .mojang .blaze3d .pipeline .RenderPipeline .builder (RenderPipelinesAccessor .optiboxes$getMatricesProjectionSnippet ());
7375 builder .withLocation (OptiBoxesClient .id ("pipeline/custom_skybox" ));
7476 builder .withVertexShader (OptiBoxesClient .id ("core/custom_skybox" ));
7577 builder .withFragmentShader (OptiBoxesClient .id ("core/custom_skybox" ));
7678 builder .withDepthWrite (false );
7779 builder .withColorWrite (true , false );
7880 if (blendFunction != null ) {
79- builder .withBlend (blendFunction );
81+ builder .withBlend (blendFunction . toNative () );
8082 }
8183 builder .withSampler ("Sampler0" );
8284 builder .withVertexFormat (DefaultVertexFormat .POSITION_TEX , VertexFormat .Mode .QUADS );
@@ -97,6 +99,11 @@ public void renderSkybox(OptiFineSkybox optiFineSkybox, Matrix4fStack modelViewS
9799 for (OptiFineSkyLayer optiFineSkyLayer : optiFineSkybox .getLayers ().stream ().filter (layer -> layer .isActive (dayTime , clampedTimeOfDay )).toList ()) {
98100 renderSkyLayer (optiFineSkyLayer , modelViewStack , level , clampedTimeOfDay , skyAngle , rainLevel , thunderLevel , optiFineSkybox .getConditionAlphaFor (optiFineSkyLayer ));
99101 }
102+
103+ //? <=1.21.5 {
104+ /*Vector4f shaderColor = Blend.ADD.getShaderColor(1.0F - rainLevel);
105+ RenderSystem.setShaderColor(shaderColor.x, shaderColor.y, shaderColor.z, shaderColor.w);
106+ */ //?}
100107 }
101108
102109 public void renderSkyLayer (OptiFineSkyLayer optiFineSkyLayer , Matrix4fStack modelViewStack , Level level , int timeOfDay , float skyAngle , float rainGradient , float thunderGradient , float conditionAlpha ) {
@@ -114,39 +121,39 @@ public void renderSkyLayer(OptiFineSkyLayer optiFineSkyLayer, Matrix4fStack mode
114121 AbstractTexture skyTexture = Minecraft .getInstance ().getTextureManager ().getTexture (optiFineSkyLayer .source ());
115122
116123 //? >=1.21.6 {
117- /* com.mojang.blaze3d.buffers.GpuBufferSlice transforms = btw.lowercase.optiboxes.utils.DynamicTransformsBuilder.of()
124+ com .mojang .blaze3d .buffers .GpuBufferSlice transforms = btw .lowercase .optiboxes .utils .DynamicTransformsBuilder .of ()
118125 .withModelViewMatrix (modelViewStack )
119126 .withShaderColor (shaderColor )
120127 .build ();
121- */ //?} else {
122- RenderSystem .setShaderColor (shaderColor .x , shaderColor .y , shaderColor .z , shaderColor .w );
123- //?}
128+ //?} else {
129+ /* RenderSystem.setShaderColor(shaderColor.x, shaderColor.y, shaderColor.z, shaderColor.w);
130+ */ //?}
124131
125132 //? >=1.21.5 {
126133 com .mojang .blaze3d .pipeline .RenderPipeline renderPipeline = this .renderPipelineCache .computeIfAbsent (optiFineSkyLayer .source (), (resourceLocation ) -> {
127- com .mojang .blaze3d .pipeline .RenderPipeline pipeline = getSkyboxPipeline (optiFineSkyLayer .blend ().getBlendFunction (). toNative () );
134+ com .mojang .blaze3d .pipeline .RenderPipeline pipeline = getSkyboxPipeline (optiFineSkyLayer .blend ().getBlendFunction ());
128135 IrisUtil .assignPipeline (pipeline , IrisUtil .skyTextured ());
129136 return pipeline ;
130137 });
131138
132139 RenderTarget renderTarget = Minecraft .getInstance ().getMainRenderTarget ();
133140
134141 //? >=1.21.6 {
135- /* com.mojang.blaze3d.textures.GpuTextureView texture = skyTexture.getTextureView();
142+ com .mojang .blaze3d .textures .GpuTextureView texture = skyTexture .getTextureView ();
136143 com .mojang .blaze3d .textures .GpuTextureView colorTexture = renderTarget .getColorTextureView ();
137- com.mojang.blaze3d.textures.GpuTextureView depthTexture = renderTarget.useDepth ? renderTarget. getDepthTextureView() : null ;
138- */ //?} else {
139- com .mojang .blaze3d .textures .GpuTexture texture = skyTexture .getTexture ();
144+ com .mojang .blaze3d .textures .GpuTextureView depthTexture = renderTarget .getDepthTextureView ();
145+ //?} else {
146+ /* com.mojang.blaze3d.textures.GpuTexture texture = skyTexture.getTexture();
140147 com.mojang.blaze3d.textures.GpuTexture colorTexture = renderTarget.getColorTexture();
141- com .mojang .blaze3d .textures .GpuTexture depthTexture = renderTarget .useDepth ? renderTarget . getDepthTexture () : null ;
142- //?}
148+ com.mojang.blaze3d.textures.GpuTexture depthTexture = renderTarget.getDepthTexture();
149+ */ //?}
143150
144151 GpuBuffer indexBuffer = this .skyBufferIndices .getBuffer (this .skyBufferIndexCount );
145152 try (RenderPass renderPass = RenderSystem .getDevice ()
146153 .createCommandEncoder ()
147154 .createRenderPass (
148155 //? >=1.21.6
149- /* () -> "Custom Sky Rendering",*/
156+ () -> "Custom Sky Rendering" ,
150157 colorTexture ,
151158 OptionalInt .empty (),
152159 depthTexture ,
@@ -156,17 +163,18 @@ public void renderSkyLayer(OptiFineSkyLayer optiFineSkyLayer, Matrix4fStack mode
156163 renderPass .setVertexBuffer (0 , this .skyBuffer );
157164 renderPass .setIndexBuffer (indexBuffer , this .skyBufferIndices .type ());
158165 //? >=1.21.6 {
159- /* RenderSystem.bindDefaultUniforms(renderPass);
166+ RenderSystem .bindDefaultUniforms (renderPass );
160167 renderPass .setUniform ("DynamicTransforms" , transforms );
161- */ //?}
168+ //?}
162169 renderPass .bindSampler ("Sampler0" , texture );
163170 //? >=1.21.6 {
164- /* renderPass.drawIndexed(0, 0, this.skyBufferIndexCount, 1);
165- */ //?} else {
166- renderPass .drawIndexed (0 , this .skyBufferIndexCount );
167- //?}
171+ renderPass .drawIndexed (0 , 0 , this .skyBufferIndexCount , 1 );
172+ //?} else {
173+ /* renderPass.drawIndexed(0, this.skyBufferIndexCount);
174+ */ //?}
168175 }
169176 //?} else {
177+
170178 //?}
171179
172180 modelViewStack .popMatrix ();
@@ -186,6 +194,8 @@ private float getAngle(Level level, float skyAngle, float speed) {
186194 }
187195
188196 public void clearCache () {
197+ //? >=1.21.5 {
189198 this .renderPipelineCache .clear ();
199+ //?}
190200 }
191201}
0 commit comments