[1481] | 1 | // transformations
|
---|
| 2 | float4x4 worldProjection;
|
---|
| 3 | float4x4 screenToWorld;
|
---|
| 4 | float4x4 modelWorld;
|
---|
| 5 | float4x4 worldModel;
|
---|
| 6 | float3 eyePos;
|
---|
| 7 | float3 tilePos;
|
---|
| 8 | float rf; //refrac coeff
|
---|
| 9 | float colOrder;
|
---|
| 10 | bool fini;
|
---|
| 11 | #define maxRayDepth 200.0
|
---|
| 12 |
|
---|
| 13 | float4 conePeak;
|
---|
| 14 | float4 coneDira;
|
---|
| 15 |
|
---|
| 16 | texture rayDirTable;
|
---|
| 17 | sampler rayDirTableSampler = sampler_state
|
---|
| 18 | {
|
---|
| 19 | Texture = <rayDirTable>;
|
---|
| 20 | MinFilter = Point;
|
---|
| 21 | MagFilter = Point;
|
---|
| 22 | MipFilter = None;
|
---|
| 23 | };
|
---|
| 24 |
|
---|
| 25 | texture rayOriginTable;
|
---|
| 26 | sampler rayOriginTableSampler = sampler_state
|
---|
| 27 | {
|
---|
| 28 | Texture = <rayOriginTable>;
|
---|
| 29 | MinFilter = Point;
|
---|
| 30 | MagFilter = Point;
|
---|
| 31 | MipFilter = None;
|
---|
| 32 | };
|
---|
| 33 |
|
---|
| 34 | texture coneDirTable;
|
---|
| 35 | sampler coneDirTableSampler = sampler_state
|
---|
| 36 | {
|
---|
| 37 | Texture = <coneDirTable>;
|
---|
| 38 | MinFilter = Point;
|
---|
| 39 | MagFilter = Point;
|
---|
| 40 | MipFilter = None;
|
---|
| 41 | };
|
---|
| 42 |
|
---|
| 43 | texture conePeakTable;
|
---|
| 44 | sampler conePeakTableSampler = sampler_state
|
---|
| 45 | {
|
---|
| 46 | Texture = <conePeakTable>;
|
---|
| 47 | MinFilter = Point;
|
---|
| 48 | MagFilter = Point;
|
---|
| 49 | MipFilter = None;
|
---|
| 50 | };
|
---|
| 51 |
|
---|
| 52 | textureCUBE environmentTexture;
|
---|
| 53 | sampler environmentSampler = sampler_state
|
---|
| 54 | {
|
---|
| 55 | Texture = <environmentTexture>;
|
---|
| 56 | MinFilter = Linear;
|
---|
| 57 | MagFilter = Linear;
|
---|
| 58 | MipFilter = None;
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | struct vsInputRenderPrimaryRayArray
|
---|
| 62 | {
|
---|
| 63 | float4 pos : POSITION;
|
---|
| 64 | float3 normal : NORMAL;
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 | struct vsOutputRenderPrimaryRayArray
|
---|
| 68 | {
|
---|
| 69 | float4 pos : POSITION;
|
---|
| 70 | float3 normal : TEXCOORD0;
|
---|
| 71 | float3 worldPos : TEXCOORD1;
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 | vsOutputRenderPrimaryRayArray
|
---|
| 75 | vsRenderPrimaryRayArray(vsInputRenderPrimaryRayArray input)
|
---|
| 76 | {
|
---|
| 77 | vsOutputRenderPrimaryRayArray output = (vsOutputRenderPrimaryRayArray)0;
|
---|
| 78 |
|
---|
| 79 | output.pos = mul(input.pos, worldProjection);
|
---|
| 80 | output.normal = input.normal;
|
---|
| 81 | float4 worldPos = mul(input.pos, modelWorld);
|
---|
| 82 | output.worldPos = worldPos.xyz / worldPos.w;
|
---|
| 83 |
|
---|
| 84 | return output;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | struct psOutputRenderPrimaryRayArray
|
---|
| 88 | {
|
---|
| 89 | float4 origin : COLOR0;
|
---|
| 90 | float4 dir : COLOR1;
|
---|
| 91 | };
|
---|
| 92 |
|
---|
| 93 | psOutputRenderPrimaryRayArray
|
---|
| 94 | psRenderPrimaryRayArray(vsOutputRenderPrimaryRayArray input) : COLOR
|
---|
| 95 | {
|
---|
| 96 | psOutputRenderPrimaryRayArray output = (psOutputRenderPrimaryRayArray)0;
|
---|
| 97 | output.origin = float4(input.worldPos, 1);
|
---|
| 98 | float3 normal = normalize(input.normal);
|
---|
| 99 | float3 viewDir = input.worldPos - eyePos;
|
---|
| 100 | viewDir = normalize(viewDir);
|
---|
| 101 |
|
---|
| 102 | float3 rfd = refract(viewDir, normal, rf);
|
---|
| 103 | if(dot(rfd, rfd) < 0.5)
|
---|
| 104 | {
|
---|
| 105 | rfd = reflect(viewDir, normal);
|
---|
| 106 | }
|
---|
| 107 | output.dir = float4(rfd, colOrder);
|
---|
| 108 |
|
---|
| 109 | output.dir.xyz = normalize(output.dir.xyz);
|
---|
| 110 |
|
---|
| 111 | return output;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | struct vsInputCopyBack
|
---|
| 115 | {
|
---|
| 116 | float4 pos : POSITION;
|
---|
| 117 | float2 tex : TEXCOORD0;
|
---|
| 118 | };
|
---|
| 119 |
|
---|
| 120 | struct vsOutputCopyBack
|
---|
| 121 | {
|
---|
| 122 | float4 pos : POSITION;
|
---|
| 123 | float2 tex : TEXCOORD0;
|
---|
| 124 | };
|
---|
| 125 |
|
---|
| 126 | vsOutputCopyBack
|
---|
| 127 | vsCopyBack(vsInputCopyBack input)
|
---|
| 128 | {
|
---|
| 129 | vsOutputCopyBack output = (vsOutputCopyBack)0;
|
---|
| 130 | output.pos = input.pos;
|
---|
| 131 | output.tex = input.tex;
|
---|
| 132 | return output;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | void
|
---|
| 136 | psCopyBack(vsOutputCopyBack input, out float4 c0 : COLOR0, out float4 c1 : COLOR1)
|
---|
| 137 | {
|
---|
| 138 | c0 = tex2D(rayOriginTableSampler, input.tex);
|
---|
| 139 | c1 = tex2D(rayDirTableSampler, input.tex);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | struct vsInputShowTex
|
---|
| 143 | {
|
---|
| 144 | float4 pos : POSITION;
|
---|
| 145 | float2 tex : TEXCOORD0;
|
---|
| 146 | };
|
---|
| 147 |
|
---|
| 148 | struct vsOutputShowTex
|
---|
| 149 | {
|
---|
| 150 | float4 pos : POSITION;
|
---|
| 151 | float2 tex : TEXCOORD0;
|
---|
| 152 | };
|
---|
| 153 |
|
---|
| 154 | vsOutputShowTex
|
---|
| 155 | vsShowTex(vsInputShowTex input)
|
---|
| 156 | {
|
---|
| 157 | vsOutputShowTex output = (vsOutputShowTex)0;
|
---|
| 158 | output.pos = input.pos;
|
---|
| 159 | output.tex = input.tex;
|
---|
| 160 |
|
---|
| 161 | return output;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | float4
|
---|
| 165 | psShowTex(vsOutputShowTex input) : COLOR0
|
---|
| 166 | {
|
---|
| 167 | // return abs(float4(tex2D(rayDirTableSampler, input.tex).xyz, 1));
|
---|
| 168 | return float4(tex2D(rayOriginTableSampler, input.tex).xyz, 1);
|
---|
| 169 | // return abs(float4(tex2D(conePeakTableSampler, input.tex).xyz, 1));
|
---|
| 170 | // return float4(1,1,0,1);
|
---|
| 171 | // return float4(input.tex.x,input.tex.y,0,1);
|
---|
| 172 | // return float4(1.0 - acos(tex2D(coneDirTableSampler, input.tex).aaa) / 3.14, 1);
|
---|
| 173 | // + float4(0, 0.7, 0, 0);
|
---|
| 174 | // + float4(tex2D(rayDirTableSampler, input.tex).xyz, 1);
|
---|
| 175 | float3 relfDir = tex2D(rayDirTableSampler, input.tex);
|
---|
| 176 | return float4((relfDir.x +1) / 2,
|
---|
| 177 | (relfDir.y + 1) / 2,
|
---|
| 178 | (relfDir.z + 1) / 2, 1);
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | struct vsInputRayCast
|
---|
| 182 | {
|
---|
| 183 | half4 sphere : POSITION;
|
---|
| 184 | half3 planePos : NORMAL;
|
---|
| 185 | half3 invmx0 : TEXCOORD0;
|
---|
| 186 | half3 invmx1 : TEXCOORD1;
|
---|
| 187 | half3 invmx2 : TEXCOORD2;
|
---|
| 188 | half3 normals0 : TEXCOORD3;
|
---|
| 189 | half3 normals1 : TEXCOORD4;
|
---|
| 190 | half3 normals2 : TEXCOORD5;
|
---|
| 191 | half3 tex0 : TEXCOORD6;
|
---|
| 192 | half3 tex1 : TEXCOORD7;
|
---|
| 193 | half3 tex2 : TEXCOORD8;
|
---|
| 194 | };
|
---|
| 195 |
|
---|
| 196 | struct vsOutputRayCast
|
---|
| 197 | {
|
---|
| 198 | half4 pos : POSITION;
|
---|
| 199 | half3 invmx0 : TEXCOORD0;
|
---|
| 200 | half3 invmx1 : TEXCOORD1;
|
---|
| 201 | half3 invmx2 : TEXCOORD2;
|
---|
| 202 | half3 normals0 : TEXCOORD3;
|
---|
| 203 | half3 normals1 : TEXCOORD4;
|
---|
| 204 | half3 normals2 : TEXCOORD5;
|
---|
| 205 | half3 tex0 : TEXCOORD6;
|
---|
| 206 | half3 tex1 : TEXCOORD7;
|
---|
| 207 | // float3 tex2 : TEXCOORD8;
|
---|
| 208 | half3 planePos : TEXCOORD8;
|
---|
| 209 | };
|
---|
| 210 |
|
---|
| 211 | vsOutputRayCast
|
---|
| 212 | vsRayCast(vsInputRayCast input)
|
---|
| 213 | {
|
---|
| 214 | vsOutputRayCast output = (vsOutputRayCast)0;
|
---|
| 215 | output.planePos = input.planePos;
|
---|
| 216 | output.invmx0 = input.invmx0;
|
---|
| 217 | output.invmx1 = input.invmx1;
|
---|
| 218 | output.invmx2 = input.invmx2;
|
---|
| 219 | output.normals0 = input.normals0;
|
---|
| 220 | output.normals1 = input.normals1;
|
---|
| 221 | output.normals2 = input.normals2;
|
---|
| 222 | output.tex0 = input.tex0;
|
---|
| 223 | output.tex1 = input.tex1;
|
---|
| 224 | // output.tex2 = input.tex2;
|
---|
| 225 | output.pos = float4(tilePos, 1);
|
---|
| 226 |
|
---|
| 227 | // float2 coneTexCoords = tilePos * 0.5 + float2(0.5 + 1.0/32.0, 0.5 + 1.0/32.0);
|
---|
| 228 | tilePos.y = - tilePos.y;
|
---|
| 229 | // float2 coneTexCoords = (tilePos + 1.0 - 1.0/32.0) * 0.5;
|
---|
| 230 | // float4 conePeak = tex2Dlod(conePeakTableSampler, float4(coneTexCoords, 0, 0));
|
---|
| 231 | // float4 coneDira = tex2Dlod(coneDirTableSampler, float4(coneTexCoords, 0, 0));
|
---|
| 232 |
|
---|
| 233 | // conePeak.xyz = mul(float4(conePeak.xyz, 1.0), worldModel);
|
---|
| 234 |
|
---|
| 235 | float3 sfc = input.sphere.xyz - conePeak.xyz;
|
---|
| 236 | float lsfc = length(sfc);
|
---|
| 237 |
|
---|
| 238 | if(input.sphere.w < lsfc)
|
---|
| 239 | {
|
---|
| 240 | float angSpMidConeMid = acos(dot(coneDira.xyz, sfc) / lsfc);
|
---|
| 241 | float angSpRad = asin(input.sphere.w / lsfc);
|
---|
| 242 | float angCone = acos(coneDira.w);
|
---|
| 243 |
|
---|
| 244 | if(angCone + angSpRad < angSpMidConeMid)
|
---|
| 245 | {
|
---|
| 246 | output.pos = float4(10000000.0, 10000000.0, 10000000.0, 1.0);
|
---|
| 247 | }
|
---|
| 248 | }/**/
|
---|
| 249 |
|
---|
| 250 | return output;
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | void
|
---|
| 254 | psRayCast(vsOutputRayCast input, in float2 vpos : VPOS, out float4 origin : COLOR0, out float4 dir : COLOR1, out float1 depth : DEPTH)
|
---|
| 255 | {
|
---|
| 256 |
|
---|
| 257 | float2 pixpos = vpos.xy;
|
---|
| 258 | pixpos /= 512.0;
|
---|
| 259 | float4 rayOrigin = tex2D(rayOriginTableSampler, pixpos.xy);
|
---|
| 260 | rayOrigin = mul(rayOrigin, worldModel);
|
---|
| 261 | float4 rayDirDepth = tex2D(rayDirTableSampler, pixpos.xy);
|
---|
| 262 | float3 rayDir = rayDirDepth.xyz;
|
---|
| 263 |
|
---|
| 264 | float hitDepth = (dot(input.planePos, input.planePos) - dot(rayOrigin, input.planePos)) / dot(rayDir, input.planePos);
|
---|
| 265 | float toler = 0.1;
|
---|
| 266 | if(hitDepth < toler || hitDepth > maxRayDepth)
|
---|
| 267 | {
|
---|
| 268 | depth = 1000000.0;
|
---|
| 269 | origin = dir = 0;
|
---|
| 270 | }
|
---|
| 271 | else
|
---|
| 272 | {
|
---|
| 273 | float3 hitPoint = rayOrigin + (rayDir * hitDepth);
|
---|
| 274 |
|
---|
| 275 | float4(10.0, 0, 0, 1);
|
---|
| 276 | depth = hitDepth / maxRayDepth;
|
---|
| 277 |
|
---|
| 278 | float baryA = dot(input.invmx0, hitPoint);
|
---|
| 279 | float baryB = dot(input.invmx1, hitPoint);
|
---|
| 280 | float baryC = dot(input.invmx2, hitPoint);
|
---|
| 281 | if(baryA > -0.001 && baryB > -0.001 && baryC > -0.001)
|
---|
| 282 | {
|
---|
| 283 | origin = mul(float4(hitPoint, 1), modelWorld);
|
---|
| 284 | float3 normalAtHitPoint = input.normals0 * baryA;
|
---|
| 285 | normalAtHitPoint += input.normals1 * baryB;
|
---|
| 286 | normalAtHitPoint += input.normals2 * baryC;
|
---|
| 287 | normalAtHitPoint = normalize(normalAtHitPoint);
|
---|
| 288 | if(dot(normalAtHitPoint, rayDir) > 0)
|
---|
| 289 | {
|
---|
| 290 | normalAtHitPoint = -normalAtHitPoint;
|
---|
| 291 | rf = 1.0 / rf;
|
---|
| 292 | }
|
---|
| 293 | float3 rfd = refract(rayDir, normalAtHitPoint, rf);
|
---|
| 294 | if(dot(rfd, rfd) < 0.5)
|
---|
| 295 | rfd = reflect(rayDir, normalAtHitPoint);
|
---|
| 296 | dir = float4(rfd, rayDirDepth.w + colOrder);
|
---|
| 297 | // dir = float4(reflect(rayDir, normalAtHitPoint), 1);
|
---|
| 298 | }
|
---|
| 299 | else
|
---|
| 300 | {
|
---|
| 301 | origin = float4(10.0, 0, 0, 1);
|
---|
| 302 | dir = float4(10.0, 0, 0, 1);
|
---|
| 303 | depth = 1000000.0;
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 |
|
---|
| 308 |
|
---|
| 309 | struct vsInputBackGround
|
---|
| 310 | {
|
---|
| 311 | float4 pos : POSITION; //Pos
|
---|
| 312 | float2 tex : TEXCOORD0;
|
---|
| 313 | };
|
---|
| 314 |
|
---|
| 315 | struct vsOutputBackGround
|
---|
| 316 | {
|
---|
| 317 | float4 pos : POSITION; //Pos
|
---|
| 318 | float2 tex : TEXCOORD0;
|
---|
| 319 | float3 worldPos : TEXCOORD1;
|
---|
| 320 | };
|
---|
| 321 |
|
---|
| 322 | vsOutputBackGround vsBackground(vsInputBackGround input){
|
---|
| 323 | vsOutputBackGround output = (vsOutputBackGround)0;
|
---|
| 324 | output.pos=input.pos;
|
---|
| 325 | float4 worldpos = mul(input.pos, screenToWorld);
|
---|
| 326 | worldpos /= worldpos.w;
|
---|
| 327 | output.worldPos = worldpos.xyz;
|
---|
| 328 | output.tex = input.tex;
|
---|
| 329 | return output;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | void psBackground(vsOutputBackGround input, out float4 o0 : COLOR0)
|
---|
| 333 | {
|
---|
| 334 | float4 dird = tex2D(rayDirTableSampler, input.tex);
|
---|
| 335 | float3 dir = dird.xyz;
|
---|
| 336 | float3 col = 1 ;
|
---|
| 337 | /*float3(pow(0.7, frac(dird.w / 10.0) * 10.0) ,
|
---|
| 338 | pow(0.7, frac(dird.w / 100.0) * 10.0) ,
|
---|
| 339 | pow(0.7, frac(dird.w / 1000.0) * 10.0));*/
|
---|
| 340 | if(dot(dir, dir) < 0.5)
|
---|
| 341 | {
|
---|
| 342 | dir = normalize(input.worldPos.xyz - eyePos.xyz);
|
---|
| 343 | col = float3(4, 4, 4);
|
---|
| 344 | }
|
---|
| 345 | o0 = float4(texCUBE(environmentSampler, dir).xyz * col * 1.1, 0.0);
|
---|
| 346 | // o0 = float4(dird.w / 5.0, dird.w / 2.0, dird.w / 10.0, 1.0);
|
---|
| 347 |
|
---|
| 348 | // o0 = float4(input.tex.x, input.tex.y, 1.0, 1.0);
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | struct vsInputCone
|
---|
| 352 | {
|
---|
| 353 | float4 pos : POSITION;
|
---|
| 354 | float2 tex : TEXCOORD0;
|
---|
| 355 | };
|
---|
| 356 |
|
---|
| 357 | struct vsOutputCone
|
---|
| 358 | {
|
---|
| 359 | float4 pos : POSITION;
|
---|
| 360 | float2 tex : TEXCOORD0;
|
---|
| 361 | };
|
---|
| 362 |
|
---|
| 363 | vsOutputCone
|
---|
| 364 | vsCone(vsInputCone input)
|
---|
| 365 | {
|
---|
| 366 | vsOutputCone output = (vsOutputCone)0;
|
---|
| 367 | output.pos = input.pos;
|
---|
| 368 | output.tex = input.tex;
|
---|
| 369 | return output;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | void
|
---|
| 373 | psCone(vsInputCone input, out float4 rpeak : COLOR0, out float4 rdir : COLOR1)
|
---|
| 374 | {
|
---|
| 375 | // rpeak = rdir = tex2D(rayDirTableSampler, input.tex + 2.0/32.0);
|
---|
| 376 | // return;
|
---|
| 377 | float3 peak = float3(0, 0, 0);//tex2D(rayOriginTableSampler, input.tex + 1.0/32.0);
|
---|
| 378 | float3 dir = float3(0, 0, 0);//tex2D(rayDirTableSampler, input.tex + 1.0/32.0);
|
---|
| 379 | float cosAngle = 1.0;
|
---|
| 380 | float sinAngle = 0.0;
|
---|
| 381 | for(int i=0; i < 16; i++)
|
---|
| 382 | for(int j=0; j < 16; j++)
|
---|
| 383 | {
|
---|
| 384 | float3 ndir = tex2D(rayDirTableSampler, input.tex + float2((float)j/512.0, (float)i/512.0));
|
---|
| 385 | if(dot(ndir, ndir) > 0.5)
|
---|
| 386 | {
|
---|
| 387 | float3 npeak = tex2D(rayOriginTableSampler, input.tex + float2((float)j/512.0, (float)i/512.0));
|
---|
| 388 | if(dot(dir,dir) < 0.5)
|
---|
| 389 | {
|
---|
| 390 | dir = ndir;
|
---|
| 391 | peak = npeak;
|
---|
| 392 | }
|
---|
| 393 | else
|
---|
| 394 | {
|
---|
| 395 | float ncos = dot(ndir,dir);
|
---|
| 396 | if(ncos < cosAngle)
|
---|
| 397 | {
|
---|
| 398 | float3 perpdir = normalize(ndir - ncos * dir);
|
---|
| 399 | float3 farConeEdge = cosAngle * dir - sinAngle * perpdir;
|
---|
| 400 | dir = farConeEdge + ndir;
|
---|
| 401 | dir = normalize(dir);
|
---|
| 402 | cosAngle = dot(dir, ndir);
|
---|
| 403 | sinAngle = sqrt(1.0 - cosAngle * cosAngle);
|
---|
| 404 | }
|
---|
| 405 | float3 pd = npeak - peak;
|
---|
| 406 | float3 ptop = normalize(pd);
|
---|
| 407 | float cospp = dot(dir, ptop);
|
---|
| 408 | if(cospp < cosAngle)
|
---|
| 409 | {
|
---|
| 410 | float3 perpdir = ptop - cospp * dir;
|
---|
| 411 | perpdir = normalize(perpdir);
|
---|
| 412 | float3 farConeEdge = (cosAngle * dir - sinAngle * perpdir);
|
---|
| 413 | float3 nearConeEdge = (cosAngle * dir + sinAngle * perpdir);
|
---|
| 414 | float3 g = npeak - peak - nearConeEdge * dot(nearConeEdge, pd);
|
---|
| 415 | peak += farConeEdge * dot(g,g) / dot(farConeEdge, g);
|
---|
| 416 | }
|
---|
| 417 | }
|
---|
| 418 | }
|
---|
| 419 | }
|
---|
| 420 | rpeak = float4(peak, 1.0);
|
---|
| 421 | rdir = float4(dir, cosAngle);
|
---|
| 422 | if(dot(dir, dir) < 0.5)
|
---|
| 423 | {
|
---|
| 424 | rpeak = float4(1000000.0, 0 , 0, 0.0);
|
---|
| 425 | rdir = float4(1, 0, 0, 1.0);
|
---|
| 426 | }
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | struct vsInputCheck
|
---|
| 430 | {
|
---|
| 431 | float4 pos : POSITION;
|
---|
| 432 | float2 tex : TEXCOORD0;
|
---|
| 433 | };
|
---|
| 434 |
|
---|
| 435 | struct vsOutputCheck
|
---|
| 436 | {
|
---|
| 437 | float4 pos : POSITION;
|
---|
| 438 | float2 tex : TEXCOORD0;
|
---|
| 439 | };
|
---|
| 440 |
|
---|
| 441 | vsOutputCheck
|
---|
| 442 | vsCheck(vsInputCheck input)
|
---|
| 443 | {
|
---|
| 444 | vsOutputCone output = (vsOutputCone)0;
|
---|
| 445 | output.pos = input.pos;
|
---|
| 446 | output.tex = input.tex;
|
---|
| 447 | return output;
|
---|
| 448 | }
|
---|
| 449 |
|
---|
| 450 | float4 psCheck(vsOutputCheck input) : COLOR
|
---|
| 451 | {
|
---|
| 452 | float3 orig = tex2D(rayOriginTableSampler, input.tex);
|
---|
| 453 | float3 dir = tex2D(rayDirTableSampler, input.tex);
|
---|
| 454 | float3 peak = tex2D(conePeakTableSampler, input.tex);
|
---|
| 455 | float4 coneDira = tex2D(coneDirTableSampler, input.tex);
|
---|
| 456 | float4 ret = float4(0, 1, 0, 1);;
|
---|
| 457 | if(dot(dir, coneDira.xyz) < coneDira.a - 0.01)
|
---|
| 458 | ret = float4(1, 0, 0, 1);
|
---|
| 459 | if( (dot(normalize(orig - peak), coneDira.xyz) < coneDira.a - 0.01))
|
---|
| 460 | ret = float4(0, 0, 1, 1);
|
---|
| 461 | // ret = float4(dir + coneDira.xyz, 1);
|
---|
| 462 | // return abs(float4(peak, 1)) * 100.0;
|
---|
| 463 | return ret;
|
---|
| 464 | }
|
---|
| 465 |
|
---|
| 466 | technique RenderPrimaryRayArray{
|
---|
| 467 | pass P0
|
---|
| 468 | {
|
---|
| 469 | VertexShader = compile vs_3_0 vsRenderPrimaryRayArray();
|
---|
| 470 | PixelShader = compile ps_3_0 psRenderPrimaryRayArray();
|
---|
| 471 | }
|
---|
| 472 | }
|
---|
| 473 |
|
---|
| 474 | technique RayCast{
|
---|
| 475 | pass P0
|
---|
| 476 | {
|
---|
| 477 | VertexShader = compile vs_3_0 vsRayCast();
|
---|
| 478 | PixelShader = compile ps_3_0 psRayCast();
|
---|
| 479 | }
|
---|
| 480 | }
|
---|
| 481 |
|
---|
| 482 | technique ShowTex{
|
---|
| 483 | pass P0
|
---|
| 484 | {
|
---|
| 485 | VertexShader = compile vs_2_0 vsShowTex();
|
---|
| 486 | PixelShader = compile ps_2_0 psShowTex();
|
---|
| 487 | }
|
---|
| 488 | }
|
---|
| 489 |
|
---|
| 490 | technique Background{
|
---|
| 491 | pass P0
|
---|
| 492 | {
|
---|
| 493 | VertexShader = compile vs_2_0 vsBackground();
|
---|
| 494 | PixelShader = compile ps_2_0 psBackground();
|
---|
| 495 | }
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 | technique CopyBack{
|
---|
| 499 | pass P0
|
---|
| 500 | {
|
---|
| 501 | VertexShader = compile vs_2_0 vsCopyBack();
|
---|
| 502 | PixelShader = compile ps_2_0 psCopyBack();
|
---|
| 503 | }
|
---|
| 504 | }
|
---|
| 505 |
|
---|
| 506 | technique ComputeCones{
|
---|
| 507 | pass P0
|
---|
| 508 | {
|
---|
| 509 | VertexShader = compile vs_3_0 vsCone();
|
---|
| 510 | PixelShader = compile ps_3_0 psCone();
|
---|
| 511 | }
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 | technique ConeChecker{
|
---|
| 515 | pass P0
|
---|
| 516 | {
|
---|
| 517 | VertexShader = compile vs_3_0 vsCheck();
|
---|
| 518 | PixelShader = compile ps_3_0 psCheck();
|
---|
| 519 | }
|
---|
| 520 | } |
---|