Recent Posts

Pages: 1 ... 7 8 [9] 10
81
3D-Tech News Around The Web / Batman: Arkham Knight NVIDIA GameWorks Video
« Last post by Stefan on June 10, 2015, 06:06:43 PM »
Check out the incredible effects NVIDIA GameWorks brings to Batman Arkham Knight!  Smoke and fog react to the movement in the fight scenes, including when a box is thrown or part of the floor blows up into piece.  Paper debris gets kicked around as Batman takes on all the baddies. Enhanced rain allows the rain to naturally  bead off when coming into contact with Batman and his cape.

It’s Batman: Arkham Knight, The Way It’s Meant to Be Played.

GameWorks Technology shown in the video:
• Interactive Fog and Smoke:
• Interactive Paper Debris
• PhysX Destruction
• Enhanced Rain
82
Quote
The Latest Tegra K1 Device Is Literally An Oven (Related: The Oven Itself Seems Pretty Awesome)

Does the Tegra K1 in your Nexus 9 run a little toasty? Well, it's got nothing on NVIDIA's latest mobile chip design win, which is literally an oven. I'm sorry, NVIDIA, but the jokes basically write themselves here.
...
As for the selfie aspect, the June has a built-in full-HD camera with two bright white LEDs providing lighting for your foodographs and live-stream cooking action. It is, of course, powered by an NVIDIA Tegra K1 (quad-core, not Denver) processor, which seems like tremendous overkill, but then again, I'm not a smart oven engineer.

Not the usual "GPU baking"...
83
3D-Tech News Around The Web / NVIDIA Mech Ti DirectX 12 tech demo
« Last post by Stefan on June 10, 2015, 05:55:01 PM »
Check out 4gamer.net and good luck with babelfish
84
3D-Tech News Around The Web / ASTC Compression Gets a CUDA Boost
« Last post by Stefan on June 10, 2015, 05:41:19 PM »
NVIDIA is using CUDA and the power of GeForce to accelerate Adaptive Scalable Texture Compression (ASTC) along multiple axes!

Adaptive Scalable Texture Compression (ASTC) is a new standard for texture compression that provides development teams and art directors with the ability to balance texture quality and texture size. Texture compression is not new, but ASTC provides a far greater number of options than older standards. It has a wide spectrum of bit-rate selections, from 8bits/texel (4x4 tiles) to 0.89bits/texel (12x12 tiles). For more information on ASTC generally and how to best use it for different texture assets, check out NVIDIA's ASTC usage guide.
...

We still have a lot of work ahead of us to achieve two axis parallelism but we are progressing nicely. The current implementation with data-parallelism is a huge leap from the CPU based encoder and should assist developers in their testing and usage of ASTC. To that end, we have posted an alpha version of our encoder in the Download Center.
85
3D-Tech News Around The Web / (WebGL) America's Cup 2015
« Last post by Stefan on June 10, 2015, 05:32:32 PM »
 America's Cup 2015   
         
  Render for trophy of america's cup 2015 in Chile

.

 
86
English forum / Re: The Institute converted
« Last post by JeGX on June 09, 2015, 04:58:34 PM »
That makes sense, because layout is a keyword in GLSL with OpenGL 3.2+. As usual, AMD is strict with GLSL compilation. 
87
English forum / Re: The Institute converted
« Last post by Stefan on June 09, 2015, 04:20:09 PM »
It appears that the variable name "layout" is illegal exclusively on AMD GPUs

Updated code with fix below

Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>

<glsl_hacker>
   
  <window name="win3d01" title="MadShaders - Shadertoy/The Institute"
          width="800" height="400"
          gl_version_major="2" gl_version_minor="1" />
         
         
