Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
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
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 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 2 of 2 1 2
Re: Tree question [Re: Matt_Aufderheide] #86104
08/17/06 11:23
08/17/06 11:23
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
I´m interested in your method, too. And I think many users are

Re: Tree question [Re: TWO] #86105
08/17/06 14:36
08/17/06 14:36
Joined: Feb 2006
Posts: 616
Netherlands
cartoon_baboon Offline
User
cartoon_baboon  Offline
User

Joined: Feb 2006
Posts: 616
Netherlands
yes Mat, I am interested in your method as well...

Re: Tree question [Re: cartoon_baboon] #86106
08/17/06 16:58
08/17/06 16:58
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Ok here is a basic shader for this.. let me know if you have problems.

Code:
	float4x4 matWorld;
float4x4 matWorldViewProj;
float4 vecSunDir;
float4 vecFog;
float4 vecViewPos;
texture entSkin1;

//these are sunlight and ambient colors
//you should pass these values in scrips.. how you get those colors in the script
//is up to you because I dont know of a way to directly pass them or get them in the shader.
//Maybe there is a way i dont know about...
float4 vecSkill9; //ambient color
float4 vecSkill5; //sunlight color

//color skin texture with alpha channel for transparency
sampler base = sampler_state
{
Texture = <entSkin1>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = clamp;
Addressv = clamp;

//you can change this or comment it out..
//this sharpens up the texture at far distances
MIPMAPLODBIAS=-0.5;
};

half4 DoSunLight(half3 N)
{
return (dot(N,normalize(-vecSunDir)));
};

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

struct TMULTI_VS_OUT // Output to the pixelshader fragment
{
float4 Pos : POSITION;
float Fog: FOG;
float2 tex : TEXCOORD0;
float light : TEXCOORD1;
};


TMULTI_VS_OUT TMulti_VS(
float4 inPos : POSITION,
float3 inNormal : NORMAL,
float2 inTexCoord0 : TEXCOORD0)
{
TMULTI_VS_OUT Out;

// transform the vector position to screen coordinates
Out.Pos = mul(inPos,matWorldViewProj);

// Calculate fogging
float3 PositionWorld = mul(inPos, matWorld);
float ofog = 1 - (distance(PositionWorld, vecViewPos) - vecFog.x) * vecFog.z;
Out.Fog = ofog;

// output tex coords
Out.tex = inTexCoord0.xy;

//calculate normal for spherical lighting
float4 vPos=mul(float4(0,0,0,1),matWorld);
vPos.y+=10;
half3 N=normalize(PositionWorld-vPos);

Out.light = DoSunLight(N);

return Out;
}

half4 TMulti_PS(TMULTI_VS_OUT In): COLOR
{
half4 Color = tex2D(base,In.tex);

float4 finalcolor=Color;
finalcolor.rgb=(finalcolor.rgb*vecSkill9) +
((vecSkill5 * finalcolor.rgb)*saturate(In.light));

return finalcolor;
}

DWORD ref=128.0f;

technique treelight
{
pass one
{
cullmode=none;
zenable=true;
zwriteenable=true;
alphablendenable=false;
alphatestenable=true;
AlphaRef=<ref>;
AlphaFunc=Greater;

VertexShader = compile vs_1_1 TMulti_VS();
PixelShader = compile ps_1_1 TMulti_PS();
}

}




Sphere Engine--the premier A6 graphics plugin.
Re: Tree question [Re: Gamesaint762] #86107
08/17/06 21:51
08/17/06 21:51
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Gamesaint762, I think, line "CullMode=none;" in your FFE does the job.
What do You think, Matt?

Re: Tree question [Re: Lion_Ts] #86108
08/18/06 08:09
08/18/06 08:09
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
No that wont affect the lighting.


Sphere Engine--the premier A6 graphics plugin.
Re: Tree question [Re: Matt_Aufderheide] #86109
08/18/06 19:14
08/18/06 19:14
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
I understand that, therefore I don't have visual problems with simple alpha-testing FFE...
Thank you for shader code with spherical lighting.

Page 2 of 2 1 2

Moderated by  HeelX, rvL_eXile 

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