Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
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
1 registered members (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
remove the cubemap from the template water shader? #182959
02/09/08 17:32
02/09/08 17:32
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline OP
Serious User
ulf  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
hello, as i'm no shader expert, i just want to ask the guru's if its a great effort to take the cubemap reflection out of the template water shader?

this could be useful for gaining diskspace + performance in some cases/games where you dont really see the water from an angle, where you need the scene reflected.
i just reduced the cubemap texture to a very low size, but thats an ugly workaround cause you still have to create the cubemap for the shader to work.
so would it be possible to just use a 64x64 picture of some clouds instead and get away with much less diskspace consumption. (and probably a lot better performance?!?)

this is the template shader i'm talking about, it's using the bumpmap in skin1 of the .hmp model. thanks for any help!

Code:

//enable: Enviroment Fresnel effect
//help: Water transparency depends on view angle
//id: 31
#define ENVIRO_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); };
sampler sCubeTex = sampler_state { Texture = (mtlSkin2); };

struct out_water_env // Output to the pixelshader
{
float4 Pos : POSITION;
float4 Color: COLOR0;
float Fog : FOG;
float2 Tex0 : TEXCOORD0;
float4 TanToCube0: TEXCOORD1;
float4 TanToCube1: TEXCOORD2;
float4 TanToCube2: TEXCOORD3;
};

out_water_env vs_water_env
(
in float4 inPos : POSITION,
in float3 inNormal : NORMAL,
in float2 inTex0 : TEXCOORD0,
in float3 inTangent : TEXCOORD2
)
{
out_water_env 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;

float3x3 ObjToTan;

ObjToTan[0] = vecSkill41.z * inTangent;
ObjToTan[1] = vecSkill41.z * cross(inTangent, inNormal);
ObjToTan[2] = inNormal;

Out.TanToCube0.xyz = mul(ObjToTan,matWorld[0].xyz);
Out.TanToCube1.xyz = mul(ObjToTan,matWorld[1].xyz);
Out.TanToCube2.xyz = mul(ObjToTan,matWorld[2].xyz);

float4 P = DoPos(inPos); // vector world position
float4 vecToView = normalize(vecViewPos-P); // direction towards camera

Out.TanToCube0.w = vecToView.x;
Out.TanToCube1.w = vecToView.y;
Out.TanToCube2.w = vecToView.z;

// color and transparency
Out.Color = vecColor;
#ifdef ENVIRO_FRESNEL
float3 N = DoNormal(inNormal); // normal world orientation
Out.Color.a = 0.5 + vecColor.a * (1.0 - dot(vecToView,N));
#endif
return Out;
}

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

sampler[0] = (sBumpTex);
sampler[3] = (sCubeTex);

VertexShader = compile vs_1_1 vs_water_env();

PixelShader = asm
{
ps_1_1
tex t0 // Normalmap
texm3x3pad t1,t0_bx2 // TanToCube0
texm3x3pad t2,t0_bx2 // TanToCube1
texm3x3vspec t3,t0_bx2 // TanToCube2, lookup in CubeTex
mul r0,v0,t3 // multiply Stage3 Texture by Color + Alpha
};
}
}

technique fallback { pass one { } }



Re: remove the cubemap from the template water shader? [Re: ulf] #182960
03/07/08 04:10
03/07/08 04:10
Joined: Mar 2008
Posts: 3
J
jokerylee Offline
Guest
jokerylee  Offline
Guest
J

Joined: Mar 2008
Posts: 3
hi, there, can you show us a screenshot of the water effect?
thanks in advance

Re: remove the cubemap from the template water sha [Re: jokerylee] #182961
03/07/08 16:38
03/07/08 16:38
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
you won't gain speed if you sample from a 2d texture instead of a cubemap. if disk space is a concern for you, try dds textures.


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