Gamestudio Links
Zorro Links
Newest Posts
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (7th_zorro, Aku_Aku, henrybane, flink, 1 invisible), 739 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
annoying offset #444069
07/29/14 23:45
07/29/14 23:45
Joined: Jul 2010
Posts: 283
Germany
J
jenGs Offline OP
Member
jenGs  Offline OP
Member
J

Joined: Jul 2010
Posts: 283
Germany
I use bmap_process a lot.
Here my question, why do I have an offset coming with the input Texture coordinates.

Code:
float4 process_bmap(float2 Tex: TEXCOORD0): COLOR 
{
	float4 color;
	if(vecSkill1[2] >= Tex.x)
	{
		color = float4(1, 0, 0, 1);
	}
	else
	{
		color = float4(0, 0, 0, 1);
	}
	
	return color;
}



TEXCOORD0 comes with an offset between -0.05 and -0.06
That means the texture coordinates are not in between 0.0 - 1.0 range

I guess it is a bug in bmap_process. But I am not a shader expert so this could have a simple different reason.

I know that my code above is an example of bad shader programming. But I did that to eliminate all hlsl functions and just debug "Tex".

Last edited by jenGs; 07/29/14 23:49. Reason: wrong values
Re: annoying offset [Re: jenGs] #444090
07/30/14 08:13
07/30/14 08:13
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
try using VPOS (the coordinate in pixels, that's why you have to add a half-pixel offset and divide it by the resolution)

Code:
void PShader(in float4 vPos : VPOS, ....
{
	float2 tex = (vPos.xy + 0.5) / vecViewPort.xy;



POTATO-MAN saves the day! - Random
Re: annoying offset [Re: Kartoffel] #444093
07/30/14 09:47
07/30/14 09:47
Joined: Jul 2010
Posts: 283
Germany
J
jenGs Offline OP
Member
jenGs  Offline OP
Member
J

Joined: Jul 2010
Posts: 283
Germany
Thank you, that worked.

Is there a special reason why there is a half pixel offset?

Re: annoying offset [Re: jenGs] #444096
07/30/14 10:12
07/30/14 10:12
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
the top left pixel has the position 0, 0 (oops, actually it's 1, 1)
in shaders however, the sample point needs to be in the middle of the pixel

But that's just needed for VPOS, I don't know why TEXCOORD0 is so inaccurate.

Last edited by Kartoffel; 07/30/14 13:25.

POTATO-MAN saves the day! - Random

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1