diff --git a/Effects/surface-lights.eff b/Effects/surface-lights.eff index f10c0065a..7603f6c2d 100644 --- a/Effects/surface-lights.eff +++ b/Effects/surface-lights.eff @@ -50,10 +50,10 @@ false - + directional point diff --git a/Nasal/canvas/gui/Widget.nas b/Nasal/canvas/gui/Widget.nas index 652da5c4b..95955bcd2 100644 --- a/Nasal/canvas/gui/Widget.nas +++ b/Nasal/canvas/gui/Widget.nas @@ -127,6 +127,10 @@ gui.Widget = { if( me._view != nil and me._view.update != nil ) me._view.update(me); }, + visibilityChanged: func(visible) + { + me._view._root.setVisible(visible); + }, _setView: func(view) { me._view = view; diff --git a/Nasal/canvas/svg.nas b/Nasal/canvas/svg.nas index 7593b1eb9..955f2d46d 100644 --- a/Nasal/canvas/svg.nas +++ b/Nasal/canvas/svg.nas @@ -49,12 +49,18 @@ var parsesvg = func(group, path, options = nil) var stack = [group]; var close_stack = []; # helper for check tag closing + var defs_stack = []; + var text = nil; var tspans = nil; # lookup table for element ids (for element) var id_dict = {}; + # lookup table for mask and clipPath element ids + var clip_dict = {}; + var cur_clip = nil; + # ---------------------------------------------------------------------------- # Create a new child an push it onto the stack var pushElement = func(type, id = nil) @@ -64,6 +70,21 @@ var parsesvg = func(group, path, options = nil) if( typeof(id) == 'scalar' and size(id) ) id_dict[ id ] = stack[-1]; + + if( cur_clip != nil ) + { + var rect = sprintf( + "rect(%f, %f, %f, %f)", + cur_clip['y'], + cur_clip['x'] + cur_clip['width'], + cur_clip['y'] + cur_clip['height'], + cur_clip['x'] + ); + + stack[-1].set("clip", rect); + stack[-1].set("clip-frame", canvas.Element.LOCAL); + cur_clip = nil; + } } # ---------------------------------------------------------------------------- @@ -367,11 +388,46 @@ var parsesvg = func(group, path, options = nil) return; } + if( size(defs_stack) > 0 ) + { + if( name == "mask" or name == "clipPath" ) + { + append(defs_stack, {'type': name, 'id': attr['id']}); + } + else if( name == "rect" ) + { + foreach(var p; ["x", "y", "width", "height"]) + defs_stack[-1][p] = evalCSSNum(attr[p]); + skip = level; + } + else + { + printlog( + "info", + "parsesvg: skipping unknown element in : <" ~ name ~ ">" + ); + skip = level; + } + return; + } + var style = parseStyle(attr['style']); + var clip_id = attr['clip-path'] or attr['mask']; + if( clip_id != nil ) + { + if( clip_id.starts_with("url(#") + and clip_id[-1] == `)` ) + clip_id = substr(clip_id, 5, size(clip_id) - 5 - 1); + + cur_clip = clip_dict[clip_id]; + if( cur_clip == nil ) + printlog("warn", "parsesvg: clip not found: " ~ clip_id); + } + if( style['display'] == 'none' ) { - skip = level - 1; + skip = level; return; } else if( name == "g" ) @@ -448,7 +504,10 @@ var parsesvg = func(group, path, options = nil) var el_src = id_dict[ substr(ref, 1) ]; if( el_src == nil ) - return printlog("info", "parsesvg: Reference to unknown element (" ~ ref ~ ")"); + return printlog( + "warn", + "parsesvg: Reference to unknown element (" ~ ref ~ ")" + ); # Create new element and copy sub branch from source node pushElement(el_src._node.getName(), attr['id']); @@ -457,6 +516,11 @@ var parsesvg = func(group, path, options = nil) # copying also overrides the id so we need to set it again stack[-1]._node.getNode("id").setValue(attr['id']); } + else if( name == "defs" ) + { + append(defs_stack, "defs"); + return; + } else { printlog("info", "parsesvg: skipping unknown element '" ~ name ~ "'"); @@ -482,11 +546,24 @@ var parsesvg = func(group, path, options = nil) if( skip ) { - if( level <= skip ) + if( level < skip ) skip = 0; return; } + if( size(defs_stack) > 0 ) + { + if( name != "defs" ) + { + var type = defs_stack[-1]['type']; + if( type == "mask" or type == "clipPath" ) + clip_dict[defs_stack[-1]['id']] = defs_stack[-1]; + } + + pop(defs_stack); + return; + } + if( size(close_stack) and (level + 1) == close_stack[-1] ) popElement(); diff --git a/Shaders/surface-light-lightfield.frag b/Shaders/surface-light-lightfield.frag index 717e2b8c2..04e46173b 100644 --- a/Shaders/surface-light-lightfield.frag +++ b/Shaders/surface-light-lightfield.frag @@ -7,6 +7,7 @@ uniform float avisibility; uniform float hazeLayerAltitude; uniform float eye_alt; uniform float terminator; +uniform float size; varying vec3 relPos; varying vec2 rawPos; @@ -140,8 +141,9 @@ void main() transmission = fog_func(transmission_arg); float lightArg = terminator/100000.0; - float attenuationScale = 1.0 + 3.0 * (1.0 -smoothstep(-15.0, 0.0, lightArg)); - float dist_att = exp(-0.3/attenuationScale/pixelSize); + float attenuationScale = 1.0 + 20.0 * (1.0 -smoothstep(-15.0, 0.0, lightArg)); + //float dist_att = exp(-100.0/attenuationScale/size); + float dist_att = exp(-dist/200.0/size/attenuationScale); //vec4 texel = texture2D(texture,gl_TexCoord[0].st); vec4 texel = light_sprite(gl_TexCoord[0].st,transmission, noise); diff --git a/Shaders/surface-light-lightfield.vert b/Shaders/surface-light-lightfield.vert index 43b6c2522..6d90cb8f0 100644 --- a/Shaders/surface-light-lightfield.vert +++ b/Shaders/surface-light-lightfield.vert @@ -20,7 +20,7 @@ void main() relPos = gl_Vertex.xyz - ep.xyz; rawPos = gl_Vertex.xy; float dist = length(relPos); - float lightScale = size * size * size * size * size / 1000.0; + float lightScale = size * size * size * size * size/ 500.0; pixelSize = min(size * size/25.0,lightScale/dist); gl_PointSize = 2.0 * pixelSize; } diff --git a/gui/dialogs/rendering.xml b/gui/dialogs/rendering.xml index 7759c24c7..0b3e739f2 100644 --- a/gui/dialogs/rendering.xml +++ b/gui/dialogs/rendering.xml @@ -363,47 +363,8 @@ - - 5 - 0 - 3 - left - - simplify-far - /sim/rendering/terrain/simplifier/enabled-far - - dialog-apply - simplify-far - - - - - 6 - 0 - 3 - left - - simplify-near - /sim/rendering/terrain/simplifier/enabled-near - - /sim/rendering/terrain/simplifier/enabled-far - - - dialog-apply - simplify-near - - - - - vbox 1 @@ -781,9 +742,23 @@