Author Topic: The Outer Limits  (Read 8237 times)

0 Members and 1 Guest are viewing this topic.

John

  • Hero Member
  • *****
  • Posts: 3249
Re: The Outer Limits
« Reply #30 on: November 30, 2015, 08:19:14 PM »
Quote
There are so many more urgent challenges in the world today!

Like building new planes that can't fly in combat and aircraft carriers they can't land on while spending billions sending shit into space. Better than going to the circus.
« Last Edit: November 30, 2015, 08:29:48 PM by John »

John

  • Hero Member
  • *****
  • Posts: 3249
Re: The Outer Limits
« Reply #31 on: February 27, 2016, 07:47:00 AM »

John

  • Hero Member
  • *****
  • Posts: 3249
Re: The Outer Limits
« Reply #32 on: March 17, 2016, 01:36:52 AM »
This years pi Day was kind of special.

3-14-16

100,000 Digits of Pi
« Last Edit: March 17, 2016, 10:37:49 PM by John »

John

  • Hero Member
  • *****
  • Posts: 3249
Re: The Outer Limits
« Reply #33 on: April 09, 2016, 12:36:28 AM »
Yesterday's date (4/8/2016):  2/2/2⁴ (for all those using the mm/dd/yy date format)

Code: Script BASIC
  1. PRINT FORMAT("%i/%i/%i\n",2^2,2^3,2^4)
  2.  


jrs@laptop:~/sb/sb22/test$ scriba 2day.sb
4/8/16
jrs@laptop:~/sb/sb22/test$

« Last Edit: April 09, 2016, 12:51:07 AM by John »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3745
    • Oxygen Basic
Re: The Outer Limits
« Reply #34 on: April 09, 2016, 12:46:21 AM »
Is this a better day than 1st April for posting an update? :)

John

  • Hero Member
  • *****
  • Posts: 3249
Re: The Outer Limits
« Reply #35 on: April 03, 2018, 01:09:04 PM »
What is the smallest number that can be exactly divided by all the numbers 1 to 10?


jack

  • Full Member
  • ***
  • Posts: 107
Re: The Outer Limits
« Reply #36 on: April 03, 2018, 01:21:58 PM »
interesting question.
« Last Edit: April 03, 2018, 02:08:34 PM by jack »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3745
    • Oxygen Basic
Re: The Outer Limits
« Reply #37 on: April 03, 2018, 02:42:11 PM »
Solving by brute force.

The challenge escalates rapidly for higher n. I would advise not going above 20.

Code: [Select]
'2018-04-03 T 23:39:49
'FIND LOWEST NUMBER EXACTLY DIVISIBLE BY 1..N
double i,m,n,mx
mx=1e11 : n=10
for m=n to mx
 for i=2 to n-1
  if mod(m,i) then exit for
 next
 if i>=n then print m : exit for
next

Any more efficient algorithms?

Perhaps something to do with primes..
« Last Edit: April 03, 2018, 08:32:58 PM by Charles Pegge »

John

  • Hero Member
  • *****
  • Posts: 3249
Re: The Outer Limits
« Reply #38 on: April 03, 2018, 08:58:42 PM »
The Cord

