Here's how to disable filtering.

Blitz3D Forums/Blitz3D Programming/Here's how to disable filtering.

If you don't like DLLs, look away now! :)

First off:
BACKUP any important files, as you would do when using any other 3rd party DLLs!!! I won't be held responsible for anything bad happening.


For version 1.88 only, adds 4 commands. Note that this isn't a 'hack', they're just regular DX7 functions wrapped in a DLL.

On with the good stuff...

Set & Get texture stage filtering:
SetTextureStageState()
GetTextureStageState()

Set & Get the Mipmap LOD bias:
SetMipmapLODBias()
GetMipmapLODBias()

http://www.tomspeed.com/texture_filters/texture_filters_dll.zip

Example in the zip, lemme know here if anything aint working.

Cya!
Tom

Thanks so much Tom. The ass kissing starts with me I guess. :D

Edit: Updated the code in the zip, you can change the anisotropic level so now when you tell a texture to use it, you see results (GFX card permitting!)

Looks smoother.

You have done, in a few lines of code, summat ive been asking for for nearly 2 years... Well done mate..
Screw the compatability...!!
Thanks.

yaaaaaaaaaaaaaaaaaaaaaayyyyyyyyyy!!!!!!!!!!!!!

Thanks man... great work...
Would it be possible to make a working antialias function now that we can access the dx7 interface?

really nice :)

2 more things to go ;)
*DDS support and SetRenderTarget for texture / image buffers*

This is very very cool!

he scouse it works here u know !

mfg panno

:)

Bouncer:

From the SDK...
Note If your application will use antialiasing, it should create the render-target surface with the DDSCAPS2_HINTANTIALIASING capability flag. Applications that omit the flag might suffer from poor performance when antialiasing is enabled, or might not receive antialiasing serices at all.


As far as I can tell the DX7Device created by B3D hasn't been created with the dwCaps2 flag 'DDSCAPS2_HINTANTIALIASING' (would be present in <dwCaps2> for the backbuffer if it was active). This is what the backbuffer looks like after a Graphics3D() call:

Pntr: 1498440
ID: 5
Width: 800
Height: 600
Pitch: 3328
Depth: 32
dwFlags: 4111
<dwCaps>
DDSCAPS_BACKBUFFER
DDSCAPS_COMPLEX
DDSCAPS_FLIP
DDSCAPS_3DDEVICE
DDSCAPS_VIDEOMEMORY
DDSCAPS_LOCALVIDMEM

<dwCaps2>
NONE

I'm not familiar with the AA problem, but maybe this is it?

Tom

Tom - excellent work! Cheers.

Odd.. I get a memory access violation.

Set texture path correctly, and it shows up initally, but errors out with a memory violation on any of the lines used in the DLL.

- .decls and DLL put in userlibs
- path corrected for gothic3.jpg
- runs okay and displays initial image, but trying to change it causes the crash.

Blitz3D 1.88
Nvidia 5700 Ultra
DirectX 9.0b

Any ideas?

+BlackD

Even more odd - got it working with a reboot, however - changing the Mipmap LOD Bias appears to have no effect on my system. Somewhat odd considering the specs support it easily. Texture filter works fine though.

Very nice work, Tom, thanks. It's a shame we have to add this stuff via DLL, but it's very generous of you to put these things together.

What's your specs & drivers BlackD?

What command exactly causes a crash?

That's alright. I fixed the crash issue with a reboot. Haven't rebooted for about 3 weeks so figure it was an artifact from something else. :)

But the problem now is, the mip'ing bias doesn't work. I could take screenshots if you want, but basically - wether Mipmap LOD bias is 1 or 100, makes no visible difference. On a 5700 Ultra, I'd imagine it should. I'll try some fixes tomorrow (drivers are about 2 months old - but the functions you're using have been around for 3 years so I don't see a problem there?) and something else. AFAIK, a difference even of 5 should be clearly distinct. :)

But right now, I need sleep. Mmmm.. sleep.

