WtymonrW Posted February 27, 2015 Share Posted February 27, 2015 So, i wanna project image that "see" camera at other place. How i can do that? I think, it have function simple fo this goal Quote Link to comment Share on other sites More sharing options...
AnthonyPython Posted February 27, 2015 Share Posted February 27, 2015 you don't have to do it in C++, this is a lua script that does this for you, http://leadwerks.wikidot.com/wiki:render-to-texture-security-cam also check igor's shader's (it has film grain , and now scan line effect too as well) you could apply to your cam's http://steamcommunity.com/sharedfiles/filedetails/?id=391325549&searchtext= 1 Quote OS: Windows 10 Pro CPU: i3-10100 CPU @ 3.60GHz GPU: NVIDIA 2060 Super - 8 GB RAM: 32 GB Link to comment Share on other sites More sharing options...
WtymonrW Posted February 27, 2015 Author Share Posted February 27, 2015 you don't have to do it in C++, this is a lua script that does this for you, http://leadwerks.wikidot.com/wiki:render-to-texture-security-cam What function call scripts in code? What value return this script? So, anyway, i can rewrite this at C++ class:D Quote Link to comment Share on other sites More sharing options...
AnthonyPython Posted February 27, 2015 Share Posted February 27, 2015 What function call scripts in code? What value return this script? So, anyway, i can rewrite this at C++ class:D --This is where security cam will render Script.TrackingPivot=""--entity --This should be your main camera where you are, like your FPSCam Script.MainCamera=""--entity --This can be any material with any diffuse shader, paint your CCTV with this Script.RenderToMaterial=""--path function Script:Start() --Create Buffer and texture so we have a rendertarget to render to. camerabuffer=Buffer:Create(256,256,1,0); tex = Texture:Create(App.context:GetWidth(),App.context:GetHeight()) camerabuffer:SetColorTexture(tex) camerabuffer:Disable(); --Fetch CCTV material mat=Material:Load(self.RenderToMaterial) self.entity:SetMaterial(mat) end function Script:UpdateWorld() camerabuffer:Enable() save=self.MainCamera:GetMatrix() --save your cam matrix self.MainCamera:SetMatrix(self.TrackingPivot:GetMatrix()) App.world:Render() -- render to buffer your pivots matrix self.MainCamera:SetMatrix(save) --restore matrix camerabuffer:Disable() --Ok now do backbuffer in mainloop (App.lua) Context:SetCurrent(App.context) --Set buffer output and send it to the shader as texture0 buffertex = camerabuffer:GetColorTexture() mat:SetTexture(buffertex,0) end it set's the camera's view as a texture and then sends it off to send that texture image as texture0 for it to render on to the surface, and updates it constantly in the update world. Quote OS: Windows 10 Pro CPU: i3-10100 CPU @ 3.60GHz GPU: NVIDIA 2060 Super - 8 GB RAM: 32 GB 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.