Josh Posted March 8, 2015 Share Posted March 8, 2015 Some changes to the SSAO filter from the Workshop: --------------------------------------------------------------------------- -- SSAO (Screen-Space Ambient Occlusion) by Igor Katrich 26/02/20015 -- Email: igorbgz@outlook.com --------------------------------------------------------------------------- function Script:Start() self.shader = Shader:Load("Shaders/PostEffects/SSAO/ssao.shader") self.combine = Shader:Load("Shaders/PostEffects/SSAO/ssao_combine.shader") self.noise = Texture:Load("Shaders/PostEffects/SSAO/noise.tex")--do this in start function end function Script:Render(camera,context,buffer,depth,diffuse,normals) --Check to see if buffer size has changed if self.buffer~=nil then if buffer:GetWidth()~=self.buffer:GetWidth() or buffer:GetHeight()~=self.buffer:GetHeight() then self.buffer:Release() self.buffer=nil end end if self.buffer==nil then self.buffer=Buffer:Create(buffer:GetWidth(),buffer:GetHeight()) self.buffer:GetColorTexture():SetFilter(Texture.Smooth) end if self.shader and self.combine and camera:GetScale().y==1 then self.buffer:Enable() self.shader:Enable() if self.noise~=nil then self.noise:Bind(10) end depth:Bind(1) normals:Bind(2) context:DrawImage(diffuse,0,0,buffer:GetWidth(),buffer:GetHeight()) buffer:Enable() diffuse:Bind(1) --Color self.buffer:GetColorTexture():Bind(2) --SSAO self.combine:Enable() context:DrawImage(diffuse,0,0,buffer:GetWidth(),buffer:GetHeight()) end end function Script:Detach() --Release shaders if self.shader then self.shader:Release() self.shader = nil end if self.combine then self.combine:Release() self.combine = nil end --Release buffer if self.buffer~=nil then self.buffer:Release() end --Release noise texture if self.noise~=nil then self.noise:Release() end end Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
shadmar Posted March 8, 2015 Share Posted March 8, 2015 Small typo I think, compare self.buffer to buffer size, not context, or self.buffer will recreate each loop if buffer:GetWidth()~=self.buffer:GetWidth() or buffer:GetHeight()~=self.buffer:GetHeight() then Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
IgorBgz90 Posted March 8, 2015 Share Posted March 8, 2015 Thank you guys. Updated. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted March 8, 2015 Author Share Posted March 8, 2015 I think this effect can also be performed in a single pass, and it will be a lot faster than two full-screen passes. Small typo I think, compare self.buffer to buffer size, not context, or self.buffer will recreate each loop if buffer:GetWidth()~=self.buffer:GetWidth() or buffer:GetHeight()~=self.buffer:GetHeight() then Oh, you are right. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.