Gamestudio Links
Zorro Links
Newest Posts
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
2 registered members (AndrewAMD, Ayumi), 1,405 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 3 of 4 1 2 3 4
Re: SoilFog [Re: Rhuarc] #56181
09/28/05 17:41
09/28/05 17:41
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
i just want it on one texture. i simply get no "volume" in it.

i tried a box, too, with all sides textured with the special texture/material. still doesn´t work.
please help!

Re: SoilFog [Re: broozar] #56182
09/28/05 17:52
09/28/05 17:52
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline OP
Developer
Rigoletto  Offline OP
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt
Have you changed the values too much?

The foor and the walls around you are minimum to see the shader effect, perhaps you can mix it with the normal fog, i have it not tested yet.

Re: SoilFog [Re: Rigoletto] #56183
09/28/05 18:01
09/28/05 18:01
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
ummm... i didn´t change any value, perhaps that´s the problem...

what´s to change?

Re: SoilFog [Re: broozar] #56184
09/29/05 10:47
09/29/05 10:47
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline OP
Developer
Rigoletto  Offline OP
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt
If your level very different scaled, change the min. fog value higher. But think you must have a wall or something similar applied with this shader to see the fog correct.

Re: SoilFog [Re: Rigoletto] #56185
09/29/05 16:09
09/29/05 16:09
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
very well, that solves it all
thx a lot

Re: SoilFog [Re: Rigoletto] #56186
09/29/05 19:29
09/29/05 19:29
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline OP
Developer
Rigoletto  Offline OP
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt


If tried to add some noise to the fog, but i can´t. I think the resolution of the vertexshader is to low. It´s a job for pixelshader, or not? Is there a solution for this problem?

Re: SoilFog [Re: Rigoletto] #56187
10/11/05 19:47
10/11/05 19:47
Joined: Mar 2005
Posts: 442
Germany, Hamburg
Blitzblaster1 Offline
Senior Member
Blitzblaster1  Offline
Senior Member

Joined: Mar 2005
Posts: 442
Germany, Hamburg
Hi !

Thanks for the fog code. Nice work ! I need it you my game Snap the Pac.

Regards
Blitzblaster1


Casual Games: www.playsmallgames.de
Re: SoilFog [Re: Blitzblaster1] #56188
11/01/05 13:47
11/01/05 13:47
Joined: Apr 2005
Posts: 18
GeishaG Offline
Newbie
GeishaG  Offline
Newbie

Joined: Apr 2005
Posts: 18
Thanks for adding this Rigoletto. I have added this code to your shader tutorial from the wiki. Here is the resulting code exactly:

Code:

////////////////////////////////////////////////////////////////////////
// A6 main wdl:
// Created by WED.
////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
// The PATH keyword gives directories where template files can be found.
path "c:\\program files\\GSTUDIO6\\template_6"; // Path to A6 templates directory
path "c:\\program files\\GSTUDIO6\\template_6\\code"; // Path to A6 template code subdirectory
path "c:\\program files\\GSTUDIO6\\template_6\\images"; // Path to A6 template image subdirectory
path "c:\\program files\\GSTUDIO6\\template_6\\sounds"; // Path to A6 template sound subdirectory
path "c:\\program files\\GSTUDIO6\\template_6\\models"; // Path to A6 template model subdirectory

/////////////////////////////////////////////////////////////////
// Filename of the starting level.
string level_str = <pst1.WMB>; // give file names in angular brackets

////////////////////////////////////////////////////////////////////////////
// Included files
include <gid01.wdl>; // global ids
include <display00.wdl>; // basic display settings

bmap alphamap = <alpha.tga>;
bmap effectmap = <grass.tga>;

material stone_tga
{
// Define your bitmaps as skins
skin1 = alphamap;
skin2 = effectmap;

effect
"
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Define your needed values
float4x4 matWorldViewProj; //
float4x4 matWorldView; //
float4x4 matWorld; // entity position/direction
float4 vecFog; // fog parameters
float4 vecViewPos; //
float4 vecTime; //

// Define your textures
texture entSkin1; // level texture
texture entSkin2; // shadow texture
texture mtlSkin1; // alpha texture
texture mtlSkin2; // effect texture

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Texture settings
sampler sBase = sampler_state // level texture
{
Texture = <entSkin1>; // Give your texture here
MipFilter = Linear; // None | Point | Linear | Anisotropic | PyramidalQuad | GaussianQuad
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap; // Wrap | Mirror | Clamp | Border | MirrorOnce
AddressV = Wrap;
AddressW = Wrap;
BorderColor = {255, 0, 0, 0}; // Color for AddressUVW with Border
};

sampler sShadow = sampler_state // shadow texture
{
Texture = <entSkin2>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};

sampler sAlpha = sampler_state // alpha texture
{
Texture = <mtlSkin1>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};

sampler sGrass = sampler_state // grass texture
{
Texture = <mtlSkin2>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Input and output structs
//
// Possible input values for vertexshader
//
// POSITION[n] position
// BLENDWEIGHT[n] blend weights
// BLENDINDICES[n] blend indices
// NORMAL[n] normal vector
// PSIZE[n] point size
// COLOR[n] diffuse and specular color
// TEXCOORD[n] texture coordinates
// TANGENT[n] tangent
// BINORMAL[n] binormal
// TESSFACTOR[n] tessellation factor
//
// Possible output values for vertexshader
//
// POSITION Position
// PSIZE Point size
// FOG Vertex fog
// COLOR[n] Color (example: COLOR0)
// TEXCOORD[n] Texture coordinates (example: TEXCOORD0)
//
//
// Possible input values for pixelshader
//
// COLOR[n] diffuse and specular color
// TEXCOORD[n] texture coordinates
//
// Possible output values for pixelshader
//
// COLOR[n] diffuse and specular color
// TEXCOORD[n] texture coordinates
// DEPTH[n] Depth (example: DEPTH0)
//

// Define the input of your vertexshader
struct VS_IN
{
float4 Pos : POSITION;
float2 Shadow : TEXCOORD0;
float2 Base : TEXCOORD1;
float2 Alpha : TEXCOORD2;
float2 Grass : TEXCOORD3;
};

// Define the output of your vertexshader
struct VS_OUT
{
float4 Pos : POSITION;
float2 Shadow : TEXCOORD0; // Shadow is binded to TEXCOORD0, so it get transported to the pixelshader
float2 Base : TEXCOORD1;
float2 Alpha : TEXCOORD2;
float2 Grass : TEXCOORD3;
float Fog : FOG;
};

// Define the input for your pixelshader
struct PS_IN
{
float2 Shadow : TEXCOORD0; // The ouput of the vertexshader is given through TEXCOORD0
float2 Base : TEXCOORD1;
float2 Alpha : TEXCOORD2;
float2 Grass : TEXCOORD3;
};

// Define the output for your pixelshader
struct PS_OUT
{
float4 Color : COLOR; // We only give a color value back
};

//////////////////////////////////////////////////////////////////////////////////////////////////////
// functions
float4 sfInvert( float4 value )
{
return 1 - value;
}

float4 sfNegate( float4 value )
{
return - value;
}

float4 sfSepia( float4 value )
{
float4 vGrey = float4( 0.3, 0.59, 0.11, 0 );
float4 vSepia = float4( 0.9, 0.70, 0.30, 1 );
return dot( value, vGrey) * vSepia;
}

float4 sfGrey( float4 value )
{
float4 vBW = float4( 0.3, 0.59, 0.11, 0 );
return dot( value, vBW);
}

float4 sfBlackWhite( float4 value, float level) // PS 1.4
{
float4 vBW = float4( 0.3, 0.59, 0.11, 0 );
value = dot( value, vBW );
value = 1 - step( value, level );
return value;
}

float4 sfPosterize( float4 value, float level ) // PS 1.4
{
if ( value.r < level ) value.r = 0; else value.r *= 1.0f;
if ( value.g < level ) value.g = 0; else value.g *= 1.0f;
if ( value.b < level ) value.b = 0; else value.b *= 1.0f;
return value;
}

float AddFog(float3 Pos)
{
float value;
float3 P = mul( Pos, matWorld );
value = 1 - ( distance( P, vecViewPos ) - vecFog.x ) * vecFog.z;
return value;
}

float _AddSoilFog(float3 Pos)
{
float value;
float3 P = mul( Pos, matWorld );
value = 1 - ( distance( P, vecViewPos ) - vecFog.x ) * vecFog.z;
//value = value + ( P.y / 60 ) * (1 - ( distance( P, vecViewPos ) - vecFog.x ) * vecFog.z) / 16;
value = value + ( P.y / 60 );
return value;
}

float AddSoilFog(float3 Pos)
{
float value;
float low;
float high;
float3 P = mul( Pos, matWorld );
high = 1 - ( distance( P, vecViewPos ) - vecFog.x ) * vecFog.z;
low = ( P.y / 30 ); // min. low fog
value = lerp( high, low, 0.2); // mixing high and low fog
return value;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// vertexshader
VS_OUT vs( VS_IN In )
{
VS_OUT Out = ( VS_OUT ) 0; // Declare your output

Out.Pos = mul( In.Pos, matWorldViewProj ); // Transform the ouput to the view

Out.Shadow = In.Shadow; // Get the shadow texture for the current position
Out.Base = In.Base; // Get the level texture for the current position
Out.Alpha = In.Base; // Cause alpha/grass texture have no current positions (they ar not applied to level geo)
Out.Grass = In.Base; // we use the positions of the level texture

Out.Alpha.y = In.Base.y - 0.5; // Shift the alpha to the bottom

Out.Fog = AddSoilFog( In.Pos );

return Out;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// pixelshader
PS_OUT ps( PS_IN In )
{
PS_OUT Out = ( PS_OUT ) 0; // Declare your output

float4 color; // Declare your needed variables
float4 shadow;
float4 alpha;
float4 grass;

color = tex2D( sBase, In.Base.xy ); // Get color of the texture sBase at the position In.Base.xy
shadow = tex2D( sShadow, In.Shadow.xy ); // ..
alpha = tex2D( sAlpha, In.Alpha.xy ); // ..
grass = tex2D( sGrass, In.Grass.xy ); // ..

color = lerp( color, grass, alpha); // Interpolates between color and grass via alpha
color = color * shadow; // and apply the shadow

Out.Color = color; // Write the output
return Out; // and give it back

// For more functions like tex2D or lerp take a look at
// [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/highlevellanguageshaders/intrinsicfunctions/intrinsicfunctions.asp]http://msdn.microsoft.com/library/defaul...icfunctions.asp[/url]
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//
technique test
{
// Define your passes
pass p0
{
// Compile your shaders
VertexShader = compile vs_1_0 vs();
PixelShader = compile ps_1_0 ps();
}
}
";
}


/////////////////////////////////////////////////////////////////
// Desc: The main() function is started at game start
function main()
{
d3d_automaterial = 1;

// set some common flags and variables
// freeze all entity functions
freeze_mode = 1;
// no level has been loaded yet...
gid01_level_state = gid01_level_not_loaded;

// entry: Warning Level (0,1, or 2)
// entry_help: Sets sensitivity to warnings (0 = none, 1 = some, 2 = all).
warn_level = 2; // announce bad texture sizes and bad wdl code


// entry: Starting Mouse Mode (0, 1, or 2)
mouse_mode = 0;

// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// now load the level
level_load(level_str);

wait(2); // let level load
// level should be loaded at this point...
gid01_level_state = gid01_level_loaded;

//+++ load starting values

freeze_mode = 0;

// main game loop
while(1)
{
if(gid01_level_state != gid01_level_loaded)
{
freeze_mode = 1; // pause the game
while(gid01_level_state != gid01_level_loaded) { wait(1); }
freeze_mode = 0; // resume the game
}
wait(1);
}

}


// Desc: this is the function used to restart the game.
function main_restart_game()
{
// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// now load the level
level_load(level_str);
// freeze the game
freeze_mode = 1;

wait(2); // 1-level loads, 2-entities load

//+++ load starting values

// un-freeze the game
freeze_mode = 0;
}


// Desc: this is the function used to quit the game.
function main_quit()
{
//+++ // save global skills & strings
exit;
}

/////////////////////////////////////////////////////////////////
// The following definitions are for the pro edition window composer
// to define the start and exit window of the application.
WINDOW WINSTART
{
TITLE "3D GameStudio";
SIZE 480,320;
MODE IMAGE; //STANDARD;
BG_COLOR RGB(240,240,240);
FRAME FTYP1,0,0,480,320;
// BUTTON BUTTON_START,SYS_DEFAULT,"Start",400,288,72,24;
BUTTON BUTTON_QUIT,SYS_DEFAULT,"Abort",400,288,72,24;
TEXT_STDOUT "Arial",RGB(0,0,0),10,10,460,280;
}

/* no exit window at all..
WINDOW WINEND
{
TITLE "Finished";
SIZE 540,320;
MODE STANDARD;
BG_COLOR RGB(0,0,0);
TEXT_STDOUT "",RGB(255,40,40),10,20,520,270;

SET FONT "",RGB(0,255,255);
TEXT "Any key to exit",10,270;
}*/


/////////////////////////////////////////////////////////////////
//INCLUDE <debug.wdl>;



The only problem is no fog is showing up when I run the level:

There is no fog

My graphics card is Radeon 9800.

Anyone have any ideas what my problem is?

Last edited by GeishaG; 11/01/05 13:51.
Re: SoilFog [Re: GeishaG] #56189
11/01/05 19:41
11/01/05 19:41
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline OP
Developer
Rigoletto  Offline OP
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt
You must activate the fog.

Code:
 
fog_color = 1;
camera.fog_start = 0.0 * camera.clip_near;
camera.fog_end = 0.2 * camera.clip_far;



Re: SoilFog [Re: Rigoletto] #56190
11/02/05 12:37
11/02/05 12:37
Joined: Apr 2005
Posts: 18
GeishaG Offline
Newbie
GeishaG  Offline
Newbie

Joined: Apr 2005
Posts: 18
Rigoletto - thanks for getting back to me! I added those lines to the main, and
as you can see the screenshot looks different (darker) - however it still
doesn't look like yours. Was the main (after the level load) the right place to
add it? Is there any thing else you can think of that I need to add?



Last edited by GeishaG; 11/02/05 12:39.
Page 3 of 4 1 2 3 4

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