Asset - Shaders TMC LUX Lighting Engine

Discussion in 'Marketplace' started by icuurd12b42, Apr 22, 2016.

  1. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    Since I can no longer update my assets, here is the fix for GMS2 2.1.5.246
    Picture In Picture GMS2 2.1.5.246 bug fix
    script:
    tmc_lux_do_sprited_lights
    under:
    scripts/TMC_LUX/Core Nothing To See Here/

    Code:
    //tmc_lux_do_sprited_lights()
    if(global.tmc_lux_sprited_lights_on == 0) exit;
    var success = false;
    //show_debug_message(global.tmc_lux_sprited_shadows_at);
    if(global.tmc_lux_sprited_lights_at or global.tmc_lux_sprited_shadows_at or global.tmc_lux_light_at)
    {
       // dbug why only one shadow is drawn
        //if we are doing the app surface vesion
        if(!global.tmc_lux_sprited_lights_compatibility_mode && surface_exists(application_surface) && application_surface_is_enabled())
        {
            //do the application surface method 
            var as_w = surface_get_width(application_surface);
            var as_h = surface_get_height(application_surface);
            var xs = as_w/__view_get( e__VW.WView, 0 );
            var ys = as_h/__view_get( e__VW.HView, 0 );
            //if full on lighting blend with back buffer
            if(global.tmc_lux_sprited_lights_on_surface)
            {
                //grab the content of the application surface to the buffer
                global.tmc_lux_back_buffer = tmc_lux_safe_surface_create(global.tmc_lux_back_buffer,as_w,as_h);
                var as_clone = global.tmc_lux_back_buffer;
                if(as_clone!=-1)
                {
                    draw_set_blend_mode(bm_normal);
                    draw_enable_alphablend(0)
                    surface_copy(as_clone,0,0,application_surface);
                    //surface_set_target(as_clone);
                    //draw_text_colour(100,100,"WTF",c_white,c_white,c_white,c_white,1);
                    //surface_reset_target();
                    draw_enable_alphablend(1)
                    var viewx1 = 0,
                        viewy1 = 0,
                        viewx2 = __view_get( e__VW.WView, 0 ),
                        viewy2 = __view_get( e__VW.HView, 0 );
                     
                    if(global.tmc_lux_sprited_shadows_on)
                    {
                        if(global.tmc_lux_sprited_shadows_at)
                        {
                            global.tmc_lux_lights_buffer = tmc_lux_safe_surface_create(global.tmc_lux_lights_buffer,as_w,as_h);   
                            var surf_lights = global.tmc_lux_lights_buffer;
                            var processed_spr_lights = 0;
                            var processed_spr_lights_at = 0;
                            var processed_lights = 0;
                            var processed_lights_at = 0;
                            if(surf_lights!=-1)
                            {
                                surface_set_target(surf_lights);
                                {
                                    draw_clear_alpha(c_black,0);
                                    draw_set_blend_mode(bm_add);
                                    var PlanePoint = tmc_lux_vect3(0,0,0);
                                    var PlaneNormal = tmc_lux_vect3(0,0,1);
                                    var out_IntersectPoint = tmc_lux_vect3(0,0,0);
                                    var shadowEndPos = tmc_lux_vect3(0,0,0);
                                    var shadowPos = tmc_lux_vect3(0,0,0);
                                    var Segment = tmc_lux_segment(shadowPos,shadowEndPos);
                                    var Direction3d = tmc_lux_vect3(0,0,0);
                                    var cone_facing = tmc_lux_vect3(0,0,0);
                                    var light,shadow,lx,ly,dx,dy,sx,sy,sz,dz,lzf,fac,range,dist,radius;
                                    d3d_set_fog(1,c_white,0,0);
                                    for(var j = 0; j<global.tmc_lux_sprited_shadows_at; ++j)
                                    {
                                        shadow = global.tmc_lux_sprited_shadows[j];
                                     
                                        sz = shadow[SPRITED_SHADOWS.Z];
                                        sx = shadow[SPRITED_SHADOWS.X];
                                        sy = shadow[SPRITED_SHADOWS.Y];
                                        radius = shadow[SPRITED_SHADOWS.RADIUS];
                                        shadowPos[@0] = sx;
                                        shadowPos[@1] = sy;
                                        shadowPos[@2] = sz;
                                        for(var i = 0; i< global.tmc_lux_sprited_lights_at; ++i)
                                        {
                                            light = global.tmc_lux_sprited_lights[i];
                                            if(light[SPRITED_LIGHT.SHADOW_PROCESSED]==0)
                                            {
                                                if(light[SPRITED_LIGHT.SHADOW_CASTING]!=0)
                                                {
                                                    lz = light[SPRITED_LIGHT.Z];
                                                    lzf = lz;
                                                    dz = sz-lz;
                                                    var doit = lz>depth;
                                                    //light[@SPRITED_LIGHT.SHADOW_PROCESSED] = doit;
                                                    if(dz>1 and doit)
                                                    {
                                                        processed_spr_lights[processed_spr_lights_at++] = i;
                                                        range = light[SPRITED_LIGHT.RADIUS];
                                                     
                                                        lx = light[SPRITED_LIGHT.X];
                                                        ly = light[SPRITED_LIGHT.Y];
                                                        lz = sz-400;
                                                        dist = point_distance(lx,ly,sx,sy);
                                                        //db[0] = range;
                                                        //db[1] = radius;
                                                        range+=radius;
                                                        //db[2] = range;
                                                        //show_debug_message(db)
                                                        //draw_circle_colour((lx-view_xview)* xs,(ly-view_yview)* ys,range* xs,c_dkgray,c_dkgray,1)
                                                         
                                                        if(dist<range)
                                                        {
                                                            Direction3d[@0] = sx-lx;
                                                            Direction3d[@1] = sy-ly;
                                                            Direction3d[@2] = sz-lz;
                                                            tmc_lux_vect_norm_self(Direction3d);
                                                            tmc_lux_vect_multr_self(Direction3d,10000000);
                                                            shadowEndPos[@0] = sx+Direction3d[0];
                                                            shadowEndPos[@1] = sy+Direction3d[1];
                                                            shadowEndPos[@2] = sz+Direction3d[2];
                                                         
                                                            //dx = sx-lx;
                                                            //dy = sy-ly;
                                                            //d = point_distance_3d(0,0,0,dx,dy,dz);
                                                            //fac = lzf+(dz)
                                                            //sx += dx*(d);
                                                            //sy += dy*(d);
                                                            if(tmc_lux_segment_intersect_plane(Segment, PlanePoint, PlaneNormal, out_IntersectPoint))
                                                            {
                                                             
                                                                var xx = (out_IntersectPoint[0]-__view_get( e__VW.XView, 0 ));
                                                                var yy = (out_IntersectPoint[1]-__view_get( e__VW.YView, 0 ));
                                                                if(xx+radius>viewx1 && xx-radius<viewx2 && yy+radius>viewy1 && yy-radius<viewy2)
                                                                {
                                                                    draw_sprite_ext(
                                                                        shadow[SPRITED_SHADOWS.SPRITE],
                                                                        shadow[SPRITED_SHADOWS.INDEX],
                                                                        xx*xs,
                                                                        yy*ys,
                                                                        shadow[SPRITED_SHADOWS.XSCALE] * xs,
                                                                        shadow[SPRITED_SHADOWS.YSCALE] * ys,
                                                                        shadow[SPRITED_SHADOWS.ROT],
                                                                        c_white,
                                                                        shadow[SPRITED_SHADOWS.ALPHA]*(1-(dist/range)) * light[SPRITED_LIGHT.SHADOW_CASTING]
                                                                    );
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        for(var i = 0; i< global.tmc_lux_light_at; ++i)
                                        {
                                            light = global.tmc_lux_lights[i];
    
                                            if(light[LIGHT.SHADOW_PROCESSED]==0)
                                            {
                                                if(light[LIGHT.SHADOW_CASTING]!=0)
                                                {
                                                    lz = light[LIGHT.Z];
                                                    lzf = lz;
                                                    dz = sz-lz;
                                                    if(dz>1)
                                                    {
                                                        range = light[LIGHT.RANGE];
                                                     
                                                        lx = light[LIGHT.X];
                                                        ly = light[LIGHT.Y];
                                                 
                                                        dist = point_distance_3d(lx,ly,lz,sx,sy,sz);
                                                        var doit = lz>depth;
                                                        //light[@LIGHT.SHADOW_PROCESSED] = doit;
                                                        if(dist<range and doit)
                                                        {
                                                            processed_lights[processed_lights_at++] = i;                                             
                                                            Direction3d[@0] = sx-lx;
                                                            Direction3d[@1] = sy-ly;
                                                            Direction3d[@2] = sz-lz;
                                                            tmc_lux_vect_norm_self(Direction3d);
                                                         
                                                         
                                                            //cone linmits
                                                            var cut_off = light[@LIGHT.CONE_CO]; //-2 is shere, -1 is a dimple sphere. .5 is half a sphere. .9 is a tight cone. must exclude 1
                                                            var cone_dot = 1;
                                                            if(cut_off>-2)
                                                            {
                                                                cone_facing[@0] = light[@LIGHT.FX];
                                                                cone_facing[@1] = light[@LIGHT.FY];
                                                                cone_facing[@2] = light[@LIGHT.FZ];
                                                                tmc_lux_vect_norm_self(cone_facing);
                                                                cone_dot = (tmc_lux_vect_dot(cone_facing,Direction3d) - cut_off)/(1.0-cut_off);
                                                                //vec3 cone_dir = normalize(vec3(-light[@LIGHT.FX],-light[@LIGHT.FY],light[@LIGHT.FZ]));
                                                                //cone_dir = normalize(vec3((cone_dir.x) * x_cosine - (cone_dir.y) * y_sine,
                                                                //                    (cone_dir.x) * y_sine + (cone_dir.y) * x_cosine,
                                                                //                    cone_dir.z));
                                                                // cone_dot = (dot(cone_dir,Final_Light)-cut_off)/(1.0-cut_off);
                                                                //db[0] = cone_facing;
                                                                //db[1] = Direction3d;
                                                                //db[2] = dot_product_3d_normalised(cone_facing[@1],cone_facing[@2],cone_facing[@3],Direction3d[@1],Direction3d[@2],Direction3d[@3]);
                                                                //db[3] = tmc_lux_vect_dot(cone_facing,Direction3d);
                                                                //db[4] = cone_dot;
                                                                //cone_dot=tmc_lux_vect_dot(cone_facing,Direction3d)-cut_off;
                                                                //db[0] = cone_dot;
                                                                //db[1] = tmc_lux_vect_dot(cone_facing,Direction3d);
                                                                //show_debug_message(db)
                                                                cone_dot = clamp(cone_dot,0.0,0.5) * 2;
                                                             
                                                            }
                                                         
                                                             
                                                             
                                                         
                                                            tmc_lux_vect_multr_self(Direction3d,10000000);
                                                            shadowEndPos[@0] = sx+Direction3d[0];
                                                            shadowEndPos[@1] = sy+Direction3d[1];
                                                            shadowEndPos[@2] = sz+Direction3d[2];
                                                         
                                                            //dx = sx-lx;
                                                            //dy = sy-ly;
                                                            //d = point_distance_3d(0,0,0,dx,dy,dz);
                                                            //fac = lzf+(dz)
                                                            //sx += dx*(d);
                                                            //sy += dy*(d);
                                                            if(cone_dot>0 and tmc_lux_segment_intersect_plane(Segment, PlanePoint, PlaneNormal, out_IntersectPoint))
                                                            {
                                                                var xx = (out_IntersectPoint[0]-__view_get( e__VW.XView, 0 ));
                                                                var yy = (out_IntersectPoint[1]-__view_get( e__VW.YView, 0 ));
                                                                if(xx+radius>viewx1 && xx-radius<viewx2 && yy+radius>viewy1 && yy-radius<viewy2)
                                                                {
                                                                    //range = point_distance_3d(lx,ly,lz,out_IntersectPoint[0],out_IntersectPoint[1],out_IntersectPoint[2])
                                                                    // var att = 2000.0 / (light[LIGHT.FALLOFF] + (light[LIGHT.FALLOFF]*range) + (light[LIGHT.FALLOFF]*range*range)); 
                                                                    range = tmc_lux_range_from_falloff(light[LIGHT.R],light[LIGHT.G],light[LIGHT.B],light[LIGHT.POWER],light[LIGHT.FALLOFF],light[LIGHT.RANGE])
                                                                    //arr[0] = dist;
                                                                    //arr[1] = range;
                                                                    range *= light[LIGHT.SHADOW_CASTING];
                                                                    //arr[2] = range;
                                                                    //arr[3] = shadow[SPRITED_SHADOWS.ALPHA]*(1-(dist/range)) *cone_dot * light[LIGHT.SHADOW_CASTING];
                                                                    //show_debug_message(arr);
                                                                    if(dist<range)
                                                                    {
                                                                        draw_sprite_ext(
                                                                            shadow[SPRITED_SHADOWS.SPRITE],
                                                                            shadow[SPRITED_SHADOWS.INDEX],
                                                                            xx * xs,
                                                                            yy * ys,
                                                                            shadow[SPRITED_SHADOWS.XSCALE] * xs,
                                                                            shadow[SPRITED_SHADOWS.YSCALE] * ys,
                                                                            shadow[SPRITED_SHADOWS.ROT],
                                                                            c_white,
                                                                            shadow[SPRITED_SHADOWS.ALPHA]*(1-(dist/range)) *cone_dot//*att
                                                                        );
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                     
                                    }
                                    d3d_set_fog(0,c_white,0,0);
                                    draw_set_blend_mode(bm_subtract);
                                    for(var j = 0; j<global.tmc_lux_sprited_shadows_at; ++j)
                                    {
                                        shadow = global.tmc_lux_sprited_shadows[j];
                                     
                                        draw_sprite_ext(
                                                shadow[SPRITED_SHADOWS.SPRITE],
                                                shadow[SPRITED_SHADOWS.INDEX],
                                                (shadow[SPRITED_SHADOWS.X]-__view_get( e__VW.XView, 0 )) * xs,
                                                (shadow[SPRITED_SHADOWS.Y]-__view_get( e__VW.YView, 0 )) * ys,
                                                shadow[SPRITED_SHADOWS.XSCALE] * xs,
                                                shadow[SPRITED_SHADOWS.YSCALE] * ys,
                                                shadow[SPRITED_SHADOWS.ROT],
                                                c_black,
                                                1
                                            )
                                    }
                                 
                                    draw_set_blend_mode(bm_normal);
                                 
                                    for(var i=0; i< processed_spr_lights_at;++i)
                                    {
                                        light = global.tmc_lux_sprited_lights[processed_spr_lights[i]];
                                        light[@SPRITED_LIGHT.SHADOW_PROCESSED] = 1;
                                    }
                                    for(var i=0; i< processed_lights_at;++i)
                                    {
                                        light = global.tmc_lux_lights[processed_lights[i]];
                                        light[@LIGHT.SHADOW_PROCESSED] = 1;
                                    }
                             
                                }
                                surface_reset_target();
                                if(surface_exists(as_clone))
                                {
                                    surface_set_target(as_clone)
                                    {
                                        //draw_set_blend_mode(bm_subtract);
                                        draw_surface_ext(surf_lights,0,0,1,1,0,c_black,global.tmc_lux_sprited_shadows_power);
                                        //draw_set_blend_mode(bm_normal);
                                        //draw_surface(as_clone,0,0);
                                    }
                                    surface_reset_target()
                                }
                            }
                            //global.tmc_lux_sprited_shadows_at = 0; //cleared next step
                        }
                    }
                }
                //process the draw batch to the lights surface
                global.tmc_lux_lights_buffer = tmc_lux_safe_surface_create(global.tmc_lux_lights_buffer,as_w,as_h);   
                var surf_lights = global.tmc_lux_lights_buffer;
                if(surf_lights!=-1)
                {
                    surface_set_target(surf_lights);
                    {
                        draw_clear_alpha(c_black,0);
                        draw_set_blend_mode(bm_add);
                     
                        var light;
                        for(var i = 0; i< global.tmc_lux_sprited_lights_at; ++i)
                        {
                            light = global.tmc_lux_sprited_lights[i];
                            if(light[SPRITED_LIGHT.PROCESSED]==0)
                            {
                                light[@SPRITED_LIGHT.PROCESSED] = 1;
                                draw_sprite_ext(
                                    light[SPRITED_LIGHT.SPRITE],
                                    light[SPRITED_LIGHT.INDEX],
                                    (light[SPRITED_LIGHT.X]-__view_get( e__VW.XView, 0 )) * xs,
                                    (light[SPRITED_LIGHT.Y]-__view_get( e__VW.YView, 0 )) * ys,
                                    light[SPRITED_LIGHT.XSCALE] * xs,
                                    light[SPRITED_LIGHT.YSCALE] * ys,
                                    light[SPRITED_LIGHT.ROT],
                                    light[SPRITED_LIGHT.COLOUR],
                                    light[SPRITED_LIGHT.ALPHA]
                                )
                           }
                        }
                     
                        draw_set_blend_mode(bm_normal);
                    }
                    surface_reset_target();
                 
                    //everything is still fine, final render the lights to the application surface
                    if(surface_exists(surf_lights) and surface_exists(as_clone) and surface_exists(application_surface))
                    {
                        var tex = surface_get_texture(surf_lights);
                     
                        //gms 2.1.5.246 bug fix
                        //surface_set_target(application_surface);
                        {
                         
                            shader_set(tmc_lux_sprited_light_shdr);
                            texture_set_stage(global.tmc_lux_sh_sprited_light_back_buffer, tex);
                            /////////
                            //gms 2.1.5.246 bug fix
                            //draw_surface(as_clone,0,0);
                            draw_surface_stretched(as_clone,__view_get(e__VW.XView,0),__view_get(e__VW.YView,0),__view_get(e__VW.WView,0),__view_get(e__VW.HView,0));
                            /////////
                            shader_reset();
                        }
                        //gms 2.1.5.246 bug fix
                        //surface_reset_target();
                        success = true;
                    }
                 
                }
                //if(surface_exists(surf_lights)) surface_free(surf_lights);
             
                //if(surface_exists(as_clone)) surface_free(as_clone);
            }
            else if(surface_exists(application_surface))
            {
                //use the back buffer is disabled, render bm_add to the app surface
                //gms 2.1.5.246 bug fix
                //surface_set_target(application_surface);
                {
                    //loop through the draw batch and simply draw with bm_add
                    draw_set_blend_mode(bm_add);
                    var light;
                    for(var i = 0; i< global.tmc_lux_sprited_lights_at; ++i)
                    {
                        light = global.tmc_lux_sprited_lights[i];
                        if(light[SPRITED_LIGHT.PROCESSED]==0)
                        {
                            light[@SPRITED_LIGHT.PROCESSED] = 1;
                            draw_sprite_ext(
                                light[SPRITED_LIGHT.SPRITE],
                                light[SPRITED_LIGHT.INDEX],
                                //////
                                //gms 2.1.5.246 bug fix
                                //(light[SPRITED_LIGHT.X]-__view_get( e__VW.XView, 0 )) * xs,
                                //(light[SPRITED_LIGHT.Y]-__view_get( e__VW.YView, 0 )) * ys,
                                //light[SPRITED_LIGHT.XSCALE] * xs,
                                //light[SPRITED_LIGHT.YSCALE] * ys,
                                (light[SPRITED_LIGHT.X]),
                                (light[SPRITED_LIGHT.Y]),
                                light[SPRITED_LIGHT.XSCALE],
                                light[SPRITED_LIGHT.YSCALE],
                                //////
                                light[SPRITED_LIGHT.ROT],
                                light[SPRITED_LIGHT.COLOUR],
                                light[SPRITED_LIGHT.ALPHA]
                            )
                        }
                    }
                    draw_set_blend_mode(bm_normal);
                }
                //gms 2.1.5.246 bug fix
                //surface_reset_target();
                success = true;
            }         
        }
        if(success == false)
        {
            //to the screen if we have to, everything failed or compatibility mode is on so forced to use the screen
            draw_set_blend_mode(bm_add);
            var light;
            for(var i = 0; i< global.tmc_lux_sprited_lights_at; ++i)
            {
                //loop through the draw batch and simply draw with bm_add on the screen directly
                light = global.tmc_lux_sprited_lights[i];
                if(light[SPRITED_LIGHT.PROCESSED]==0)
                {
                    light[@SPRITED_LIGHT.PROCESSED] = 1;
                    draw_sprite_ext(
                        light[SPRITED_LIGHT.SPRITE],
                        light[SPRITED_LIGHT.INDEX],
                        (light[SPRITED_LIGHT.X]),
                        (light[SPRITED_LIGHT.Y]),
                        light[SPRITED_LIGHT.XSCALE],
                        light[SPRITED_LIGHT.YSCALE],
                        light[SPRITED_LIGHT.ROT],
                        light[SPRITED_LIGHT.COLOUR],
                        light[SPRITED_LIGHT.ALPHA]
                    )
                }
            }
            draw_set_blend_mode(bm_normal);
        }
        //global.tmc_lux_sprited_lights_at = 0;
    }
    
    
     
    Last edited: Aug 14, 2018
  2. StakFallT

    StakFallT Member

    Joined:
    Sep 10, 2017
    Posts:
    5
    hmmm... I'm a little curious. I recently (within a day or two of this post -- 12/23/2018 7:39PM ET) downloaded / updated through the My Library window in GMS 2 and the change notes in that window stats there was a PIP fix, yet when I compare a freshly downloaded version (within a few days of this post -- 12/23/2018 7:44PM ET) with the fix, I get differences in the file contents... I did read the bit about the inability to fix assets (not sure why that would be, I'm kind've curious as to why that would be the case) so I was about to post a url (in text form, since I believe I'm below the 5 post threshold) to a diff file containing the fix. However, I saw the bit in the changelog about the PIP fix. So now I'm kinda curious as to how the freshly downloaded version I got has content-differences than the fix.

    On a side note (but maybe related): I'm having issues with TMC LUX giving a shader error (specifically mentioning tmc_lux_norm_spec_shdr -- though in the debug / compile tab all 4 shaders have an "Invalid shader (is it marked as incompatible type for this target?)" error and I know I've tested TMC LUX before from a freshly imported-into-new-project-of-its-own import. It may be because my video ram and regular ram are fragmented since I haven't rebooted in a few weeks (since having played some graphically intense games -- FFXV for one) but that seems a little odd for that to be the cause for the error given it seems to be a shader compilation error not a shader execution kind of thing. This -seems- like the right place to seek support for TMC LUX specifically since clicking the GMS2 compatible link in the marketplace took me to this thread; however that doesn't seem right either as if everyone posted their problem here it'd become a disorganized mess lol. I've checked TMC's site and the forums there seem almost not even barren it's so barren. I can provide more information (i.e. the Code Error and debugger logs) but I'll defer to icuurd12b42 or other TMC staff as to how best to proceed.
     
  3. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    I can no longer upload/update assets on the store bc I lost my distributor credential file used the sign the asset.

    as for shader compile error, I seen this a long while back. check the shader type. should be glsl....
     
  4. StakFallT

    StakFallT Member

    Joined:
    Sep 10, 2017
    Posts:
    5
    I sort've tried that before. I set tmc_lux_norm_shdr to GLSL (from GLSL ES) and no luck. This time around, I tried setting all 5 shaders to GLSL (from GLSL ES), now I get the error starting at line 345: shader_set(tmc_lux_sprited_light_shdr); in tmc_lux_do_sprited

    It seems swapping around the setting from GLSL to GLSL ES and back gives the same result only it errors at a different point. I then tried variations (some GLSL ES and some not, and no dice). I also deleted the test project that was created when I told it to import all assets into its own project, and reimported into a new project again and still no joy.


    And that sucks about the cred file. Sorry to hear that!
     
  5. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    send me a project export I'll take a look
     
  6. StakFallT

    StakFallT Member

    Joined:
    Sep 10, 2017
    Posts:
    5
    How should I send it to you? Do you want a file-sharing link in this thread (not sure if a project file using a marketplace asset would be sufficient for someone to pull the asset out and use it without paying -- hence my reluctance to just posting a link without asking). I tried to see if I could DM it to you but I don't see where to do that, and the contact publisher link allows me to send you an email but no attachments.
     
  7. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    dropbox has link share. pm me the link
     
  8. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837

    Open every shader, right click the code and set the shader type to glsl es...

    that will fix the problem. you still need to update the tmc_lux_do_sprited_lights code with the posted fix.
     
  9. StakFallT

    StakFallT Member

    Joined:
    Sep 10, 2017
    Posts:
    5
    deleted.
     
  10. StakFallT

    StakFallT Member

    Joined:
    Sep 10, 2017
    Posts:
    5
    For anyone that's been following, are curious and that may have the issue I'm having, icuurd12b42 is still working with me to figure out what the shader issue I'm having is being caused by. It -definitely- looks like it's something on my side, but given various aspects of the issue (was working before -- maybe a month or two ago, other shader code work, HLSL versions of the code don't cause GMS2 to crash, etc.), it's hard to figure out what the actual culprit is. Hopefully, this will all be a little anecdote of things in the toolbox to try if someone else runs into a similar issue :)
     
  11. Morendral

    Morendral Member

    Joined:
    Jun 27, 2016
    Posts:
    364
    Is there any planned compatibility update planned for this with GMS2? right now I get about 15FPS in the platformer demo. I didn't change any of the settings on the side to get that, disabling everything also doesn't help.
     
  12. Bayesian

    Bayesian Member

    Joined:
    Sep 13, 2016
    Posts:
    421
    icuurd12b42 said they can't update their assets anymore. There are at least two posts in this thread about fixes for GMS2. Make sure you read them all.
     
  13. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    the asset only requires the code top in post 51, top of this page to be gms2 compliant.

    as for slowdown I'm not sure. this depends on your video card, the display you run it on. On the right of the demo are a bunch of sliders to tweak... reduce the app surface slider to 1080.

    if you are running at 4k or a resolution too high for the video card, it may borderline the card efficiency...

    Also check your nvidia control panel settings

    upload_2019-2-19_14-48-59.png
     
  14. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    Problem: Array too large for shader

    Reported May 1st 2019 by Aaron Thorne... thanks for helping out!

    On GMS MAC

    Error:
    This is because I am calling shader_set_uniform_f_array using an array returned by background_get_uvs.
    I assume they made some changes that makes this function return an array that is not compatible...

    FIX:
    Add a function
    Code:
    ///ConvertArr(arr);
    var arr = argument0;
    return [arr[0],arr[1],arr[2],arr[3]];
    
    This will convert the background_get_uvs() array to an array accepted by shader_set_uniform_f_array.

    and replace all occurences of
    variable = background/sprite_get_uvs(...);
    variable = ConvertArr(background/sprite_get_uvs(...));


    A less optimised fix is to call ConvertArr(m_Variable); for the following functions and lines...


    tmc_lux_set_norm_shdr

    ==================

    Line 130 shader_set_uniform_f_array(global.tmc_lux_sh_norm_source_texture_pos, ConvertArr(m_SrcTexPos));

    Line 131 shader_set_uniform_f_array(global.tmc_lux_sh_norm_norm_texture_pos, ConvertArr(m_NormTexPos));


    tmc_lux_set_norm_spec_shdr

    =======================

    Line 133 shader_set_uniform_f_array(global.tmc_lux_sh_norm_spec_source_texture_pos, ConvertArr(m_SrcTexPos));

    Line 134 shader_set_uniform_f_array(global.tmc_lux_sh_norm_spec_norm_texture_pos, ConvertArr(m_NormTexPos));

    Line 137shader_set_uniform_f_array(global.tmc_lux_sh_norm_spec_spec_texture_pos, ConvertArr(m_SpecTexPos));


    tmc_lux_set_norm_occ_shdr

    ======================

    Line 132 shader_set_uniform_f_array(global.tmc_lux_sh_norm_occ_source_texture_pos, ConvertArr(m_SrcTexPos));

    Line 133 shader_set_uniform_f_array(global.tmc_lux_sh_norm_occ_norm_texture_pos, ConvertArr(m_NormTexPos));

    Line 137 shader_set_uniform_f_array(global.tmc_lux_sh_norm_occ_amb_texture_pos, ConvertArr(m_OccTexPos));


    tmc_lux_set_norm_spec_occ_shdr

    ===========================

    Line 132 shader_set_uniform_f_array(global.tmc_lux_sh_norm_spec_occ_source_texture_pos, ConvertArr(m_SrcTexPos));

    Line 133 shader_set_uniform_f_array(global.tmc_lux_sh_norm_spec_occ_norm_texture_pos, ConvertArr(m_NormTexPos));

    Line 136 shader_set_uniform_f_array(global.tmc_lux_sh_norm_spec_occ_spec_texture_pos, ConvertArr(m_SpecTexPos));

    Line 139 shader_set_uniform_f_array(global.tmc_lux_sh_norm_spec_occ_amb_texture_pos, ConvertArr(m_OccTexPos));


    Sorry for the inconvenience[/quote]
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice