Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by 7th_zorro. 04/16/24 13:19
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:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (rki, Ayumi), 475 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 4 1 2 3 4
Re: Use draw_quad outside the window / render on bmap [Re: Benni003] #455216
10/13/15 15:49
10/13/15 15:49
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Glad of been helpful laugh
Maybe you need to encrease the zbuffer meassures. The render target and the source map need to be meassured square of two.

Code:
bmap_zbuffer ( bmap_createblack ( 4096, 2048, 32 ) );



The example is a zoom in, yes. That was the first step: converting the screen coords to map coords.

Now I am adding a fake anisotropy by 3x3 gaussian cubic samples to the shader but I get little inacuracies on the process. I am not sure if it comes from variable inacuracies or from that dx9 offset that has to be applied and I don't master xP

Anyway, this multisample method gives a pretty good zooming out results up to 1:4 scale. For smaller scales it will need more samples.

main.c
Code:
#include <acknex.h>

// Material skills
#define skPosX       skill9  // X coord relative to the center of the map in map coords (centered on the screen)
#define skPosY       skill10 // Y coord
#define skScale      skill11 // scale of the map
#define skScaleNext  skill12 // needed a map scale smooth transition variable

void main ()
{
	video_mode = 10;
	mouse_mode = 4;
	fps_max = 60;
	wait(1);
	
	BMAP *bmpMap = bmap_create ( "grid.tga" );
	BMAP *bmpScreen = bmap_createblack ( screen_size.x, screen_size.y, 24 );
	PANEL *panScreen = pan_create ( "flags=SHOW", 1 );
	panScreen->bmap = bmpScreen;
	MATERIAL *mtlCamMap = mtl_create ();
	mtlCamMap->skPosX = 0;
	mtlCamMap->skPosY = 0;
	mtlCamMap->skScale = 1;
	mtlCamMap->skScaleNext = mtlCamMap->skScale;
	effect_load ( mtlCamMap, "display_map.fx" );
	
	mtlCamMap->skill4 = floatd ( bmap_height(bmpScreen) * bmap_width(bmpMap), bmap_width(bmpScreen) * bmap_height(bmpMap) );
	var nProp = bmap_width(bmpScreen) / bmap_width(bmpMap);
	
	while ( !key_esc )
	{
		if ( mouse_left )
		{
			mtlCamMap->skPosX += mickey.x / mtlCamMap->skScale;
			mtlCamMap->skPosY += mickey.y / mtlCamMap->skScale;
		}
		if ( mickey.z > 0 )
		{
			mtlCamMap->skScaleNext = minv ( mtlCamMap->skScaleNext * 1.414, 2 ); // 1.414 ~= sqrt(2)
		}
		if ( mickey.z < 0 )
		{
			mtlCamMap->skScaleNext = maxv ( mtlCamMap->skScaleNext / 1.414, 0.25 );
		}
		mtlCamMap->skScale += ( mtlCamMap->skScaleNext - mtlCamMap->skScale ) * time_step * 0.5;
		
		mtlCamMap->skill1 = floatd ( mtlCamMap->skPosX, bmap_width(bmpMap) );
		mtlCamMap->skill2 = floatd ( mtlCamMap->skPosY, bmap_height(bmpMap) );
		mtlCamMap->skill3 = floatd ( nProp, mtlCamMap->skScale );
		mtlCamMap->skill5 = floatd ( 0.5, bmap_width(bmpMap) * mtlCamMap->skScale );
		mtlCamMap->skill6 = floatd ( 0.5, bmap_height(bmpMap) * mtlCamMap->skScale );
		bmap_process ( bmpScreen, bmpMap, mtlCamMap );
		
		wait(1);
	}
	
	mtl_remove ( mtlCamMap );
	pan_remove ( panScreen );
	bmap_remove ( bmpScreen );
	bmap_remove ( bmpMap );
	
	sys_exit ( NULL );
}



display_map.fx
Code:
float4 vecSkill1;
float4 vecSkill5;
texture TargetMap;
sampler ColorSampler = sampler_state { Texture = <TargetMap>; MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; };

float2 fOffset3x3[9] = { -1,-1, 0,-1, 1,-1, -1,0, 0,0, 1,0, -1,1, 0,1, 1,1 };
float fGauss3x3[9] = { 0.0625, 0.125, 0.0625, 0.125, 0.25, 0.125, 0.0625, 0.125, 0.0625 };

