It's a bit off topic, but I have coincidentally been getting into shader authoring lately and have been toying with a night vision post process effect. It's probably horribly inefficient and unnecessary, but if anyone is interested in seeing my shader, I've uploaded the RenderMonkey project here:
http://s87575413.onlinehome.us/night_vision.rfx (you may have to "save link as," I'm too lazy to add a binary MIME type for .rfx right now) Try playing with the artist variables. It's not all that pretty, it has an inexcusable reliance on PS 2.0, and probably eats too much "GPU time" to be usable. It's my first "real" shader, if it can even be called that. It demonstrates the R/G/B visual acuity ratios that Imperio mentioned for the transform into monochrome (luminance)--I think--but I found that doubling the green (or anything comparable) ended up looking too dark and flat, so I figured out a way to make the brightest spots look a little brighter. Advice is more than welcome. On 5/31/05, Ignacio Mart�n <[EMAIL PROTECTED]> wrote: > -- > [ Picked text/plain from multipart/alternative ] > First, I think that you should give an alpha value less than 1 to each quad > and enable alpha blending. If you dont do it, the material will be > completely opaque and won�t add to the "layer" below. > Second, I will use a shader (in fact, I achieve this effect with one :) ). I > convert the entire imge to grayscale (dot product of the pixel color with > the eye sensitivity to each color component), multiply each color component > by an amplification factor (try until you find a value that looks good), and > multiply now only the green component by another factor (doubling it should > be ok). This can be improved adding a noise texture and applying some > blurring. I think that this should be done with a second pass. > Regards, > Newen > > 2005/5/31, Imperio59 <[EMAIL PROTECTED]>: > > > > Ok, > > The title may sound corny, but this is what i have so far (thanks root > > for giving me msot of this code ;) ). > > I'm trying to copy CSS's Nightvision, except i'm trying to make it light > > DARK spots as well as brigthen existing lit-up spots. > > > > Here's what i have so far, it brightens the scene but not enough for me: > > This is in CViewRender::RenderView. > > //Imperio59 NVG > > if ( C_BasePlayer::GetLocalPlayer() && > > C_BasePlayer::GetLocalPlayer()->m_bNVG ) > > { > > IMaterial *pMaterial = materials->FindMaterial( > > "effects/nightvision", TEXTURE_GROUP_CLIENT_EFFECTS, true ); > > > > if ( pMaterial ) > > { > > > > // This copies the contents of the framebuffer (drawn > > during RenderView) into our nightvision texture. > > > > UpdateScreenEffectTexture( 0 );//"_rt_FrameBufferFB" > > > > materials->MatrixMode( MATERIAL_PROJECTION ); > > materials->PushMatrix(); > > materials->LoadIdentity(); > > > > materials->MatrixMode( MATERIAL_VIEW ); > > materials->PushMatrix(); > > materials->LoadIdentity(); > > > > materials->MatrixMode( MATERIAL_MODEL ); > > materials->LoadIdentity(); > > > > materials->DrawScreenSpaceQuad( pMaterial ); > > materials->DrawScreenSpaceQuad( pMaterial ); > > > > //Draw twice + a third time modulated. > > > > pMaterial->AlphaModulate(cl_nvg_brightness.GetFloat()); > > materials->DrawScreenSpaceQuad( pMaterial ); > > > > materials->MatrixMode( MATERIAL_PROJECTION ); > > materials->PopMatrix(); > > materials->MatrixMode( MATERIAL_VIEW ); > > materials->PopMatrix(); > > } > > } > > //END NVG > > > > Except drawing twice + modulated doesn't make it brighter than drawing > > ONCE! I think this is because of me just slapping a quad with the > > texture on top of the scene, no matter how many times i do it it's still > > the same texture. Right. > > > > So what i wanted to do was get a fullbright image (i want to get an > > image of what you see when mat_fullbright is 1) and slap that onto my > > screen, alpha'ed of course, and with my green screenfade (to make it > > look NVG-ish ;) ) > > I haven't been able to figure this out yet, i've tried calling > > UpdateScreenEffectTexture( 0 ); before the call to RenderLights, at the > > beginning of the frame, lots of places, with various unwanted results. > > > > Can someone from valve explain to me where i need to stick this call so > > i get my fullbright image, or somehow manage to unload the lightmaps > > from all textures, get the image of the scene, then reload the lightmaps > > (sounds like it's going to drag performance down). > > > > I also thought of using a post-processing shader, but most cards don't > > support them (am I wrong?) and you would need to turn on Shaders in the > > options to have a working NVG, wich is not what i want. > > > > Am i stuck with what i have now ( a semi-bright NVG wich brightens lit > > up spots but not dark spots) or is there a way to do this right? > > > > Imperio59 > > > > -- > > No virus found in this outgoing message. > > Checked by AVG Anti-Virus. > > Version: 7.0.322 / Virus Database: 267.3.0 - Release Date: 30/05/2005 > > > > _______________________________________________ > > To unsubscribe, edit your list preferences, or view the list archives, > > please visit: > > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > > > > -- > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list archives, please > visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > -- "I am at the point where coffee just makes my teeth vibrate." - Tycho, Penny-Arcade.com _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

