Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 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
Page 2 of 2 1 2
Re: Normal Mapping and no fog, but i need fog... help [Re: dead_poet] #60563
12/15/05 20:56
12/15/05 20:56
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
On the other hand, you can try this also. In the blue ink.


Code:

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[9]= <vecFog>;
vertexShaderConstant[10]=<vecSunDir>;
vertexShaderConstant[11]=<vecLight>;
VertexShaderConstant[12]={0.5f, 0.5f, 10.0f, 10.0f};
VertexShaderConstant[14]=<matWorldView>;

VertexShader =
asm
{
vs_1_1 // Declarations

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

m4x4 oPos, v0, c0 // Transform position to clip space

m3x3 r3, v8, c4 // Tranform normal and tangent to world space
m3x3 r5, v3, c4

mul r0, r3.zxy, r5.yzx // Compute binormal
mad r4, r3.yzx, r5.zxy, -r0

dp3 r0.x, r3.xyz, -c10 // Transform (Sun)light vector to tangent space
dp3 r0.y, r4.xyz, -c10
dp3 r0.z, r5.xyz, -c10

dp3 r0.w, r0, r0 // Normalize transformed light vector
rsq r0.w, r0.w
mul r0, r0, r0.w

mad r0, r0, c12.x, c12.x // Put light vector in range from 0 to 1
mul r0, r0, c12.y // Adjust the intensity
add oD0.xyz,r0,c11 // Add environment light then send it down the diffuse pipe

// Fog calculations
mov r1.w,c9.w
dp4 r0,v0,c16 // distance to camera position
add r0,r0,-c9.x // distance-fog_start

//float3 PositionWorld = mul(inPos, matWorld);
//float ofog = 1 - (distance(PositionWorld, vecViewPos) - vecFog.x) * (vecFog.z*1.5);
//Out.Fog = ofog;
mad r0.x,-r0.x,c9.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog,r0.x,c12.w // clamp with custom max value

// Pass the texture coordinates through
mov oT0, v7
mov oT1, v7
};




Last edited by Steempipe; 12/15/05 20:56.
Re: Normal Mapping and no fog, but i need fog... h [Re: Steempipe] #60564
12/15/05 22:02
12/15/05 22:02
Joined: May 2005
Posts: 50
D
dead_poet Offline OP
Junior Member
dead_poet  Offline OP
Junior Member
D

Joined: May 2005
Posts: 50
nice, the matrix-thingy got it to work, thanks a lot, dude.

Page 2 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