forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
2
render_to_texture/README.md
Normal file
2
render_to_texture/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
#### Keyboard
|
||||
`R T F G V B` to rotate suzanne
|
||||
36
render_to_texture/Sources/lnx/MyTrait.hx
Normal file
36
render_to_texture/Sources/lnx/MyTrait.hx
Normal file
@ -0,0 +1,36 @@
|
||||
package lnx;
|
||||
|
||||
class MyTrait extends iron.Trait {
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
notifyOnInit(function() {
|
||||
// Retrieve camera object
|
||||
var cam = cast(iron.Scene.active.getChild("Camera.001"), iron.object.CameraObject);
|
||||
|
||||
// Create render target for camera
|
||||
cam.renderTarget = kha.Image.createRenderTarget(
|
||||
640,
|
||||
360,
|
||||
kha.graphics4.TextureFormat.RGBA32,
|
||||
kha.graphics4.DepthStencilFormat.NoDepthAndStencil
|
||||
);
|
||||
|
||||
// Display camera output on this plane
|
||||
var o = cast(object, iron.object.MeshObject);
|
||||
o.materials[0].contexts[0].textures[0] = cam.renderTarget; // Override base color texture
|
||||
|
||||
notifyOnRender(function(g:kha.graphics4.Graphics) {
|
||||
// Set as scene camera
|
||||
var activeCamera = iron.Scene.active.camera;
|
||||
iron.Scene.active.camera = cam;
|
||||
|
||||
// Update camera output
|
||||
cam.renderFrame(g);
|
||||
|
||||
// Restore original camera
|
||||
iron.Scene.active.camera = activeCamera;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
BIN
render_to_texture/render_to_texture.blend
Normal file
BIN
render_to_texture/render_to_texture.blend
Normal file
Binary file not shown.
Reference in New Issue
Block a user