Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Need help with "Flares" or "Glowing" elumination  (Read 1509 times)
Magnum357jhp
Community Member
*
Posts: 124


« on: January 22, 2010, 06:07:34 PM »

I've been trying to find any technique that allows you to add "Flares" or "Glowing" lights to a mesh or whatever, but I have no idea on how to do this.  The tutorials that come with Truevision are kinda vague on this and most just deal with Light illumination, I was hoping to just add a "flare" glow to a mesh or whatever type of object to a scene, but I have no idea on how to do this.  I don't really care about lighting (I already know how to do that) I just want to find a way to make a mesh (say a planet or something similar) have a "glow" or "flare" effect behind the mesh so that it appears illuminated.

Does anyone have any suggestions on how to do this?  I'm using Truevsion version 6.0 to 6.3.
Logged

"There is no such thing as the ultimate programming language.  Every language has its weaknesses."
Dimple
Community Member
*
Posts: 539


« Reply #1 on: January 23, 2010, 09:53:09 PM »

 Smiley

I'm not sure what language you are programming in? But is this the sort of thing you are trying to do?

http://tv3dsamples.blogspot.com/2008/04/emissive-texture.html

Logged

Using VB.NET, TV3D 6.5, VISTA
~~~~~~~~~~~~~~~~~~~~~~~

"Know how to ask. There is nothing more difficult for some people, nor for others, easier."

- Baltasar Gracian
Magnum357jhp
Community Member
*
Posts: 124


« Reply #2 on: January 23, 2010, 11:04:21 PM »

No not exactly, but this is VERY useful information aswell.   Smiley  I kinda wanted to know how to make illumination maps, Truevision tutorials for version 6.0 to 6.3 don't seem to have many examples of this.  I forgot to mention that I'm using VB6 for a programming language.  Will your example work with VB6 and Truevision 6.0 to 6.3?  Also, your example tutorial only works with C#, not with VB6.   Sad
« Last Edit: January 23, 2010, 11:06:02 PM by Magnum357jhp » Logged

"There is no such thing as the ultimate programming language.  Every language has its weaknesses."
Mithrandir
Community Member
*
Posts: 325


« Reply #3 on: January 23, 2010, 11:43:19 PM »

Well TV6.3 is a bit limited but if search 6.3 boards for "Glow" you will find some tips and maybe even some code.

But when I was doing something similar a long time ago I used render surface.
You can render everything that is supposed to glow on render surface (meshes with emissive textures, light glow effects on billboards etc.) and then just blend the image with your normally rendered scene. By blend I mean render it as texture over the whole scene.

I don't have any code but it shouldn't be too hard make (if I managed it)  Wink
Logged
Magnum357jhp
Community Member
*
Posts: 124


« Reply #4 on: January 24, 2010, 01:40:42 AM »

Lets see if I understand this correctly.  When you say..

"You can render everything that is supposed to glow on render surface (meshes with emissive textures, light glow effects on billboards etc.) and then just blend the image with your normally rendered scene. By blend I mean render it as texture over the whole scene."

..do you mean that you use the "TVRenderSurface" Class and apply say two textures to a mesh.  One texture is effected by lighting that you apply to the mesh in the scene, while the other texture is not effected by the "lighting" and "appears" illuminated.  Is that basically what you are explaining? 

Can you give a code example if this is what you mean?  I'm looking at the TVDN library and have found the "TVRenderSurface" class, but all the features of this class are kinda vague explaining if this is how "glow" works.  The closes feature of this class that might work for this "glow" effect is the "CreateStaticTextureFromRenderSurface" but I have no idea how I could apply this to a mesh.

Am I on the right track here?  Huh
Logged

"There is no such thing as the ultimate programming language.  Every language has its weaknesses."
Mithrandir
Community Member
*
Posts: 325


« Reply #5 on: January 24, 2010, 10:42:48 AM »

Quote
..do you mean that you use the "TVRenderSurface" Class and apply say two textures to a mesh.  One texture is effected by lighting that you apply to the mesh in the scene, while the other texture is not effected by the "lighting" and "appears" illuminated.  Is that basically what you are explaining?

Yes that was the idea.

As to the other part, when you finish rendering to this surface you should just render this surface over the whole screen using TVScreen2DImmediate.DRAW_Texture. To obtain the texture ID you can use CreateStaticTextureFromRenderSurface but this is rather slow. I think you can can just use GetTexture which is faster but I am not sure any more if this gives you a texture which can be used for drawing.

