home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 April
/
Gamestar_83_2006-04_dvd.iso
/
Dema
/
demowot_english.exe
/
InfDX
/
Shaders
/
ratmospherecloud-deferred-transparent-pixel.hlsl
< prev
next >
Wrap
Text File
|
2005-05-02
|
2KB
|
62 lines
//***************************************************************************
// Author: Laszlo Rimoczi (Rimo)
// Purpose: RCloud.mat
//
// Copyright (C) 2005 by Digital Reality Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Digital Reality Inc.
//***************************************************************************
//float4 TDX_CONST_RFOGCOLOR;
float4 TDX_CONST_CLOUDFACTOR;
float4 TDX_CONST_CLOUDLIGHT;
float TDX_CONST_CLOUDDENSITY;
struct VS_OUTPUT
{
float4 cDiffuse: COLOR0;
float2 cUV: TEXCOORD0;
float4 cUV12: TEXCOORD1;
float4 cUV34: TEXCOORD2;
};
sampler pNoise: register(s0);
sampler pTable: register(s1);
float4 main(VS_OUTPUT i_sIn): COLOR
{
float3 cIndex;
cIndex.rgb = tex2D(pNoise, i_sIn.cUV12.xy).rgb * TDX_CONST_CLOUDFACTOR.xxx;
cIndex.rgb += tex2D(pNoise, i_sIn.cUV12.zw).rgb * TDX_CONST_CLOUDFACTOR.yyy;
cIndex.rgb += tex2D(pNoise, i_sIn.cUV34.xy).rgb * TDX_CONST_CLOUDFACTOR.zzz;
cIndex.rgb += tex2D(pNoise, i_sIn.cUV34.zw).rgb * TDX_CONST_CLOUDFACTOR.www;
cIndex *= 0.25f;
float2 cUV;
cUV.x = cIndex.r*cIndex.r;
float3 cNrm;
cNrm.x = cIndex.b - 0.5f;
cNrm.y = cIndex.g - 0.5f;
cNrm.z = 1.0f - sqrt(cNrm.x*cNrm.x + cNrm.y*cNrm.y);
cNrm.x *= TDX_CONST_CLOUDLIGHT.w;
cNrm.y *= TDX_CONST_CLOUDLIGHT.w;
cNrm = (1.0f-cUV.x) * normalize(cNrm);
cUV.y = 0.25f + 0.25f * dot(cNrm, TDX_CONST_CLOUDLIGHT.xyz);
float4 cColor = lerp(tex2D(pTable, cUV), tex2D(pTable, float2(cUV.x, cUV.y+0.5f)), TDX_CONST_CLOUDDENSITY);
cColor.a *= tex2D(pNoise, i_sIn.cUV).a;
cColor *= i_sIn.cDiffuse;
// cColor.rgb = lerp(cColor.rgb, TDX_CONST_RFOGCOLOR.rgb, TDX_CONST_RFOGCOLOR.a);
return cColor;
}