Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, ozgur, AbrahamR, wdlmaster), 849 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem with using water shader in 16:9? #219351
08/02/08 10:40
08/02/08 10:40
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline OP
User
cro_games  Offline OP
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
I have problem with using water shader in 16:9 resolution because view.aspect is being change..

I use this code to change resolution to 16:9:
Code:
function set_resolution(res_,wide_,_depth,_window)
{
	var new_ratio;
	var x_;
	var y_;
	var view_aspect;
	if (res_ == 0) { video_set(0,0,_depth, _window); return; }
	if (wide_ == 0 || _window == 2)
	{
		if (res_ == 1)
		{
			x_ = 640;
			y_ = 480;
		}
		if (res_ == 2)
		{
			x_ = 800;
			y_ = 600;
		}
		if (res_ == 3)
		{
			x_ = 1024;
			y_ = 768;
		}
		if (res_ == 4)
		{
			x_ = 1280;
			y_ = 960;
		}
		if (res_ == 5)
		{
			x_ = 1280;
			y_ = 1024;
		}
		if (res_ == 6)
		{
			x_ = 1400;
			y_ = 1050;
		}
		if (res_ == 7)
		{
			x_ = 1600;
			y_ = 1200;
		}
	}
	else
	{
		if (wide_ == 1)
		{
			if (res_ == 1)
			{
				x_ = 848;
				y_ = 480;
			}
			if (res_ == 2)
			{
				x_ = 960;
				y_ = 600;
			}
			if (res_ == 3)
			{
				x_ = 1088;
				y_ = 612;
			}
			if (res_ == 4)
			{
				x_ = 1280;
				y_ = 720;
			}
			if (res_ == 5)
			{
				x_ = 1360;
				y_ = 768;
			}
			if (res_ == 6)
			{
				x_ = 1600;
				y_ = 900;
			}
			if (res_ == 7)
			{
				x_ = 1920;
				y_ = 1080;
			}
				if (res_ == 8)//moja
			{
				x_ = 1440;
				y_ = 900;
			}
		}
		if (wide_ == 2)
		{
			if (res_ == 1)
			{
				x_ = 640;
				y_ = 400;
			}
			if (res_ == 2)
			{
				x_ = 960;
				y_ = 600;
			}
			if (res_ == 3)
			{
				x_ = 1280;
				y_ = 768;
			}
			if (res_ == 4)
			{
				x_ = 1280;
				y_ = 800;
			}
			if (res_ == 5)
			{
				x_ = 1600;
				y_ = 1024;
			}
			if (res_ == 6)
			{
				x_ = 1680;
				y_ = 1050;
			}
			if (res_ == 7)
			{
				x_ = 1920;
				y_ = 1200;
			}
		}
	}
	video_set(x_, y_, _depth, _window);
	wait(1);
	new_ratio = x_ / y_;
	view_aspect = new_ratio / (4/3);
	camera.aspect = view_aspect;
}


And this water shader from temp_FX.wdl:

