havenphillip Posted February 15, 2021 Share Posted February 15, 2021 I put together this depth buffer model shader but it doesn't work when I put post effects up. What causes this? How do I fix it/get around the problem? I assume there's a way around it because the depth part of the shader I got right from Josh's water shader. I think it must have something to do with the script, then...something I"m not doing right. Here's the script: function Script:Start() depthbuffer = Buffer:Create(context:GetWidth(),context:GetHeight(),0,1) depth = depthbuffer:GetDepthTexture() surface = self.entity:GetFace(0) mat = surface:GetMaterial() mat:SetBlendMode(Blend.Alpha) mat:SetTexture(depth,4) end function Script:UpdateWorld() depthbuffer:Enable() self.entity:Hide() world:Render() self.entity:Show() Context:SetCurrent(context) end Quote Link to comment Share on other sites More sharing options...
havenphillip Posted February 26, 2021 Author Share Posted February 26, 2021 bump Quote Link to comment Share on other sites More sharing options...
Staplers Posted February 27, 2021 Share Posted February 27, 2021 I am not too certain what's happening, but from what I know, Post Effects = after rendering scene = will be on top. You didn't specify what your depth is doing, so I am just assuming that the post effect is rendering on top of everything. If it's backwards, then that'll be odd. Quote Link to comment Share on other sites More sharing options...
havenphillip Posted February 27, 2021 Author Share Posted February 27, 2021 This line disappears when I add post-effects to the scene, which is a bummer. 1 Quote Link to comment Share on other sites More sharing options...
reepblue Posted February 27, 2021 Share Posted February 27, 2021 Try it with the null shader. If it still doesn't work, then it has something to do with the final result. Might want to ask Josh directly about this. Null Post Shader - Game Art - Leadwerks Community Adding Postprocessing shaders does something. Probes don't work right without an effect loaded to the camera, and it might also be the cause of your shader not working. Really interested in this, I could use it in my project. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
havenphillip Posted February 27, 2021 Author Share Posted February 27, 2021 You know what I actually saw your post and tried the null shader. I get nothin. What do you mean by "final result"? I don't even know where to start digging for answers. Quote Link to comment Share on other sites More sharing options...
reepblue Posted February 27, 2021 Share Posted February 27, 2021 It might have something to do with the fragData. Not an expert on shaders but I suggest you load the null shader and figure out what's causing the conflict. out vec4 fragData0; void main(void) { vec2 icoord = vec2(gl_FragCoord.xy/buffersize); if (isbackbuffer) icoord.y = 1.0 - icoord.y; fragData0 = texture(texture1,icoord); } Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
havenphillip Posted February 27, 2021 Author Share Posted February 27, 2021 That's what I did. I loaded your null shader. Same results as other posteffect shaders. No line. It's the depth from the Leadwerks water shader, which works while there are posteffects running from what I can tell. So it seems to me there is something that is enabled or present somewhere in water mode that I'm not aware of . Quote Link to comment Share on other sites More sharing options...
havenphillip Posted February 28, 2021 Author Share Posted February 28, 2021 So this works but it eats up the FPS constantly loading and deleting the shader. Bloom effect brought me all the way down to a constant 7 FPS. Not sure exactly why this works but there's got to be a better way. Anyone? function Script:UpdateWorld() self.world = World:GetCurrent() if self.camera==nil then for i=0,self.world:CountEntities()-1 do if self.world:GetEntity(i):GetClass()==Object.CameraClass then self.camera=self.world:GetEntity(i) tolua.cast(self.camera,"Camera") return end end end depthbuffer:Clear() depthbuffer:Enable() self.camera:ClearPostEffects() <--- world:Render() depthbuffer:Disable() self.camera:AddPostEffect("Shaders/PostEffects/bloom.lua") <--- Context:SetCurrent(context) end Quote Link to comment Share on other sites More sharing options...
havenphillip Posted March 12, 2021 Author Share Posted March 12, 2021 No one? Is this thing on? Quote Link to comment Share on other sites More sharing options...
reepblue Posted March 12, 2021 Share Posted March 12, 2021 Does storing the camera variable once so you're not doing a for loop every tick helps? Really sorry, I am not a shader expert. ? Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
havenphillip Posted March 13, 2021 Author Share Posted March 13, 2021 That's ok. I"m not a shader expert either. I appreciate you taking a stab at it. It would be nice to solve it just because it irritates me to find this apparent limitation. I'm hoping someone will read this and be able to tell me at least why it happens. It seems if I set the player (camera) in the scene then create the depth buffer object I can get away with putting the camera variable in the Start() function. But when I turn the player's head the depth buffer wobbles around in odd ways. If I remove the player and put him back in the scene, the depth buffer stops moving around but I then have to grab the camera in the UpdateWorld() function. I don't know if that has to do with the problem and might offer a clue, or if it's just a whole other problem. Quote 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.