Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,055 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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