Code: C
  1. //#define ANOTHER_LEVEL
  2.  
  3.  
  4. /* SHADERTOY FROM HERE */
  5.  
  6. float guiLead = 0.6;
  7. float guiInnerRatio = 0.4407892623709694;
  8. float guiFocal = 3.;
  9. float guiRotateModel = 0.4560833039600971;
  10. float guiDebug = 0.6749066960348409;
  11. float guiZipOffset = 30.;
  12. float guiZipSize = 60.;
  13. float guiZipSpeed = 3.3;
  14. float guiZoom = 0.1;
  15. float guiModelScale = 7.749066960348409;
  16.  
  17. mat4 cameraMatrix = mat4(
  18.     -0.7063226699829102,
  19.     0.7052236199378967,
  20.     0.06198469549417496,
  21.     0,
  22.     -0.30620118975639343,
  23.     -0.3832840919494629,
  24.     0.8714323043823242,
  25.     0,
  26.     0.6382971405982971,
  27.     0.5965006947517395,
  28.     0.48660656809806824,
  29.     0,
  30.     0.14653973281383514,
  31.     0.6211488246917725,
  32.     0.13233166933059692,
  33.     1
  34. );
  35.  
  36. vec3 camPosition = vec3(0.14653973281383514, 0.6211488246917725, 0.13233166933059692);
  37.  
  38. float time;
  39.  
  40. #define PI 3.14159265359
  41. #define HALF_PI 1.5707963267948966
  42. #define TAU 6.28318530718
  43. #define PHI 1.618033988749895
  44.  
  45.  
  46. // --------------------------------------------------------
  47. // Utils
  48. // --------------------------------------------------------
  49.  
  50. #define saturate(x) clamp(x, 0., 1.)
  51.  
  52. // Rotate around a coordinate axis (i.e. in a plane perpendicular to that axis) by angle <a>.
  53. // Read like this: R(p.xz, a) rotates "x towards z".
  54. // This is fast if <a> is a compile-time constant and slower (but still practical) if not.
  55. void pR(inout vec2 p, float a) {
  56.     p = cos(a)*p + sin(a)*vec2(p.y, -p.x);
  57. }
  58.  
  59. // http://www.neilmendoza.com/glsl-rotation-about-an-arbitrary-axis/
  60. mat3 rotationMatrix(vec3 axis, float angle)
  61. {
  62.     axis = normalize(axis);
  63.     float s = sin(angle);
  64.     float c = cos(angle);
  65.     float oc = 1.0 - c;
  66.    
  67.     return mat3(
  68.         oc * axis.x * axis.x + c,           oc * axis.x * axis.y - axis.z * s,  oc * axis.z * axis.x + axis.y * s,
  69.         oc * axis.x * axis.y + axis.z * s,  oc * axis.y * axis.y + c,           oc * axis.y * axis.z - axis.x * s,
  70.         oc * axis.z * axis.x - axis.y * s,  oc * axis.y * axis.z + axis.x * s,  oc * axis.z * axis.z + c
  71.     );
  72. }
  73.  
  74. float range(float vmin, float vmax, float value) {
  75.   return (value - vmin) / (vmax - vmin);
  76. }
  77.  
  78. float rangec(float a, float b, float t) {
  79.     return clamp(range(a, b, t), 0., 1.);
  80. }
  81.  
  82. float vmax(vec2 v) {
  83.     return max(v.x, v.y);
  84. }
  85.  
  86. float fBox2(vec2 p, vec2 b) {
  87.     vec2 d = abs(p) - b;
  88.     return length(max(d, vec2(0))) + vmax(min(d, vec2(0)));
  89. }
  90.  
  91. // Repeat space along one axis. Use like this to repeat along the x axis:
  92. // <float cell = pMod1(p.x,5);> - using the return value is optional.
  93. float pMod1(inout float p, float size) {
  94.     float halfsize = size*0.5;
  95.     float c = floor((p + halfsize)/size);
  96.     p = mod(p + halfsize, size) - halfsize;
  97.     return c;
  98. }
  99.  
  100. vec3 cartToPolar(vec3 p) {
  101.     float x = p.x; // distance from the plane it lies on
  102.     float a = atan(p.y, p.z); // angle around center
  103.     float r = length(p.zy); // distance from center
  104.     return vec3(x, a, r);
  105. }
  106.  
  107. vec3 polarToCart(vec3 p) {
  108.     return vec3(
  109.         p.x,
  110.         sin(p.y) * p.z,
  111.         cos(p.y) * p.z
  112.     );
  113. }
  114.  
  115. vec2 closestPointOnLine(vec2 line, vec2 point){
  116.     line = normalize(line);
  117.     float d = dot(point, line);
  118.     return line * d;
  119. }
  120.  
  121. // Closest of two points
  122. vec3 closestPoint(vec3 pos, vec3 p1, vec3 p2) {
  123.     if (length(pos - p1) < length(pos - p2)) {
  124.         return p1;
  125.     } else {
  126.         return p2;
  127.     }
  128. }
  129.  
  130. // --------------------------------------------------------
  131. // Helix
  132. // --------------------------------------------------------
  133.  
  134. // Closest point on a helix for one revolution
  135. vec3 closestHelixSection(vec3 p, float lead, float radius) {
  136.  
  137.     p = cartToPolar(p);
  138.     p.y *= radius;
  139.  
  140.     vec2 line = vec2(lead, radius * PI * 2.);
  141.     vec2 closest = closestPointOnLine(line, p.xy);
  142.  
  143.     closest.y /= radius;
  144.     vec3 closestCart = polarToCart(vec3(closest, radius));
  145.  
  146.     return closestCart;
  147. }
  148.  
  149. // Closest point on a helix for infinite revolutions
  150. vec3 closestHelix(vec3 p, float lead, float radius) {
  151.     float c = pMod1(p.x, lead);
  152.     vec3 offset = vec3(lead, 0, 0);
  153.     vec3 A = closestHelixSection(p, lead, radius);
  154.     vec3 B = closestHelixSection(p + offset, lead, radius) - offset;
  155.     vec3 C = closestHelixSection(p - offset, lead, radius) + offset;
  156.     vec3 closest = closestPoint(p, A, closestPoint(p, B, C));
  157.     closest += offset * c;
  158.     return closest;
  159. }
  160.  
  161. // Cartesian to helix coordinates
  162. void pModHelix(inout vec3 p, float lead, float radius) {
  163.     vec3 closest = closestHelix(p, lead, radius);
  164.     float helixAngle = atan((2. * PI * radius) / lead);
  165.     vec3 normal = normalize(closest - vec3(closest.x,0,0));
  166.     vec3 tangent = vec3(1,0,0) * rotationMatrix(normal, helixAngle);
  167.     float x = (closest.x / lead) * radius * PI * 2.;
  168.     float y = dot(p - closest, cross(tangent, normal));
  169.     float z = dot(p - closest, normal);
  170.     p = vec3(x, y, z);
  171. }
  172.  
  173. float pModHelixScale(inout vec3 p, float lead, float innerRatio) {
  174.     float radius = mix(.25, .5, innerRatio);
  175.     pModHelix(p, lead, radius);
  176.     float scale = mix(.5, 0., innerRatio);
  177.     p /= scale;
  178.     return 1. / scale;
  179. }
  180.  
  181. float pModHelixUnwrap(inout vec3 p, float lead, float innerRatio, float t) {
  182.     float radius = mix(.25, .5, innerRatio);
  183.     float width = cos(asin(t));
  184.     float adjust = (1. / width);
  185.     float offset = ((.5 * adjust) - .5) * 7.;
  186.  
  187.     vec3 pp = p;
  188.     pp.z -= radius;
  189.     pR(pp.xy, PI * -.5);
  190.     pp.x *= -1.;
  191.  
  192.     p.z += offset;
  193.     radius += offset;
  194.     pModHelix(p, lead, radius);
  195.  
  196.     p = mix(p, pp, rangec(.8, 1., t));
  197.  
  198.     float scale = mix(.5, 0., innerRatio);
  199.     p /= scale;
  200.     return 1. / scale;
  201. }
  202.  
  203.  
  204. // --------------------------------------------------------
  205. // Modelling
  206. // --------------------------------------------------------
  207.  
  208. struct Model {
  209.     float dist;
  210.     vec3 albedo;
  211.     int id;
  212. };
  213.  
  214. float anim(float t, float index) {
  215.     float overlap = .5;
  216.     float steps = 2.;
  217.     float all = mix(steps, 1., overlap);
  218.     float width = 1. / (all - 1.);
  219.     float each = width * (1.- overlap);
  220.     float start = index * each - width * .5;
  221.     float end = start + width;
  222.     return range(start, end, t);
  223. }
  224.  
  225. float unzip(vec3 p, float t) {
  226.     float size = guiZipSize;
  227.     float speed = guiZipSpeed;
  228.  
  229.     t *= size * speed;
  230.  
  231.     if (sign(p.y) != sign(p.x)) {
  232.         float radius = mix(.25, .5, guiInnerRatio);
  233.         float scale = mix(.5, 0., guiInnerRatio);
  234.         float factor = radius / scale * PI * 2.;
  235.         t -= (factor - .5);
  236.     }
  237.  
  238.     return range(size, 0., abs(p.x) + size - t);
  239. }
  240.  
  241. void addPipe(inout float d, vec3 p, float scale, float tt) {
  242.  
  243.     float t = clamp(tt, 0., 1.);
  244.  
  245.     float boundry = 1.;
  246.     float part;
  247.     float separate = (
  248.         rangec(0., boundry * .01, t) * .3 +
  249.         rangec(boundry * .01, boundry, t) * .7
  250.     );
  251.  
  252.     float round = rangec(.0, 1., t);
  253.  
  254.     part = fBox2(p.yz, vec2(mix(guiLead * 2., .5, separate), .5));
  255.     part = mix(part, length(p.yz) - .5, round);
  256.     part /= scale;
  257.  
  258.     d = mix(d, part, smoothstep(.0, .01, t));
  259. }
  260.  
  261. void unzipHelixModel(inout float d, inout float scale, inout vec3 p, float lead, float innerRatio, float step, float invert) {
  262.     float offset = guiZipOffset / lead;
  263.     scale *= pModHelixScale(p, lead, innerRatio);
  264.     p.x *= -1.;
  265.     float t1 = unzip(p + vec3(offset,0,0) * invert, anim(time, step));
  266.     addPipe(d, p, scale, t1);
  267. }
  268.  
  269. Model map(vec3 p) {
  270.  
  271.     float part, d, t1, t2, t3, t4;
  272.     float lead = guiLead;
  273.     float innerRatio = guiInnerRatio;
  274.     vec2 uv1, uv2, uv3;
  275.  
  276.     p /= guiModelScale;
  277.  
  278.     vec3 pp = p;
  279.  
  280.     d = 1e12;
  281.  
  282.     float s = mix(.5, 0., innerRatio);
  283.  
  284.     float scale = 1./pow(1./s, time);
  285.  
  286.     pR(p.xy, PI * -.5 * time + guiRotateModel * PI * 2.);
  287.    
  288.     p *= scale;
  289.     p.z += .5;
  290.  
  291.     scale *= pModHelixUnwrap(p, lead, innerRatio, time);
  292.     p.x *= -1.;
  293.     scale *= pModHelixScale(p, lead, innerRatio);
  294.     p.x *= -1.;
  295.  
  296.     #ifdef ANOTHER_LEVEL
  297.         scale *= pModHelixScale(p, lead, innerRatio);
  298.         p.x *= -1.;
  299.     #endif
  300.  
  301.     d = min(d, length(p.yz) - .5);
  302.     d /= scale;
  303.  
  304.     unzipHelixModel(d, scale, p, lead, innerRatio, -1., 1.);
  305.     unzipHelixModel(d, scale, p, lead, innerRatio, 0., -1.);
  306.     unzipHelixModel(d, scale, p, lead, innerRatio, 1., 1.);
  307.  
  308.     d *= guiModelScale;
  309.  
  310.     return Model(d, vec3(0), 1);
  311. }
  312.  
  313.  
  314. // --------------------------------------------------------
  315. // Ray Marching
  316. // Adapted from: https://www.shadertoy.com/view/Xl2XWt
  317. // --------------------------------------------------------
  318.  
  319. const float MAX_TRACE_DISTANCE = 1.5; // max trace distance
  320. const float INTERSECTION_PRECISION = .001; // precision of the intersection
  321. const int NUM_OF_TRACE_STEPS = 100;
  322. const float FUDGE_FACTOR = 1.; // Default is 1, reduce to fix overshoots
  323.  
  324. struct CastRay {
  325.     vec3 origin;
  326.     vec3 direction;
  327. };
  328.  
  329. struct Ray {
  330.     vec3 origin;
  331.     vec3 direction;
  332.     float len;
  333. };
  334.  
  335. struct Hit {
  336.     Ray ray;
  337.     Model model;
  338.     vec3 pos;
  339.     bool isBackground;
  340.     vec3 normal;
  341.     bool isOutline;
  342. };
  343.  
  344. // Faster runtime
  345. vec3 _calcNormal(vec3 pos){
  346.     vec3 eps = vec3(.0001,0,0);
  347.     vec3 nor = vec3(
  348.         map(pos+eps.xyy).dist - map(pos-eps.xyy).dist,
  349.         map(pos+eps.yxy).dist - map(pos-eps.yxy).dist,
  350.         map(pos+eps.yyx).dist - map(pos-eps.yyx).dist );
  351.     return normalize(nor);
  352. }
  353.  
  354. // Faster compilation
  355. const int NORMAL_STEPS = 6;
  356. vec3 calcNormal(vec3 pos){
  357.     vec3 eps = vec3(.001,0,0);
  358.     vec3 nor = vec3(0);
  359.     float invert = 1.;
  360.     for (int i = 0; i < NORMAL_STEPS; i++){
  361.         nor += map(pos + eps * invert).dist * eps * invert;
  362.         eps = eps.zxy;
  363.         invert *= -1.;
  364.     }
  365.     return normalize(nor);
  366. }
  367.  
  368.  
  369. Hit raymarch(CastRay castRay){
  370.  
  371.     float currentDist = INTERSECTION_PRECISION * 2.0;
  372.     float outlineDist = INTERSECTION_PRECISION * 2.0;
  373.     Model model;
  374.  
  375.     float outline = .0023;
  376.     bool isOutline = false;
  377.     bool miss = false;
  378.  
  379.     float lastDist = currentDist;
  380.  
  381.     Ray ray = Ray(castRay.origin, castRay.direction, 0.);
  382.  
  383.     for( int i=0; i< NUM_OF_TRACE_STEPS ; i++ ){
  384.         if (currentDist < INTERSECTION_PRECISION || ray.len > MAX_TRACE_DISTANCE) {
  385.             break;
  386.         }
  387.         model = map(ray.origin + ray.direction * ray.len);
  388.         lastDist = currentDist;
  389.         currentDist = model.dist;
  390.         miss = currentDist > lastDist;
  391.         outlineDist = currentDist * -1. + outline;
  392.         isOutline = outlineDist > .0 && outlineDist < currentDist && miss;
  393.         if (isOutline) {
  394.             currentDist = outlineDist;
  395.         }
  396.         ray.len += currentDist * FUDGE_FACTOR;
  397.     }
  398.  
  399.     bool isBackground = false;
  400.     vec3 pos = vec3(0);
  401.     vec3 normal = vec3(0);
  402.  
  403.     if (ray.len > MAX_TRACE_DISTANCE) {
  404.         isBackground = true;
  405.     } else {
  406.         pos = ray.origin + ray.direction * ray.len;
  407.         normal = calcNormal(pos);
  408.     }
  409.  
  410.     return Hit(ray, model, pos, isBackground, normal, isOutline);
  411. }
  412.  
  413.  
  414. // --------------------------------------------------------
  415. // Rendering
  416. // --------------------------------------------------------
  417.  
  418. float softshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
  419. {
  420.     float res = 1.0;
  421.     float t = mint;
  422.     float ph = 1e10;
  423.    
  424.     for( int i=0; i<32; i++ )
  425.     {
  426.         float h = map( ro + rd*t ).dist;
  427.         res = min( res, 10.0*h/t );
  428.         t += h;
  429.         if( res<0.0001 || t>tmax ) break;
  430.        
  431.     }
  432.     return clamp( res, 0.0, 1.0 );
  433. }
  434.  
  435.  
  436. float calcAO( in vec3 pos, in vec3 nor )
  437. {
  438.     float occ = 0.0;
  439.     float sca = 1.0;
  440.     for( int i=0; i<5; i++ )
  441.     {
  442.         float hr = 0.01 + 0.12*float(i)/4.0;
  443.         vec3 aopos =  nor * hr + pos;
  444.         float dd = map( aopos ).dist;
  445.         occ += -(dd-hr)*sca;
  446.         sca *= 0.95;
  447.     }
  448.     return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );    
  449. }
  450.  
  451.  
  452. vec3 doLighting(vec3 pos, vec3 nor, vec3 ref, vec3 rd) {
  453.  
  454.     vec3 col;
  455.     vec3 up = normalize(vec3(1));
  456.  
  457.     // lighitng        
  458.     float occ = mix(calcAO( pos, nor ), 1., .8);
  459.     vec3  lig = normalize(vec3(0,.2,1));
  460.     float amb = clamp(dot(nor, up) * .5 + .5, 0., 1.);
  461.     float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
  462.     float fre = pow( clamp(1.0+dot(nor,rd),0.0,1.0), 2.0 );
  463.     vec3  hal = normalize( lig-rd );
  464.     float spe = pow(clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
  465.  
  466.     vec3 cA = vec3(.7,.3,.9);
  467.     vec3 cB = vec3(.4,.9,.8);
  468.     vec3 cC = vec3(.7,0,.7);
  469.  
  470.     col = mix(cA, cB, rangec(.0, 1., dot(-rd, nor))); // need better ramp
  471.     col = mix(col, vec3(.8,.5,1), rangec(.5, 1., dif) * .5);
  472.     col += cC * rangec(.5, 1., dif) * .1;
  473.  
  474.     dif *= softshadow( pos, lig, 0.02, 2.5 ) * .9;
  475.  
  476.     vec3 lin = vec3(0);
  477.     lin += .5 * dif;
  478.     lin += .1 * spe * dif;
  479.     lin += .2 * fre * occ;
  480.     lin += .5 * amb * occ;
  481.     lin += .4 * occ;
  482.     col = col*lin;
  483.  
  484.     return col;
  485. }
  486.  
  487. void render(inout vec3 color, Hit hit){
  488.  
  489.     vec3 background = vec3(.1)* vec3(.5,0,1);
  490.     background = color;
  491.  
  492.     if (hit.isBackground) {
  493.         color = background;
  494.         return;
  495.     }
  496.  
  497.     if (hit.isOutline) {
  498.         color = vec3(background * .33);
  499.     } else {
  500.         vec3 ref = reflect(hit.ray.direction, hit.normal);
  501.         color = doLighting(
  502.             hit.pos,
  503.             hit.normal,
  504.             ref,
  505.             hit.ray.direction
  506.         );
  507.     }
  508.  
  509.     float fog = length(camPosition - hit.pos);
  510.     fog = smoothstep(float(MAX_TRACE_DISTANCE) * .36, float(MAX_TRACE_DISTANCE), fog);
  511.     color = mix(color, background, fog);
  512. }
  513.  
  514. void mainImage( out vec4 fragColor, in vec2 fragCoord )
  515. {
  516.     vec2 p = (-iResolution.xy + 2.0*fragCoord.xy)/iResolution.y;
  517.  
  518.     vec3 color = mix(vec3(.4,.3,.5) * .9, vec3(.6), -.2);
  519.  
  520.     vec3 bgA = vec3(.6,.5,.8) * .55;
  521.     vec3 bgB = vec3(.7,.9,1.) * .5;
  522.     color = mix(bgA, bgB, dot(p, normalize(vec2(.2,-.6))) * .5);
  523.  
  524.     time = iTime;
  525.     time *= .6;
  526.     time = mod(time, 1.);
  527.  
  528.     float camDist = length(camPosition);
  529.  
  530.     mat4 camMat = cameraMatrix;
  531.     float focalLength = guiFocal;
  532.     vec3 rd = normalize(
  533.         (vec4(p, -focalLength, 1) * camMat).xyz
  534.     );
  535.  
  536.     Hit hit = raymarch(CastRay(camPosition, rd));
  537.  
  538.     render(color, hit);
  539.  
  540.     vec2 uv = fragCoord/iResolution.xy;
  541.     float vig = pow(
  542.         16. * uv.x * uv.y * (1. - uv.x) * (1. - uv.y),
  543.         0.075
  544.     );
  545.     color *= vec3(.9, .95, 1.) * vig * 1.1;
  546.  
  547.     color = mix(color, vec3(pow(length(color * .6), 2.)), .1);
  548.     color *= 1.05;
  549.     color = pow(color, vec3(1.2,1.3,1.2));
  550.  
  551.     fragColor = vec4(color,1.0);
  552. }
  553.  

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1856
Re: The Outer Limits
« Reply #39 on: April 04, 2018, 01:29:51 AM »
John,

This is part of OpenGL GLSL shader source code. Not sufficient to run OOTB though. Where can I find the rest of it, please?

This raymarching stuff will be pretty hard to run in a medium sized OpenGL window even on a decent hardware accelerated GPU like mine. And it will be absolutely impossible to mimic it in real time in an ordinary C or assembly program run on a conventional CPU. ;)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

