[bug?] sampling of 1x1 texture just returns black

Problems building or running the engine, queries about how to use features etc.
Post Reply
johny5
Kobold
Posts: 38
Joined: Sat Mar 25, 2006 5:52 pm

[bug?] sampling of 1x1 texture just returns black

Post by johny5 »

Hello.

A little bit of details what I'm trying to do (however IMHO it is slightly or not related to the bug):
I made one common shader for all of the meshes, with bump mapping. I'm using normal maps.
For one of the very simple meshes I don't need to use normal map, so I provided a texture 1x1 with 128,128,255 color.
However, when I'm sampling this texture and just output to the color (for sampling test) I see black pixel.
Rescaling texture to the 2x2 size solves the problem. I used .tga and .jpg formats for test with same result.

May you please check it? It' could be a Ogre bug, quite annoying, because I lost some amount of time on it.
Windows XP, NVIDIA GeForce 9600GT, 512Mb, Driver on 4/11/2008, version 6.14.11.7488, OGRE v1-6-0

PS: I found some mentioning of similar bug here: http://www.ogre3d.org/forums/viewtopic. ... 3&start=25
Kojack wrote:Hmm, textures as small as 2x1 work fine, but 1x1 comes out as white. Strange.
PPS: I updated drivers up to 3/27/2009, 6.14.11.8250 - same effect.

Thanks!
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: [bug?] sampling of 1x1 texture just returns black

Post by xavier »

Do you have texture filtering on when this happens?
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: [bug?] sampling of 1x1 texture just returns black

Post by Kojack »

I just tried using a 1x1 png and it worked fine in both opengl and directx.
Of course I'm using different hardware, drivers and ogre version than when I had that 1x1 pixel problem in the motion blur demo 2 years ago.
johny5
Kobold
Posts: 38
Joined: Sat Mar 25, 2006 5:52 pm

Re: [bug?] sampling of 1x1 texture just returns black

Post by johny5 »

xavier wrote:Do you have texture filtering on when this happens?
Probably. :) I just think that everything is by default.
I would better lay out minimal material & shader sources, which has the effect:

rocket1.material:

Code: Select all

vertex_program normal_specular_vs  hlsl
{
	source normal_specular.hlsl
	target vs_2_0
	entry_point  vs
}

fragment_program normal_specular_ps  hlsl
{
	source normal_specular.hlsl
	target ps_2_0
	entry_point  ps
}


material rocket1
{
	technique
	{
		pass
		{
			ambient 0 0 0 1
			diffuse 1 1 1 1
			specular 1 0 1 10 0
			
			vertex_program_ref  normal_specular_vs
			{
				param_named_auto gWorldViewProj	worldviewproj_matrix
			}
			
			fragment_program_ref  normal_specular_ps
			{}
			
			texture_unit
			{
				texture 3d\textures\rocket1NormalsMap.tga
			}
		}
	}
}
normal_specular.hlsl:

Code: Select all


uniform sampler2D TangentNormal		: register(s0);
float4x4 gWorldViewProj;


struct VINPUT
{
	float4 position : POSITION;
};

struct VOUTPUT
{
	float4 position	: POSITION;
};




VOUTPUT  vs(VINPUT  Input)
{
	VOUTPUT  Output;
	
	//	transponed multiply, due to ogre matrixes is all in OGL format
	Output.position = mul(gWorldViewProj, float4(Input.position.xyz, 1));
		
	return Output;
}


float4 ps() : COLOR
{
	return float4( tex2D(TangentNormal, float2(0.5,0.5)).rgb, 1 );
}
I did even uploaded .tga file of 1x1 pixel, just in case: http://dl.getdropbox.com/u/623555/rocket1NormalsMap.tga
BTW: I checked with .png format - it seems it's not because of format.

And I tried to debug it on my computer, but I can't find where DirectX renderer sets up textures for a pixel/vertex shader? I want to put breakpoint there and see what is going on. And also, place where Ogre loads rocket1NormalsMap.tga texture, maybe IDirect3D.. just does not allow to create texture of 1x1 size.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: [bug?] sampling of 1x1 texture just returns black

Post by xavier »

I am pretty sure you cannot create anything smaller than 2x2 -- just out of curiosity, what is the need for a 1x1 vs a 2x2?
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
johny5
Kobold
Posts: 38
Joined: Sat Mar 25, 2006 5:52 pm

Re: [bug?] sampling of 1x1 texture just returns black

Post by johny5 »

xavier wrote:what is the need for a 1x1 vs a 2x2?
No real need in there :)
I'm just a perfectionist :)

And anyway, it would be helpful to others if we together will find this bug. Or at least, you and others be aware that this bug is possible, i.e. it will get to known bugs list.
:D
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: [bug?] sampling of 1x1 texture just returns black

Post by xavier »

Well it's not an Ogre bug -- Ogre just uses what the underlying APIs and hardware provide, so if this is an issue with those, there's nothing to file in Ogre's bug list. ;)
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
johny5
Kobold
Posts: 38
Joined: Sat Mar 25, 2006 5:52 pm

Re: [bug?] sampling of 1x1 texture just returns black

Post by johny5 »

xavier wrote:Well it's not an Ogre bug -- Ogre just uses what the underlying APIs and hardware provide, so if this is an issue with those, there's nothing to file in Ogre's bug list. ;)
Yep, just second ago I've checked this 1x1 texture in my own DirectX API based application - loads & working without problems (this texture too is used as an input to the shader, however I'm using DirectX effect files and there is different DirectX API in compare to which Ogre uses).
So, it should be somehow related to Ogre. Anyway, I admit that this issue doesn't worth so many words we've already written :) But if somebody will point me on the source code points where texture is loaded (via .material file description) and where it puts to the shader - it would be good & I'll dig a little bit more.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: [bug?] sampling of 1x1 texture just returns black

Post by xavier »

Well, Texture is a Resource, and Resource has variations on load() and create*(), so I'd start there.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
Post Reply