float4 PS ( in float2 inTex: TEXCOORD0 ) : COLOR0
{
	inTex.xy -= 0.5f;
	inTex.xy *= vecSkill1.z;
	inTex.y *= vecSkill1.w;
	inTex.xy += 0.5f - vecSkill1.xy;
	float4 Color = 0;
	for ( int i=0; i<9; i+=1 )
		Color.rgb += tex2D ( ColorSampler, inTex + fOffset3x3[i] * vecSkill5.xy ).rgb * fGauss3x3[i];
	Color.a = 1.0f;
	return Color;
}

technique
{
	pass
	{
		VertexShader = null;
		PixelShader  = compile ps_2_0 PS();
	}
}



Salud!

Last edited by txesmi; 10/14/15 10:18. Reason: bamp_zbuffer syntax error x·
Re: Use draw_quad outside the window / render on bmap [Re: txesmi] #455217
10/13/15 17:01
10/13/15 17:01
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline OP
Senior Member
Benni003  Offline OP
Senior Member

Joined: Aug 2008
Posts: 394
Germany
It Looks really good, but still the Problem with draw_quad() outside the original Screen resolution. I've also tried with increasing the zbuffer size, as you sayed, but it's still not working. The graphics are always cutted at the end Point .. smirk

Re: Use draw_quad outside the window / render on bmap [Re: Benni003] #455219
10/13/15 17:19
10/13/15 17:19
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
So you are using bmap_rendertarget(). Have you called bmap_zbuffer(), too?
http://www.conitec.net/beta/bmap_zbuffer.htm


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Use draw_quad outside the window / render on bmap [Re: Superku] #455220
10/13/15 17:27
10/13/15 17:27

M
Malice
Unregistered
Malice
Unregistered
M



@Superku - I sent him that way a few post back. All be it, I'm adding much confusion to the thread...

Re: Use draw_quad outside the window / render on bmap [Re: Superku] #455221
10/13/15 17:31
10/13/15 17:31
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline OP
Senior Member
Benni003  Offline OP
Senior Member

Joined: Aug 2008
Posts: 394
Germany
@Superku: Of course, but just the first three pics are drawn. I zoomed out with the code from txesmi to see it.
bmpMap have also the size 2048x2048. The screen size.x is 1440px

Code:
bmap_zbuffer(bmap_createblack(2048,2048,32));

while(1)
{
bmap_rendertarget(bmpMap,0,0);
		
		draw_quad(tt,vector(100,20,0),NULL,NULL,NULL,NULL,100,NULL);	
		draw_quad(tt,vector(500,20,0),NULL,NULL,NULL,NULL,100,NULL);	
		draw_quad(tt,vector(1000,20,0),NULL,NULL,NULL,NULL,100,NULL);	
		draw_quad(tt,vector(1500,20,0),NULL,NULL,NULL,NULL,100,NULL);	
		draw_quad(tt,vector(2000,20,0),NULL,NULL,NULL,NULL,100,NULL);	
		
bmap_rendertarget(NULL,0,0);
wait(1);
}



Does anyone have a solution for this problem? smirk

Last edited by Benni003; 10/13/15 19:37.
Re: Use draw_quad outside the window / render on bmap [Re: Benni003] #455232
10/14/15 11:18
10/14/15 11:18
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
It does not happen on my computer.
The engine loads some functionalities when a level is loaded. Try loading an empty level... just guessing.

Anuway, I just realized there are other troubles. The 1:1 scale is not pixel to pixel on big maps but the map scaled to screen width...

I will revise it.
txes

Last edited by txesmi; 10/14/15 11:21.
Re: Use draw_quad outside the window / render on bmap [Re: txesmi] #455234
10/14/15 13:39
10/14/15 13:39
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Cleaner version but same acuracy problem frown

main.c
Code:
#include <acknex.h>

// Material skills
#define skPosX       skill17 // X coord in map coords relative to the center of the map (centered on the screen)
#define skPosY       skill18 // Y coord...
#define skScale      skill19 // scale of the map
#define skScaleNext  skill20 // needed a map scale smooth transition variable