Code:
MATERIAL mtl_water_mirror
{
	effect=
	"
//enable: Mirror Fresnel effect
//help: Water transparency depends on view angle
//id: 21
#define MIRROR_FRESNEL

	#include <transform>
	#include <fog>
	#include <pos>
	#include <normal>
	
	float4 vecTime;
	float4 vecSkill41; // Wind_X, Wind_Y, Ripple, Scale
	float4 vecColor;	

	texture entSkin1;
	texture mtlSkin2;

	sampler sBumpTex = sampler_state
	{
		Texture = <entSkin1>;
		MipFilter = Linear;
		MinFilter = Linear;
		MagFilter = Linear;
		AddressU = Wrap;
		Addressv = Wrap;
	};

	sampler sMirrorTex = sampler_state
	{
		Texture = <mtlSkin2>;
		MipFilter = Linear;
		MinFilter = Linear;
		MagFilter = Linear;
		AddressU = Clamp;
		Addressv = Clamp;
	};


	struct out_water_mirror // Output to the pixelshader fragment
	{
		float4 Pos	: POSITION;
		float4 Color: COLOR0;
		float  Fog	: FOG;
		float2 Tex0	: TEXCOORD0;
		float2 Tex1	: TEXCOORD1;
	};

	out_water_mirror vs_water_mirror
	(
		in float4 inPos		: POSITION,
		in float3 inNormal	: NORMAL,
		in float4 inTex0	: TEXCOORD0
	)
	{
		out_water_mirror Out;
		
		Out.Pos = DoTransform(inPos); // transform to screen coordinates
		Out.Fog = DoFog(inPos);

// bump and reflection coordinates
		Out.Tex0 = (inTex0 + vecSkill41.xy * vecTime.w ) * vecSkill41.w;
		Out.Tex1 = 0.5 * (1.0 + (Out.Pos/Out.Pos.w));

// color and transparency
		Out.Color = vecColor;
#ifdef MIRROR_FRESNEL
		float4 P = DoPos(inPos); // vector world position
		float3 N = DoNormal(inNormal); // normal world orientation
		float4 vecToView = normalize(vecViewPos-P); // direction towards camera
		Out.Color.a = 0.5 + vecColor.a * (1.0 - dot(vecToView,N));
#endif		
		return Out;
	}
	
#ifdef WONTWORK
	float4 ps_mirror_straight(out_water_mirror In): COLOR
	{
		return tex2D(sMirrorTex,In.Tex1) * In.Color;
	}
	
	float4 ps_water_mirror(out_water_mirror In): COLOR
	{
		float4 Bump = tex2D(sBumpTex,In.Tex0);
		float2 Coord = In.Tex1 + Bump.xy * vecSkill41.z;
		return tex2D(sMirrorTex,Coord) * In.Color;
	}
#endif

//////////////////////////////////////////////////////////////////
	technique water_mirror
	{
		pass one
		{
			AlphaBlendEnable = True;

			sampler[0] = (sBumpTex);
			sampler[1] = (sMirrorTex);

			VertexShader = compile vs_1_1 vs_water_mirror();

// bump matrix - required for texbem
			BumpEnvMat00[1] = (vecSkill41.z);
			BumpEnvMat11[1] = (vecSkill41.z);
			BumpEnvMat01[1] = 0.0;
			BumpEnvMat10[1] = 0.0;

// We need an asm shader here - for some reason,
// ps_1_1 HLSL tex2D won't sample modified coordinates
			PixelShader = asm
			{
				ps_1_1
				tex t0         // sample Stage0 Texture rg 
				texbem t1,t0   // multiply rg with BumpEnvMat to uv, 
							   // and sample Stage1 Texture using uv+t1
				mul r0,v0,t1   // multiply Stage1 Texture by Color + Alpha
			};
		}
	}

	technique fallback { pass one { } }
	";
}


Can anyone make this shader work in 16:9?

Last edited by cro_games; 08/02/08 10:42.

Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)
Re: problem with using water shader in 16:9? [Re: cro_games] #219439
08/02/08 16:13
08/02/08 16:13
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
you have to change the arc of the mirrow view to the arc of the camera and it should work

Re: problem with using water shader in 16:9? [Re: Scorpion] #219460
08/02/08 17:42
08/02/08 17:42
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline OP
User
cro_games  Offline OP
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
How to do that?

Last edited by cro_games; 08/02/08 17:43.

Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)
Re: problem with using water shader in 16:9? [Re: cro_games] #219472
08/02/08 18:26
08/02/08 18:26
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
view.arc += 10;
or
view.arc -= 10;


3333333333
Re: problem with using water shader in 16:9? [Re: Quad] #219477
08/02/08 18:46
08/02/08 18:46
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
or
water_view.aspect = camera.aspect;
:P

Last edited by Slin; 08/02/08 18:53. Reason: changed arc to aspect :P
Re: problem with using water shader in 16:9? [Re: Slin] #219479
08/02/08 18:48
08/02/08 18:48
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
I'm sorry I ment aspekt...it's aspekt I'm sure

You can also calculate it direct by the screen resolution
Code:
reflectView.aspect = screen_size.x/screen_size.y;


PS: I'm not sure what the name of the reflection view was...i think it was something with mirror

Last edited by Scorpion; 08/02/08 18:50.
Re: problem with using water shader in 16:9? [Re: Scorpion] #219499
08/02/08 21:02
08/02/08 21:02
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline OP
User
cro_games  Offline OP
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
Thanks,but all of you are wrong..
I have find solution by my self:

Code:
view_mirror.aspect = (screen_size.x/screen_size.y)*camera.aspect;



Last edited by cro_games; 08/02/08 21:05.

Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)
Re: problem with using water shader in 16:9? [Re: cro_games] #219758
08/04/08 12:42
08/04/08 12:42
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
that doesn't make sense to me...can you or someone else explain it to me? the aspect is just the relation of x and y. so what is the camera aspekt is doing here?


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