TylerH Posted July 19, 2010 Share Posted July 19, 2010 After speaking with Josh, though he is busy, I think I am doing it the proper way (yet it still isn't working) -- Create cubemap camera cubemapcamera = CreateCamera() -- Create cubemap cubemap = CreateCubemap(512,512) -- Create cubemap 'gbuffer' cubemapbuffer = CreateBuffer(512,512,1+2+4+8) -- Create six buffers to render each cube face to cubemapbufferpx = CreateBuffer(512,512,1+2+4+8) cubemapbuffernx = CreateBuffer(512,512,1+2+4+8) cubemapbufferpy = CreateBuffer(512,512,1+2+4+8) cubemapbufferny = CreateBuffer(512,512,1+2+4+8) cubemapbufferpz = CreateBuffer(512,512,1+2+4+8) cubemapbuffernz = CreateBuffer(512,512,1+2+4+8) -- Bind each buffer to a face of the cubemap SetColorBuffer(cubemapbufferpx, cubemap, 0, 0) -- positive x SetColorBuffer(cubemapbuffernx, cubemap, 0, 1) -- negative x SetColorBuffer(cubemapbufferpy, cubemap, 0, 2) -- positive y SetColorBuffer(cubemapbufferny, cubemap, 0, 3) -- negative y SetColorBuffer(cubemapbufferpz, cubemap, 0, 4) -- positive z SetColorBuffer(cubemapbuffernz, cubemap, 0, 5) -- negative z Then during rendering: -- Realtime cubemap CameraProjMode(camera, 0) -- Disable player cam PositionEntity(cubecamera,mesh.position) -- Position cubemap camera at the center of the mesh CameraProjMode(cubecamera, 1) -- Enable cubemap camera --Render Positive X SetBuffer(cubemapbuffer) RotateEntity(cubecamera, Vec3(0, 90, 0)) world:Render() SetBuffer(cubemapbufferpx) world:RenderLights(cubemapbuffer) -- Render Negative X SetBuffer(cubemapbuffer) RotateEntity(cubecamera, Vec3(0, -90, 0)) world:Render() SetBuffer(cubemapbuffernx) world:RenderLights(cubemapbuffer) --Render Positive Y SetBuffer(cubemapbuffer) RotateEntity(cubecamera, Vec3(-90, 0, 0)) world:Render() SetBuffer(cubemapbufferpy) world:RenderLights(cubemapbuffer) -- Render Negative Y SetBuffer(cubemapbuffer) RotateEntity(cubecamera, Vec3(90, 0, 0)) world:Render() SetBuffer(cubemapbufferny) world:RenderLights(cubemapbuffer) --Render Positive Z SetBuffer(cubemapbuffer) RotateEntity(cubecamera, Vec3(0, 0, 0)) world:Render() SetBuffer(cubemapbufferpz) world:RenderLights(cubemapbuffer) --Render Negative Z SetBuffer(cubemapbuffer) RotateEntity(cubecamera, Vec3(0, -180, 0)) world:Render() SetBuffer(cubemapbuffernz) world:RenderLights(cubemapbuffer) CameraProjMode(cubecamera, 0) -- Disable cubemap camera CameraProjMode(camera, 1) -- Enable player camera SetShader(GetMaterialShader(mesh.material)) BindTexture(cubemap,0) -- Bind cubemap to material SetShader(nil) -- render world to GBuffer and draw to BackBuffer as usual. This is the result (all 6 individual buffers are rendered to fine, but the cubemap doesn't seem to be getting rendered to): Full script is attached. cubemap.lua Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
flachdrache Posted July 19, 2010 Share Posted July 19, 2010 I have no idea - at first glance hide/unhide the entity which uses the cubemap but aint doing nothing so does switching materials from invisible.mat to cubemap.mat. What i didnt tried is to bind a dummy cubemap in the material and use kind of a FreeTexture before using cubemap.material or a freeBuffer on the cubemap buffers each pass. Cant give anymore time on this currently. Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
TylerH Posted July 19, 2010 Author Share Posted July 19, 2010 Josh suggested it may be an nVidia drivers issues, which I researched and found plausible. I need people with ATI cards to test this and see if it works, to determine if the issue lies in the code, or in the GPU drivers. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
macklebee Posted July 19, 2010 Share Posted July 19, 2010 In my mind, SetColorBuffer is not doing this: -- Bind each buffer to a face of the cubemap but rather is doing this: -- Set a face of the cubemap to a buffer and then you are rendering the buffer and it shows up as a texture in DrawImage, but I do not see a place where you are assigning the individual textures created from the buffers back into the cubemap itself. You need a way to copy those buffers back to those individual cubemap indexes I suspect for this to work. Something like SetCubeMap(cubemap,texture,index) seems like it would be needed... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
flachdrache Posted July 19, 2010 Share Posted July 19, 2010 Hmmm, the cubemap faces are fine. Replace to -- REALTIME CUBE MAP CameraProjMode(camera, 0) PositionEntity(cubecamera, camera.position) CameraProjMode(cubecamera, 1) its the upload through the material pipeline which isnt working as aspected. i.e. "SetShader(GetMaterialShader(mesh.material))" might be a little to lazy. PS: Hmmm, so we have to sphere map, the opposite direction that we are looking, to the mesh, through the material pipeline and have the cubemap rotate counterclockwise just so that it is not too easy, right ? Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
macklebee Posted July 19, 2010 Share Posted July 19, 2010 Hmmm, the cubemap faces are fine. Replace to -- REALTIME CUBE MAP CameraProjMode(camera, 0) PositionEntity(cubecamera, camera.position) CameraProjMode(cubecamera, 1) that sets the position of the cubemap camera to the normal camera's postion... which is fine if he was trying something like a cctv screen, but since he is trying to do a reflection, the cubemap camera needs to look out from the cube not at it. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Gilmer Posted July 20, 2010 Share Posted July 20, 2010 thanks TylerH.. :) I tested here, and also was without displaying the texture. I tested putting the skybox texture in place of cubemap, and it showed. I think it is related in time to pass the cubemap to shader =/ Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 21, 2010 Share Posted July 21, 2010 I have a realtime "cubemap" (of a sort) as an object scripted model. except I am hacking it by having a different material on each face, rendering to each face's buffer, and then setting the resulting colorbuffer to each face's material... effectively creating a "cubemap". Using the framework camera for the buffer renders gives it a nice crystal clear reflection and all of the nice framework effects rendered... but its a fps killer doing 6 faces. For actual use in a game, you could just use a normal camera for the render which will give a greater fps boost. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Gilmer Posted July 21, 2010 Share Posted July 21, 2010 Cool your idea macklebee, i think right now would be more appropriate. But how could the normal check that is being presented at the render? Quote Link to comment Share on other sites More sharing options...
TylerH Posted July 21, 2010 Author Share Posted July 21, 2010 I have a realtime "cubemap" (of a sort) as an object scripted model. except I am hacking it by having a different material on each face, rendering to each face's buffer, and then setting the resulting colorbuffer to each face's material... effectively creating a "cubemap". Using the framework camera for the buffer renders gives it a nice crystal clear reflection and all of the nice framework effects rendered... but its a fps killer doing 6 faces. For actual use in a game, you could just use a normal camera for the render which will give a greater fps boost. Very cool. Care to share how you did that? Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
macklebee Posted July 21, 2010 Share Posted July 21, 2010 Cool your idea macklebee, i think right now would be more appropriate. But how could the normal check that is being presented at the render? Thanks gilmer. I am not sure I understand exactly what you are asking... If its what I think you are asking then right now I am just setting the camera up to a predefined surface normal vector in the object script using a correctly oriented pivot. Very cool. Care to share how you did that? yeah, its pretty straight forward. I was trying to figure out the 3d angle of incidence math to get the reflection right, cause right now it just "reflects" straight out from the cube face... which looks ok but gives more of an impression that its a video screen than an actual reflection. Let me clean up my code and comment it and I will post it. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
TylerH Posted July 22, 2010 Author Share Posted July 22, 2010 Sounds great Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
macklebee Posted July 22, 2010 Share Posted July 22, 2010 Here is the same concept added to a mirror model. It still suffers from the same problem as the cube as it doesn't use the angle of incidence to calculate the reflected image... but I have to go work out of town for the next three days so I won't be able to work on it. Perhaps someone like Tyler can figure out the proper math needed to get the angle of incidence/reflection? I can upload the cube but it really is a fps killer and I don't want anyone to complain when their editor locks up! Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Masterxilo Posted July 24, 2010 Share Posted July 24, 2010 Try calling: -- Bind each buffer to a face of the cubemap SetColorBuffer(cubemapbufferpx, cubemap, 0, 0) -- positive x SetColorBuffer(cubemapbuffernx, cubemap, 0, 1) -- negative x SetColorBuffer(cubemapbufferpy, cubemap, 0, 2) -- positive y SetColorBuffer(cubemapbufferny, cubemap, 0, 3) -- negative y SetColorBuffer(cubemapbufferpz, cubemap, 0, 4) -- positive z SetColorBuffer(cubemapbuffernz, cubemap, 0, 5) -- negative z after every render. Quote Hurricane-Eye Entertainment - Site, blog. 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.