<gpu_program name="shadertoy_prog" >
    <raw_data_vs><![CDATA[     
void main()
{   
    gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;       
}
  ]]></raw_data_vs>
 
    <raw_data_ps><![CDATA[     

// https://www.shadertoy.com/view/Xll3Wn

uniform vec3      iResolution;     // viewport resolution (in pixels)
uniform float     iGlobalTime;     // shader playback time (in seconds)
uniform vec4      iMouse;          // mouse pixel coords. xy: current (if MLB down), zw: click

// illegal variable name "layout" replaced with "yikes"

//

//The Institute by eiffie

#define time iGlobalTime
#define size iResolution
#define AUTO_OVERSTEP

float px;
vec4 prp=vec4(0.0);
vec3 L;

float rnd(vec2 c){return fract(sin(dot(vec2(1.317,19.753),c))*413.7972);}
float rndStart(vec2 gl_FragCoord){
    return 0.5+0.5*rnd(gl_FragCoord.xy);
}
float smin(float a,float b,float k){float h=clamp(0.5+0.5*(b-a)/k,0.0,1.0);return b+h*(a-b-k+k*h);}
float noyz(vec2 p){//value noise - original author??
    vec2 c=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);
    float k=257.0,u=c.x+c.y*k;
    vec4 v=vec4(u,u+1.0,u+k,u+k+1.0);v=fract(fract(v*1.23456789)*9.18273645*v);
    return mix(mix(v.x,v.y,f.x),mix(v.z,v.w,f.x),f.y);
}
float fbm(vec2 p){
    vec2 s=sin(p*0.3+2.4*sin(p.yx*0.3));
    float h=1.0+(s.x+s.y)*0.5,a=0.5;
    p+=s.yx*0.66;
    for(int i=0;i<3;i++){
        h+=noyz(p)*a;
        a*=0.3;p=vec2(p.x+p.y*0.7,p.x-p.y+0.13)*2.0;
    }   
    return h;
}
vec3 Sky(vec3 rd){
    vec3 col=mix(vec3(0.4,0.2,0.0),vec3(0.5,0.7,0.7),clamp(0.25-0.5*rd.z,0.0,1.0));
    col+=vec3(1.2,1.1,0.9)*pow(max(0.0,dot(rd,L)),100.0);
    float h=noyz(rd.xy*5.0)*0.5+noyz(vec2(2.0*abs(atan(rd.y,rd.x)),rd.z*20.0));
    col=mix(col,vec3(0.9,0.8,0.6),clamp(h*0.5-0.4,0.0,1.0));
    return mix(vec3(0.1,0.2,0.1),col,clamp((-rd.z+0.05)*20.0,0.0,1.0));
}

float capsule(vec3 p){return length(vec3(p.x,p.y-clamp(p.y,-3.0,10.0),p.z));}
float rcap(vec3 p){return length(vec2(p.x-clamp(p.x,-7.0,7.0),max(abs(p.y),abs(p.z))));}

float DE(in vec3 p){
    float yikes=(length(p.xy+vec2(8.0,-6.0))-45.0);
    yikes=smin(yikes,abs(p.y-28.0+sin(p.x*0.01)*40.0)-5.0,20.0)*0.02;
    float h=fbm(p.xy*0.1)*10.0*pow(clamp(yikes,0.0,1.0),0.7),d=-p.z+7.0-h,dG=d;
    for (int n = 0; n < 4; n++) {
        p=clamp(p, -3.1, 3.1) *2.0-p;
        p+=vec3(1.9,3.2,8.6);
        p=p.yzx;
        d=min(d,min(capsule(p)-3.0,rcap(p)-2.0));
    }
   
    if(d<0.25 && d<dG){
        float flr=floor(p.y);
        float rs=1.0+sin(flr)*0.5;
        p=vec3(rs,1.0,rs)*0.5-abs(mod(p,vec3(rs,1.0,rs))-vec3(rs,1.0,rs)*0.5);
        float d2=d+0.05;
        if(flr<-rs || rs<0.6)
            d=min(d2,max(d,min(p.y,min(p.x,p.z))-0.0125));
        else if(flr<rs*2.0 || rs<0.75)
            d=max(d,min(p.y,min(p.x,p.z))-0.025);
        else {
            d=max(d,min(p.y,max(p.x,p.z))-0.05);
            if(prp.x<0.0)prp=vec4((rs>1.3)?length(p):10.0,0.0,0.0,(max(p.x,p.z)<0.06)?4.0:3.0);
        }
        if(prp.x<0.0){
            if(d==d2)prp=vec4(10.0,0.0,0.0,2.0);
            else prp=vec4(10.0,0.0,0.0,3.0);
        }
    }else if(prp.x<0.0)prp=vec4(10.0,h,yikes,1.0);
    return d;
}

float shadao(vec3 ro, vec3 rd, float px,vec2 gl_FragCoord){//pretty much IQ's SoftShadow
    float res=1.0,d,t=10.0*px*rndStart(gl_FragCoord);
    for(int i=0;i<12;i++){
        d=max(0.0,DE(ro+rd*t)*1.5);
        t+=d;
        res=min(res,d/t);
    }
    return res;
}

vec3 Color(vec3 ro, vec3 rd, float t, vec3 col, bool bFill, vec2 gl_FragCoord){
    ro+=rd*t;
    prp.x=-1.0;
    float d=DE(ro),spec=0.0,n=noyz(ro.xy*3.0);
    vec2 e=vec2(px*t,0.0);
    vec3 dn=vec3(DE(ro-e.xyy),DE(ro-e.yxy),DE(ro-e.yyx));
    vec3 dp=vec3(DE(ro+e.xyy),DE(ro+e.yxy),DE(ro+e.yyx));
    vec3 N=(dp-dn)/(length(dp-vec3(d))+length(vec3(d)-dn));
    vec3 R=reflect(rd,N);
    vec3 lc=vec3(1.0,0.9,0.,sc,rc=Sky(R);
    if(prp.w<1.5){
        sc=mix(vec3(0.8,0.8,0.3),vec3(0.2),clamp(abs(abs(ro.y-28.0+sin(ro.x*0.01)*40.0)-0.25)*4.0,0.0,1.0));
        sc=mix(sc,mix(vec3(0.2,0.3,0.1),vec3(0.6,0.5,0.4),clamp(prp.y*0.05-0.25,0.0,1.0)),clamp(prp.z*100.0,0.0,1.0));
        spec=0.2;//clamp(2.5-prp.y,0.0,1.0);
        n*=0.1;
    }else if(prp.w<2.5){sc=vec3(0.4,0.5,0.6);spec=1.0;n*=0.3;
    }else if(prp.w<3.5){sc=vec3(0.6,0.63,0.62);spec=0.5;n*=0.4;}
    else {sc=vec3(0.5,0.5,0.0);spec=0.5;}
    sc*=(1.0-n);
    float sh=clamp(shadao(ro,L,px*t,gl_FragCoord)+0.2,0.0,1.0);
    sh=sh*(0.5+0.5*dot(N,L))+exp(-prp.x*5.0);
    vec3 scol=sh*lc*(sc+0.5*spec*rc*pow(max(0.0,dot(R,L)),2.0));
    if(bFill)d*=0.05;
    col=mix(scol,col,clamp(d/(px*t),0.0,1.0));
    return col;
}
mat3 lookat(vec3 fw){
    fw=normalize(fw);vec3 rt=normalize(cross(fw,vec3(0.0,0.0,-1.0)));return mat3(rt,cross(rt,fw),fw);
}
vec3 cpnt(float t){
    if(t<0.5)return vec3(-45.0,30.0,-38.0);
    if(t<1.5)return vec3(-20.0,23.0,-25.0);
    if(t<2.5)return vec3(-13.0,23.0,-2.5);
    if(t<3.5)return vec3(10.0,26.0,-2.5);
    return vec3(12.0,21.0,6.6);
}
vec3 path(float t){
    float t2=t-t*t*0.05;
    if(t<10.0)return vec3(-1000.0+t2*200.0,30.0-sin((-1000.0+t2*200.0)*0.01)*40.0,4.25);
    t2=time-10.0;
    float r=60.0-t2;
    if(t<25.0)return vec3(-8.0+r*cos(t2*0.3),6.0+r*sin(t2*0.25),-t2*4.0);
    if(t<45.0){
        t2=(t-25.0)/5.0;r=floor(t2);t2=fract(t2);
        return mix(cpnt(r),cpnt(r+1.0)-0.25*cpnt(r+2.0)*(1.0-t2),t2);
    }
    if(t<60.0){
        t2=t-45.0;
        t2=t2-t2*t2*0.025;
        r=500.0-t2*50.0;
        vec3 p=vec3(cos(t2*0.2)*r,sin(t2*0.2)*r,-30.0);
        float d1=DE(p),d2=DE(p+vec3(0.0,-10.0,0.0));
        p.z+=(d1+d2)*0.4;
        return p;
    }
    return vec3(-8.0+cos(t*0.3)*60.0,6.0+60.0*sin(t*0.2),-29.5+sin(t*0.1)*10.0);
}
void main()
{
    px=0.5/size.y;
    L=normalize(vec3(0.5,0.3,-0.6));
    float tim=time;
    vec3 ro=path(tim);
    vec3 ta=path(tim+0.5);
    if(tim>10.0 && tim<25.0)ta=vec3(0.0);
    if(tim>60.0)ta=vec3(0.0,0.0,-20.0);
    vec3 rd=lookat(ta-ro)*normalize(vec3((2.0*gl_FragCoord.xy-size.xy)/size.y,3.0));
    //ro=eye*10.0;rd=normalize(dir);
    float t=DE(ro)*rndStart(gl_FragCoord),d=0.0,od=1.0,step=0.0,os=0.0,pd=10.0;
    if(t<0.0){
        gl_FragColor=vec4(0.0,0.0,0.0,1.0);
        return;
    }
    vec4 edge=vec4(-1.0);
    bool bGrab=false;
    for(int i=0;i<78;i++){
        t+=step;
        d=DE(ro+rd*t);
#ifdef AUTO_OVERSTEP
        if(d>=os){        //we have NOT stepped over anything
            os=0.36*d*d/pd;//overstep based on ratio of this step to last
            step=d+os;    //add in the overstep
            pd=d;        //save this step length for next calc
        }else{step=-os;d=0.0001;pd=100000.0;os=0.0;}//remove overstep
#else
        step=d;
#endif

        if(d>od){
            if(bGrab && od<px*t && edge.x<0.0){
                edge=vec4(edge.yzw,t-od);
                bGrab=false;
            }
        }else bGrab=true;
        od=d;
        if(t>1000.0 || d<0.00001)break;
    }
    bool bFill=false;
    d*=0.05;
    if(d<px*t){
        if(edge.x>0.0)edge=edge.wxyz;
        edge=vec4(edge.yzw,t);
        bFill=true;
    }
    vec3 col=Sky(rd);
    for(int i=0;i<4;i++){
        if(edge.w>0.0)col=Color(ro,rd,edge.w,col,bFill,gl_FragCoord);
        edge=edge.wxyz;
        bFill=false;
    }
    float dimmer=clamp(min(abs(time-10.0),min(abs(time-25.0),min(abs(time-45.0),abs(time-60.0)))),0.0,1.0);
    gl_FragColor = vec4(1.5*col*dimmer*dimmer,1.0);
}

//

]]></raw_data_ps>

