Guilherme.Nemeth Posted December 4, 2025 Posted December 4, 2025 I'm trying to render outline for interactive objects and was following both the docs (https://developer.unigine.com/ch/docs/future/content/materials/scriptable) and this other topic (https://developer.unigine.com/forum/topic/7111-simple-outlinehighlight-effect/) which is very similar to what I want to do. This hammer is the object I'm trying to render the outline of: And this is the Shader Graph being used for the hammer: Everything was going fine and I was able to render the desired object into the Auxiliary Buffer, but when I try to sample it in my custom Post Material I get nothing. This is currently the Material I'm using, it's just a simple sampling of the Aux Buffer: // More information on ULON format - https://developer.unigine.com/docs/code/formats/ulon_format // More information on scriptable materials - https://developer.unigine.com/docs/content/materials/scriptable BaseMaterial post_sobel <options_hidden=1 preview_hidden=1 var_prefix=var texture_prefix=tex> { // Texture to be used in a shader (see Fragment shader below). Will be displayed in the Editor UI. Texture2D screen_texture <type=procedural internal=true> Texture2D auxiliary <type=auxiliary internal=true> // Custom parameter to be used in a shader (see Fragment shader below). Will be displayed in the Editor UI. Color selection_color = [0.5 0.5 0.5 1.0] Slider threshold = 1.0 <min=0.0 max=1.0> Slider distance = 1.0 <min=0.0 max=5.0> // Declaration of a custom rendering pass named 'selection_pass'. You can add as many passes as necessary. Pass selection_pass { // Shader declaration (you can add multiple shaders for a single pass) Fragment = #{ #include <core/materials/shaders/render/common.h> STRUCT_FRAG_BEGIN INIT_COLOR(float4) STRUCT_FRAG_END MAIN_FRAG_BEGIN(FRAGMENT_IN) // take 3x3 samples float4 aux_color = TEXTURE_BIAS_ZERO(tex_auxiliary, IN_UV); // Choose between scene and selection colors OUT_COLOR = aux_color; MAIN_FRAG_END #} } // Expression written in Unigine Script to be called after the specified stage of the rendering sequence // the name should be the same as the corresponding callback of the Render class // (here RENDER_CALLBACK_END_POST_MATERIALS to execute it after rendering Post Materials) Expression RENDER_CALLBACK_END_POST_MATERIALS = #{ // Get the screen color texture rendered for the current frame Texture screen_texture = engine.render_state.getScreenColorTexture(); Texture source = engine.render.getTemporaryTexture(screen_texture); source.copy(screen_texture); // Set the source texture to be used as the 'screen_texture' in the shader setTexture("screen_texture", source); // Render the pass named 'selection_pass' and put the result to the screen color texture of the current frame renderPassToTexture("selection_pass", screen_texture); // Release the temporary texture engine.render.releaseTemporaryTexture(source); #} } This gives me a completely black screen, while the debug output of the Aux Buffer clearly shows the object: The in-game debug view of the textures also show the object in the Aux Buffer: Is there anything I'm doing wrong? Would appreciate any help, thanks!
vovan675 Posted December 5, 2025 Posted December 5, 2025 Hello. You need to use "source" instead of "type" in your Texture2D definitions
Guilherme.Nemeth Posted December 5, 2025 Author Posted December 5, 2025 Wow, don't know how I missed that... That was it! Thank you very much. 1
Recommended Posts