Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 05:41
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 (AbrahamR, AndrewAMD), 1,278 guests, and 2 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
Getting shader effects working #58116
10/26/05 22:37
10/26/05 22:37
Joined: Sep 2005
Posts: 6
J
josh Offline OP
Newbie
josh  Offline OP
Newbie
J

Joined: Sep 2005
Posts: 6
I'm trying to get shader effects working on a new material called brick039_T. This code is based on a tutorial piece - can anyone tell me why this isn't working? (The texture shows up with no maps)

brick039_T - the standard default brick texture
brick039_H - map1
brick039_N - map2



var video_mode = 8; // screen size 640x480
var video_depth = 32; // 32 bit colour D3D mode

string level_str = <techex.WMB>; // give file names in angular brackets

dllfunction prototype;
dllfunction render_backbuffer(entity);

function main()
{
level_load(level_str);
freeze_mode = 1;
wait(4);
freeze_mode = 0;
screengrab();
}

// Shader Part
var light_dist=700; //this is how far away form a light it will be visible.
action light_pos_object
{
wait(5);
my.invisible=on;
my.passable=on;


my.lightrange=700; //could be set also to a skill


my.red=128; //just put in the r,g,b values
my.green=128;
my.blue=128;

my.cast=on; //casts a shadow when on

}



//******************

bmap env_bmp=<env_map.bmp>;
bmap brick = <brick039_T.tga>;
bmap brickH = <brick039_H.tga>;
bmap brickN = <brick039_N.tga>;

material brick039_T
{

skin2 = brickN;
skin3 = brickH;
flags = tangent;
}


/////////////////////////
// Bloom

material mat_bloom
{

}

entity glow_quad
{
type = <grey.TGA>; //128*128 works best but can be any size
//this entity is always invisible..
}

entity glow_quad_view
{
type = <grey.TGA>;
layer = 2; // display above view entities with layer 1
view = CAMERA; // same camera parameters as the default view
// set the x position according to the texture size..
// x = 36; // for 32
// x = 72; // for 64
x = 145; // for 128
y = 0; //center horzontally
z = 0; // and center vertically
}

function map_glow()
{
me=glow_quad_view;
my.ambient=10;
my.transparent=on;
my.bright=on;
my.alpha=50;
my.visible=on;
my.material=mat_bloom;
my.scale_x=1.33; //this scales it to screen proportions..
while(1)
{
//sets material skin1 to the rendered view tex
mat_bloom.skin1=bmap_for_entity(glow_quad,0);
wait(1);
}
}

function screengrab()
{
wait(20);
me=glow_quad;
map_glow();
while(1)
{
render_backbuffer(me);
wait(1);
}
}

///////////////////
// Toon Shading

// Normaliser cubemap sprite
bmap bmp_normalizationcube=<tsnormalise.tga>;
// Paint shade map for toonshader
bmap bmp_tstonemap=<ts2tone.tga>; // <<< CHANGE THIS TO CHANGE PAINT SHADING

function mat_toon_init
{
bmap_to_cubemap(mtl.skin1);
}

material mat_toon
{
skin1=bmp_normalizationcube; // This is the normalisation cubemap created by the starter function
skin2=bmp_tstonemap;

flags=tangent;

event = mat_toon_init;
}

action Shader_Toon
{
//my.shadow = on;
//my.cast = on;
my.material = mat_toon;
render_shadows();
}

/*******************************************************
softshadows.wdl
(c)2005 Matt Aufderheide
*******************************************************/

string my_file;
string empty="";
string sourcefile;
entity* temp_ent;
var VecTo[3];
var VecFrom[3];

//change this for different LOD versions..
//here I am using the LOD 0 file ..
//however if you want, you can change it 1,2,3 to always have a
//low res model as your shadow..however it seems to work fine this way if you have LODs
//if you dont have LOD change this string to simply ".mdl"
string control_file="e.mdl";

//i have included this tga file
bmap softshadow_bmap = <shadow_color.tga>;

material mat_softshadows{}

