Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, VoroneTZ, AndrewAMD), 834 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to let mtlFX.c supporting 2-face displaying ,just like 3DMAX #382612
09/10/11 06:47
09/10/11 06:47
Joined: Sep 2011
Posts: 9
H
hallohope Offline OP
Newbie
hallohope  Offline OP
Newbie
H

Joined: Sep 2011
Posts: 9
How to let mtlFX.c supporting 2-face displaying ,just like 3DMAX.
We can display bothside of the mesh in 3DMAX
But just display one-side in 3DGS!?


Re: How to let mtlFX.c supporting 2-face displaying ,just like 3DMAX [Re: hallohope] #382616
09/10/11 09:45
09/10/11 09:45
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
effect = "technique x { pass y { CullMode = None; } }";

Re: How to let mtlFX.c supporting 2-face displaying ,just like 3DMAX [Re: Tobias] #382675
09/11/11 03:27
09/11/11 03:27
Joined: Sep 2011
Posts: 9
H
hallohope Offline OP
Newbie
hallohope  Offline OP
Newbie
H

Joined: Sep 2011
Posts: 9
thank you,Tobias.this code can work!
But if coding like this.It can't use lighting-map and bumping-map for the model anymore.
Is there any idear to do this by coding FX file?


// Blinn / Phong bump mapping
// (c) oP group 2008 Version 2.1

#include <tangent_vs>
#include <phong>

bool REQUIRE_HEIGHT;

texture entSkin1; // texture
texture entSkin2; // normal map or lightmap
texture entSkin3; // normal map on blocks

sampler sBaseTex = sampler_state { Texture = <entSkin1>; MipFilter = Linear; };
sampler sSkin2 = sampler_state { Texture = <entSkin2>; MipFilter = Linear; };
sampler sSkin3 = sampler_state { Texture = <entSkin3>; MipFilter = Linear; };

///////////////////////////////////////////////////////////////////////

float3 DoSpecular(tangentOut In,float3 View,float3 Normal,float fSpecular)
{
float fLight = DoShine(In.Light1.xyz-View,Normal);
float3 Diffuse = DoPhong(In.Diffuse1,fLight,fLight,fSpecular);

fLight = DoShine(In.Light2.xyz-View,Normal);
Diffuse += DoPhong(In.Diffuse2,fLight,fLight,fSpecular);

return Diffuse;
}

float3 DoSpecParallax(tangentOut In,sampler sNormal,out float2 offsetUV)
{
matTangent = float3x3(In.Tangent0,In.Tangent1,In.Tangent2);

float3 View = normalize(In.PosView);

// normal map on rgb, height map on w
float4 normalMap = tex2D(sNormal,In.Tex12.xy)*2-1;

// texture coordinates with height offset
offsetUV = normalMap.w * mul(View,matTangent).xy * 0.02;

// transform normal to world space
return normalize(mul(normalMap.xyz,matTangent));
}

float4 specParallax_PS(tangentOut In) : COLOR
{
float2 offsetUV;
float3 Normal = DoSpecParallax(In,sSkin2,offsetUV);
float4 Basemap = tex2D(sBaseTex,In.Tex12.xy + offsetUV);
float3 Diffuse = DoSpecular(In,normalize(In.PosView),Normal,Basemap.w);
return Basemap * DoColor(Diffuse,In.Ambient);
}

float4 specParallaxLM_PS(tangentOut In) : COLOR
{
float2 offsetUV;
float3 Normal = DoSpecParallax(In,sSkin3,offsetUV);
float4 Basemap = tex2D(sBaseTex,In.Tex12.xy + offsetUV);
float4 Lightmap = tex2D(sSkin2,In.Tex12.zw);
float3 Diffuse = DoSpecular(In,normalize(In.PosView),Normal,Basemap.w);
return Basemap * DoLightmap(Diffuse,Lightmap,In.Ambient);
}

/////////////////Techniques/////////////////

technique specParallax
{
pass p0
{
ZWriteEnable = True;
AlphaBlendEnable = False;

VertexShader = compile vs_2_0 tangent_VS();
PixelShader = compile ps_2_0 specParallax_PS();
}
}

technique specParallax_lm
{
pass p0
{
ZWriteEnable = True;
AlphaBlendEnable = False;

VertexShader = compile vs_2_0 tangent_VS();
PixelShader = compile ps_2_0 specParallaxLM_PS();
}
}

Re: How to let mtlFX.c supporting 2-face displaying ,just like 3DMAX [Re: hallohope] #382680
09/11/11 08:21
09/11/11 08:21
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
You only need to add the CullMode = None; to the pass.

technique specParallax
{
pass p0
{
ZWriteEnable = True;
AlphaBlendEnable = False;
CullMode = None;

...


Rendering will then be slower because more polygons are rendered. Thats why 2 sided polygons are normally not used for game models, only in special cases like vegetation.


Re: How to let mtlFX.c supporting 2-face displaying ,just like 3DMAX [Re: Tobias] #382849
09/13/11 11:52
09/13/11 11:52
Joined: Sep 2011
Posts: 9
H
hallohope Offline OP
Newbie
hallohope  Offline OP
Newbie
H

Joined: Sep 2011
Posts: 9
Thank you very much!


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