hlsl shader - tex2Dbias does not work correctly

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
pnyx
Posts: 1
Joined: Sun Mar 08, 2009 3:39 pm

hlsl shader - tex2Dbias does not work correctly

Post by pnyx »

Hiho folks,

I'm currently working on implementing some shaders for a University project into Irrlicht. I've been pretty successful so far but when I wanted to implement my blooming shader I ran into a problem.

I'm wanted to use the mipmap levels instead of blurring the image for performance reasons but it seems when using Irrlicht this function does not work.

Code: Select all

float4 diffuse1 =  tex2Dbias( Texture0,float4(texCoord.xy, 0,3)); 
this is the line (or one of the lines) of code that does not work - all it does is give me the normal texture in full resolution instead of the 3rd mipmap as i would expect. (I coded the shader in rendermonkey before and it works fine there)

I also tried to use

Code: Select all

rt->regenerateMipMapLevels();
after rendering the screen to my rendertarget to make sure the texture really has mipmaps but this had no effect whatsoever.

I hope someone can help me here or point me in the right direction :)
As I am pretty new to Irrlicht and cpp in general there is a got chance i just overlooked something important :D

Greetings
pnyx
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Hmmm Direct3D9 driver eh. If you look in CD3D9Texture.cpp, you can see a compiler define for generating mipmaps manually or using the driver to do it, and it gets enabled/disabled based on whether the D3D8 driver is compiled in too.

Anyway, even if it's an RTT, you may have some luck using the manual mipmap generation again, you can probably achieve this by enabling the D3D8 driver in IrrCompileConfig.h.

Note this is just off the top of my head, they may have changed this recently with all the changes.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
9YkKsvXM
Posts: 64
Joined: Tue Mar 11, 2008 11:45 pm

Post by 9YkKsvXM »

-
Last edited by 9YkKsvXM on Mon Jun 08, 2020 1:34 am, edited 1 time in total.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Nate_D wrote:I got this to work just fine using shader model 3 and the tex2Dlod function.

float4 color = tex2Dlod( tex0, float4(TexCoord.xy, 0, 0));
bias and lod won't work with a non-mipped texture though...
9YkKsvXM
Posts: 64
Joined: Tue Mar 11, 2008 11:45 pm

Post by 9YkKsvXM »

-
Last edited by 9YkKsvXM on Mon Jun 08, 2020 1:20 am, edited 1 time in total.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Nate_D wrote:I got this to work just fine using shader model 3 and the tex2Dlod function.

float4 color = tex2Dlod( tex0, float4(TexCoord.xy, 0, 0));
but you missed the crucial piece of info that your texture was mipped. Without mips it will appear not to work and hence a possible explanation for the OP's issue.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Yeah the op was using a render target texture if you hadn't noticed.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
9YkKsvXM
Posts: 64
Joined: Tue Mar 11, 2008 11:45 pm

Post by 9YkKsvXM »

-
Post Reply