Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 396 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 9 of 10 1 2 7 8 9 10
Re: use a second uv-set on your models [Re: ventilator] #131564
12/29/07 18:58
12/29/07 18:58
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I have no clue about this business. So, maybe you can help me out?

Re: use a second uv-set on your models [Re: HeelX] #131565
12/29/07 19:07
12/29/07 19:07
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
here is a modification of taco cohen's normal mapping shader. the necessary additions are marked with #####.

Code:
/***********************************************************************************************
/ Copyright 2006 by Taco Cohen. All rights reserved
/***********************************************************************************************/

/***********************************************************************************************
/ Global Variables:
/***********************************************************************************************/
// Tweakables:
static const float AmbientIntensity = 1.1f; // The intensity of the ambient light.
static const float DiffuseIntensity = 1.0f; // The intensity of the diffuse light.
static const float SpecularIntensity = 2.0f; // The intensity of the specular light.
static const float SpecularPower = 14.5f; // The specular power. Used as 'glossyness' factor.
static const float4 SunColor = {0.9f, 0.9f, 0.9f, 1.0f}; // Color vector of the sunlight.

// Application fed data:
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; // Color map.
sampler ColorMapSampler = sampler_state // Color map sampler.
{
Texture = <entSkin1>;
AddressU = Wrap;
AddressV = Wrap;
};

texture entSkin2; // Normal map.
sampler NormalMapSampler = sampler_state // Normal map sampler.
{
Texture = <entSkin2>;
AddressU = Wrap;
AddressV = Wrap;
};

texture mtlSkin1; // ##### light map
sampler LightMapSampler = sampler_state // ##### light map sampler.
{
Texture = <mtlSkin1>;
AddressU = Wrap;
AddressV = Wrap;
};


/***********************************************************************************************
/ Vertex Shader:
/***********************************************************************************************/
void NormalMapVS( in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,
in float2 InTex2 : TEXCOORD1, // ##### second uv-set
in float3 InTangent : TEXCOORD2,

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float2 OutTex2 : TEXCOORD3, // ##### second uv-set
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;

// ##### output second uv-set
OutTex2 = InTex2;

// 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));
}


/***********************************************************************************************
/ Pixel Shader:
/***********************************************************************************************/
float4 NormalMapPS( in float2 InTex : TEXCOORD0,
in float3 InViewDir : TEXCOORD1,
in float3 InSunDir : TEXCOORD2,
in float2 InTex2 : TEXCOORD3) : COLOR // ##### second uv-set
{
// Read the normal from the normal map and convert from [0..1] to [-1..1] range
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);

// ##### fetch the light map color from the light map:
float4 Light = tex2D(LightMapSampler, InTex2);

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

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



Re: use a second uv-set on your models [Re: ventilator] #131566
12/30/07 00:19
12/30/07 00:19
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Thanks! I will check it out!

Re: use a second uv-set on your models [Re: HeelX] #131567
12/30/07 13:16
12/30/07 13:16
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Many thanks! It is really easy to adopt it to other shaders. I took the phong normalmap - shader from the current A7 version and applied it:



One question, though: Now I have got specular areas even in dark areas like that:



I know that this doesn't have to do 100% with your plugin and should be handle in the shader, but is it possible to evaluate the darkness of the shadowmap and return then the _unprocessed_ pixel OR a less lit pixel? (theoretically) and if this is not too complicated or too much performance consuming.. - how would I have to achieve that?

Cheers and many many thanks!
Christian

Re: use a second uv-set on your models [Re: HeelX] #131568
12/30/07 13:36
12/30/07 13:36
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
if you only use one light it can be fixed but i think if you use multiple lights it isn't easily possible to really solve this problem since you would have to know which light cast which shadow to handle specularity correctly. (maybe it would work by encoding the light ids in the alpha channel of the light map somehow but i don't know a light mapper which does this. )

i would experiment with thresholds or something like that. it should at least be possible to make it less noticable.

...
the recent realtime shadow mapping examples by jcl have the same problem if you use multiple lights.

Re: use a second uv-set on your models [Re: ventilator] #131569
01/04/08 11:36
01/04/08 11:36
Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
Machinery_Frank Offline
Senior Expert
Machinery_Frank  Offline
Senior Expert

Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
Great approach! I like it.

I think if the specularity is less bright in the shadow then it will be ok. There can be some specularity as long as the shadow is not completely dark. And if I understand it right then the specularity will also be less bright in the shadow. So it is fine.


Models, Textures and Games from Dexsoft
Re: use a second uv-set on your models [Re: Machinery_Frank] #131570
01/04/08 12:12
01/04/08 12:12
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
I like the combination of shadow and shader as it can be seen in the pics.

Where did you make the shadowmap?
On the terrain it is brighter near the edges of the boxes, what is a bit irritating.

Re: use a second uv-set on your models [Re: Machinery_Frank] #131571
01/04/08 17:27
01/04/08 17:27
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Hi,

I made the meshes, the UV set and the lightmap in Cinema4D, the normalmaps with Crazybump. There are some parameters inside the shader I compiled for this and you can control and produce several "settings" for the shinyness of the normalmapped - surface.

Greetings from Barcelona,
Christian

Re: use a second uv-set on your models [Re: ventilator] #199527
03/30/08 23:30
03/30/08 23:30
Joined: Nov 2006
Posts: 33
A
alfredm Offline
Newbie
alfredm  Offline
Newbie
A

Joined: Nov 2006
Posts: 33
How to buy this plug ?
please give me your price and way to download it

Re: use a second uv-set on your models [Re: alfredm] #322246
05/05/10 15:08
05/05/10 15:08
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
Does anybody have this Plugin on your HDD? Please PM me


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Page 9 of 10 1 2 7 8 9 10

Moderated by  aztec, Blink, HeelX 

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