Hi. I was excited about this, But this doesn't work here.
I get a memory access violation using the demo and for every command I try to use.
Nvidia FX5700 / Athlon 2200 XP directx 9.0c.

@BlackD

Are any of the settings on your GFX card overriding your Blitz commands? I had this problem once because I had set my GFX card to use 'Max Quality' which then overrode any software settings and ALWAYS gave me max mipmapping etc.

Just a thought :)

Oh, and this sounds good. Gonna download and have a look :)

Woah, access dx7 interface! I nearly closed the window until I read that :)
Nice job.

Thanks Tom, very much appreciated.

Marg

FYI
I also get no mipmap lod changes.
winXP, geforce GTS pro/32

Elias, almost same spec as mine. I'm using 66.93 drivers at the moment, what you using?

Hi. I was excited about this, But this doesn't work here.
I get a memory access violation using the demo and for every command I try to use.

I fixed this by re-running the Blitz3DUpdate188.exe, then rebooting. Give it a shot. :)

Now just gotta try and get the mipmap lod working. Antialiasing and ansitropic filtering are both set to application controlled. Direct3D settings are set to quality. Installing new vid drivers now.. brb :)

Well - I've removed PowerStrip, reinstalled nvidia drivers, set them to default settings, made sure everything is application-controlled, and it still doesn't apply mipmap LOD changes. However, this windows install is about 9 months old and has had a lot of stuff go through it so a reinstall would probably fix it but MEH! Not gonna do that just yet. :)

Fantastic work Tom, it's clear that these things could make a major difference to Blitz Basic in general. The difference with the filtering is very cool.

For me, the facility to use Anti-alias would be a godsend - it looks as though you are on the right track. Some people have problems with AntiAlias that it doesn't turn on with their cards, whereas other people have it so that it doesn't turn OFF after being called.

Anyone whos having a problem, you just dont have the latest Blitz3d. :)

Not quite Zenith - as you'd notice if you'd read the posts. I have the latest Blitz3D, the latest video card drivers, no third-party video software interfering, up-to-date windows XP, an nVidia 5700 Ultra video card, all video settings set to enable applications to control mipmaps, and guess what - it doesn't work. It's not an nvidia problem, as other folk with nvidias have it working fine. Computer issues are not always so simplistic as "update your Blitz3D" as any technician will tell you. :)

+BlackD

elias_t:

Are you using v1.88?

Does this print a non 0 value?:

Graphics3D 800,600,32,2
Print SystemProperty$("Direct3DDevice7")
WaitKey
End


Pretty sure you'd have to have your display settings for various features on something like: 'Application Controlled' else your display drivers will override stuff you try to do in B3D.

BlackD - sorry for not reading the latest posts. I'm a dick. :(

Aww .. don't take it so hard. :) Glad you've got it working ok. :)

It all works here, as well as can be expected on my old card anyway. I am not sure why the example program was using cleartexturefilters in conjunction with changing the LODbias. Don't you need a mipmapped texture to see the difference? So I changed it some, as below.

Anyway setting lodbias to -1 produces a quantum leap in mipmap quality particularly on terrains. Well in fact -1 is the only value that did anything sensible on my card. It is so much better though, I will be using it all the time.

Many thanks Tom.

; DLL for tweaking Texture Filter states
; must have blitz3d version 1.88 update


; GetTextureStageState(Direct3DDevice7, D3D_TEXTURE_STAGE_STATE_TYPE, index%)
; SetTextureStageState(Direct3DDevice7, D3D_TEXTURE_STAGE_STATE_TYPE, index%, value%)