Just a hint, if you switch to 6.5 you can use shaders which are much faster and easier to implement. And there is also a built in glow effect.
Logged
Magnum357jhp
Community Member
*
Posts: 124


« Reply #6 on: January 27, 2010, 05:45:44 PM »

Mithrandir, thank you for helping me out here, but I'm still having trouble trying to get this too work right.  I have worked on a simple project to see if I can make "glowing" textures, but have little success with it yet.  Here is the following code I'm using...

Code:
Option Explicit

Private tv8 As TVEngine

Private scene As TVScene

Private InputEngine As TVInputEngine

Private DoLoop As Boolean

Private Box As TVMesh

Private Camera As TVCamera

Private BoxPosition As Single

Private TextureFactory As TVTextureFactory

Private LightEngine As TVLightEngine
Private Light As D3DLIGHT8
Private AlphaTexture As TVRenderSurface

Private sngPositionX As Single
Private sngPositionY As Single
Private sngPositionZ As Single
Private sngAngleX As Single
Private sngAngleY As Single
Private sngAngleZ As Single

Private Angle As Single
Private Distance As Single
Private Altitude As Single


Private RotateControlLeft As Boolean
Private RotateControlRight As Boolean
Private ZoomInControl As Boolean
Private ZoomOutControl As Boolean
Private PanUpControl As Boolean
Private PanDownControl As Boolean

Private Sub cmdQuit_Click()

    ' We have clicked on the "Quit" button, so we change the DoLoop.
    DoLoop = False

End Sub

Private Sub Form_Load()

    Set tv8 = New TVEngine
   
    Set Camera = New TVCamera
   
    Set TextureFactory = New TVTextureFactory
   
    Set LightEngine = New TVLightEngine
   
    ' Set the search directory of the objects, textures, ...
    tv8.SetSearchDirectory App.Path
   
    ' We initialize TV8 in the picture box of the form.
    tv8.Init3DWindowedMode Picture1.hWnd

    ' We want to see the FPS.
    tv8.DisplayFPS = True

    ' We create the input object.
    Set InputEngine = New TVInputEngine

    Set scene = New TVScene
    scene.SetViewFrustum 35, 4000
   
    Set Box = New TVMesh
   
    TextureFactory.LoadTexture "..\..\Illumination Testing\Box.bmp", "Box", , , TV_COLORKEY_NO, True, True
   
    'AlphaTexture.CreateStaticTextureFromRenderSurface
   
    Set Box = scene.CreateMeshBuilder
    Box.Load3DsMesh "..\..\..\Illumination Testing\Box.3ds", True
    Box.SetMaterial 1
    Box.SetTexture GetTex("Box")
    Box.SetShadowCast 1, 1
   
    sngAngleX = 0
    sngAngleY = 0
    sngAngleZ = 0
    Box.SetPosition sngAngleX, sngAngleY, sngAngleZ
    Box.ScaleMesh 1, 1, 1
    Box.SetColor RGBA(0.1, 0.1, 0.1, 1), False
   
   
    Angle = 0
    Distance = 100
    Altitude = 100
    Camera.RotateAroundMesh Box, True, Angle, Distance, Altitude
   
    Lighting
       
    Form1.Show
       
    ' We start the main loop.
    DoLoop = True
    Main_loop
   
End Sub

Private Sub Lighting()
   
    Light.Type = D3DLIGHT_POINT
    Light.Position = Vector3(500, 0, 0)
    Light.Ambient = DXColor(1, 1, 1, 1) 'RGBA (3,3,3,1=Daylight) (1.5,1.5,1.5,1=Night)
    Light.diffuse = DXColor(4, 4, 4, 1)
    Light.Attenuation0 = 1
    Light.Range = 1500
    LightEngine.CreateLight Light, "Light"
    LightEngine.UpdateLight 1, Light
End Sub

Private Sub form_unload(cancel As Integer)
    DoLoop = False
    main_quit
End Sub

