I’m trying to render to a texture using a RenderPath with just a fullscreen quad command (to generate a procedural heightmap for a terrain vertex shader). However, it doesn’t seem to matter what I set the RenderPath to for the RTT viewport, it always uses the same RenderPath as the backbuffer. The code is like this(mostly copied from the renderToTexture lua sample code):
scene_ = Scene()
scene_:CreateComponent("Octree")
local rttCameraNode = scene_:CreateChild("Camera2")
local rttCam = rttCameraNode:CreateComponent("Camera")
local renderTexture = Texture2D:new()
renderTexture:SetSize(2048, 2048, Graphics: GetRGBA16Format(), TEXTURE_RENDERTARGET)
local surface = renderTexture.renderSurface
local rttViewport = Viewport:new( scene_, rttCameraNode:GetComponent("Camera"))
surface:SetViewport(0, rttViewport)
rttViewport.renderPath:Load(cache:GetResource("XMLFile", "RenderPaths/RenderTerrainHeightMap.xml"));
local screenNode = scene_:CreateChild("Screen")
local screenObject = screenNode:CreateComponent("StaticModel")
screenObject.model = cache:GetResource("Model", "Models/Plane.mdl")
local renderMaterial = Material:new()
renderMaterial:SetTechnique(0, cache:GetResource("Technique", "Techniques/DiffUnlit.xml"))
renderMaterial:SetTexture(TU_DIFFUSE, renderTexture)
screenObject.material = renderMaterial
cameraNode = scene_:CreateChild("Camera")
local camera = cameraNode:CreateComponent("Camera")
local viewport = Viewport:new(scene_, camera)
viewport.renderPath:Load(cache:GetResource("XMLFile", "RenderPaths/SSAO.xml"));
renderer:SetViewport(0,viewport)
I don’t think the problem is with the RenderPath file, because even setting the RTT viewport RenderPath to one of the built-in ones doesn’t seem to work (the rendered texture still has the SSAO effect applied from my SSAO RenderPath that I’m using for the backbuffer).