HLSL shader hints

Posted By: jcl

HLSL shader hints - 11/16/04 03:47

I've put some general information about how to use sun light, dynamic lights, and fog in HLSL shaders on the Wiki:

http://www.conitecserver.com/wiki/index.php/ShaderHints
Posted By: Steempipe

Re: HLSL shader hints - 11/16/04 05:30

Thanks. Useful stuff.
Posted By: jcl

Re: HLSL shader hints - 11/16/04 06:15

This is a template script as an example how to do a shader with dynamic lights, using the terrain multitexture shader concept by you and ventilator. It mixes three textures plus a shadow map, according to the red, green, and blue channels of the first terrain skin.

http://server.conitec.net/down/mtlterrainmulti.wdl

A6.31.3 is required for running the script. At the moment the 8 dynamic lights must be set manually by a script or in the shader code. In the next update, the engine will pass the light positions and colors directly to the shaders.

Posted By: Steempipe

Re: HLSL shader hints - 11/16/04 10:22

Runs smooth and fast. Easy to implement.

Thanks.. this is a very good template. Now for the experimenting!


Posted By: Matt_Aufderheide

Re: HLSL shader hints - 11/16/04 11:41

Quote:

In the next update, the engine will pass the light positions and colors directly to the shaders.





is this what i think it is? awsome!!
Posted By: Steempipe

Re: HLSL shader hints - 11/16/04 12:19

Here's _one_ way to modify the code to put light constants in:

Code:

// preset this with light positions (xyz) and ranges (w)
const float4 vecLightPos[8]= {
-327,650,470,400,
-893,607,400,400,
62,703,417,800,
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0};

// preset this with light colors
const float4 vecLightColor[8]= {
1,0,0,1, //Red
0,1,0,1, //Green
0,0,1,1, //Blue
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0};


Posted By: Patrick_Star

Re: HLSL shader hints - 01/07/05 15:05

Quick question. How would you implement fog into this? Currently I've had no luck in getting this to work. TIA.
Posted By: Steempipe

Re: HLSL shader hints - 01/07/05 17:32

There was a brief discussion on fog here:
web page

And you can see it in a complete code here:
web page
Posted By: Patrick_Star

Re: HLSL shader hints - 01/07/05 17:39

Ah many thanks for pointing those posts out. All is working well now.
Posted By: Darkstorm

Re: HLSL shader hints - 01/10/05 15:23

Hey quick question. Any idea why is it that when I try to use mtlSkin instead of entSkin on the sencond and third texture skin I get a strange black "fog" over the HMP? The textures are there but there is almost a fog-of-war thing going on .
Posted By: Darkstorm

Re: HLSL shader hints - 01/12/05 06:23

Anyone have any insight on this? If a screenshot would help let me know and I'll post one.
Posted By: Rhuarc

Re: HLSL shader hints - 01/12/05 06:35

Screenshot would be good, also what GPU this is being rendered on...
Posted By: Darkstorm

Re: HLSL shader hints - 01/12/05 17:39

Okay here's a shot of what I'm talking about:



The code that I added is this:

Code:

bmap grassmap = <grass001.bmp>;
bmap dirtmap = <dirt001.bmp>;

function mtl_terrainmulti3_init()
{
bmap_to_mipmap(mtl.skin2);
bmap_to_mipmap(mtl.skin3);
}


MATERIAL mtl_terrainmulti3
{
skin2 = grassmap;
skin3 = dirtmap;

event = mtl_terrainmulti3_init;

effect = "

........



And I canged the two skins from entSkin to mtlSkin:

Code:

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

sampler sBaseTex = sampler_state
{
Texture = <mtlSkin2>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};

sampler sRedTex = sampler_state
{
Texture = <mtlSkin3>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};

#ifdef GREENMASK
sampler sGreenTex = sampler_state
{
Texture = <entSkin4>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};
#endif



The entSkins are working as they should but the mtlSkins have that blacked out look.
© 2024 lite-C Forums