Jump to content

How i can project camera image like a entity texture or like simple image in real time?


WtymonrW
 Share

Recommended Posts

you don't have to do it in C++, this is a lua script that does this for you, wink.pnghttp://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=

  • Upvote 1

OS: Windows 7

Processor: AMD A6-3420M APU integrated Radeon HD Graphics 1.50 GHz

Link to comment
Share on other sites

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.

OS: Windows 7

Processor: AMD A6-3420M APU integrated Radeon HD Graphics 1.50 GHz

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...