; GetMipmapLODBias(Direct3DDevice7, index%) ; B3D Default = 0.0
; SetMipmapLODBias(Direct3DDevice7, bias#, index%)

; In both Set.. commands, the index can be 0 to 7 to specify
; 1 texture stage, Or 8 To set ALL 8 texture stages at once

; Renamed to more sensible names

;D3D_TEXTURE_STAGE_STATE_TYPE
Const D3D_MAGFILTER			= 16	; D3DTEXTUREMAGFILTER filter To use For magnification
Const D3D_MINFILTER			= 17	; D3DTEXTUREMINFILTER filter To use For minification
Const D3D_MIPFILTER			= 18	; D3DTEXTUREMIPFILTER filter To use between mipmaps during minification
;Const D3D_MIPMAPLODBIAS	= 19	; D3DVALUE Mipmap LOD bias

;D3DTEXTUREMAGFILTER
Const MAG_POINT					= 1
Const MAG_LINEAR				= 2 ; B3D default
Const MAG_FLATCUBIC			= 3
Const MAG_GAUSSIANCUBIC	= 4
Const MAG_ANISOTROPIC		= 5

;D3DTEXTUREMINFILTER
Const MIN_POINT					= 1
Const MIN_LINEAR				= 2 ; B3D default
Const MIN_ANISOTROPIC		= 3

;D3DTEXTUREMIPFILTER
Const MIP_NONE					= 1
Const MIP_POINT					= 2
Const MIP_LINEAR				= 3 ; B3D default 



Graphics3D 800,600,32,2
MoveMouse 400,300

dev7=SystemProperty$("Direct3DDevice7")

cam=CreateCamera()
CameraRange cam,.1,1000
PositionEntity cam,0,.5,-4

light=CreateLight()
RotateEntity light,20,10,0

cube1=CreateCube()
ScaleEntity cube1,1,1,5
RotateEntity cube1,-30,0,0
tex1=LoadTexture("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\castle\gothic3.jpg",1)
If tex1=0 Then RuntimeError("Cube texture not found")
ScaleTexture tex1,2,.5
EntityTexture cube1,tex1

terrain=LoadTerrain("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\environ\heightmap_256.BMP")
If terrain=0 Then RuntimeError("Heightmap not found")
tex2=LoadTexture("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\environ\terrain-1.jpg")
If tex2=0 Then RuntimeError("Terrain texture not found")

ScaleEntity terrain,2,50,2
ScaleTexture tex2,20,20
EntityTexture terrain,tex2


MinFilter=2
MagFilter=2
MipFilter=3
bias#=0.0

While Not KeyHit(1)
	If KeyHit(2)
		MagFilter=MagFilter+1 : If Magfilter>5 Then MagFilter=1
		SetTextureStageState(dev7,D3D_MAGFILTER,0,MagFilter)
	End If

	If KeyHit(3)
		MinFilter=MinFilter+1 : If MinFilter>3 Then MinFilter=1
		SetTextureStageState(dev7,D3D_MINFILTER,0,MinFilter)
	End If

	If KeyHit(4)
		mipFilter=MipFilter+1 : If MipFilter>3 Then MipFilter=1
		SetTextureStageState(dev7,D3D_MIPFILTER,0,MipFilter)
	EndIf

	If KeyHit(5)
		bias=bias-1
		SetMipmapLODBias(dev7,bias,8)
	EndIf

	If KeyHit(6)
		bias=bias+1
		SetMipmapLODBias(dev7,bias,8)
	End If

	If KeyDown(57) Then TurnEntity cube1,1,0,0

	TurnEntity cam,-MouseYSpeed(),0,0
	TurnEntity cam,0,-MouseXSpeed(),0,1
	MoveEntity cam,0,0,MouseDown(1)-MouseDown(2)
	MoveMouse 400,300	

	RenderWorld

	If MilliSecs()>time Then time=MilliSecs()+1000 : fps=frame : frame=1 Else frame=frame+1

	Text 0,0,fps
	
	If KeyHit(59) Then htext=Not htext ; F1 enables text

	If htext Then
		Text 0,12,"Keys 1,2 & 3 to change between filtering levels"
		Text 0,24,"MagFilter "+GetTextureStageState(dev7,D3D_MAGFILTER,0)
		Text 0,36,"MinFilter "+GetTextureStageState(dev7,D3D_MINFILTER,0)
		Text 0,48,"MipFilter "+GetTextureStageState(dev7,D3D_MIPFILTER,0)
		Text 0,60,"Mipmap LOD Bias (Keys 4 & 5 changes): "+GetMipmapLODBias(dev7,0)
	EndIf
	
	Flip
Wend
End


Hahaha!

Note my signature..

Thanks DJ. Removing ClearTextureFilters did the trick. No idea why its there either, and didn't notice it. Was too busy trying to change the LOD settings manual to effect an actual difference. Now what I'm wondering is though, how come for some people the LOD is working correctly with "cleartexturefilters" and for some people it isn't? Or maybe the people who said it was working nicely didn't know what they were looking at and simply thought "mmm.. blurred is better than pixelated.. nice work!"

GW! Take out the ClearTextureFilters line.. mipmap LOD will work. :D

Now that the ansiotropic filtering is working (couldn't see it before ofcourse, with the texture mag filter being cleared :p).. WOW! :D Nice work Tom. :)

+BlackD

The LOD Bias can be any float b.t.w (not steps of 1.0 in my demo)

Before I expand on this any further I'm just writing some Caps checking functions. Send a few type pointers to a few calls then you'll get something like this:

(debug output)
http://www.tomspeed.com/DeviceCaps.txt

>0 = supported

Then simply do:

If (pcaps\RasterCaps And D3DPRASTERCAPS_MIPMAPLODBIAS)
; Safe to tweak the Mipmap LOD Bias

It may seem over the top to get all the caps, but they may come in useful later. I should have done this from the start. (As the blonde bad guy said in Segals 'Under Siege2'..."Assumption is the mother of all f**k ups!") :)

The only downside to using some features is that you may need to do multipass renders to use them exclusively.

Blitz3D renders all non-hidden entitys when RenderWorld is called. To make use of a certain feature on just 1 entity, you would need to render your other entitys, hide them, then show & set the texture stages or whatnot for 'this' entity, render it, e.t.c

Another example would be something Fredborg mentioned, rendering 1 entity with Wireframe:

Render scene, hide scene, show entity, set wireframe shade mode, render, e.t.c.

But there's no harm in trying :)

Cya!
Tom
p.s The more I mess with the SDK, the more sympathy I have for Mark :P

Hmm.. does anyone else have this available now? the links broken and ive got a need for it :)

