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
Rate Thread
Normal Maps for WED-blocks? #150464
08/27/07 03:37
08/27/07 03:37
Joined: Aug 2005
Posts: 29
Germany, Harz
ratu65 Offline OP
Newbie
ratu65  Offline OP
Newbie

Joined: Aug 2005
Posts: 29
Germany, Harz
I read a lot about NM in 3dgs. Can I use it also for the blocks in WED?
Or must I transform the blocks in entities and put a code to that?
Or is it only for model-skins?
I search in manual, but dont find an answer.

Re: Normal Maps for WED-blocks? [Re: ratu65] #150465
08/27/07 04:04
08/27/07 04:04
Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30"E
Frederick_Lim Offline
User
Frederick_Lim  Offline
User

Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30"E
This thread may help

NVIDIA Shader Library

Re: Normal Maps for WED-blocks? [Re: Frederick_Lim] #150466
08/27/07 09:55
08/27/07 09:55
Joined: Jan 2007
Posts: 651
Germany
R
RedPhoenix Offline
User
RedPhoenix  Offline
User
R

Joined: Jan 2007
Posts: 651
Germany
Quote:

d3d_automaterial
Activates automatic material assignments by material names. This way, default materials can be assigned to individual level textures and entity files, and material effects like bumpmapping and shaders can be assigned to level texures.
Range:
0 no automatic material assignment (default).
1 assign a material to all level textures with the same name.
2 assign a material to all level textures and entity files with the same name ('.' replaced by an underscore '_').

Type:
var, redefine
Remarks:
For assigning a material to a certain texture, define it with the same name as the texture.
For assigning a material to a certain file, define a material that has the same name as the file with the extension preceded by an underscore (like "warlock_mdl" or"brickwall_tga").
Surface texture names are limited to 15 characters.
Levels load faster if this variable is at 0.
Example:
d3d_automaterial = 2;
...
material stonewall { ... } // assigned to all "stonewall" surface textures
material skyblue_tag { ... } // assigned to "skyblue.tga"
material monster_mdl { ... } // assigned to "monster.mdl"





Re: Normal Maps for WED-blocks? [Re: RedPhoenix] #150467
08/28/07 02:06
08/28/07 02:06
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
It can be done but dont bother, the result is bad.. it is extremely slow and the tangents/normals look very bad because of the vertex welding.

WED blocks are obsolete, use models for now.


Sphere Engine--the premier A6 graphics plugin.
Re: Normal Maps for WED-blocks? [Re: Matt_Aufderheide] #150468
09/05/07 17:20
09/05/07 17:20
Joined: Aug 2005
Posts: 29
Germany, Harz
ratu65 Offline OP
Newbie
ratu65  Offline OP
Newbie

Joined: Aug 2005
Posts: 29
Germany, Harz
Thanks for your helps. I will think about that.

d3d_automaterial: I had overlook.

The NVIDIA shader library is too complicated to me honestly said. In any case, still...perhaps.

Re: Normal Map effect for WED blocks [Re: ratu65] #150469
09/06/07 19:52
09/06/07 19:52
Joined: Aug 2007
Posts: 17
S
sCKan Offline
Newbie
sCKan  Offline
Newbie
S

Joined: Aug 2007
Posts: 17
i have modified a effect for apply Normal Map on blocks it is faster compared with other effects

first create a new .fx file for example NormalMap.fx and save it on your proyect root folder

then write this in effect file :

//content of NormalMap.fx
static const float AmbientIntensity = 1.0f; // The intensity of the ambient light.
static const float DiffuseIntensity = 1.0f; // The intensity of the diffuse light.
static const float SpecularIntensity = 1.0f; // The intensity of the specular light.
static const float SpecularPower = 8.0f; // The specular power. Used as 'glossyness' factor.
static const float4 SunColor = {0.9f, 0.9f, 0.5f, 1.0f}; // Color vector of the sunlight.


const float4x4 matWorldViewProj; // World*view*projection matrix.
const float4x4 matWorld; // World matrix.
const float4 vecAmbient; // Ambient color.
const float4 vecSunDir; // The sun direction vector.
const float4 vecViewPos; // View position.

texture entSkin1;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};

texture mtlSkin1; // Normal map.
sampler NormalMapSampler = sampler_state // Normal map sampler.
{
Texture = <mtlSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


void NormalMapVS( in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,
in float3 InTangent : TEXCOORD2,

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutViewDir: TEXCOORD1,
out float3 OutSunDir: TEXCOORD2)
{
// Transform the vertex from object space to clip space:
OutPos = mul(InPos, matWorldViewProj);

// Pass the texture coordinate to the pixel shader:
OutTex = InTex;

// Compute 3x3 matrix to transform from world space to tangent space:
half3x3 worldToTangentSpace;
worldToTangentSpace[0] = mul(InTangent, matWorld);
worldToTangentSpace[1] = mul(cross(InTangent, InNormal), matWorld);
worldToTangentSpace[2] = mul(InNormal, matWorld);

// Calculate the view direction vector in tangent space:
OutViewDir = normalize(mul(worldToTangentSpace, vecViewPos - mul(InPos, matWorld)));

// Calculate the light direction vector in tangent space:
OutSunDir = normalize(mul(worldToTangentSpace, -vecSunDir));
}


float4 NormalMapPS( in float2 InTex : TEXCOORD0,
in float3 InViewDir : TEXCOORD1,
in float3 InSunDir : TEXCOORD2) : COLOR
{

float3 BumpNormal = 2 * tex2D(NormalMapSampler, InTex) - 1;

// Calculate the ambient term:
float4 Ambient = AmbientIntensity * vecAmbient;

// Calculate the diffuse term:
float4 Diffuse = DiffuseIntensity * saturate(dot(InSunDir, BumpNormal));
Diffuse *= SunColor;

// Calculate the reflection vector:
float3 R = normalize(2 * dot(BumpNormal, InSunDir) * BumpNormal - InSunDir);

// Calculate the specular term:
InViewDir = normalize(InViewDir);
float Specular = pow(saturate(dot(R, InViewDir)), SpecularPower) * SpecularIntensity;

// Fetch the pixel color from the color map:
float4 Color = tex2D(ColorMapSampler, InTex);

// Calculate final color:
return (Ambient + Diffuse + Specular) * Color;
}


technique SpecularTechnique
{
pass P0
{
VertexShader = compile vs_2_0 NormalMapVS();
PixelShader = compile ps_2_0 NormalMapPS();
}
}


///////////////////////////////////////////////////////////////
// NOW : in your proyect script file you will need a bitmap


bmap wall_tDOT3 = <wall_tDOT3.tga>;

//NOW : Create a material

material wall_effect //<-- same name that you must asign to wall texture
{
skin1 = wall_tDOT3; //bmap effect
flags = tangent;
}


//now apply shader to blocks
starter load_shaders() // your starter that loads the shader at engine startup
{
d3d_automaterial=1;
wait(1);
effect_load(wall_effect,"NormalMap.fx");
}



//RUN IT AND ENJOY IT
//REMEMBER : USE FLAT FOR WALL TEXTURE


Web Master

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