Oh, noes.
It's not quite that easy. Drat. Here's what I tried. More if I can find time to get back to this.
Code: Select all
--REFLECTION SETUP
local reflectionSpec = {
target = GL.REFLECTION_MAP,
min_filter = GL.LINEAR,
mag_filter = GL.LINEAR,
}
local reflectionTex = gl.CreateTexture(3072, 512, reflectionSpec)
reflectionFBO = gl.CreateFBO()
reflectionFBO.color0 = reflectionTex
reflectionFBO.drawbuffers = {
GL_COLOR_ATTACHMENT0_EXT,
}
local function CreateReflectionTexture()
local reflectionShader = gl.CreateShader({
vertex = [[
void main(void)
{
gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
gl_Position = gl_Vertex;
}
]],
fragment = [[
uniform sampler2D ReflectTextureOne;
uniform sampler2D ReflectTextureTwo;
void main()
{
// RENDER TO TEXTURES
gl_FragData[0] = texture2D(ReflectTextureTwo,gl_TexCoord[0].xy);
}
]],
uniformInt = {
ReflectTextureOne = 0,
ReflectTextureTwo = 1,
},
})
return reflectionShader
end
function gadget:Initialize()
reflectionShader = CreateReflectionTexture()
end
local reflectionSet = 0
function gadget:DrawWorld()
if reflectionSet == 0 then
gl.ActiveFBO(reflectionFBO, true, function()
glTexture(1,"unittextures/mesa_city_cube.tga")
glUseShader(reflectionShader) -- DRAW THE TEXTURE
gl.TexRect(-1,-1,1,1,0,0,1,1)
end) -- END FBO
reflectionSet = 1
end
end
It all compiles and stuff, but it's getting treated like a 2D image when I send it to unitRendering, i.e. it gets ignored. And attempting to define ReflectTextureOne as a cubemap causes the shader to crash... so, did I forget something when setting the texture parameters, or is there something else I need to do here?