Re: [Flightgear-devel] Stencil operations for effects and new "light cone"
Hi Patrice, and thanks Heiko! > There is a detail that I do not manage to sort out, though. > The effect looks great at day : http://imagebin.org/82128 > but at night, it tends to fill the lit area with grey, overwriting the > ground texture : http://imagebin.org/82129 Yes, that is an issue, and it is because this "light" is rendered as kind of an post processing effect. Basically, the current blend mode just adds the light's color to whatever there is on the screen. And during night it is mostly black which results in only the light's color showing up. I tried with multiplying the existing color values, but again, because there is just black, the result is not physically correct (the otherwise hidden details will not become visible). I don't know if the only real solution is to use real lights for "critical" lights as Tim suggested, but that is not possible at the moment. I will try to investigate if I can find some way around this. > my light cone matierial is as follows : MATERIAL "DefaultWhite" rgb 0.2 > 0.2 0.2 amb 0.2 0.2 0.2 emis 0 0 0 spec 0 0.5 0 shi 64 trans 0.2 This is ok, but I would rather use "rgb 1 1 1 amb 1 1 1" (white cone) and "trans 0.8" which means the cone is almost invisible. The trans works the opposite of normal alpha, at least to my experiences. Only the rgb or amb material is used, the others should have no effect. Hope this clears things up, Lauri -- Lauri Peltonen lauri.pelto...@gmail.com -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
Re: [Flightgear-devel] Stencil operations for effects and new "light cone"
Hello ! I have just tried the new light patch, it is great ! No more visible light cone :) There is a detail that I do not manage to sort out, though. The effect looks great at day : http://imagebin.org/82128 but at night, it tends to fill the lit area with grey, overwriting the ground texture : http://imagebin.org/82129 my light cone matierial is as follows : MATERIAL "DefaultWhite" rgb 0.2 0.2 0.2 amb 0.2 0.2 0.2 emis 0 0 0 spec 0 0.5 0 shi 64 trans 0.2 I tried to change the rgb, ambient, emis and alpha, but didn't find a way to fix it. Any idea ? On 27/01/2010 12:59, Heiko Schulz wrote: > Hi Lauri!, > > > >> Hi! >> >> The attached patch adds support for stencil operations in >> effects. >> Patches are for simgear's scene/material/Effect.cxx and >> flightgear's >> Main/CameraGroup.cxx. I did them with "cvs diff >> " against latest >> CVS version. Hope that is correct way. >> >> >> The format of stencil operations in effect file is >> following: >> >> ... >> ... >> ... >> ... >> ... >> ... >> >> >> Where function can be never, always, less, less-or-equal, >> equal, >> not-equal, greater-or-equal or greater. >> >> Value is the reference value used in stencil operations and >> mask is the >> stencil bit mask. >> >> Stencil-fail, z-fail and pass are stencil operations if >> stencil test >> fails or stencil-test passes but z-test fails or both >> passes. Possible >> functions are zero, keep, replace, increase, decrease, >> invert, >> increase-wrap and decrease-wrap. >> >> I think one has to know something about stencil buffers to >> use this ;) >> >> >> I also added a new general tag > type="vec4d">1 0 0 >> 1 that allows only writing to certain >> channel (in this >> example only to red and alpha channel. >> >> >> As an example, I attached new version of the light-cone.eff >> I posted few >> days ago. This one does the same thing but with stencil >> operations. >> The .ac model used with this should be almost transparent >> or it will be >> too bright. >> >> This version has some issue if there is more than 5 light >> models >> simultaneously. I don't know if this is a OSG issue about >> rendering >> orders or something? But please test and comment. >> >> Lauri, a.k.a. Zan >> -- >> Lauri Peltonen >> lauri.pelto...@gmail.com >> > > This are great news! That means we can have now landinglights, cockpitlights > etc. > > Can't wait to to try this! > > Many thanks for this! > > Cheers > Heiko > > __ > Do You Yahoo!? > Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz > gegen Massenmails. > http://mail.yahoo.com > > -- > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > ___ > Flightgear-devel mailing list > Flightgear-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/flightgear-devel > -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
Re: [Flightgear-devel] Stencil operations for effects and new "light cone"
Hi Lauri!, > Hi! > > The attached patch adds support for stencil operations in > effects. > Patches are for simgear's scene/material/Effect.cxx and > flightgear's > Main/CameraGroup.cxx. I did them with "cvs diff > " against latest > CVS version. Hope that is correct way. > > > The format of stencil operations in effect file is > following: > > ... > ... > ... > ... > ... > ... > > > Where function can be never, always, less, less-or-equal, > equal, > not-equal, greater-or-equal or greater. > > Value is the reference value used in stencil operations and > mask is the > stencil bit mask. > > Stencil-fail, z-fail and pass are stencil operations if > stencil test > fails or stencil-test passes but z-test fails or both > passes. Possible > functions are zero, keep, replace, increase, decrease, > invert, > increase-wrap and decrease-wrap. > > I think one has to know something about stencil buffers to > use this ;) > > > I also added a new general tag type="vec4d">1 0 0 > 1 that allows only writing to certain > channel (in this > example only to red and alpha channel. > > > As an example, I attached new version of the light-cone.eff > I posted few > days ago. This one does the same thing but with stencil > operations. > The .ac model used with this should be almost transparent > or it will be > too bright. > > This version has some issue if there is more than 5 light > models > simultaneously. I don't know if this is a OSG issue about > rendering > orders or something? But please test and comment. > > Lauri, a.k.a. Zan > -- > Lauri Peltonen > lauri.pelto...@gmail.com This are great news! That means we can have now landinglights, cockpitlights etc. Can't wait to to try this! Many thanks for this! Cheers Heiko __ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
[Flightgear-devel] Stencil operations for effects and new "light cone"
Hi! The attached patch adds support for stencil operations in effects. Patches are for simgear's scene/material/Effect.cxx and flightgear's Main/CameraGroup.cxx. I did them with "cvs diff " against latest CVS version. Hope that is correct way. The format of stencil operations in effect file is following: ... ... ... ... ... ... Where function can be never, always, less, less-or-equal, equal, not-equal, greater-or-equal or greater. Value is the reference value used in stencil operations and mask is the stencil bit mask. Stencil-fail, z-fail and pass are stencil operations if stencil test fails or stencil-test passes but z-test fails or both passes. Possible functions are zero, keep, replace, increase, decrease, invert, increase-wrap and decrease-wrap. I think one has to know something about stencil buffers to use this ;) I also added a new general tag 1 0 0 1 that allows only writing to certain channel (in this example only to red and alpha channel. As an example, I attached new version of the light-cone.eff I posted few days ago. This one does the same thing but with stencil operations. The .ac model used with this should be almost transparent or it will be too bright. This version has some issue if there is more than 5 light models simultaneously. I don't know if this is a OSG issue about rendering orders or something? But please test and comment. Lauri, a.k.a. Zan -- Lauri Peltonen lauri.pelto...@gmail.com Index: CameraGroup.cxx === RCS file: /var/cvs/FlightGear-0.9/source/src/Main/CameraGroup.cxx,v retrieving revision 1.18 diff -r1.18 CameraGroup.cxx 157c157 < camera->setClearMask(GL_DEPTH_BUFFER_BIT); --- > camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 205c205 < camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); --- > camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 216c216 < camera->setClearMask(GL_DEPTH_BUFFER_BIT); --- > camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); Index: Effect.cxx === RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/material/Effect.cxx,v retrieving revision 1.29 diff -r1.29 Effect.cxx 53a54 > #include 255a257,274 > struct ColorMaskBuilder : PassAttributeBuilder > { > void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop, > const osgDB::ReaderWriter::Options* options) > { > const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop); > if (!realProp) > return; > > ColorMask *mask = new ColorMask; > Vec4 m = getColor(realProp); > mask->setMask(m.r(), m.g(), m.b(), m.a()); > pass->setAttributeAndModes(mask); > } > }; > > InstallAttributeBuilder installColorMask("color-mask"); > 477a497,589 > > EffectNameValue stencilFunctionInit[] = > { > {"never", Stencil::NEVER }, > {"less", Stencil::LESS}, > {"equal", Stencil::EQUAL}, > {"less-or-equal", Stencil::LEQUAL}, > {"greater", Stencil::GREATER}, > {"not-equal", Stencil::NOTEQUAL}, > {"greater-or-equal", Stencil::GEQUAL}, > {"always", Stencil::ALWAYS} > }; > > EffectPropertyMap stencilFunction(stencilFunctionInit); > > EffectNameValue stencilOperationInit[] = > { > {"keep", Stencil::KEEP}, > {"zero", Stencil::ZERO}, > {"replace", Stencil::REPLACE}, > {"increase", Stencil::INCR}, > {"decrease", Stencil::DECR}, > {"invert", Stencil::INVERT}, > {"increase-wrap", Stencil::INCR_WRAP}, > {"decrease-wrap", Stencil::DECR_WRAP} > }; > > EffectPropertyMap stencilOperation(stencilOperationInit); > > struct StencilBuilder : public PassAttributeBuilder > { > void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop, > const osgDB::ReaderWriter::Options* options) > { > if (!isAttributeActive(effect, prop)) > return; > > const SGPropertyNode* pmode = getEffectPropertyChild(effect, prop, > "mode"); > if (pmode && !pmode->getValue()) { > pass->setMode(GL_STENCIL, StateAttribute::OFF); > return; > } > const SGPropertyNode* pfunction > = getEffectPropertyChild(effect, prop, "function"); > const SGPropertyNode* pvalue > = getEffectPropertyChild(effect, prop, "value"); > const SGPropertyNode* pmask > = getEffectPropertyChild(effect, prop, "mask"); > const SGPropertyNode* psfail > = getEffectPropertyChild(effect, prop, "stencil-fail"); > const SGPropertyNode* pzfail > = getEffectPropertyChild(effect, prop, "z-fail"); > const SGPropertyNode* ppass >