@@ -256,66 +256,7 @@ public int GetTexture(RawTextureBuffer rawBuffer, bool linearFilter = false)
256256 }
257257
258258 /// <summary>
259- /// Gets the fallback texture.
260- /// </summary>
261- /// <returns>Id of Texture, fallback, checkerboard</returns>
262- public int GetFallbackTexture ( )
263- {
264- if ( _fallbackTextureId >= 0 ) return _fallbackTextureId ;
265-
266- // 1. Expand the 2x2 grid to 64x64 to create a deep, smooth Mipmap chain
267- var size = 64 ;
268- var halfSize = size / 2 ;
269- var pixels = new byte [ size * size * 4 ] ;
270-
271- for ( var y = 0 ; y < size ; y ++ )
272- {
273- for ( var x = 0 ; x < size ; x ++ )
274- {
275- // Recreates your exact Black/White/White/Black 4-square pattern
276- var isWhite = ( x >= halfSize ) ^ ( y >= halfSize ) ;
277- var color = isWhite ? ( byte ) 255 : ( byte ) 0 ;
278-
279- var idx = ( y * size + x ) * 4 ;
280- pixels [ idx ] = color ; // R
281- pixels [ idx + 1 ] = color ; // G
282- pixels [ idx + 2 ] = color ; // B
283- pixels [ idx + 3 ] = 255 ; // A
284- }
285- }
286-
287- _fallbackTextureId = GL . GenTexture ( ) ;
288- GL . BindTexture ( TextureTarget . Texture2D , _fallbackTextureId ) ;
289- GL . TexImage2D ( TextureTarget . Texture2D , 0 , PixelInternalFormat . Rgba , size , size , 0 ,
290- PixelFormat . Rgba , PixelType . UnsignedByte , pixels ) ;
291-
292- // 2. Wrap mode (Assuming your custom meshes require clamping instead of repeating)
293- GL . TexParameter ( TextureTarget . Texture2D , TextureParameterName . TextureWrapS ,
294- ( int ) TextureWrapMode . ClampToEdge ) ;
295- GL . TexParameter ( TextureTarget . Texture2D , TextureParameterName . TextureWrapT ,
296- ( int ) TextureWrapMode . ClampToEdge ) ;
297-
298- // 3. The filtering hybrid (Smooth distance, Sharp close-up)
299- GL . TexParameter ( TextureTarget . Texture2D , TextureParameterName . TextureMinFilter ,
300- ( int ) TextureMinFilter . LinearMipmapLinear ) ;
301- GL . TexParameter ( TextureTarget . Texture2D , TextureParameterName . TextureMagFilter ,
302- ( int ) TextureMagFilter . Nearest ) ;
303-
304- // 4. Mipmap generation (Now generates a 6-level deep chain instead of just 1)
305- GL . GenerateMipmap ( GenerateMipmapTarget . Texture2D ) ;
306-
307- // 5. Anisotropic Filtering (Disabled temporarily for the fallback)
308- // High-contrast procedurals like checkerboards often fight with Anisotropic sampling.
309- // Since we created proper mipmaps, we can turn this off for the fallback texture.
310- GL . TexParameter ( TextureTarget . Texture2D , ( TextureParameterName ) 0x84FE , 1.0f ) ;
311-
312- GL . BindTexture ( TextureTarget . Texture2D , 0 ) ;
313-
314- return _fallbackTextureId ;
315- }
316-
317- /// <summary>
318- /// Creates a lookup collection of compiled GPU texture resources directly from raw math arrays.
259+ /// Creates the master textures.
319260 /// </summary>
320261 /// <param name="textures">The procedural textures data map.</param>
321262 /// <returns>Dictionary of Input id and Id of texture</returns>
0 commit comments