- Timestamp:
- 10/17/08 18:33:41 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg
r3009 r3040 5 5 6 6 7 struct VertexInput7 struct vtxin 8 8 { 9 9 float4 position: POSITION; … … 24 24 float3 normal: TEXCOORD2; 25 25 float4 mypos: TEXCOORD3; 26 float4 color2: TEXCOORD4; 27 }; 28 29 30 struct pixel 31 { 32 float4 col: COLOR0; 33 float4 norm: COLOR1; 34 float3 pos: COLOR2; 26 float4 hdrColor: TEXCOORD4; 35 27 }; 36 28 … … 44 36 45 37 float4 projPos: WPOS; 46 float4 worldPos: TEXCOORD1; // world position47 38 float3 normal: TEXCOORD2; 48 float4 mypos: TEXCOORD3; 49 float4 color2: TEXCOORD4; 39 float4 hdrColor: TEXCOORD4; 50 40 }; 41 42 43 struct fragout 44 { 45 float4 col: COLOR0; 46 float4 norm: COLOR1; 47 float3 pos: COLOR2; 48 }; 49 50 51 51 52 //-------------------------------------------------------------------------------------- 52 53 // Vertex Shaders … … 54 55 55 56 56 vtxout default_vs( VertexInputIN,57 vtxout default_vs(vtxin IN, 57 58 uniform float3 lightDir, 58 59 uniform float2 thetaSun, … … 63 64 uniform float3 dColor, 64 65 uniform float3 eColor, 65 uniform float4x4 ModelView,66 66 uniform float multiplier) 67 67 { … … 70 70 OUT.position = mul(glstate.matrix.mvp, IN.position); 71 71 72 73 72 const float dotLN = dot(lightDir, IN.normal); 74 73 const float cos2gamma = dotLN * dotLN; 75 74 76 75 const float gamma = acos(dotLN); 77 const float theta = dot(float3( 0.0, 0.0, 1.0), IN.normal);76 const float theta = dot(float3(.0f, .0f, 1.0f), IN.normal); 78 77 79 float3 num = (1.0 + aColor * exp(bColor / theta)) * (1.0+ cColor * exp(dColor * gamma) + eColor * cos2gamma);80 float3 den = (1.0 + aColor * exp(bColor)) * (1.0+ cColor * exp(dColor * thetaSun.x) + eColor * thetaSun.y);78 float3 num = (1.0f + aColor * exp(bColor / theta)) * (1.0f + cColor * exp(dColor * gamma) + eColor * cos2gamma); 79 float3 den = (1.0f + aColor * exp(bColor)) * (1.0f + cColor * exp(dColor * thetaSun.x) + eColor * thetaSun.y); 81 80 float3 xyY = (num / den) * zenithColor; 82 81 … … 88 87 89 88 const static float3x3 conv_Mat = 90 float3x3( 3.240479, -1.537150, -0.498535,91 -0.969256 , 1.875992, 0.041556,92 0.055648, -0.204043, 1.057311);89 float3x3( 3.240479f, -1.537150f, -0.498535f, 90 -0.969256f, 1.875992f, 0.041556f, 91 0.055648f, -0.204043f, 1.057311f); 93 92 94 93 float3 hcol = mul(conv_Mat, XYZ); 95 OUT.color = float4(hcol, 1.0 );94 OUT.color = float4(hcol, 1.0f); 96 95 97 96 OUT.color.rgb *= multiplier; 98 99 OUT.color2 = OUT.color; 100 OUT.worldPos = mul(ModelView, IN.position); 97 /// put out color into different color channel to avoid clamping 98 OUT.hdrColor = OUT.color; 101 99 102 100 OUT.normal = IN.normal; 103 OUT.mypos = OUT.position;104 101 105 102 return OUT; … … 107 104 108 105 109 pixelfrag_skydome(fragin IN)106 fragout frag_skydome(fragin IN) 110 107 { 111 pixelpix;108 fragout pix; 112 109 113 pix.col = IN. color2;110 pix.col = IN.hdrColor; 114 111 pix.col.w = 1e20f; 115 116 pix.norm.xyz = IN.normal; 117 pix.norm.w = IN.mypos.w; 118 119 //pix.pos = 1e20f; 112 pix.norm = IN.normal; 120 113 121 114 return pix;
Note: See TracChangeset
for help on using the changeset viewer.