void main ()
{
	video_mode = 10;
	mouse_mode = 4;
	fps_max = 60;
	wait(1);
	
	BMAP *bmpMap = bmap_create ( "grid.tga" );
	BMAP *bmpScreen = bmap_createblack ( screen_size.x, screen_size.y, 24 );
	PANEL *panScreen = pan_create ( "flags=SHOW", 1 );
	panScreen->bmap = bmpScreen;
	MATERIAL *mtlCamMap = mtl_create ();
	mtlCamMap->skPosX = 0;
	mtlCamMap->skPosY = 0;
	mtlCamMap->skScale = 1;
	mtlCamMap->skScaleNext = mtlCamMap->skScale;
	
	mtlCamMap->skill1 = floatv ( bmap_width(bmpScreen) );
	mtlCamMap->skill2 = floatv ( bmap_height(bmpScreen) );
	mtlCamMap->skill3 = floatd ( 1, bmap_width(bmpMap) );
	mtlCamMap->skill4 = floatd ( 1, bmap_height(bmpMap) );
	effect_load ( mtlCamMap, "display_map.fx" );
	
	while ( !key_esc )
	{
		if ( mouse_left )
		{
			mtlCamMap->skPosX -= mickey.x / mtlCamMap->skScale;
			mtlCamMap->skPosY -= mickey.y / mtlCamMap->skScale;
		}
		if ( mickey.z > 0 )
		{
			mtlCamMap->skScaleNext = minv ( mtlCamMap->skScaleNext * 1.414, 2 ); // 1.414 ~= sqrt(2)
		}
		if ( mickey.z < 0 )
		{
			mtlCamMap->skScaleNext = maxv ( mtlCamMap->skScaleNext / 1.414, 0.25 );
		}
		var nTemp = ( mtlCamMap->skScaleNext - mtlCamMap->skScale ) * time_step * 0.75;
		if ( nTemp )
			mtlCamMap->skScale += nTemp;
		else
			mtlCamMap->skScale = mtlCamMap->skScaleNext;
		
		mtlCamMap->skill5 = floatv ( mtlCamMap->skPosX );
		mtlCamMap->skill6 = floatv ( mtlCamMap->skPosY );
		mtlCamMap->skill7 = floatd ( 1, mtlCamMap->skScale );
		bmap_process ( bmpScreen, bmpMap, mtlCamMap );
		
		wait(1);
	}
	
	mtl_remove ( mtlCamMap );
	pan_remove ( panScreen );
	bmap_remove ( bmpScreen );
	bmap_remove ( bmpMap );
	
	sys_exit ( NULL );
}



display_map.fx
Code:
float4 vecSkill1;
float4 vecSkill5;
texture TargetMap;
sampler ColorSampler = sampler_state { 
	Texture=<TargetMap>; 
	MipFilter=Linear; MinFilter=Linear; MagFilter=Linear; 
	AddressU=Border; AddressV=Border; 
	BorderColor=0xFF000000; }; // ARGB format

float2 fOffset3x3[9] = { -0.5,-0.5, 0,-0.5, 0.5,-0.5, -0.5,0, 0,0, 0.5,0, -0.5,0.5, 0,0.5, 0.5,0.5 };
float fGauss3x3[9] = { 0.0625, 0.125, 0.0625, 0.125, 0.25, 0.125, 0.0625, 0.125, 0.0625 };

float4 PS ( in float2 inTex: TEXCOORD0 ) : COLOR0
{
	inTex.xy -= 0.5f;
	inTex.xy *= vecSkill1.xy;
	inTex.xy *= vecSkill5.z;
	inTex.xy += vecSkill5.xy;
	inTex.xy *= vecSkill1.zw;
	inTex.xy += 0.5f;
	float4 Color = 0;
	for ( int i=0; i<9; i+=1 )
		Color.rgb += tex2D ( ColorSampler, inTex + fOffset3x3[i] * vecSkill1.zw * vecSkill5.z ).rgb * fGauss3x3[i];
	Color.a = 1.0f;
	return Color;
}

technique
{
	pass
	{
		VertexShader = null;
		PixelShader  = compile ps_2_0 PS();
	}
}



Salud!

Re: Use draw_quad outside the window / render on bmap [Re: txesmi] #455235
10/14/15 14:36
10/14/15 14:36
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline OP
Senior Member
Benni003  Offline OP
Senior Member

Joined: Aug 2008
Posts: 394
Germany
Originally Posted By: txesmi
Hi,
It does not happen on my computer.
The engine loads some functionalities when a level is loaded. Try loading an empty level... just guessing.
txes


I've tried also with loading a level before, but not working.
Here is the main.c Code I'm using to try it. I have 5 draw_quad calls, but just the first three of them are drawn. Did I something wrong?
Could you try it on your pc? Size.x is 1440px

Code:
#include <acknex.h>