</gpu_program>

 
    <script name="init_scene" run_mode="INIT" >
        <raw_data><![CDATA[   

app_dir = gh_utils.get_scripting_libs_dir()         
dofile(app_dir .. "lua/Moon3D_v2.lua")

moon3d.init(2, 1)
moon3d.graphics.vsync(0)

bmfont = moon3d.font.create("trebuchet_20px.fnt", "data/")
bmfont_texture = moon3d.font.getTexture(bmfont)
moon3d.madshaders.setBmFontData(bmfont, bmfont_texture)

winW, winH = moon3d.window.getSize()

quad = moon3d.graphics.newQuad(winW, winH)
shadertoy_prog = moon3d.graphics.getGpuProgram("shadertoy_prog")

-- tex0 = moon3d.image.load2d("./data/tex16.png")

moon3d.madshaders.resetBenchmarkData()

        ]]></raw_data>
    </script>

 
    <script name="update_scene" run_mode="FRAME" >
        <raw_data><![CDATA[   

moon3d.startFrame(0, 0, 0, 1)

local global_time = moon3d.getTime()

moon3d.madshaders.updateBenchmarkData(global_time)

moon3d.camera.bindOrtho()

moon3d.graphics.bindGpuProgram(shadertoy_prog)
moon3d.madshaders.updateShadertoyCommonParams(shadertoy_prog, global_time)
--moon3d.madshaders.setShadertoyTexture(shadertoy_prog, tex0, 0)
moon3d.graphics.draw(quad)

moon3d.madshaders.displayBenchmarkInfoV2("Shadertoy/The institute", global_time, 1, 1, 1, 1)

moon3d.endFrame()

        ]]></raw_data>
    </script>
   

    <script name="resize_scene" run_mode="SIZE" >
        <raw_data><![CDATA[   

moon3d.window.resize()
winW, winH = moon3d.window.getSize()
moon3d.graphics.resizeQuad(quad, winW, winH)

        ]]></raw_data>
    </script>
 
</glsl_hacker>
88
3D-Tech News Around The Web / DirectX12 Feature Level for AMD, Intel and NVIDIA GPUs
« Last post by JeGX on June 09, 2015, 02:06:34 PM »
A bit lost with DirectX feature level?

Quote
A DirectX feature level, in contrast, defines the level of support a GPU gives while still supporting the underlying specification. This capability was first introduced in DirectX 11. Microsoft defines a feature level as “a well defined set of GPU functionality. For instance, the 9_1 feature level implements the functionality that was implemented in Microsoft Direct3D 9, which exposes the capabilities of shader models ps_2_x and vs_2_x, while the 11_0 feature level implements the functionality that was implemented in Direct3D 11.”



Link:
- http://www.extremetech.com/extreme/207598-demystifying-directx-12-support-what-amd-intel-and-nvidia-do-and-dont-deliver
89
English forum / Flappy Bird converted
« Last post by Stefan on June 08, 2015, 11:04:47 PM »
Flappy Bird converted to GLSL Hacker format

iChannelTime[0] needs to be replaced with iGlobalTime

Copy the code and save as Flappy_Bird_gl2.xml in demo folder of MadShaders.

Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>

<glsl_hacker>
   
  <window name="win3d01" title="MadShaders - Shadertoy/Flappy Bird"
          width="800" height="400"
          gl_version_major="2" gl_version_minor="1" />
         
         