Private Sub Main_loop()

    Do
        DoEvents
       
        tv8.Clear
       
        scene.RenderAllMeshes
       
        tv8.RenderToScreen
       
        Box.RenderShadow
       
        If RotateControlLeft = True Then
            Angle = Angle + (tv8.TimeElapsed / 500)
            Camera.RotateAroundMesh Box, True, Angle, Distance, Altitude
        End If
       
        If RotateControlRight = True Then
            Angle = Angle - (tv8.TimeElapsed / 500)
            Camera.RotateAroundMesh Box, True, Angle, Distance, Altitude
        End If
       
        If ZoomInControl = True Then
            Distance = Distance - (tv8.TimeElapsed / 4)
            Camera.RotateAroundMesh Box, True, Angle, Distance, Altitude
        End If
       
        If ZoomOutControl = True Then
            Distance = Distance + (tv8.TimeElapsed / 4)
            Camera.RotateAroundMesh Box, True, Angle, Distance, Altitude
        End If
       
        If PanUpControl = True Then
            Altitude = Altitude + (tv8.TimeElapsed / 4)
            Camera.RotateAroundMesh Box, True, Angle, Distance, Altitude
        End If
       
        If PanDownControl = True Then
            Altitude = Altitude - (tv8.TimeElapsed / 4)
            Camera.RotateAroundMesh Box, True, Angle, Distance, Altitude
        End If
       
       
       
    Loop Until DoLoop = False

    main_quit
   
End Sub

Private Sub main_quit()

    ' We want to quit the project, so we destroy the teapot object.
    Set Box = Nothing
   
    ' Then, we destroy the scene object.
    Set scene = Nothing
   
    ' We finish the frenetic destroy with the TV8 object.
    Set tv8 = Nothing
   
    Set LightEngine = Nothing
    ' We end the application.
    End
   
End Sub

Private Sub PanDown_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    PanDownControl = True
End Sub

Private Sub PanDown_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    PanDownControl = False
End Sub

Private Sub PanUp_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    PanUpControl = True
End Sub

Private Sub PanUp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    PanUpControl = False
End Sub

Private Sub RotateLeft_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RotateControlLeft = True
End Sub

Private Sub RotateLeft_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RotateControlLeft = False
End Sub

Private Sub RotateRight_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RotateControlRight = True
End Sub

Private Sub RotateRight_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RotateControlRight = False
End Sub

Private Sub ZoomIn_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ZoomInControl = True
End Sub

Private Sub ZoomIn_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ZoomInControl = False
End Sub

Private Sub ZoomOut_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ZoomOutControl = True
End Sub

Private Sub ZoomOut_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ZoomOutControl = False
End Sub


So far, the code allows me to display a box with lighting, so that if I can get an illumination texture to work, it would show up as a green "cross" on each face of the box.  here is an image of the program so far..



I hope the pic loaded right.   Roll Eyes  Anyway, as you can see, I'm trying to get the green "cross" to illuminate, but I'm having little success.  Can someone with some TV3D6.0 to 6.3 experience help me out here??
Logged

"There is no such thing as the ultimate programming language.  Every language has its weaknesses."
Mithrandir
Community Member
*
Posts: 325


« Reply #7 on: January 27, 2010, 10:03:01 PM »

Well I am a bit rusty around the edges with VB6 and TV6.3 but with some small changes following code could work:
Code:
' In your main loop

DoEvents

RenderSurface.StartRender
' Change textures here or add anything that should glow
scene.RenderAllMeshes
RenderSurface.EndRender

Dim Glow as Integer = RenderSurface.GetTexture

tv8.Clear
scene.RenderAllMeshes
' Set additive blending
Scr2D.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_ONE, True
Scr2D.Draw_Texture Glow, ... ' make it full screen/window
tv8.RenderToScreen

Initialize RenderSurface somewhere at the beginning.
Scr2D is TVScreen2DImmediate.
Additive blending mode might not be what I put in code but you can sure find the right settings.
Logged
Magnum357jhp
Community Member
*
Posts: 124


« Reply #8 on: January 28, 2010, 03:39:02 AM »

Mithrandir, thank you for all the help, unfortunetly I'm still having problems with this.  I'm wondering if part of the problem I'm having with this is the .3ds model I'm using.  Can .3ds files be used to make "glow" effects on a texture? 

I'm really at a loss here and might just scrap the whole idea because most of my projects work with either .3ds or .X file and if ethier can't be used to make "glowing" textures, I should just stick with "lighting" tricks with Truevision.   Roll Eyes

Anyone else have any other suggestions?
« Last Edit: January 28, 2010, 03:42:17 AM by Magnum357jhp » Logged

"There is no such thing as the ultimate programming language.  Every language has its weaknesses."
tagget
Customers
Community Member
*****
Posts: 243


« Reply #9 on: January 28, 2010, 06:18:19 PM »

I think there's little reason to stick with 6.3. Like Mithrandir said, 6.5 supports proper shaders and already has a glow effect built in. It's also very stable and you can release a commercial product with it.

You could have completed this wihtin 10 mintues in 6.5 instead of the 6 days it has taken you in 6.3 to achieve nothing!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks