November 25, 2020, 02:36:35 AM

Author Topic: how to disable bilinear filtering (on textures) (Blitz3d)  (Read 3711 times)

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
how to disable bilinear filtering (on textures) (Blitz3d)
« on: December 23, 2017, 09:55:27 PM »
I repost this here, because it is really useful, especially for the current competition (for those who choose the 3d path (meshes+textures))

instead of having textures which look "blurred" (with bilinear filtering) :


you will have textures which look "sharp" (without bilinear filtering) :


here : http://rd-stuff.fr/disable-bilinear-filtering-of-textures-201612021732.zip
Put the DX7DBF.dll and DX7DBF.decls in your Blitz3d/userlibs directory
Then when you want to distribute your game/tool, copy paste the DX7DBF.dll in the same directory than the executable...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline GW

  • Full Member
  • ***
  • Posts: 202
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #1 on: December 24, 2017, 06:50:13 AM »
Cant you just use texturefilter?

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #2 on: December 24, 2017, 08:51:11 AM »
@GW>>the commands ClearTextureFilters() and TextureFilter() do not remove bilinear filtering on my computers, not sure why. See : http://wasted.nz/posts.php?topic=103591

But in any case, this is an alternative !
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline MagosDomina

  • Full Member
  • ***
  • Posts: 121
    • Aspiring game developer website.
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #3 on: January 06, 2018, 01:53:20 AM »
What is your hardware specs?
Central hub for my Game Design related activities.
http://www.magosdomina.com/

Windows 7 PRO 64-bit, 48Gb RAM, CPU: Dual Hexacore Intel Xeon 3.33 GHZ, Nvidia Quadro 5800FX 4Gb x 2 SLI.

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #4 on: January 06, 2018, 10:22:24 AM »
@MagosDomina>>
DualCore AMD E-450 1646 MHz, 6 Go DDR3 SDRAM, Radeon HD 6320 Graphics  (384 Mo), Windows 7 home premium 64 bits, (directx 9.0c installed)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline MagosDomina

  • Full Member
  • ***
  • Posts: 121
    • Aspiring game developer website.
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #5 on: January 06, 2018, 05:02:05 PM »
Hate to point the finger at the graphics and or driver. But doesn't Blitz3d have minor issue with ATI hardware? This was likely more of an issue back in the earlier days of Blitz3d.

Seems you are very familiar with this issue occurring. XD
http://wasted.nz/posts.php?topic=103591

This may be worth a look too:
http://wasted.nz/posts.php?topic=40848
Central hub for my Game Design related activities.
http://www.magosdomina.com/

Windows 7 PRO 64-bit, 48Gb RAM, CPU: Dual Hexacore Intel Xeon 3.33 GHZ, Nvidia Quadro 5800FX 4Gb x 2 SLI.

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #6 on: January 06, 2018, 05:21:21 PM »
@MagosDomina>>there is no problem here, apparently there are several ways to activate/disactivate the bilinear filtering on textures in directx7, the way that i posted here, works on all computers that i have tested it on (on Windows xp, vista, 7, 8, 10)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #7 on: January 06, 2018, 05:22:54 PM »
I'm not sure, but apparently the configuration of the graphics card is above the application configuration. On my graphics card you have options to allow the configuration to be decided by the graphics card or blitz3d.

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #8 on: January 06, 2018, 06:58:19 PM »
OFF / ON

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #9 on: January 06, 2018, 07:25:15 PM »
@Yue>>you won't notice the difference if the texel size of your textures is very small, or if you add others full screen effects (like on your example...)

To disable bilinear filtering of textures is useful for graphics where you want to see sharp texels like old 2d/3d games...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #10 on: January 06, 2018, 07:36:32 PM »
Here's the same scene with the bookstore.   I don't really know the difference very well.


Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #11 on: January 06, 2018, 08:06:14 PM »
@Yue>>
bilinear filtering of a texture, calculates the progressive colors between one texel and its neighbours texels, but for the pixels displayed on screen...

Try this :
Create a quad of 1.0width 1.0height
Then create a texture of 8x8texels and apply it on the quad
Then try to display the same texture quad with bilinear filtering and without bilinear filtering, you will see the difference because the texel size is big enough to see the difference.
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #12 on: January 06, 2018, 08:24:56 PM »
try this code : (one time without bilinear filtering, one time with bilinear filtering)
Code: [Select]
Graphics3D(500,312,32,2)

