[highlight]Most, if not all, of these functions are now included in Garry's Mod.[/highlight]
Extended rendering library, adding fog, stencil buffers, clip planes, etc.
[b]Release:[/b] [url]http://dl.dropbox.com/u/4266088/facepunch/gmcl_renderx.zip[/url]
[b]Source:[/b] [url]http://dl.dropbox.com/u/4266088/facepunch/gmcl_renderx_src.zip[/url]
[b]Functions:[/b]
[list]
[*]render.OverrideDepthEnable( enable, depth )
[*]render.PushCustomClipPlane( ( vplane ) or ( normal, distance ) )
[*]render.PopCustomClipPlane()
[*]render.EnableClipping( enable )
[*]render.CreateRenderTargetTexture( name, width, height, sizemode, imageformat, rt depth )
[*]render.GetBackBufferFormat()
[*]render.SetStencilEnable( enable )
[*]render.SetStencilFailOperation( stenciloperation )
[*]render.SetStencilZFailOperation( stenciloperation )
[*]render.SetStencilPassOperation( stenciloperation )
[*]render.SetStencilCompareFunction( stencilfunction )
[*]render.SetStencilReferenceValue( value )
[*]render.SetStencilTestMask( value )
[*]render.SetStencilWriteMask( value )
[*]render.ClearStencilBufferRectangle( x, y, w, h, value )
[*]render.ClearObeyStencil( r, g, b, a )
[*]render.ClearDepthObeyStencil()
[*]render.GetFogDistances()
[*]render.GetFogColor()
[*]render.SetFogColor( r, g, b )
[*]render.GetFogMode()
[*]render.SetFogZ( z )
[*]render.SetFogEnd( dist )
[*]render.SetFogStart( dist )
[*]render.SetFogMode( mode )
[*]render.SetFogMaxDensity( density )
[*]render.ClearStencil()
[*]render.DepthRange( near, far )
[*]ITexture:IsError()
[*]IMaterial:IsError()
[*]IMaterial:GetNumAnimationFrames()
[*]Entity:SetRenderClipPlaneEnabled( enabled )
[*]Entity:SetRenderClipPlane( ( vplane ) or ( normal, distance ) );
[*]Plane( normal, point )
[*]Player:GetFogParams()
[*]Player:SetFogParams( table )
[*]Player:GetFogParamsSkybox()
[*]Player:SetFogParamsSkybox( table )
[*]render.GetDynamicMesh( buffered )
[*]MeshBuilder()
[*]CMeshBuilder:Begin( dynamic mesh, primitive type, primitive count )
[*]CMeshBuilder:End()
[*]CMeshBuilder:AdvanceVertex()
[*]CMeshBuilder:Position( vector )
[*]CMeshBuilder:Normal( unit vector )
[*]CMeshBuilder:Color( color )
[*]CMeshBuilder:TexCoord( stage, u, v )
[*]CMeshBuilder:Specular( color )
[*]CMeshBuilder:TangentS( unit vector )
[*]CMeshBuilder:TangentT( unit vector )
[*]CMeshBuilder:Reset()
[*]DynamicMesh:Draw()
[/list]
[b]Primitive Types[/b]
[list]
[*]MATERIAL_POINTS
[*]MATERIAL_LINES
[*]MATERIAL_TRIANGLES
[*]MATERIAL_TRIANGLE_STRIP
[*]MATERIAL_LINE_STRIP
[*]MATERIAL_LINE_LOOP
[*]MATERIAL_POLYGON
[*]MATERIAL_QUADS
[*]MATERIAL_INSTANCED_QUADS
[*]MATERIAL_HETEROGENOUS
[/list]
[b]Stencil Operations:[/b]
[list]
[*]STENCILOPERATION_KEEP
[*]STENCILOPERATION_ZERO
[*]STENCILOPERATION_REPLACE
[*]STENCILOPERATION_INCRSAT
[*]STENCILOPERATION_DECRSAT
[*]STENCILOPERATION_INVERT
[*]STENCILOPERATION_INCR
[*]STENCILOPERATION_DECR
[*]STENCILOPERATION_FORCE_DWORD
[/list]
[b]Stencil Comparison Functions:[/b]
[list]
[*]STENCILCOMPARISONFUNCTION_NEVER
[*]STENCILCOMPARISONFUNCTION_LESS
[*]STENCILCOMPARISONFUNCTION_EQUAL
[*]STENCILCOMPARISONFUNCTION_LESSEQUAL
[*]STENCILCOMPARISONFUNCTION_GREATER
[*]STENCILCOMPARISONFUNCTION_NOTEQUAL
[*]STENCILCOMPARISONFUNCTION_GREATEREQUAL
[*]STENCILCOMPARISONFUNCTION_ALWAYS
[*]STENCILCOMPARISONFUNCTION_FORCE_DWORD
[/list]
[b]Render Target Size Modes:[/b]
[list]
[*]RT_SIZE_NO_CHANGE
[*]RT_SIZE_DEFAULT
[*]RT_SIZE_PICMIP
[*]RT_SIZE_HDR
[*]RT_SIZE_FULL_FRAME_BUFFER
[*]RT_SIZE_OFFSCREEN
[*]RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP
[/list]
[b]Image Formats:[/b]
[list]
[*]IMAGE_FORMAT_UNKNOWN
[*]IMAGE_FORMAT_RGBA8888
[*]IMAGE_FORMAT_ABGR8888
[*]IMAGE_FORMAT_RGB888
[*]IMAGE_FORMAT_BGR888
[*]IMAGE_FORMAT_RGB565
[*]IMAGE_FORMAT_I8
[*]IMAGE_FORMAT_IA88
[*]IMAGE_FORMAT_P8
[*]IMAGE_FORMAT_A8
[*]IMAGE_FORMAT_RGB888_BLUESCREEN
[*]IMAGE_FORMAT_BGR888_BLUESCREEN
[*]IMAGE_FORMAT_ARGB8888
[*]IMAGE_FORMAT_BGRA8888
[*]IMAGE_FORMAT_DXT1
[*]IMAGE_FORMAT_DXT3
[*]IMAGE_FORMAT_DXT5
[*]IMAGE_FORMAT_BGRX8888
[*]IMAGE_FORMAT_BGR565
[*]IMAGE_FORMAT_BGRX5551
[*]IMAGE_FORMAT_BGRA4444
[*]IMAGE_FORMAT_DXT1_ONEBITALPHA
[*]IMAGE_FORMAT_BGRA5551
[*]IMAGE_FORMAT_UV88
[*]IMAGE_FORMAT_UVWQ8888
[*]IMAGE_FORMAT_RGBA16161616F
[*]IMAGE_FORMAT_RGBA16161616
[*]IMAGE_FORMAT_UVLX8888
[*]IMAGE_FORMAT_R32F
[*]IMAGE_FORMAT_RGB323232F
[*]IMAGE_FORMAT_RGBA32323232F
[*]IMAGE_FORMAT_NV_DST16
[*]IMAGE_FORMAT_NV_DST24
[*]IMAGE_FORMAT_NV_INTZ
[*]IMAGE_FORMAT_NV_RAWZ
[*]IMAGE_FORMAT_ATI_DST16
[*]IMAGE_FORMAT_ATI_DST24
[*]IMAGE_FORMAT_NV_NULL
[*]IMAGE_FORMAT_ATI2N
[*]IMAGE_FORMAT_ATI1N
[/list]
[b]Material Fog Modes:[/b]
[list]
[*]MATERIAL_FOG_NONE
[*]MATERIAL_FOG_LINEAR
[*]MATERIAL_FOG_LINEAR_BELOW_FOG_Z
[/list]
[b]Material RT Depth:[/b]
[list]
[*]MATERIAL_RT_DEPTH_SHARED
[*]MATERIAL_RT_DEPTH_SEPARATE
[*]MATERIAL_RT_DEPTH_NONE
[*]MATERIAL_RT_DEPTH_ONLY
[/list]
Example of using the stencil buffer to draw a screen space quad that is only over the entity.
[lua]// setup the stencil buffer
render.ClearStencil();
render.SetStencilEnable( true );
render.SetStencilFailOperation( STENCILOPERATION_KEEP );
render.SetStencilZFailOperation( STENCILOPERATION_KEEP );
render.SetStencilPassOperation( STENCILOPERATION_REPLACE );
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS );
render.SetStencilWriteMask( 1 );
render.SetStencilReferenceValue( 1 );
// draw the model into the stencil buffer
self:DrawModel();
// setup the stencil buffer
render.SetStencilTestMask( 1 );
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL );
render.SetStencilPassOperation( STENCILOPERATION_REPLACE );
// disable depth writing
render.OverrideDepthEnable( true, false );
// draw
render.SetMaterial( SomeMaterial );
render.DrawScreenQuad();
// enable depth writing
render.OverrideDepthEnable( false, true );
// disable stencil buffer
render.SetStencilEnable( false );
[/lua]
It has fog. Awesome.
[b]Edit:[/b]
I know this is lazy, but the material fog mode "MATERIAL_FOG_LINEAR_BELOW_FOG_Z" is a low, ankle/shin/knee deep fog, right?
Man... This is just plain awesome.
Would it be possible to make a server side version of clip planes? So that we can cut physics objects.
uhh, can anyone explain what it does?
[QUOTE=Ico]uhh, can anyone explain what it does?[/QUOTE]
Did someone say clip planes?
[img]http://cdbarrett.com/dump/gm_flatgrass0114.jpg[/img] [img]http://cdbarrett.com/dump/gm_flatgrass0115.jpg[/img]
How about cutting the world in half?
[img]http://cdbarrett.com/dump/gm_flatgrass0116.jpg[/img] [img]http://cdbarrett.com/dump/gm_flatgrass0117.jpg[/img]
Also
[img]http://img49.imageshack.us/img49/1421/shitholyec6.png[/img]
What is that chat thingy?
GTalk I think.
[QUOTE=Jinto]
[list]
[*]render.PushCustomClipPlane( normal, distance )
[*]render.PopCustomClipPlane()
[*]render.EnableClipping( enable )
[/list]
[/QUOTE]
Okay, so obviously render.EnableClipping allows for the use of clipping.
I was wonder, however, what is the difference between push and pop.
I can tell that push has something to do with using the unit vector direction and a distance which probably results in extending your clipping plane along that axis for a certain distance.
But does this create the plane or just modify it?
And does pop create the plane?
Okay, I just saw the function Plane(normal,point) so that solves how to create it. But still not sure what pop does.
I still don't get it, but it sounds really cool, is this used for scripts or does it have effects in-game?
[QUOTE=jdm12989]Okay, so obviously render.EnableClipping allows for the use of clipping.
I was wonder, however, what is the difference between push and pop.
I can tell that push has something to do with using the unit vector direction and a distance which probably results in extending your clipping plane along that axis for a certain distance.
But does this create the plane or just modify it?
And does pop create the plane?
Okay, I just saw the function Plane(normal,point) so that solves how to create it. But still not sure what pop does.[/QUOTE]
I think push adds one more plane on which the model will get cut and pop removes that plane.
I have one question:
Does it clip props in a way so that you can walk through the clipped areas?
I mean, will the part where the prop was visible before still block me?
[lua]/*------------------------------------
Draw
------------------------------------*/
function ENT:Draw( )
// define our plane
local plane = Plane( self:GetForward(), self:GetPos() );
// render with clip plane enabled
render.EnableClipping( true );
render.PushCustomClipPlane( plane.Normal, plane.Distance );
self:DrawModel();
render.PopCustomClipPlane();
end[/lua]
Clips the model on a scripted entity. Planes are infinitely long.
Is there a way to fake the physics box being clipped?
I have a way to clip physics, but tracelines will still hit the original object. They use the model's vcollide info instead of its physics hull.
[QUOTE=Jinto]I have a way to clip physics, but tracelines will still hit the original object. They use the model's vcollide info instead of its physics hull.[/QUOTE]
Tracelines are bullets right?
Holy fuck, we could chop a box in half.
We almost could have some sort of digital molecular matterish analog thing.
Even if it's laggy.
That's actually a good thing(sometimes), because then you don't have a trace going through a hole in a hole created by a clipping plane when it's supposed to hit it...
Also, is this fog in the RT screens, across the world, inside the specified entity, etc? (Wow, what I just said even confused me... but I can't think of another way to say it.)
[QUOTE=Jinto]I have a way to clip physics, but tracelines will still hit the original object. They use the model's vcollide info instead of its physics hull.[/QUOTE]
Physics clipping is in this mod now right?
Jinto, I am almost crying with amazement right now. This opens up possibilities I can't even begin to enumerate. Thank you.
Jesus Anal Christ. Jinto should be working at Valve.
Can someone check if my ass is still there
because I just shit so many bricks right now.
[B]Edit:[/B]
[media]http://www.hoganblogs.com/blogs/newbornhouse/images/albums/week09/thebrickpile.jpg[/media]
Oh, and are there some demo Sents with this so I can see all the neat shit it does with out coding shit?
I'm confused. The only thing I half understood was stencil buffers. I think they were used to make a hacky dynamic shadow addon for Startopia. I could be thinking of something completely different though.
Could someone explain to me the possibilities of this implementation? Can we really dynamically segment props and brushes? And exactly how many bricks of shit are we talking here, like revolutionary amounts or two to three toilet-loads?
Coolest thing I've seen in the dll section, easily.
[QUOTE=DieHardDeus]Oh, and are there some demo Sents with this so I can see all the neat shit it does with out coding shit?[/QUOTE]
Yea i would also love to see some demo sents.
[QUOTE=DieHardDeus]Physics clipping is in this mod now right?[/QUOTE]
Yes - If you use a binary module.
[b]Edit:[/b]
[QUOTE=kevkev]Yea i would also love to see some demo sents.[/QUOTE]
Copy and paste jintos example over the draw hook in a SENT's cl_init.lua and watch what happens.
Is there a way to make it so that traces collide with designated planes?
Thank you Jinto. :3
I'm going to explode if I don't know what this is.
:wooow: + :tizzy:
Has any one started any work with this yet?
Some care to tell me why we are all getting so worked up? dumb it down as much as is possible please.
Sorry, you need to Log In to post a reply to this thread.