Jump to content

Problem with "Render to texture"


Gilmer
 Share

Recommended Posts

Well, my objective is to create a texture that update dynamically. A cubemap dynamic, for example. Each face of this texture, will have 256x256. I did the following, I took a shader, which mounts the cube map, from a 1536x256 texture. Being a face side by side, so I need updating this texture.

 

I want to do so, put the camera in the center of the object, render, and place the rendered texture (256x256), in the buffer that I created that has 1536x256. So rotate 90 degrees to the camera, rendering, and position in the buffer on the side of the texture you created earlier. So it goes ...

 

But the problem is the rendered image is not rendering the skybox. Only the models around. Is there any command that I need to upgrade to, or set it?

 

Here's a picture of my scene. The camera to render this is inside the box:

 

1zoas69.png

 

 

And the code used in the box model:

 

require("scripts/class")
require("Scripts/constants/engine_const")
require("Scripts/LinkedList")
require("Scripts/filesystem")
require("Scripts/math/math")

local class=CreateClass(...)

fw=GetGlobalObject("framewerk")

function class:CreateObject(model)
local object=self.super:CreateObject(model)

cameracube = CreateCamera()
CameraClearMode(cameracube,1+2)
CameraClearColor(cameracube,Vec4(255,0,0,0))
cameracube:SetPosition(model:GetPosition())
cameracube:Hide()

rotcam = cameracube:GetRotation()

--main camera
maincamera = fw.main.camera


-- buffers
mainbuffer = CurrentBuffer()
buffercam = CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4)
--bufferlight = CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4)

buffertex = CreateBuffer(256*2,256,1+2+4)
--buffertex2 = CreateBuffer(256,256,1+2+4)


function object:Update()

	model:Hide()


	cameracube:Show()
	maincamera:Hide()

	--Visao1
	cameracube:SetRotation(rotcam)
	SetBuffer(buffercam)
	RenderWorld()
	RenderLights(buffercam)

	colorbuffer = GetColorBuffer(buffercam)

	SetBuffer(buffertex)
	DrawImage(colorbuffer,0,256,256,-256)


	--Visao2
	cameracube:Turnf(0,90,0)
	SetBuffer(buffercam)
	RenderWorld()
	RenderLights(buffercam)

	colorbuffer = GetColorBuffer(buffercam)

	SetBuffer(buffertex)
	DrawImage(colorbuffer,256,256,256,-256)




	SetBuffer(mainbuffer)


	colorbuffer3 = GetColorBuffer(buffertex)
	colorbuffer4 = GetColorBuffer(buffertex2)

	cameracube:Hide()
	maincamera:Show()


	DrawImage(colorbuffer3,0,256,256*2,-256)
	--DrawImage(colorbuffer4,0,512,256,-256)
	Flip()



	model:Show()



end



end

 

And as I do for the texture image rendered, not flashing on the screen there?

 

 

Thanks all

 

 

(I posted here, why do not know what would be the most appropriate place for this doubt)

Link to comment
Share on other sites

ok, but how can I access the background of framewerk?

 

And one question, how do i change a texture, which is inside the file.mat? For example, in the file, is this:

 

"texture0=reflect.dds"

 

How i can create a texture, but the shader always update the new texture??

 

Thanks Joh...

Link to comment
Share on other sites

no one?

 

I need to know how I do to render the skybox from the background of framewerk, through a file .lua of some model. I already tried a lot of ways but I can not, the documentation is not very explanatory:

 

fw.main.world.GetBackground()..

fw.background....

 

how??

Link to comment
Share on other sites

Well you could be able to do it, just changing the world goes on BG paint the buffer, so change the world again paint the buffer and find a way to merge the 2 image.

Wich color you get where should be the skyboxes?

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Link to comment
Share on other sites

Here is the problem ..

So, I try to reformulate my question, I do not speak English very well, I guess I'm not getting play me right ... hehehe

 

I have two cameras on the scene, one is the framewerk, which normally created in the editor, and the other is one I created the script .lua of model. But the problem is that when i send rendering some image created by the camera, it renders everything except the skybox. The visions they are having:

 

16gbk3b.png

 

2nibsrp.png

 

What function should i use to be able to show the skybox on the second camera?

 

thanks joh

Link to comment
Share on other sites

What i am tryng to explain is that you use framewerk wich have 3 worlds in total.. With your cam you don't renderize those worlds, so the cam won't be able to see them.

RenderWorld()

With this command you renderize only the current world, so you will probably fix the problem when you'll renderize every world in the correct order..

So it should be BG, World and transparency.

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Link to comment
Share on other sites

In the future, I want to implement a feature I am calling "stages". This will allow you to define a stage for an entity or material, and then render a camera one stage at a time, with your own code in between to handle effects. Something like this:

 

camera.BeginRender();

camera.Render(-1);// draw skybox

camera.Render(0);// draw main stuff

//Do whatever post-processing stuff you want

camera.Render(1);// draw transparent objects

camera.EndRender();

 

This would eliminate the need for multiple worlds and multiple camera renders.

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

Stages sounds like a nice way to do things like Megaparticles which I was having a look at recently.

 

mega_particles.JPG

 

 

Plus it would make my cockpit problems go-away if you could reset the camera matrix back to zero for a final stage.

 

camera.Render(1);// draw transparent objects

MatrixReset(camera);

camera.Render(2);// draw cockpit object

camera.EndRender();

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

Josh do you mean something similar to the way XNA does it? Initlize(),Update(gametime),Draw(gametime) methods.

I don't know how XNA works, but that does not sound like what I am describing.

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

Stages sounds like a nice way to do things like Megaparticles which I was having a look at recently.

 

Plus it would make my cockpit problems go-away if you could reset the camera matrix back to zero for a final stage.

 

camera.Render(1);// draw transparent objects

MatrixReset(camera);

camera.Render(2);// draw cockpit object

camera.EndRender();

That's pretty clever, but how would you blur the depth buffer of the particle image?

 

I do like that idea a lot. It makes sense to render the shape of the volume first, and then make it look like particles after.

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

For me? I don't need it :)

Gilmer needs but seem he solve the problem.

 

In the future, I want to implement a feature I am calling "stages". This will allow you to define a stage for an entity or material, and then render a camera one stage at a time, with your own code in between to handle effects.

This seem smart.

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Link to comment
Share on other sites

Guest Red Ocktober

OOOOOOOPPPS!!!

 

sorry... thought you were the original poster asking the question Joh...

 

racing through 3 different forums and paying attention to a render in progress on the other machine...

 

 

--Mike

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...