Game Development Community

T3D shaders for GUI elements?

by Michael Lorenz · in Torque 3D Beginner · 01/19/2011 (8:37 pm) · 6 replies

Is there any resource available for integration of shaders for GUI elements in Torque 3d? I have attempted integration of the resource for 1.7.1 with no luck. My exposure to Torque is from T3D 1.1b3 so I am unaware of the ancestry of T3D's functions and how they correlate to TGEA. Thanks all!

About the author

Recent Threads

  • T3D Camera Modes

  • #1
    01/20/2011 (8:53 am)
    You cannot shade 2d images.
    You can render a 3d model in a GUI and process a shader during the rendering.
    GuiObjectView is a good start point.
    #2
    01/20/2011 (10:48 am)
    This resource that I linked to in my above post seemingly attains the desired result that I'm searching for. Doesn't there exist the ability to shoehorn this into T3D? I'm trying to render out alpha FLV's from the BrowserWnd resource and do not think that rendering to a 3D model will work. Also, this process is a bit convoluted and something that GarageGames needs to address in further releases of Torque 3D.
    #3
    01/21/2011 (8:47 am)
    You could adapt the PostFX shaders to work in a specified area,using different texture coordinates.
    You pass four shader constants from a script to the shader.
    In the pixel shader you process only pixels,that have coords in the area, you discard the rest ones.This way the post effect will shade only the gui area.
    #4
    01/21/2011 (10:26 am)
    Excellent idea, I will work on this. Although, isn't the PostFX process going to be using the texture that is the composite of scene + gui? This would result in discarding pixels from the scene that were occluded by the gui elements and being able to look into the abyss of the client window (and a beautiful magenta!)?
    #5
    01/21/2011 (2:20 pm)
    Yes,this would be a potential problem.

    This old resource does not seem difficult to be ported by the way.
    If I compare the resource files with the original files of TGEA 1.7.1 , there are very little changes and several new methods.
    #6
    01/25/2011 (9:22 am)
    I suppose it may not be too difficult to port for one who is intimate with how Torque 3D 1.1b3 evolved from from 1.7.1. I took a stab at it and couldn't make it work. Consider from the 1.7.1 resouce in guiControl.cpp beginning at line 2147:

    // Check if texture is ok
    		if(!mOffscreenTex || mOffscreenTex->getWidth() != size.x || mOffscreenTex->getHeight() != size.y) {
    			mOffscreenTex.set(  size.x, size.y, GFXFormatR8G8B8A8, &GFXDefaultRenderTargetZBufferProfile, 1 );
    			mFxTarget = GFX->allocRenderToTextureTarget();
    			mFxTarget->attachTexture(GFXTextureTarget::Color0, mOffscreenTex );
    			mFxTarget->attachTexture(GFXTextureTarget::DepthStencil, GFXTextureTarget::sDefaultDepthStencil);
    			if(!mOffscreenTex) {
    				Con::warnf("[Fx] Cannot set offscreen texture");
    				mActiveFx = false;
    			}
    		}

    I could not get any GFX profile to work because I had to replace
    mOffscreenTex.set(  size.x, size.y, GFXFormatR8G8B8A8, &GFXDefaultRenderTargetZBufferProfile, 1 );
    with 'something' that is supported. That is just a single instance. Maybe I'll try again since I have a small amount of time on my hands at the moment. Thanks for looking, too!