Game Development Community

How to make mirror in Torque 3D?

by Tom Giant · in Torque 3D Professional · 11/01/2010 (9:58 am) · 14 replies

I have read some threads in the forum about mirror. The following link is relatively new one. It seems to need to write the shader for the mirror function. Currently, is that still so? If must write shader,
how should I write shader for Torque 3D? Any guy has the related experience, or related reference documentation?

http://www.torquepowered.com/community/forums/viewthread/99105

Thanks for any help in advance.

#1
11/02/2010 (4:38 pm)
TGEA and TGE used to have a planar reflection shader (mirror shader). This was a custom shader. However this custom shader was applied to a .dif (interior) object, something that has been falling apart since the beginning of T3D I'm currently unaware if this shader was applicable to .dts objects. Anyhow, the torque devs have told (in this thread) that planar reflection might make it into T3D 1.1 final:

Tom (Spilman) said:
Quote:We haven't gotten to fixing planar reflections just yet... it could make it into 1.1, but it just depends on the time we got and if we solve some issues with it.

So the two solutions you have are;
Write the shader yourself (difficult but safe)
Hope that they will have it working in 1.1 final (easy but less reliable)

About shader writing itself, there is simply no easy way to learn/understand it Internet + existing code + fail and trial is how i "learned" shader code :P
#2
11/03/2010 (1:05 am)
Thanks for your detailed reply. That is real helpful.
#3
11/03/2010 (3:29 am)
this is ridiculous really, we have no planar reflect shader or ability to use backbuffer for refractions without hacks.


I am beginning to think they look at this as hobby development rather than a business in which they take pride.
#4
11/03/2010 (4:30 am)
do the old dif mirrors still work in t3d?

it looks like the code for transform portals is still in there.
#5
11/03/2010 (4:49 am)
Quote:
do the old dif mirrors still work in t3d?
img822.imageshack.us/img822/802/screenshot00100001.th.png
No.
#6
11/03/2010 (2:50 pm)
Doesn't a dynamic cubemap do reflection?
says the man with no knowledge of shaders...
#7
11/03/2010 (4:26 pm)
Hmmm.... where did the option for dynamic cubemap go?

Interestingly enough I just applied a cubemap to the deathball, and it worked - for only fake sky reflection - until leaving the editor :/
#8
11/04/2010 (7:22 am)
Hmmm, we played around with the water reflections a bit and yes it makes dynamic reflections. Honestly I must say, we just played with this a bit, we put a water plane vertical in the world and jumped in front of the water, nice looking, as long you tell the water to stay calm. ;-)
Currently we are thinking about taking the water code and code a mirror scene object from it.
#9
11/04/2010 (5:05 pm)
www.tubettiworld.com/image/screenshot_001-00001.jpgwww.tubettiworld.com/image/screenshot_001-00002.jpgwww.tubettiworld.com/image/screenshot_001-00003.jpgwww.tubettiworld.com/image/screenshot_001-00000.jpg
Below are settings that get you very close to the screenshots. I forgot to save that scene before quitting. Took me ten minutes to set up the scene the first time, about 1 minute to get the settings back to pretty close. But I gotta run...

new WaterBlock(wellwater2) {
      gridElementSize = "0.5";
      gridSize = "0.5";
      density = "1";
      viscosity = "1";
      liquidType = "Water";
      baseColor = "240 240 240 0";
      fresnelBias = "1";
      fresnelPower = "10";
      specularPower = "255";
      specularColor = "0.890196 0.917647 0.941177 0";
      waveDir[0] = "0 1";
      waveDir[1] = "0 1";
      waveDir[2] = "0 1";
      waveSpeed[0] = "0";
      waveSpeed[1] = "0";
      waveSpeed[2] = "0";
      waveMagnitude[0] = "0.2";
      waveMagnitude[1] = "0.2";
      waveMagnitude[2] = "0.02";
      overallWaveMagnitude = "0";
      rippleTex = "core/art/water/ripple";
      rippleDir[0] = "0 0";
      rippleDir[1] = "0 0";
      rippleDir[2] = "0 0";
      rippleSpeed[0] = "0";
      rippleSpeed[1] = "0";
      rippleSpeed[2] = "0";
      rippleTexScale[0] = "0 0";
      rippleTexScale[1] = "0 0";
      rippleTexScale[2] = "0 0";
      rippleMagnitude[0] = "0";
      rippleMagnitude[1] = "0";
      rippleMagnitude[2] = "0";
      overallRippleMagnitude = "0";
      foamTex = "core/art/water/foam";
      foamDir[0] = "1 0";
      foamDir[1] = "0 1";
      foamSpeed[0] = "0";
      foamSpeed[1] = "0";
      foamTexScale[0] = "1 1";
      foamTexScale[1] = "3 3";
      foamOpacity[0] = "0";
      foamOpacity[1] = "0";
      overallFoamOpacity = "0";
      foamMaxDepth = "0";
      foamAmbientLerp = "0";
      foamRippleInfluence = "0";
      whiteCapAmount = "0";
      cubemap = "BlankSkyCubemap";
      fullReflect = "1";
      reflectivity = "2";
      reflectPriority = "10";
      reflectMaxRateMs = "5";
      reflectDetailAdjust = "10";
      reflectNormalUp = "0";
      useOcclusionQuery = "1";
      reflectTexSize = "1024";
      waterFogDensity = "10";
      waterFogDensityOffset = "0";
      wetDepth = "10";
      wetDarkening = "10";
      depthGradientTex = "core/art/water/depthcolor_ramp";
      depthGradientMax = "0";
      distortStartDist = "0";
      distortEndDist = "0";
      distortFullDepth = "0";
      clarity = "1";
      underwaterColor = "0 0 0 1";
      soundAmbience = "AudioAmbienceDefault";
      position = "-4.72684 -19.152 27.3729";
      rotation = "0.910539 0.292335 -0.292335 95.3618";
      scale = "0.5 0.5 0.1";
      canSave = "1";
      canSaveDynamicFields = "1";
   };
#10
11/04/2010 (5:12 pm)
Nice display of adaptability!

I'm so used to using the waterplane and forgot all about the creative uses of the good old waterblock :)
#11
11/04/2010 (5:47 pm)
Nice display, that´s it, we played around with! ;-)

Now we´re trying to make the water walking through the world...
#12
11/05/2010 (12:32 am)
It's awesome. Thanks for your replies.
#13
11/05/2010 (10:34 pm)
Awesome stuff! The only problem is that the reflection is off for FOV other than 90. Apart from that, it's perfect!
#14
11/06/2010 (1:21 am)
really? Have to admit, haven't tested to change the FOV.

But I noticed in code, that reflection calculation is stopped after a proper amount of time to avoid timing conflicts.