;to disable bilinear filtering of textures
InitDX7Hack()
DisableTextureFilters()

;Camera
Global Camera = CreateCamera()
CameraViewport(Camera,0,0,GraphicsWidth(),GraphicsHeight())
CameraRange(Camera,0.1,100)
CameraClsColor(Camera,000,000,000)

;textured quad
Global Quad = CreateMesh()
Surface = CreateSurface(Quad)
AddVertex(Surface,0.5,0.5,0.0) : VertexTexCoords(Surface,0,Float(0)/8,Float(0)/8)
AddVertex(Surface,-0.5,0.5,0.0) : VertexTexCoords(Surface,1,Float(8)/8,Float(0)/8)
AddVertex(Surface,0.5,-0.5,0.0) : VertexTexCoords(Surface,2,Float(0)/8,Float(8)/8)
AddVertex(Surface,-0.5,-0.5,0.0) : VertexTexCoords(Surface,3,Float(8)/8,Float(8)/8)
AddTriangle(Surface,0,1,2)
AddTriangle(Surface,2,1,3)
UpdateNormals(Quad)
EntityColor(Quad,255,255,255)
EntityFX(Quad,1)

Texture = CreateTexture(8,8)
SetBuffer(TextureBuffer(Texture))
For PX% = 0 To 8-1 Step 1
 For PY% = 0 To 8-1 Step 1
  Color(Rand(025,255),Rand(025,255),Rand(025,255))
  Plot(PX,PY)
 Next
Next
EntityTexture(Quad,Texture) : FreeTexture(Texture)

PositionEntity(Camera,0,0,1.5,True)
RotateEntity(Camera,0,-180.0,0,True)

Global MainLoopTimer = CreateTimer(30)

Main()

End()

Function Main()

 Repeat

  MainLoopMilliStart% = MilliSecs()

 
  SetBuffer(BackBuffer())
  CameraViewport(Camera,0,0,GraphicsWidth(),GraphicsHeight())
  CameraClsColor(Camera,000,000,000)

  RenderWorld()

  ;Flip(1)
  WaitTimer(MainLoopTimer)
  VWait():Flip(False)

  MainLoopMilliTime = MilliSecs() - MainLoopMilliStart
  If( MainLoopMilliTime < 1 )
   MainLoopMilliTime = 1
  EndIf

  FPS% = 1000.0/MainLoopMilliTime

 Until( KeyDown(1)=1 )

End Function

Const D3DTSS_MAGFILTER      = 16
Const D3DTSS_MINFILTER      = 17
Const D3DTSS_MIPFILTER      = 18
Const D3DTSS_MIPMAPLODBIAS  = 19
Const D3DTSS_MAXMIPLEVEL    = 20

Const D3DTFG_POINT        = 1
Const D3DTFG_LINEAR       = 2
Const D3DTFP_NONE         = 1
Const D3DTFN_POINT        = 1
Const D3DTFN_LINEAR       = 2

Function InitDX7Hack()
DX7DBF_SetSystemProperties( SystemProperty("Direct3D7"), SystemProperty("Direct3DDevice7"), SystemProperty("DirectDraw7"), SystemProperty("AppHWND"), SystemProperty("AppHINSTANCE") )
End Function

Function DisableTextureFilters()
;DX7DBF_SetMipmapLODBias( -10.0, 0 )
For Level = 0 To 7
DX7DBF_SetTextureStageState( Level, D3DTSS_MAGFILTER, D3DTFG_POINT )
DX7DBF_SetTextureStageState( Level, D3DTSS_MINFILTER, D3DTFN_POINT )
DX7DBF_SetTextureStageState( Level, D3DTSS_MIPFILTER, D3DTFP_NONE  )
Next
End Function
(put a comma before InitDX7Hack() and one comma before DisableTextureFilters() to activate bilinear filtering)

The texture applied on the quad is the same with/without bilinear filtering, but the final render on screen is different because of the bilinear filtering...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1066
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #13 on: January 06, 2018, 11:16:13 PM »
@Yue>>if you don't see the difference with/without bilinear filtering, using the code that i provided, maybe that's because of fastext which does something behind the scenes...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: how to disable bilinear filtering (on textures) (Blitz3d)
« Reply #14 on: January 07, 2018, 02:29:17 PM »

Nice!!

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal