         return prog
 
     reupload: ->
-        @constructor(@name, @fs_code,
-        @uniforms_config, @attributes_config, @vs_code, @scene)
+        @constructor(@context, @data, @scene)
 
     destroy: ->
         @context.render_manager.gl.deleteProgram @_program

    #        * there are more types but of limited use outside Blender for now
    #   }
    #   There are two implicit vec3 attributes: vertex, vnormal.
    constructor: (@context, data, @scene) ->
        @id = id++
        if @context.all_materials.indexOf(@) == -1
            @context.all_materials.push @
        {@name, uniforms, attributes, params=[]} = data
        @shading_params_dict = {}
        @shading_params = for p in params
            @shading_params_dict[p.name] = new ShadingParams p

            # If matches weren't found, fat chance. We're not warning.

        return cloned

    debug_blender_material: (varnum) ->
        if not @fs_code.splice
            throw "Not a Blender material"
        [lib, code] = @orig_fs_code = @orig_fs_code or @fs_code[...]
        re = new RegExp("\\btmp#{varnum}\\b", "g")
        value = "tmp#{varnum}.x"
        if re.test code
            for line in code.split('\n') when re.test line
                if line.length < 15
                    if /float/.test line
                        value = "tmp#{varnum}"
                else
                    console.log line.replace(re, "TMP"+varnum)
            @fs_code[1] = code.replace('gl_FragColor = ',
                "gl_FragColor = vec4(-#{value}, #{value}, #{value}*10.0-5.0, 1.0);//")
            @reupload()
        else
            console.log "No such variable"
        return



module.exports = {Material,
CD_MCOL, CD_MTFACE, CD_ORCO, CD_TANGENT, CD_SHAPE_KEY, CD_ARMATURE_DEFORM,