jack

  • Full Member
  • ***
  • Posts: 107
Re: The Outer Limits
« Reply #40 on: April 04, 2018, 02:15:40 AM »
@John
D.J.Peters posted FreeBasic code to run shadertoy code https://www.freebasic.net/forum/viewtopic.php?p=217073
using his FB code and replacing iTime with iGlobalTime everything works on my Mac, I get 60 fps
« Last Edit: April 04, 2018, 02:42:28 AM by jack »

jack

  • Full Member
  • ***
  • Posts: 107
Re: The Outer Limits
« Reply #41 on: April 04, 2018, 03:29:24 AM »
I am impressed with what is possible with so few lines of code https://www.shadertoy.com/view/Ms2SD1

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1856
Re: The Outer Limits
« Reply #42 on: April 04, 2018, 03:35:12 AM »
Thanks Jack,

The FB code you pointed to helps to determine which uniforms in fact the shader uses. I'm not going to use the code proper though because I have a renderer written in FBSL that can run ShaderToy GLSL shaders directly without modification.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1856
Re: The Outer Limits
« Reply #43 on: April 04, 2018, 07:40:58 AM »
Like I said, the shader is rather heavy on the GPU as is always the case with such complex raymarching techniques. The original FB code isn't very reliable in its FPS measurements, so what I get in a 640x360 px OpenGL window that would be the ShaderToy's default is in fact stable 30 FPS (verified by 3rd party Fraps app; yellow figures at bottom right) @ some 75% GPU load. The attached renderer is VSYNC'ed at 60FPS so that's the upper limit it would allow the scene to be rendered at. I'm getting 5FPS full screen on my 1980x1050 monitors.

The zip below contains the precompiled renderer and may cause false AV alarms.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

John

  • Hero Member
  • *****
  • Posts: 3249
Re: The Outer Limits
« Reply #44 on: April 04, 2018, 08:03:16 AM »
Outstanding Mike!