Anyone have a link or can email this one to me?
Thanks

Try this:

http://www.tomspeed.com/texture_filters/texture_filters_dll.zip

Apologies for reviving the topic, but...

I just tried this out, and it doesn't seem to compile anymore - I get the 'oops' error. Does anyone use this DLL in their work, or is there any alternative DLL which can be used to achieve the same result?

hmm me too

IPete2.

ohh, i had a check to non update filters if setsystemproperties failed... so i didn't notice it isn't working now!

I have testes with 1.88,1.90 and 1.91 and nothing...

what's the problem? the latest nvidia drivers?

:(

I'm on ATI here. Surely it should still compile regardless of drivers too.

You maye need to change this line, if it says 'If SetSystem.....' add in a Not like so:

If Not SetSystemProperties(d3d,dev7,draw7,hwnd,instance) RuntimeError "Ooops!"

Or vice versa, I changed something and forgot to update the code, "Ooops!" :P

I'm all done trying to get 'this, that and the other' working in a DLL, a lot of stuff in Blitz3D is hard coded, i.e whatever you set it to renderworld will overwrite it.

Some kinda release version coming in next few days, else may I never drink another cup of tetley ever again! :)

Oops, you're right. so my original file is working anyway... hehe...

I don't blame you for not wanting to touch B3d much more. However, I really appreciate you releasing this hack to the community. It makes a big difference with my game and I'm sure it does for other people too. I'll actively look forward to a new release so I can use it again! ^-^

Sorry to necro this thread, but was a final version of this DLL ever released? I'd like to compile libraries and DLLs in my Blitz 3D 'folder' so that I can back them up for the future, if I'm using them in my game.

Does anyone have a copy of this they can upload?

shouldn't these be built in Blitz3D?