LearnOpenGL 总结记录<8> Stencil Testing And Object Outlining

The routine for outlining your objects is as follows:

1. Set the stencil func to GL_ALWAYS before drawing the (to be outlined) objects, updating the stencil buffer with 1s wherever the objects’ fragments are rendered.

2. Render the objects.
3. Disable stencil writing and depth testing.
4. Scale each of the objects by a small amount.
5. Use a different fragment shader that outputs a single (border) color.
6. Draw the objects again, but only if their fragments’ stencil values are not equal to 1. 7. Enable stencil writing and depth testing again.

 

总结:

1. 哪一些物体需要描边的,就利用 stencil func GL_ALWAYS 进行渲染那些物体,那么在 stencil buffer 里面,那些物体对应的stencil value 记录为 1.

2.  关闭 stencil write 和 depth testing

3. 把需要描边的物体进行放大,利用 stencil func GL_NOTEQUAL ,使用其他的shader来进行渲染 放大后的 物体. 

(因为第一步的 stencil buffer 就有了 1 的值,那么这个时候由于GL_NOTEQUAL,就是把放大多出来的部分进行渲染)

4. Enable stencil write and depth

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Public Function UpdateStencilData(stencil As StencilDetailEntity) As Boolean Dim arrSql(2) As String If stencil.IsDateEdit Then '当状态不是维修状态下不用添加维修时间 arrSql(0) = $"UPDATE M_StencilDetails SET StencilID='{stencil.StencilID}',StencilName='{stencil.StencilName}',Thickness='{stencil.Thickness}' ,location_char='{stencil.Location.Substring(0, 1)}',location_no='{stencil.Location.Substring(1)}',workshop='{stencil.WorkShop}' ,MakeDate='{stencil.MakeDate}',StartDate='{stencil.StartDate}',StateID ={stencil.StateID},stencilUsesCount={stencil.StencilUseCount} ,Notes='{stencil.Notes}' " Else '当状态不是维修状态下不用添加维修时间 arrSql(0) = $"UPDATE M_StencilDetails SET StencilID='{stencil.StencilID}',StencilName='{stencil.StencilName}',Thickness='{stencil.Thickness}' ,location_char='{stencil.Location.Substring(0, 1)}',location_no='{stencil.Location.Substring(1)}',workshop='{stencil.WorkShop}' ,MakeDate='{stencil.MakeDate}',StateID ={stencil.StateID},stencilUsesCount={stencil.StencilUseCount} ,Notes='{stencil.Notes}' ,StartDate=NULL" End If If stencil.StateID = 3 Then arrSql(0) = arrSql(0) & $",repairDate='{stencil.RepairDate}' " End If arrSql(0) = arrSql(0) & $" where ID={stencil.ID}" '钢网编号发生改变时 If stencil.StencilID <> stencil.oldStencilID Then arrSql(1) = $"delete M_StencilAndProduct where StencilID='{stencil.oldStencilID}'" arrSql(2) = $"update M_StencilOperationLog set StencilId='{stencil.StencilID}' where StencilID='{stencil.oldStencilID}'" Else arrSql(1) = $"delete M_StencilAndProduct where StencilID='{stencil.StencilID}'" arrSql(2) = $"update M_StencilOperationLog set StencilId='{stencil.StencilID}' where StencilID='{stencil.StencilID}'" End If ReDim Preserve arrSql(3) arrSql(3) = $"insert into M_StencilOperationLog (StencilID,Time,Nickname,Reason,Operation) values ('{stencil.StencilID}','{stencil.Time}','{stencil.Nickname}' ,'{stencil.OperationReason}','{stencil.Operation}')" If stencil.StateID <> 2 Then ReDim Preserve arrSql(4) If stencil.ProductName.Count <> 0 Then Dim sql = $"insert into M_StencilAndProduct (StencilID,ProductName) values('{stencil.StencilID}','{stencil.ProductName(0)}')" For i = 1 To stencil.ProductName.Count - 1 sql += $",('{stencil.StencilID}','{stencil.ProductName(i)}')" Next arrSql(4) = sql End If End If Return DBHel.ExecuteNoQueryMul(arrSql, 1) > 0 End Function 请在原有逻辑的情况下对以上代码进行优化,让代码具有更好的可读性,可维护性,提升性能,并说出理由
最新发布
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值