// Material skills
#define skPosX       skill9  // X coord relative to the center of the map in map coords (centered on the screen)
#define skPosY       skill10 // Y coord
#define skScale      skill11 // scale of the map
#define skScaleNext  skill12 // needed a map scale smooth transition variable

void main ()
{
	video_mode = 10;
	mouse_mode = 4;
	fps_max = 60;

	wait(1);

	BMAP *bmpMap = bmap_createblack(1920,1200,32);
	
	BMAP *bmpScreen = bmap_createblack(1920,1200,24);
	PANEL *panScreen = pan_create ( "flags=SHOW", 1 );
	panScreen->bmap = bmpScreen;
	MATERIAL *mtlCamMap = mtl_create ();
	mtlCamMap->skPosX = 0;
	mtlCamMap->skPosY = 0;
	mtlCamMap->skScale = 1;
	mtlCamMap->skScaleNext = mtlCamMap->skScale;
	effect_load ( mtlCamMap, "display_map.fx" );
	
	mtlCamMap->skill4 = floatd ( bmap_height(bmpScreen) * bmap_width(bmpMap), bmap_width(bmpScreen) * bmap_height(bmpMap) );
	var nProp = bmap_width(bmpScreen) / bmap_width(bmpMap);

	var x=100;
	
	bmap_zbuffer(bmap_createblack(2048,2048,32));
	
	while ( !key_esc )
	{
		//------------

		bmap_rendertarget(bmpMap,0,0);
		
		draw_quad(NULL,vector(-50,20,0),NULL,vector(100,100,0),NULL,vector(200,200,200),100,NULL);	
		draw_quad(NULL,vector(500,20,0),NULL,vector(100,100,0),NULL,vector(200,200,200),100,NULL);	
		draw_quad(NULL,vector(1000,20,0),NULL,vector(100,100,0),NULL,vector(200,200,200),100,NULL);	
		draw_quad(NULL,vector(1450,20,0),NULL,vector(100,100,0),NULL,vector(200,200,200),100,NULL);	
		draw_quad(NULL,vector(2000,20,0),NULL,vector(100,100,0),NULL,vector(200,200,200),100,NULL);	
		
		bmap_rendertarget(NULL,0,0);
		
		//----------
		
		if ( mouse_left )
		{
			mtlCamMap->skPosX += mickey.x / mtlCamMap->skScale;
			mtlCamMap->skPosY += mickey.y / mtlCamMap->skScale;
		}
		
		if ( mickey.z )
		{
			mtlCamMap->skScaleNext = clamp ( mtlCamMap->skScaleNext + sign(mickey.z),0.001, 1000 );
		}
		mtlCamMap->skScale += ( mtlCamMap->skScaleNext - mtlCamMap->skScale ) * time_step * 0.5;
		
		mtlCamMap->skill1 = floatd ( mtlCamMap->skPosX, bmap_width(bmpMap) );
		mtlCamMap->skill2 = floatd ( mtlCamMap->skPosY, bmap_height(bmpMap) );
		mtlCamMap->skill3 = floatd ( nProp, mtlCamMap->skScale );
		mtlCamMap->skill5 = floatd ( 0.5, bmap_width(bmpMap) * mtlCamMap->skScale );
		mtlCamMap->skill6 = floatd ( 0.5, bmap_height(bmpMap) * mtlCamMap->skScale );
		
		bmap_process ( bmpScreen, bmpMap, mtlCamMap );
		
		
		wait(1);
	}
	
	mtl_remove ( mtlCamMap );
	pan_remove ( panScreen );
	bmap_remove ( bmpScreen );
	bmap_remove ( bmpMap );
	
	sys_exit ( NULL );
}


Re: Use draw_quad outside the window / render on bmap [Re: Benni003] #455236
10/14/15 15:18
10/14/15 15:18
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
It certainly happens in my computer too shocked sorry

Tried to encrease the camera size on an empty level but it does not modify those draw_quad limits frown

The only workaround I can imagine is cutting the map in pieces, but pretty unruly...

Last edited by txesmi; 10/14/15 15:28.
Re: Use draw_quad outside the window / render on bmap [Re: txesmi] #455237
10/14/15 15:50
10/14/15 15:50
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline OP
Senior Member
Benni003  Offline OP
Senior Member

Joined: Aug 2008
Posts: 394
Germany
Hm I hope there is an other possibility... Maybe jcl knows something else? smirk

Page 3 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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