Changeset 1598 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Timestamp:
- 10/10/06 11:13:58 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Phong.hlsl
r1590 r1598 4 4 { 5 5 float4 hPos :POSITION; 6 float4 hPosition :TEXCOORD4; 6 7 float3 wPos :TEXCOORD1; 7 8 float2 texCoord :TEXCOORD0; … … 17 18 { 18 19 vertOUT OUT; 19 OUT.hPos = mul(worldViewProj, position);20 OUT.hPos = OUT.hPosition = mul(worldViewProj, position); 20 21 OUT.wPos = mul(world, position).xyz; 21 22 OUT.mNormal = mul(world, normal); … … 59 60 float3 pos = IN.wPos; 60 61 61 float M = 8;62 float M = 4; 62 63 63 64 float3 lightpositions[8]; … … 91 92 L = normalize(L); 92 93 float3 H = normalize(L + V); 93 float4 spec = specular * lightcolors[i] * pow(dot(H, N), shininess); 94 float4 diff = diffuse * lightcolors[i] * abs(dot(L, N)); 94 float lightscale = 3; 95 float4 spec = specular * lightcolors[i] * pow(dot(H, N), shininess) * lightscale; 96 float4 diff = diffuse * lightcolors[i] * abs(dot(L, N)) * lightscale; 95 97 float range = 4.0; 96 98 I += 1.0 / d * (spec + diff); … … 102 104 } 103 105 106 107 float4 PhongPlaneReflectPS( vertOUT IN, 108 uniform float3 cameraPos, 109 uniform float3 lightpos1, 110 uniform float3 lightpos2, 111 uniform float3 lightpos3, 112 uniform float3 lightpos4, 113 uniform float3 lightpos5, 114 uniform float3 lightpos6, 115 uniform float3 lightpos7, 116 uniform float3 lightpos8, 117 uniform float4 lightcol1, 118 uniform float4 lightcol2, 119 uniform float4 lightcol3, 120 uniform float4 lightcol4, 121 uniform float4 lightcol5, 122 uniform float4 lightcol6, 123 uniform float4 lightcol7, 124 uniform float4 lightcol8, 125 uniform float4 ambientLight, 126 uniform float shininess, 127 uniform float4 specular, 128 uniform float4 diffuse, 129 uniform float4 ambient, 130 uniform sampler2D reflectionTex, 131 uniform float reflectionAmount 132 133 ) : COLOR0 134 { 135 136 137 float3 N = IN.mNormal; 138 N = normalize( N ); 139 float3 pos = IN.wPos; 140 141 float M = 4; 142 143 float3 lightpositions[8]; 144 float4 lightcolors[8]; 145 146 lightpositions[0] = lightpos1; 147 lightpositions[1] = lightpos2; 148 lightpositions[2] = lightpos3; 149 lightpositions[3] = lightpos4; 150 lightpositions[4] = lightpos5; 151 lightpositions[5] = lightpos6; 152 lightpositions[6] = lightpos7; 153 lightpositions[7] = lightpos8; 154 155 lightcolors[0] = lightcol1; 156 lightcolors[1] = lightcol2; 157 lightcolors[2] = lightcol3; 158 lightcolors[3] = lightcol4; 159 lightcolors[4] = lightcol5; 160 lightcolors[5] = lightcol6; 161 lightcolors[6] = lightcol7; 162 lightcolors[7] = lightcol8; 163 164 float4 I = ambientLight * ambient; 165 166 for(int i=0; i< M; i++) 167 { 168 float3 V = normalize(cameraPos - pos); 169 float3 L = lightpositions[i] - pos; 170 float d = length(L); 171 L = normalize(L); 172 float3 H = normalize(L + V); 173 float lightscale = 3; 174 float4 spec = specular * lightcolors[i] * pow(dot(H, N), shininess) * lightscale; 175 float4 diff = diffuse * lightcolors[i] * abs(dot(L, N)) * lightscale; 176 float range = 4.0; 177 I += 1.0 / d * (spec + diff); 178 } 179 180 float2 uv = (IN.hPosition.xy/IN.hPosition.w + 1.0) * 0.5; 181 uv.y = 1.0 - uv.y; 182 float4 reflection = tex2D(reflectionTex, uv); 183 I *= reflectionAmount * reflection + (1 - reflectionAmount); 184 185 //I = reflection; 186 //return 1; 187 return I; 188 189 }
Note: See TracChangeset
for help on using the changeset viewer.