Jump to content

Draw to cubemap seems not working


Aily
 Share

Recommended Posts

Hi Josh.

 

Here have strange things. That's code to render to simple 2D texture, it works great

Framework leadwerks.engine

registerabstractpath AppDir

Graphics 800,600

createworld

cp=createpivot()
cam=createcamera()
cameraclearcolor cam,vec4(.5,.5,.5,1)
entityparent cam,cp
moveentity cam,vec3(0,1,-1)
pointentity cam,cp

c=createsphere()

mat=creatematerial()
setmaterialshader mat,loadshader("abstract::mesh.vert","abstract::mesh_diffuse.frag")

tex=createtexture(256,256)
setmaterialtexture mat,tex,0

paintentity c,mat

tex_buffer=createbuffer(256,256,BUFFER_COLOR)
setcolorbuffer tex_buffer,tex,0

setbuffer tex_buffer
SetColor vec3(0)
DrawRect 0,0,256,256
SetColor vec3(1)
DrawRect 50,50,100,100

Repeat

If KeyHit(key_escape) Or AppTerminate() End

turnentity cp,vec3(0,.2,0)

setbuffer backbuffer()
renderworld
Flip 1

Forever

 

Here's the code to load cubemap from file, and just to check that mesh_cubemap.frag works:

Framework leadwerks.engine

registerabstractpath AppDir

Graphics 800,600

createworld

cp=createpivot()
cam=createcamera()
cameraclearcolor cam,vec4(.5,.5,.5,1)
entityparent cam,cp
moveentity cam,vec3(0,1,-1)
pointentity cam,cp

c=createsphere()

mat=creatematerial()
setmaterialshader mat,loadshader("abstract::mesh_cubemap.vert","abstract::mesh_cubemap.frag")

tex=loadtexture("abstract::sunol_cubemap.dds")
setmaterialtexture mat,tex,0

paintentity c,mat

Repeat

If KeyHit(key_escape) Or AppTerminate() End

turnentity cp,vec3(0,.2,0)

setbuffer backbuffer()
renderworld
Flip 1

Forever

 

And this is code like above, but drawing to cubemap:

Framework leadwerks.engine

registerabstractpath AppDir

Graphics 800,600

createworld

cp=createpivot()
cam=createcamera()
cameraclearcolor cam,vec4(.5,.5,.5,1)
entityparent cam,cp
moveentity cam,vec3(0,1,-1)
pointentity cam,cp

c=createsphere()

mat=creatematerial()
setmaterialshader mat,loadshader("abstract::mesh_cubemap.vert","abstract::mesh_cubemap.frag")

tex=createcubemap(256,256)
setmaterialtexture mat,tex,0

paintentity c,mat

tex_buffer_0=createbuffer(256,256,BUFFER_COLOR)
tex_buffer_1=createbuffer(256,256,BUFFER_COLOR)
tex_buffer_2=createbuffer(256,256,BUFFER_COLOR)
tex_buffer_3=createbuffer(256,256,BUFFER_COLOR)
tex_buffer_4=createbuffer(256,256,BUFFER_COLOR)
tex_buffer_5=createbuffer(256,256,BUFFER_COLOR)

setcolorbuffer tex_buffer_0,tex,0,0
setcolorbuffer tex_buffer_1,tex,0,1
setcolorbuffer tex_buffer_2,tex,0,2
setcolorbuffer tex_buffer_3,tex,0,3
setcolorbuffer tex_buffer_4,tex,0,4
setcolorbuffer tex_buffer_5,tex,0,5

setbuffer tex_buffer_0
SetColor vec3(0)
DrawRect 0,0,256,256
SetColor vec3(1)
DrawRect 50,50,100,100

setbuffer tex_buffer_1
SetColor vec3(0)
DrawRect 0,0,256,256
SetColor vec3(1)
DrawRect 50,50,100,100

setbuffer tex_buffer_2
SetColor vec3(0)
DrawRect 0,0,256,256
SetColor vec3(1)
DrawRect 50,50,100,100

setbuffer tex_buffer_3
SetColor vec3(0)
DrawRect 0,0,256,256
SetColor vec3(1)
DrawRect 50,50,100,100

setbuffer tex_buffer_4
SetColor vec3(0)
DrawRect 0,0,256,256
SetColor vec3(1)
DrawRect 50,50,100,100

setbuffer tex_buffer_5
SetColor vec3(0)
DrawRect 0,0,256,256
SetColor vec3(1)
DrawRect 50,50,100,100

Repeat

If KeyHit(key_escape) Or AppTerminate() End

turnentity cp,vec3(0,.2,0)

setbuffer backbuffer()
renderworld
Flip 1

Forever

 

As you can see - i'm using same technique as draw to 2D texture - assign it to buffer,

But with cubemaps im assigning cubefaces to 6 buffers.

 

Think this code must be work, but it didnt :) Maybe you can show the correct way to use render to cubemaps?

Thanks.

post-260-0-01704600-1325755765_thumb.jpg

post-260-0-24003600-1325755769_thumb.jpg

post-260-0-32037900-1325755773_thumb.jpg

"Better" is big enemy of "good"

Link to comment
Share on other sites

I'm on my Mac right now and don't have an easy way of checking your texture, but if it doesn't have mipmaps, NVidia cards will render it pure black.

 

Thanks for turbo reply

 

Even if i use?

textureCubeLod(LW_CUBEMAP,cubecoord,0)

 

So then any way to build mipmaps after buffer render? (let it be so, let it be so....... :) )

"Better" is big enemy of "good"

Link to comment
Share on other sites

Aily... i believe klepto did it and posted it in his blog... but he did it without using the LE inherent commands but rather raw opengl...

http://www.leadwerks.com/werkspace/blog/16/entry-654-cubemaps-realtime-here-we-go/

which to me indicates there is something wrong with LE's implementation... :)

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

Aily... i believe klepto did it and posted it in his blog... but he did it without using the LE inherent commands but rather raw opengl...

http://www.leadwerks.com/werkspace/blog/16/entry-654-cubemaps-realtime-here-we-go/

which to me indicates there is something wrong with LE's implementation... :)

Yeah, i saw thais, but im making this by LUA, and such method is impossible there, you know it yourself :P That's why ask Josh to fix this.

"Better" is big enemy of "good"

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