<gpu_program name="shadertoy_prog" >
    <raw_data_vs><![CDATA[     
void main()
{   
    gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;       
}
  ]]></raw_data_vs>
 
    <raw_data_ps><![CDATA[     

// https://www.shadertoy.com/view/ls2GRt

uniform vec3      iResolution;     // viewport resolution (in pixels)
uniform float     iGlobalTime;     // shader playback time (in seconds)
uniform vec4      iMouse;          // mouse pixel coords. xy: current (if MLB down), zw: click

//iChannelTime[0] replaced with iGlobalTime

// Flappy Bird (tribute), fragment shader by movAX13h, Feb.2014

float rand(float n)
{
    return fract(sin(n * 12.9898) * 43758.5453)-0.5;
}

void pipe(inout vec3 col, vec2 p, float h)
{
    vec2 ap = abs(p);
    if (ap.y > h)
    {
        float dy = ap.y - h;
        if (dy < 60.0) ap.x *= 0.93;
        col = mix(col, vec3(0.322, 0.224, 0.290), step(ap.x, 65.0)); // outline
        if (dy > 60.0 || mod(dy, 55.0) > 5.0)
        {
            float gradient = 0.0;
            if (abs(dy - 57.5) > 7.5) gradient = max(0.0, 0.5*cos(floor((p.x+25.0)/5.0)*5.0*(0.026 - 0.006*step(dy, 10.0))));
            col = mix(col, vec3(0.322, 0.506, 0.129) + gradient, step(ap.x, 60.0)); // pipe
        }
    }
}

// constant-array-index workaround ---
float slice(int id)
{
    // flappy bird character (no worries, I have a tool)
    if (id == 0) return 2359296.0;
    if (id == 1) return 585.0;
    if (id == 2) return 4489216.0;
    if (id == 3) return 46674.0;
    if (id == 4) return 4751360.0;
    if (id == 5) return 2995812.0;
    if (id == 6) return 8945664.0;
    if (id == 7) return 3003172.0;
    if (id == return 9469963.0;
    if (id == 9) return 7248164.0;
    if (id == 10) return 2359385.0;
    if (id == 11) return 10897481.0;
    if (id == 12) return 6554331.0;
    if (id == 13) return 9574107.0;
    if (id == 14) return 2134601.0;
    if (id == 15) return 9492189.0;
    if (id == 16) return 3894705.0;
    if (id == 17) return 9474632.0;
    if (id == 18) return 2396785.0;
    if (id == 19) return 9585152.0;
    if (id == 20) return 14380132.0;
    if (id == 21) return 8683521.0;
    if (id == 22) return 2398500.0;
    if (id == 23) return 1.0;
    if (id == 24) return 4681.0;   
    return 0.0;   
}

vec3 color(int id)
{
    // flappy bird colors
    if (id == 0) return vec3(0.0);
    if (id == 1) return vec3(0.320,0.223,0.289);
    if (id == 2) return vec3(0.996,0.449,0.063);
    if (id == 3) return vec3(0.965,0.996,0.965);
    if (id == 4) return vec3(0.996,0.223,0.000);
    if (id == 5) return vec3(0.836,0.902,0.805);
    return vec3(0.965,0.707,0.191);
}
// ---

int sprite(vec2 p)
{
    // this time it's 3 bit/px (8 colors) and 8px/slice, 204px total
    int d = 0;
    p = floor(p);
    p.x = 16.0 - p.x;
   
    if (clamp(p.x, 0.0, 16.0) == p.x && clamp(p.y, 0.0, 11.0) == p.y)
    {
        float k = p.x + 17.0*p.y;
        float s = floor(k / 8.0);
        float n = slice(int(s));
        k = (k - s*8.0)*3.0;
        if (int(mod(n/(pow(2.0,k)),2.0)) == 1)         d += 1;
        if (int(mod(n/(pow(2.0,k+1.0)),2.0)) == 1)     d += 2;
        if (int(mod(n/(pow(2.0,k+2.0)),2.0)) == 1)     d += 4;
    }
    return d;
}

void hero(inout vec3 col, vec2 p, float angle)
{
    p = vec2(p.x * cos(angle) - p.y * sin(angle), p.y * cos(angle) + p.x * sin(angle));
    int i = sprite(p*0.2);
    col = mix(col, color(i), min(1.0, float(i)));
}

void ground(inout vec3 col, vec2 p)
{
    p = floor(p);
    if (p.y > -280.0) return;
    if (p.y < -285.0) col = color(1);
    if (p.y < -290.0) col = vec3(0.902, 1.000, 0.549);
    if (p.y < -295.0) col = mix(vec3(0.612, 0.906, 0.353), vec3(0.451, 0.745, 0.192), step(mod(p.x-floor(p.y/5.0)*5.0, 60.0), 30.0));
    if (p.y < -325.0) col = vec3(0.322, 0.506, 0.129);
    if (p.y < -330.0) col = vec3(0.839, 0.667, 0.290);
    if (p.y < -335.0) col = vec3(0.871, 0.843, 0.580);
}

void sky(inout vec3 col, vec2 p)
{
    col = mix(col, vec3(1.0), 0.3*sin(p.y*0.01));
}

float hAt(float i)
{
    return 250.0*rand(i*1.232157);
}

void main()
{
    float s = 2000.0/iResolution.x;
    vec2 p = max(1.6666667, s)*(gl_FragCoord.xy - iResolution.xy * 0.5);
    float dx = iGlobalTime * 320.0;
    p.x += dx;
   
    vec3 col = vec3(0.322, 0.745, 0.808);
    sky(col, vec2(0.0, -100.0)-p);
   
    pipe(col, vec2(mod(p.x, 400.0)-200.0, p.y + hAt(floor(p.x / 400.0)) - 80.0), 110.0);
   
    float hx = dx - 200.0; // hero x
    float sx = hx - 300.0; // sample x
    float i = floor(sx/400.0); // instance
    float ch = hAt(i); // current height
    float nh = hAt(i+1.0); // next height
    //    float bh = abs(60.0*sin(iChannelTime[0]*6.0)); // bounce height
    float bh = abs(60.0*sin(iGlobalTime*6.0)); // bounce height
    float hy = bh - mix(ch, nh, min(1.0, mod(sx, 400.0)*0.005)) + 80.0; // hero y
    float angle = -min(0.1, 0.002*(bh));
    hero(col, vec2(hx, hy)-p, angle);
   
    ground(col, p);
   
    gl_FragColor = vec4(col,1.0);
}



//

]]></raw_data_ps>

</gpu_program>

 
    <script name="init_scene" run_mode="INIT" >
        <raw_data><![CDATA[   

app_dir = gh_utils.get_scripting_libs_dir()         
dofile(app_dir .. "lua/Moon3D_v2.lua")

moon3d.init(2, 1)
moon3d.graphics.vsync(0)

bmfont = moon3d.font.create("trebuchet_20px.fnt", "data/")
bmfont_texture = moon3d.font.getTexture(bmfont)
moon3d.madshaders.setBmFontData(bmfont, bmfont_texture)

winW, winH = moon3d.window.getSize()

quad = moon3d.graphics.newQuad(winW, winH)
shadertoy_prog = moon3d.graphics.getGpuProgram("shadertoy_prog")

moon3d.madshaders.resetBenchmarkData()

        ]]></raw_data>
    </script>

 
    <script name="update_scene" run_mode="FRAME" >
        <raw_data><![CDATA[   

moon3d.startFrame(0, 0, 0, 1)

local global_time = moon3d.getTime()

moon3d.madshaders.updateBenchmarkData(global_time)

moon3d.camera.bindOrtho()

moon3d.graphics.bindGpuProgram(shadertoy_prog)
moon3d.madshaders.updateShadertoyCommonParams(shadertoy_prog, global_time)
moon3d.graphics.draw(quad)

moon3d.madshaders.displayBenchmarkInfoV2("Shadertoy/Flappy Bird", global_time, 1, 1, 1, 1)

moon3d.endFrame()

        ]]></raw_data>
    </script>
   

    <script name="resize_scene" run_mode="SIZE" >
        <raw_data><![CDATA[   

moon3d.window.resize()
winW, winH = moon3d.window.getSize()
moon3d.graphics.resizeQuad(quad, winW, winH)

        ]]></raw_data>
    </script>
 
</glsl_hacker>

90
Quote
A 24.8 precision texture interpolator means that there's a maximum of 256 intermediate values possible between two adjacent pixels of a texture. 256 values are a lot for albedo textures for sure, but often in computer graphics textures encode not only surface properties, but they serve as LookUp Tables (LUT), heighfields (for terrain rendering), or who knows what. In those cases, you can find yourself easily lacking more resolution than 256 values between pixels. This article is about why this problem manifests and how it can be easily workarounded. In the image below you can see the difference between a regular GLSL's texture() or texture2D() call which triggers the hardware texture interpolation with its 256 intermediate values and that procudes starcase artifacts versus the correct full floating point texture interpolation which produces the desired smooth results.

Link: http://iquilezles.org/www/articles/hwinterpolation/hwinterpolation.htm

In short for GLSL shaders, replace:
Code: [Select]
// regular texture fetching
vec4 textureBad( sampler2D sam, vec2 uv )
{
    return texture( sam, uv );
}

by

Code: [Select]
// improved bilinear interpolated texture fetch
vec4 textureGood( sampler2D sam, vec2 uv )
{
    vec2 res = textureSize( sam );

    vec2 st = uv*res - 0.5;

    vec2 iuv = floor( st );
    vec2 fuv = fract( st );

    vec4 a = texture( sam, (iuv+vec2(0.5,0.5))/res );
    vec4 b = texture( sam, (iuv+vec2(1.5,0.5))/res );
    vec4 c = texture( sam, (iuv+vec2(0.5,1.5))/res );
    vec4 d = texture( sam, (iuv+vec2(1.5,1.5))/res );

    return mix( mix( a, b, fuv.x),
                mix( c, d, fuv.x), fuv.y );
}
Pages: 1 ... 7 8 [9] 10