Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (AndrewAMD, Quad, soulman3, Ayumi), 675 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Loading skins in real time #121181
04/03/07 12:05
04/03/07 12:05
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline OP
Serious User
JetpackMonkey  Offline OP
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco
Hi everybody,

I have been trying to figure out a way to make my game load some models' entSkins1 and 2, in order to use normal maps, when the game starts. This way I do not have to go and open a million models in MED and individually do it each time. So far I have not found a way to change entSkins 1 & 2 with C-Script.

I ask because my levels are made of hundreds of MDL objects, and are generated not by MED but ventilator's objSplitter directly from my 3D modelling tool, which I believe only supports one texutre per model.

Can anyone tell me how to do this?

merci!

JPM

Re: Loading skins in real time [Re: JetpackMonkey] #121182
04/03/07 12:47
04/03/07 12:47
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
well i can modify your script to use mtlskins instead of entskins and you can just use bmaps

Re: Loading skins in real time [Re: JetpackMonkey] #121183
04/03/07 12:51
04/03/07 12:51
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I asked the same thing JCL 3 weeks or so ago and he promised to implement it soon.

[EDIT]

here is the link:
http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/727194/an/0/page/3#Post727194

Last edited by HeelX; 04/03/07 12:52.
Re: Loading skins in real time [Re: lostclimate] #121184
04/03/07 18:25
04/03/07 18:25
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline OP
Serious User
JetpackMonkey  Offline OP
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco
Quote:

well i can modify your script to use mtlskins instead of entskins and you can just use bmaps




Thanks for the link HeelX, that would be a teriffic feature. I am kind of surprised it isn't already implemented.

Lostclimate, wow is that difficult to modify? I just want a simple normalmapping shader that can do that... do you know of one out there for this?

Thanks for the tips!
JPM

Re: Loading skins in real time [Re: JetpackMonkey] #121185
04/03/07 20:42
04/03/07 20:42
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
well upload your current normal mapping shader, and i can modify it for you in 1 minute. its really a very simple process

Re: Loading skins in real time [Re: lostclimate] #121186
04/03/07 21:13
04/03/07 21:13
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline OP
Serious User
JetpackMonkey  Offline OP
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco
Oot thanks lostclimate, how about just using Bloodline's enhanced version of Matt's normal map shader? I'm new to normal map shaders, so if there is something that would be faster/lighter, I am open to recommendations. I really just want to put em into my game and see what it looks like and what kind of performance hit it would be. Thanks a ton!

JPM
Code:

// -------------------------------------------------------------
// Diffuse and specular shader for models
// -------------------------------------------------------------
// [18/3/06 Bloodline] - Added ambient and a 3rd light


float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecLightPos[8]; //light position
float4 vecLightColor[8]; //light color
float4 vecViewPos;

// Change ambient here
float4 Ambient = { 0.6f, 0.6f, 0.6f, 1.0f };

texture entSkin1; //this is the color map
texture entSkin2; //this is the normal map

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


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




///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//first pass
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------
// Output channels
// -------------------------------------------------------------
struct VS_OUTPUT0
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;

float3 Light1 : TEXCOORD2;
float3 View1 : TEXCOORD3;
float3 Att1 : TEXCOORD4;

float3 Light2 : TEXCOORD5;
float3 View2 : TEXCOORD6;
float3 Att2 : TEXCOORD7;

float3 Light3 : TEXCOORD8;
float3 View3 : TEXCOORD9;
float3 Att3 : TEXCOORD10;

};

// -------------------------------------------------------------
// vertex shader function (input channels)
// -------------------------------------------------------------
VS_OUTPUT0 VS_PASS0(float4 Pos : POSITION, float2 texcoord0 : TEXCOORD0, float3 Normal : NORMAL, float3 Tangent : TEXCOORD2 )
{
VS_OUTPUT0 Out = (VS_OUTPUT0)0;
Out.Pos = mul(Pos, matWorldViewProj); // transform Position

// compute the 3x3 tranform matrix
// to transform from world space to tangent space
float3x3 worldToTangentSpace;
worldToTangentSpace[0] = mul(Tangent, matWorld);
worldToTangentSpace[1] = mul(cross(Tangent, Normal), matWorld);
worldToTangentSpace[2] = mul(Normal, matWorld);

Out.Tex = texcoord0.xy;

float3 PosWorld = mul(Pos, matWorld);

float LightRange = 1/vecLightPos[0].w;
float LightRange2 = 1/vecLightPos[1].w;
float LightRange3 = 1/vecLightPos[2].w;

//light 1
float3 Light1 = PosWorld - vecLightPos[0] ;
Out.Light1.xyz = mul(worldToTangentSpace, -Light1); // L

float3 Viewer1 = PosWorld - vecViewPos;
Out.View1 = mul(worldToTangentSpace, -Viewer1); // V

Out.Att1 = Light1 * LightRange; // Point light

//light 2
float3 Light2 = PosWorld - vecLightPos[1] ;
Out.Light2.xyz = mul(worldToTangentSpace, -Light2); // L

float3 Viewer2 = PosWorld - vecViewPos;
Out.View2 = mul(worldToTangentSpace, -Viewer2); // V

Out.Att2 = Light2 * LightRange2; // Point light

//light 3
float3 Light3 = PosWorld - vecLightPos[2] ;
Out.Light3.xyz = mul(worldToTangentSpace, -Light3); // L

float3 Viewer3 = PosWorld - vecViewPos;
Out.View3 = mul(worldToTangentSpace, -Viewer3); // V

Out.Att3 = Light3 * LightRange3; // Point light

return Out;
}


struct PS_INPUT0
{
float2 Tex : TEXCOORD0;

float3 Light1 : TEXCOORD2;
float3 View1 : TEXCOORD3;
float3 Att1 : TEXCOORD4;

float3 Light2 : TEXCOORD5;
float3 View2 : TEXCOORD6;
float3 Att2 : TEXCOORD7;

float3 Light3 : TEXCOORD8;
float3 View3 : TEXCOORD9;
float3 Att3 : TEXCOORD10;

};

float4 PS_PASS0( PS_INPUT0 psInStruct ):COLOR


{

float4 color = tex2D(sColorMap, psInStruct.Tex); // fetch color map
float3 bumpNormal = 2 * (tex2D(sBumpMap, psInStruct.Tex) - 0.5); // fetch bump map
float4 gloss = tex2D( sBumpMap, psInStruct.Tex );

//light1
float3 LightDir1 = normalize(psInStruct.Light1);
float3 ViewDir1 = normalize(psInStruct.View1);
float4 diff1 = saturate(dot(bumpNormal, LightDir1)); // diffuse component
float shadow1 = saturate(4 * diff1);
float3 Reflect1 = normalize(2 * diff1 * bumpNormal - LightDir1); // R
float4 spec1 = pow(saturate(dot(Reflect1, ViewDir1)), 15);
float4 Attenuation1 = saturate(dot(psInStruct.Att1, psInStruct.Att1));

//light2
float3 LightDir2 = normalize(psInStruct.Light2);
float3 ViewDir2 = normalize(psInStruct.View2);
float4 diff2 = saturate(dot(bumpNormal, LightDir2)); // diffuse component
float shadow2 = saturate(4 * diff2);
float3 Reflect2 = normalize(2 * diff2 * bumpNormal - LightDir2); // R
float4 spec2 = pow(saturate(dot(Reflect2, ViewDir2)), 15);
float4 Attenuation2 = saturate(dot(psInStruct.Att2, psInStruct.Att2));

//light3
float3 LightDir3 = normalize(psInStruct.Light3);
float3 ViewDir3 = normalize(psInStruct.View3);
float4 diff3 = saturate(dot(bumpNormal, LightDir3)); // diffuse component
float shadow3 = saturate(4 * diff3);
float3 Reflect3 = normalize(2 * diff3 * bumpNormal - LightDir3); // R
float4 spec3 = pow(saturate(dot(Reflect3, ViewDir3)), 15);
float4 Attenuation3 = saturate(dot(psInStruct.Att3, psInStruct.Att3));

return (
(0.1 * color + 0.2 * Ambient) +
((shadow1 * (color * diff1 + (spec1*gloss.w)) * (1 -Attenuation1))*vecLightColor[0])+
((shadow2 * (color * diff2 + (spec2*gloss.w)) * (1 -Attenuation2))*vecLightColor[1])+
((shadow3 * (color * diff3 + (spec3*gloss.w)) * (1 -Attenuation3))*vecLightColor[2])
);
}



// -------------------------------------------------------------
// techniques//
// -------------------------------------------------------------
technique two_pass
{
pass P0
{
alphablendenable=false;
srcblend=zero;

VertexShader = compile vs_3_0 VS_PASS0();
PixelShader = compile ps_3_0 PS_PASS0();
}



}



Re: Loading skins in real time [Re: JetpackMonkey] #121187
04/03/07 22:25
04/03/07 22:25
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Try adding the mtlSkin's to the [NM] shader I posted in the UserContributions...


It works great, and it would only be a short/simple modification to switch to the mtlSkin's...


xXxGuitar511
- Programmer
Re: Loading skins in real time [Re: xXxGuitar511] #121188
04/04/07 11:59
04/04/07 11:59
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline OP
Serious User
JetpackMonkey  Offline OP
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco
Great, guys, thanks

I don't know how to add the mtlSkins.. Do I just change all instances of entSkin1 and entSkin2 to mtlSkin1 and mtlSkin2 Then how do I dynamically load the mtlSkins?

Merci
JPM

Re: Loading skins in real time [Re: JetpackMonkey] #121189
04/04/07 13:58
04/04/07 13:58
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
To change the shader (works in all shaders):

Code:

texture entSkin1; -> [b]texture mtlSkin1;[/b]

sampler sColorMap = sampler_state
{
Texture = <entSkin1>; -> [b]Texture = <mtlSkin1>;[/b]
MinFilter = Linear;
...



Then, in C-Script:

Code:

bmap Test1 = "lala.bmp";
bmap Test2 = "lala.bmp";

material NM_fx
{
skin1=Test1;
}

...
NM_fx.skin1=Test2;
...

...
NM_fx.skin1=bmap_create("lala3.bmp");
...



Hope that helps. BTW you should use a newer version of the shader from xXxGuitar.

Re: Loading skins in real time [Re: TWO] #121190
04/04/07 15:03
04/04/07 15:03
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline OP
Serious User
JetpackMonkey  Offline OP
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco

thanks!

Page 1 of 2 1 2

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