//flatten the shadow to the ground normals
function shadow_to_normal()
{

temp_ent = YOU;

trace_mode = IGNORE_PASSENTS+ IGNORE_ME+ IGNORE_YOU+ IGNORE_MODELS;
vec_set(vecFrom,YOU.X);
vec_set(vecTo,vecFrom);
vecTo.Z -= 500;
result = trace(vecFrom,vecTo);

YOU = temp_ent; // YOU (the entity itself) is changed by SONAR

if(result > 0)
{
// place shadow 2 quants above the floor
MY.z = YOU.z - RESULT + 2; //YOUR.min_z*/ + 2 - RESULT;
MY.x = YOU.x;
MY.y = YOU.y;

// adapt shadow orientation to floor slope
if ((NORMAL.x != 0) || (NORMAL.y != 0))
{ // we're on a slope
// conform shadow to slope
MY.PAN = 0;
MY.tilt = - asin(NORMAL.x);
MY.roll = - asin(NORMAL.y);
temp.pan = YOU.PAN;
temp.tilt = 0;
temp.roll = 0;
rotate(my,temp,nullvector);
}
else
{
MY.pan = YOU.pan;
MY.tilt = 0; // set it flat onto the floor
MY.roll = 0;
}
}


}


//this function controls the far disnace you can see shadow
function shadow_vis()
{
while(me)
{
if (vec_dist(my.x,camera.x) > 1000) //adjust this dist here
{
my.invisible=on;
}

else

{
my.invisible=off;
}

wait(10+(random(5)));
}

}

//animate and move the shadow mesh
function shadow_mesh()
{
my.scale_x=your.scale_x;
my.scale_y=your.scale_y;
my.scale_z=your.scale_z;
my.scale_z*=0.01;

my.passable=on;
my.push=-1;

my.ambient=0;
my.transparent=on;
my.flare=on;
my.passable=on;
my.push=-1;

shadow_vis();

my.material=mat_softshadows;
mat_softshadows.skin1=softshadow_bmap;

my.skill41=float(0.4); // adjust this to increase blurriness..

while(me)
{

if you!=null
{
my.frame=your.frame;
my.next_frame=your.next_frame;
shadow_to_normal();
}

if you==null
{
ent_remove(me);
}

wait(1);
}

}

function render_shadows()
{
str_cpy(my_file,empty);
str_for_entfile (sourcefile, me);
str_trunc(sourcefile,5);
str_cpy(my_file,sourcefile);
str_cat(my_file,control_file);
ent_create(my_file,my.x,shadow_mesh);
}


///////////////////////
// Load Shaders

starter load_shaders()
{
d3d_automaterial=1;
effect_load(mat_bloom,"bloom.fx");
effect_load(mat_toon,"toon.fx");
effect_load(mat_softshadows,"softshadow.fx");
effect_load(brick039_T,"parallex.fx");
}

Last edited by josh; 10/27/05 00:41.
Re: Getting shader effects working [Re: josh] #58117
10/29/05 16:22
10/29/05 16:22
Joined: Sep 2005
Posts: 357
Florida
Hellcrypt Offline
Senior Member
Hellcrypt  Offline
Senior Member

Joined: Sep 2005
Posts: 357
Florida
Does it crash the game? What errors does it give? Also are the images in your folder?


I do not solve problems.... I prevent them.
Re: Getting shader effects working [Re: Hellcrypt] #58118
10/31/05 09:59
10/31/05 09:59
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
From what I can guess from the material name you provided, it seems to me you want to apply the shader to level geometry. In this case, did you make sure the surfaces the shader should be used on were set to flat shading? With "shaded" mode, these effects usually do not work. Hope that helps...


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: Getting shader effects working [Re: josh] #58119
10/31/05 17:25
10/31/05 17:25
Joined: May 2002
Posts: 66
CH
M
maximo Offline
Junior Member
maximo  Offline
Junior Member
M

Joined: May 2002
Posts: 66
CH
Hi,
maybe have you miss to call "load_shaders();" after level load.
Hope this help you.
Cheers,Maximo


maximo
Re: Getting shader effects working [Re: maximo] #58120
11/01/05 22:22
11/01/05 22:22
Joined: Sep 2005
Posts: 6
J
josh Offline OP
Newbie
josh  Offline OP
Newbie
J

Joined: Sep 2005
Posts: 6
Quote:


Does it crash the game? What errors does it give? Also are the images in your folder?






it gives no errors and doesn't crash. However it just shows the standard flat texture with no bumps applied.

Quote:

From what I can guess from the material name you provided, it seems to me you want to apply the shader to level geometry. In this case, did you make sure the surfaces the shader should be used on were set to flat shading? With "shaded" mode, these effects usually do not work. Hope that helps...





Yes, the texture is set to 'flat' in the settings.

Quote:

Hi,
maybe have you miss to call "load_shaders();" after level load.
Hope this help you.




I have tried this, it makes no noticeable difference (still a flat texture).

Thanks for the help thus far, does anyone have any other suggestions?


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