Gilmer Posted April 29, 2010 Share Posted April 29, 2010 I have a model, which will begin to load with this material: texture0="cardif.dds" texture1="cardot.dds" texture6="reflect.dds" cullface=0 shader="abstract::mesh_cube_reflection_bump_difuse_specular.vert","abstract::mesh_cube_reflection_bump_difuse_specular.frag" shadowshader="abstract::mesh_shadow.vert","" But I want the script in this model, in the update it, pass the image of the a texture, which was taken from the buffer(GetColorBuffer()) to the "texture6=...", because this textures will always changing, like a reflect, so i would like to change in the shader too, and show this change. The my question is, what are the commands necessary for this? I tried a lot of commands to set materials, shaders, textures....but so far i not getting results.. Edit: i need use, some like the BindTexture()?? Quote Link to comment Share on other sites More sharing options...
Gilmer Posted April 30, 2010 Author Share Posted April 30, 2010 Josh, You would have some example to change the layer of the texture of shader that already this in execution? Regards Quote Link to comment Share on other sites More sharing options...
Gilmer Posted May 1, 2010 Author Share Posted May 1, 2010 Somebody could help me? I am needing really to know as it modifies the texture of a layer of shader, but in execution I have date to finish the project Thanks all Quote Link to comment Share on other sites More sharing options...
ArBuZ Posted May 2, 2010 Share Posted May 2, 2010 Hi Gilmer. The code should look something like this: Entity myEntity("abstract::myEntity.gmf"); Mesh myMesh=myMesh.FindChild("myMesh"); Material myMat=myEntity.GetSurface(1).GetMaterial(); Texture tex; tex=buffer.GetColor(); myMat.SetTexture(tex); This is how I did it. Hope it will help. Quote Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64 3ds max / photoshop CS3 / C++ http://www.arbuznikov.com Link to comment Share on other sites More sharing options...
Gilmer Posted May 4, 2010 Author Share Posted May 4, 2010 Hello Arbuz, thanks for feedback, i did something, and really worked. But not yet completed, i noticed the followin: when i create a texture to skybox and cubemap, by the photoshop using the NVidia dds, i need set to "cubemap" instead of "2D Texture". But if a create in the leadwerks, get the buffers to use as texture, it does not work, because it dont is set for "cubemap". Have someway to i create this texture in memory, being that i want use to cubemap, and not to comum texture?! Im using a shader to fit the texture in the model, as cubemap. This is the code witch im using in the script: 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) colorbuffer2=CreateTexture(256*6,256,2+4) TextureFilter(colorbuffer2,1) entity=FindChild(model,"cube") surf=GetSurface(entity,1) mat=GetSurfaceMaterial(surf) shader=GetMaterialShader(mat) texreflect=LoadTexture("abstract::reflect.dds") texreflect2=LoadTexture("abstract::reflect2.dds") texxadrez=LoadTexture("abstract::reflect_xadrez.dds") texxadrez2=LoadTexture("abstract::reflect_xadrez.dds") function object:Update() model:Hide() maincamera:Hide() cameracube:Show() --Visao1 SetBuffer(buffercam) cameracube:SetRotation(rotcam) world=fw.main.world bgworld=fw.background.world RenderWorld() 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() 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() 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() 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() 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() 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) SetMaterialTexture(mat,colorbuffer2,6) if drawscreen==1 then DrawImage(colorbuffer2,0,256,256*6,-256) DrawImage(texreflect,0,512,256*6,-256) end Flip() model:Show() --## SALVA A IMAGEM DO BUFFER PARA TESTES if chave==20 then SetBuffer(bufferprint) DrawImage(GetColorBuffer(buffertex),0,0,256*6,256) SetBuffer(BackBuffer()) SaveBuffer(bufferprint,"testebuffer.tga") chave=30 end if chave<21 then chave=chave+1 end end end and this is the shader: http://www.leadwerks.com/forum/viewtopic.php?p=43333#p43333 Quote Link to comment Share on other sites More sharing options...
Masterxilo Posted May 4, 2010 Share Posted May 4, 2010 The functionality to combine 6 textures into a cubemap at runtime might be here: http://www.leadwerks.com/wiki/index.php?title=Buffers#SetColorBuffer haven't tried it yet though. Quote Hurricane-Eye Entertainment - Site, blog. Link to comment Share on other sites More sharing options...
Gilmer Posted May 5, 2010 Author Share Posted May 5, 2010 Thanks Masterxilo, but where should I put it in code? And for example, as each side of the texture is 256x256, so the texture would have a whole 256*6x256, right? The texture is that i create have to have this size or should i put it as 256x256, so that it will add a side by side? Quote Link to comment Share on other sites More sharing options...
Gilmer Posted May 6, 2010 Author Share Posted May 6, 2010 anyone?? 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.