- Timestamp:
- 10/17/08 18:33:41 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3025 r3040 779 779 > 780 780 </File> 781 <File 782 RelativePath=".\src\shaders\treeanimation.cg" 783 > 784 </File> 781 785 </Filter> 782 786 <Filter -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3039 r3040 478 478 479 479 //InitCg(); 480 480 ShaderProgram *treeAnimation = loader->CreateVertexProgram("treeanimation", "animateVtx"); 481 481 const float turbitiy = 5.0f; 482 482 preetham = new SkyPreetham(turbitiy, skyDome); -
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; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/treeanimation.cg
r3038 r3040 4 4 5 5 6 7 struct VertexInput 6 struct vtxin 8 7 { 9 8 float4 position: POSITION; … … 21 20 22 21 float4 color: COLOR0; 23 float4 worldPos: TEXCOORD1; // world position24 22 float3 normal: TEXCOORD2; 25 float4 mypos: TEXCOORD3; 26 float4 color2: TEXCOORD4; 23 float4 eyePos: TEXCOORD3; 27 24 }; 28 25 29 26 30 struct pixel31 {32 float4 col: COLOR0;33 float4 norm: COLOR1;34 float3 pos: COLOR2;35 };36 27 37 38 // fragment input39 struct fragin40 {41 float4 color: COLOR0;42 float4 position: POSITION; // eye space43 float4 texCoord: TEXCOORD0;44 45 float4 projPos: WPOS;46 float4 worldPos: TEXCOORD1; // world position47 float3 normal: TEXCOORD2;48 float4 mypos: TEXCOORD3;49 float4 color2: TEXCOORD4;50 };51 28 //-------------------------------------------------------------------------------------- 52 29 // Vertex Shaders … … 54 31 55 32 56 vtxout default_vs(VertexInput IN, 57 uniform float3 lightDir, 58 uniform float2 thetaSun, 59 uniform float3 zenithColor, 60 uniform float3 aColor, 61 uniform float3 bColor, 62 uniform float3 cColor, 63 uniform float3 dColor, 64 uniform float3 eColor, 65 uniform float4x4 ModelView, 66 uniform float multiplier) 33 vtxout animateVtx(vtxin IN, 34 uniform float3 windDir, 35 uniform float windStrength, 36 uniform float2 minmaxPos, 37 uniform float timer) 67 38 { 68 39 vtxout OUT; 69 40 41 OUT.color = IN.color; 42 OUT.texCoord = IN.texCoord; 43 // transform the vertex position into eye space 44 OUT.eyePos = mul(glstate.matrix.modelview[0], IN.position); 45 46 const float pos = (minmaxPos.x - IN.position.y / (minmaxPos.x - minmaxPos.y); 47 48 float factor = windStrength * sin(timer); 49 50 // displace the input position 51 float4 newPos = IN.position + float4(factor * windDir, 0.0f); 52 // transform the vertex position into post projection space 70 53 OUT.position = mul(glstate.matrix.mvp, IN.position); 71 54 72 73 const float dotLN = dot(lightDir, IN.normal);74 const float cos2gamma = dotLN * dotLN;75 76 const float gamma = acos(dotLN);77 const float theta = dot(float3(0.0, 0.0, 1.0), IN.normal);78 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);81 float3 xyY = (num / den) * zenithColor;82 83 float3 XYZ;84 85 XYZ.x = (xyY.x / xyY.y) * xyY.z;86 XYZ.y = xyY.z;87 XYZ.z = ((1.0f - xyY.x - xyY.y) / xyY.y) * xyY.z;88 89 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);93 94 float3 hcol = mul(conv_Mat, XYZ);95 OUT.color = float4(hcol, 1.0);96 97 OUT.color.rgb *= multiplier;98 99 OUT.color2 = OUT.color;100 OUT.worldPos = mul(ModelView, IN.position);101 102 55 OUT.normal = IN.normal; 103 OUT.mypos = OUT.position;104 56 105 57 return OUT; 106 58 } 107 108 109 pixel frag_skydome(fragin IN)110 {111 pixel pix;112 113 pix.col = IN.color2;114 pix.col.w = 1e20f;115 116 pix.norm.xyz = IN.normal;117 pix.norm.w = IN.mypos.w;118 119 //pix.pos = 1e20f;120 121 return pix;122 }
Note: See TracChangeset
for help on using the changeset viewer.