Here's how to disable filtering.

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

Tom(Posted 2004) [#1]
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


Zenith(Posted 2004) [#2]
Thanks so much Tom. The ass kissing starts with me I guess. :D


Tom(Posted 2004) [#3]
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.


Ion-Storm(Posted 2004) [#4]
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.


DrakeX(Posted 2004) [#5]
yaaaaaaaaaaaaaaaaaaaaaayyyyyyyyyy!!!!!!!!!!!!!


Bouncer(Posted 2004) [#6]
Thanks man... great work...
Would it be possible to make a working antialias function now that we can access the dx7 interface?


Dreamora(Posted 2004) [#7]
really nice :)

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


GW(Posted 2004) [#8]
This is very very cool!


Panno(Posted 2004) [#9]
he scouse it works here u know !

mfg panno


TeraBit(Posted 2004) [#10]
:)


Tom(Posted 2004) [#11]
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


Who was John Galt?(Posted 2004) [#12]
Tom - excellent work! Cheers.


BlackD(Posted 2004) [#13]
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


BlackD(Posted 2004) [#14]
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.


Gabriel(Posted 2004) [#15]
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.


Tom(Posted 2004) [#16]
What's your specs & drivers BlackD?

What command exactly causes a crash?


BlackD(Posted 2004) [#17]
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.


elias_t(Posted 2004) [#18]
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.


Rhyolite(Posted 2004) [#19]
@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 :)


Picklesworth(Posted 2004) [#20]
Woah, access dx7 interface! I nearly closed the window until I read that :)
Nice job.


JBR(Posted 2004) [#21]
Thanks Tom, very much appreciated.

Marg


GW(Posted 2004) [#22]
FYI
I also get no mipmap lod changes.
winXP, geforce GTS pro/32


Tom(Posted 2004) [#23]
Elias, almost same spec as mine. I'm using 66.93 drivers at the moment, what you using?


BlackD(Posted 2004) [#24]
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 :)


BlackD(Posted 2004) [#25]
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. :)


Dock(Posted 2004) [#26]
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.


Zenith(Posted 2004) [#27]
Anyone whos having a problem, you just dont have the latest Blitz3d. :)


BlackD(Posted 2004) [#28]
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


Tom(Posted 2004) [#29]
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.


Zenith(Posted 2004) [#30]
BlackD - sorry for not reading the latest posts. I'm a dick. :(


BlackD(Posted 2004) [#31]
Aww .. don't take it so hard. :) Glad you've got it working ok. :)


DJWoodgate(Posted 2004) [#32]
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.




BlackD(Posted 2004) [#33]
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


Tom(Posted 2004) [#34]
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


Damien Sturdy(Posted 2005) [#35]
Hmm.. does anyone else have this available now? the links broken and ive got a need for it :)


Wayne(Posted 2005) [#36]
Anyone have a link or can email this one to me?
Thanks


Mustang(Posted 2005) [#37]
Try this:

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


Dock(Posted 2005) [#38]
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?


IPete2(Posted 2005) [#39]
hmm me too

IPete2.


KuRiX(Posted 2005) [#40]
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?

:(


Dock(Posted 2005) [#41]
I'm on ATI here. Surely it should still compile regardless of drivers too.


Tom(Posted 2005) [#42]
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! :)


KuRiX(Posted 2005) [#43]
Oops, you're right. so my original file is working anyway... hehe...


Dock(Posted 2005) [#44]
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! ^-^


Dock(Posted 2007) [#45]
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.


boomboom(Posted 2007) [#46]
Does anyone have a copy of this they can upload?


_33(Posted 2007) [#47]
shouldn't these be built in Blitz3D?


Chroma(Posted 2009) [#48]
Anyone have this? If you do can you host it or something. I really need these commands to fix a few things.


Ross C(Posted 2009) [#49]
Check out your post in the blitz showcase forum. Krischan has posted some stuff on the .dds textures.


Chroma(Posted 2009) [#50]
Yeah, I just want to use the one command though.

SetMipMapLODBias

It's floating around here somewhere in a .dll. Just have to find it.


GIB3D(Posted 2009) [#51]
Just google searched it and came up with 2 results. This page and one that says dx7.dll

http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=Awc&q=SetMipMapLODBias+in+DLL&aq=f&oq=&aqi=

Is that it?


Chroma(Posted 2009) [#52]
Nope that's not it. I'll keep looking...


Warner(Posted 2009) [#53]
I believe that DLL is part of the devil shadow system. If you look in the decls you'll find SetMipMapLODBias.
Download here:
http://devil-engines.dev-ch.de/Downloads/DSS_1.35u.zip


GfK(Posted 2009) [#54]
I have it but I'm not willing to distribute it without Tom's say-so. I'm not sure where he's gone, haven't spoken to him in ages.


Chroma(Posted 2009) [#55]
Yup Warner, I already got the Devil system and tried it. Didn't notice a difference whatsoever.

Tom released it to the public at one point so I doubt he's renigged on the offer. His website is down but it's up to you. I'm assuming it's the same DX7.dll though so it should work the same in Devil's .dll I would hope.

I set the mipmapbios to 0, 0.1, 1, 8, 20, 100,1000,10000,100000,10000000

And no difference...

Tried setstagefilter thing too...still banding on the runway.

I've spent too much time toying with mipmapping so I'll move on to other stuff. Hopefully someone knows how this works and will shed some light.


Kryzon(Posted 2009) [#56]
How can I edit the TextureStageState individually for each texture?

You specify the "layer" from 0 ~ 7 (or 8 if you want them all), but for what entity\texture?!

Cheers

PS: the pack does not include the source that Tom made available, it's just various DLLs + DECLS.


Warner(Posted 2009) [#57]
I think that is not possible. If so, you should set SetTextureStageState between rendering two entities. Maybe you can render in multiple passes:
	CameraClsMode camera, True, True
	ShowEntity ent1
	HideEntity ent2
	SetTextureStageState ..etc
	RenderWorld ;---->render first entity
	HideEntity ent1
	ShowEntity ent2
	CameraClsMode camera, False, False
	SetTextureStageState ..etc
	RenderWorld ;---->render second entity
	Flip



Kryzon(Posted 2009) [#58]
I get what you mean, but I'm almost certain there is a way to do it for each texture. Someone out there is hiding the gold.


Kryzon(Posted 2009) [#59]
Hmm, funny how in about 5 thousand advanced forum users nobody knows the answer.

Just so I don't look like an ice-hole, here is the Dx7 DLLs pack:

http://www.geocities.com/rafael_nvg/DX7-Libs_for_Blitz3D.zip

The question still remains, if anybody would be so kind as to answer it!


Warner(Posted 2009) [#60]
Maybe they are all on vacation? I think the idea behind SetTextureStageState is that you change the texture state per stage. Maybe there is another command to change it per texture? Per entity is not going to work, since DirectX doesn't use entities.


Kryzon(Posted 2009) [#61]
It don't think there is something like that (although I'd be glad if it did!), as little as I know of Dx7. It seems that when you are going to render every entity, you set up the textures for each object and then render them. Something like:
SetTextureStageState(...)
SetTextureStageState(...)

SetTexture( 0, Ground )
SetTexture( 1, Grass )

DrawPrimitiveUP(...) //...or some other method of drawing the object.

It draws a certain mesh using the current texture layers, so, if another mesh uses different textures, then the SetTexture functions would need to be called again to set different textures and THEN render that other mesh.

And then doing that for every single object in the scene. This is what Blitz3D probably does when we call RenderWorld(), for every object in the scene it iterates through that logic.
That's why we don't have how to control it using SetTextureStageState, because when we call RenderWorld() the stage states get over-written or something like that.

In the end, we need to find a way to alter the state value to which RenderWorld() set a specific texture to. Having access to that, we can specify whatever we want the states to be.

Looking at the texture structure that MikhailV came up with, there is a certain memory offset that holds the current BLEND value for that texture, set up with TextureBlend. It seems that RenderWorld() uses this value to set up the appropriate Stage State (in which case we have 5 to select from within Blitz3D, the available Texture Blends). But Direct3D 7 has much more than 5, and so if there was a way to write a memory value to the Blend offset in the texture structure and have RenderWorld() use that value, then we would have control over the stage state value.
I've tried writing some values to it but it didn't make any difference.


MikhailV(Posted 2009) [#62]
@Kryzon: It is really necessary for you? What for?
Now (with FastExt library) it is possible to establish demanded LodBias & Filtering for all scene. I can make it for each texture, but I do not see sense in it...


Warner(Posted 2009) [#63]
Alternatively, you could write your own RenderWorld function. That way you could render anything the way you want to. That would require a good insight in how the entities and textures are set up.