Jump to content

Change the texture of the shader!


Gilmer
 Share

Recommended Posts

Hello all..

 

I have a shader ready to use, and i add in a model. How i can change the texture of this shader, by programming? For example, in the file .mat, which has "texture0='tex.dds'", i want pass this parameter for programming. Whats function for this?? But the texture, in really, is a buffer. I get the screen with the GetColorBuffer(), and wanna pass this, to parameter of the shader. Like a reflect, which a camera render the world, and passes the image to texture, which in this case, would the shader..

 

 

And other issue...

I have two cameras, one is the main camera from framewerk, and other, is the a camera, which myself create, in a file .lua, of the a model. In this file, i change sometimes the visios between they. But, all time which i change the camera, and render, it render only models, and terrain, and the skybox renderized, is the same skybox, renderized froum framewerk camera. I want to know, how i can renderized, the background from second camera? Without merge, the image(models and terrain) of the first camera, with the skybox of the second camera...

 

A image, for explain bettter my issue:

 

10zmolu.png

 

 

Thanks all

Link to comment
Share on other sites

I have a shader ready to use, and i add in a model. How i can change the texture of this shader, by programming? For example, in the file .mat, which has "texture0='tex.dds'", i want pass this parameter for programming. Whats function for this?? But the texture, in really, is a buffer. I get the screen with the GetColorBuffer(), and wanna pass this, to parameter of the shader. Like a reflect, which a camera render the world, and passes the image to texture, which in this case, would the shader..

Could this help you?

SetMaterialShader

 

And other issue...

I have two cameras, one is the main camera from framewerk, and other, is the a camera, which myself create, in a file .lua, of the a model. In this file, i change sometimes the visios between they. But, all time which i change the camera, and render, it render only models, and terrain, and the skybox renderized, is the same skybox, renderized froum framewerk camera. I want to know, how i can renderized, the background from second camera? Without merge, the image(models and terrain) of the first camera, with the skybox of the second camera..

Could you should us the code? I am not sure, but myabe i know why..

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

Link to comment
Share on other sites

Thank Joh, for the feedback.. :)

 

So, this is the code of the model:

 

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

local class=CreateClass(...)

fw=GetGlobalObject("framewerk")

--CONST
drawscreen=0 --desenhar na tela?

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

chave=0

cameracube = CreateCamera()
CameraClearMode(cameracube,1+2)
cameracube:SetPosition(model:GetPosition())
cameracube:Hide()
rotcam = cameracube:GetRotation()

maincamera = fw.main.camera

-- buffers
mainbuffer = CurrentBuffer()
buffercam = CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4)
buffertex = CreateBuffer(256*6,256,1+2+4)
bufferprint = CreateBuffer(256*6,256,BUFFER_COLOR)


--Cria o material
material=LoadMaterial("abstract::casa3mat.mat")
--Aplica a textura
model:Paint(material,1)

function object:Update()


	model:Hide()
	maincamera:Hide()
	cameracube:Show()



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

	world=fw.main.world
	bgworld=fw.background.world

	RenderWorld()
	--RenderLights(buffercam)

	SetWorld(bgworld)
	RenderWorld()

	colorbuffer = GetColorBuffer(buffercam)
	SetBuffer(buffertex)
	DrawImage(colorbuffer,0,256,256,-256)

	SetWorld(world)

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

	RenderWorld()
	--RenderLights(buffercam)

	SetWorld(bgworld)
	RenderWorld()

	colorbuffer = GetColorBuffer(buffercam)
	SetBuffer(buffertex)
	DrawImage(colorbuffer,256,256,256,-256)

	SetWorld(world)

	--Visao3
	SetBuffer(buffercam)
	cameracube:Turnf(0,90,0)

	RenderWorld()
	--RenderLights(buffercam)

	SetWorld(bgworld)
	RenderWorld()

	colorbuffer = GetColorBuffer(buffercam)
	SetBuffer(buffertex)
	DrawImage(colorbuffer,512,256,256,-256)

	SetWorld(world)

	--Visao4
	SetBuffer(buffercam)
	cameracube:Turnf(0,90,0)

	RenderWorld()
	--RenderLights(buffercam)

	SetWorld(bgworld)
	RenderWorld()

	colorbuffer = GetColorBuffer(buffercam)
	SetBuffer(buffertex)
	DrawImage(colorbuffer,768,256,256,-256)

	SetWorld(world)

	--Visao5
	SetBuffer(buffercam)
	cameracube:Turnf(0,90,0)
	cameracube:Turnf(90,0,0)

	RenderWorld()
	--RenderLights(buffercam)

	SetWorld(bgworld)
	RenderWorld()

	colorbuffer = GetColorBuffer(buffercam)
	SetBuffer(buffertex)
	DrawImage(colorbuffer,1024,256,256,-256)
	cameracube:Turnf(-90,0,0)

	SetWorld(world)

	--Visao6
	SetBuffer(buffercam)
	cameracube:Turnf(-90,0,0)

	RenderWorld()
	--RenderLights(buffercam)

	SetWorld(bgworld)
	RenderWorld()

	colorbuffer = GetColorBuffer(buffercam)
	SetBuffer(buffertex)
	DrawImage(colorbuffer,1280,256,256,-256)
	cameracube:Turnf(90,0,0)


	--CRIA A IMAGEM
	SetWorld(world)

	SetBuffer(mainbuffer)

	cameracube:Hide()
	maincamera:Show()

	colorbuffer2 = GetColorBuffer(buffertex)


	if drawscreen==1 then
		DrawImage(colorbuffer2,0,256,256*6,-256)
	end
	Flip()


	model:Show()

end

end

 

 

 

And about the command SetMaterialShader, i think it would not be just this. I want to pass the buffer arnazenado in "colorbuffer2" for "texture6" of the material, which this case in the shader. Would the reflect. I believe putting this in the Update of the code, makes dynamic reflection. But this is the problem, I'm not able to pass the image, stored of the buffer to the material parameter..

Link to comment
Share on other sites

About the camera i think you should rotate the main cam (bg camera is parented to that one i think).

 

For image issue, i don't know right now, i need to think about it.

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

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