Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1] 2
  Print  
Author Topic: How To __________ in Prerelease.  (Read 13500 times)
Pavel
Customers
Community Member
*****
Posts: 850


WWW
« on: July 14, 2004, 10:47:22 AM »

First if you are really lost, go to the Getting started page : http://www.truevision3d.com/beta_howto.php

You got a lot of samples & demos there : http://tv3dsamples.blogspot.com/.

How To SetWaterReflection
To use this new feature in TVGraphicEffect this is what you have to do.

These are the declaration that I called.
We need 2 RenderSurface. 1 is for Reflection and the Other for Refraction.
Code:
Private GraphicFX As TVGraphicEffect
Private RenderSurf1 As TVRenderSurface
Private RenderSurf2 As TVRenderSurface
Private WaterMesh As TVMesh
Private WPlane As TV_PLANE


First We Create the Water Mesh. Thats basically the water.
After that we create the 2 Rendersurface and set the size 256, 256.
Then we set the the Water Plane. Its Dist has to be the negative of the altitude we put in the WaterMesh.
Then we create TVGraphic and Initiate reflection with the paramenters.
Code:
Set WaterMesh = Scene.CreateMeshBuilder
WaterMesh.AddFloor 1, -256, -256, 256, 256, 30, 1, 1, False
Set RenderSurf1 = Scene.CreateRenderSurface(256, 256, True, -1)
Set RenderSurf2 = Scene.CreateRenderSurface(256, 256, True, -1)
WPlane.Dist = -30
WPlane.Normal = Vector3(0, 1, 0)
Set GraphicFX = New TVGraphicEffect
GraphicFX.SetWaterReflection WaterMesh, RenderSurf1, RenderSurf2, 0, WPlane


We have to render what will be in the reflection for both rendersurfaces.
Note: Rendering the RenderSurface must be before TV.Clear
Code:
        RenderSurf1.StartRender False
            Atmos.Atmosphere_Render
            Land.Render
        RenderSurf1.EndRender
        RenderSurf2.StartRender False
            Atmos.Atmosphere_Render
            Land.Render
        RenderSurf2.EndRender


And then dont forget to Render the WaterMesh itself.






How To use Glow Effect
To use this new feature in TVGraphicEffect this is what you have to do.

These are the declaration that I called.
We need the RenderSurface to Render all the objects to apply the glow to.
Code:
Private TVGraphics As TVGraphicEffect
Private RenderSurface As TVRenderSurface

This is what we do to set the glow.
Code:
Set TVGraphics = New TVGraphicEffect
Set RenderSurface = Scene.CreateRenderSurface(256, 256, True, -1)
TVGraphics.InitGlowEffect RenderSurface

We have to render what will be Glowen by rendering them in the rendersurface.
And after that we UPDATE the Glow.
Note: Rendering the RenderSurface must be before TV.Clear

Idea: You may scale the object larger when rendering in the RenderSurface to get a bigger glow.
Code:
RenderSurface.StartRender False
Teapot.Render '( Render all the objects you want glown here.)
RenderSurface.EndRender
TVGraphics.UpdateGlow

And finally right before TV.RenderToScreen
Idea: You can do this multiple times for more glow.
Code:
TVGraphics.RenderGlow

You may also have Emissive maps for Actors and Mesh. This allows for you to control the glow. Once you set it, this emissive map will be used to render the glow.
Code:
SetTextureEx(Tv_LAYER_EMISSIVE, emissivetexture)



Glow Emmissive Map >> http://www.truevision3d.com/puppy/radioactiveass.jpg
Glow Emmissive Map 2 >> http://www.truevision3d.com/puppy/emissive_test/emissive.jpg
Glow Trick >>  http://img78.photobucket.com/albums/v283/errrRus/glow2.jpg
Glow DevDiary 1 >> http://www.truevision3d.com/devdiary/glow.jpg
Glow DevDiary 2 >> http://www.truevision3d.com/devdiary/glow2.jpg


How To use Depth Of Field (DOF)
To use this new feature in TVGraphicEffect this is what you have to do.

These are the declaration that I called.
We need the RenderSurface to Render the whole scene to add the DOF to.
Code:
Private TVGraphics As TVGraphicEffect
Private RenderSurface As TVRenderSurface

This is what we do to set the DOF.
The size of the rendersurface should be same or higher then the screen rendered to since if it is smaller then it will seem that the whole scene is blurry.

iNumZLayers > The higher the number, the higher the accuracy of the depth information.
Code:
Set RenderSurf = Scene.CreateRenderSurface(512, 512, True, -1)
Set GraphicFX = New TVGraphicEffect
GraphicFX.InitDepthOfField 8, RenderSurf


First we update the the DOF Parameters. Then we have to render what will be rendered in the scene by rendering them in the rendersurface. After that we update the DOF.
Note: Rendering the RenderSurface must be before TV.Clear

fFocalPlane >  Distance of the focal plane to the camera, focal plane is the place where it's not blurred.
fFocalRange > This defines the "width" of the plane in which it is not really blurred.
fBlur > Blur Factor. 0 is no blur. 3 or 4 usually creates good look. Higher numbers should be used for testing.
Code:
        GraphicFX.SetDepthOfFieldParameters 5, 100, 3
        RenderSurf.StartRender True
            Land.Render '( Render all the objects in your scene here)
            Teapot(0).Render
        RenderSurf.EndRender
        GraphicFX.UpdateDepthOfField

Then inside TV.Clear you dont render the scene over again, you just do this and it will render what you have previously rendered on the RenderSurface to the screen.
After this you should render your 2D objects and then TV.RenderToScreen.
Code:
GraphicFX.DrawDepthOfField

DOF >> http://www.truevision3d.com/devdiary/dof.jpg



How To use BumpMapping

First thing you need in BumpMapping is to setup a light.
After that load the BumpMap. The last value is intensity of the BumpMap.
Code:
TextureFactory.LoadBumpTexture "..\..\..\Media\test\NewBrickBump.jpg", "myBump", , , , 30


On the object you want to add the bump mapping to do the following. We are using a Mesh called Teapot here.

Code:
    Teapot.SetTextureEx TV_LAYER_BUMPMAP, GetTex("myBump")
    Teapot.SetTextureEx TV_LAYER_HEIGHTMAP, GetTex("myBump")
    Teapot.SetLightingMode TV_LIGHTING_OFFSETBUMPMAPPING_TANGENTSPACE

Offset Bumpmapping requires a Layer for HeightMap.
There are also 2 more type of bumpmapping.
Code:
Teapot.SetLightingMode TV_LIGHTING_BUMPMAPPING_OBJECTSPACE 
Code:
Teapot.SetLightingMode TV_LIGHTING_BUMPMAPPING_TANGENTSPACE




How To use Normal Mapping

There are 2 things you can do with Normal Mapping.
1) Generate them from a Hi-Poly and Low-Poly mesh and Set Them.
2) Load from Texture the Normal Map and set them.

1) To Generate a Normal map in TV you need 2 Mesh. One is the low poly that you will render and the other is the Hi-Poly version of the same mesh from which you will get all the details to put in the Low-Poly version.

Load your Low Poly mesh into a TVMesh (Teapot). Then create another mesh for the Hi-Poly (TeapotHi). And then do.
Code:
       
        Teapot.GenerateNormalMap TeapotHi, True, 1024, 1024, True
When you run your project it will take time for TV to generate the Map dependeing on the PolyCount of your Hi-Poly mesh. It may seem to be hanged up, but its not. It took me about 3mins for it to Generate on a 150k mesh.
You may then save this Normal Map by doing this
Code:
TextureFactory.SaveTexture TextureFactory.GetTextureCount - 1, "test1.bmp"

2) To Load a Normal Map in TV and set them:

Code:
        TextureFactory.LoadTexture "test1.bmp", "myNorm"
    Teapot.SetTextureEx TV_TEXTURE_NORMALMAP, GetTex("myNorm")
    Teapot.SetLightingMode TV_LIGHTING_BUMPMAPPING_TANGENTSPACE




How To use Shaders

First thing you need to use shaders, is to have one. You can download FX Composers. It has 136 Shaders ( .fx ) files in it for you to use, you can ofcourse also create your own.
Note: The scene shaders in FX Composers does not work with TV as it uses special FX Composer specific instructions that are not in FX standards.

This is the declaration you need for your shader
Code:
Private myShader As TVShader

And then you will create your shader, set some parameters if you want. Here we are loading the Cartoon Shader from FX Composer and setting the Parameters to change the color. You may use FX Composer to look for these parameters.

Color is like a 4D Vector and this is the way TV treats them. So we create a TV_4DVector and set the color, and then change the preference on the shader.
Code:
Set myShader = Scene.CreateShader("NewShader")
myShader.CreateFromEffectFile "D:\Program Files\NVIDIA Corporation\NVIDIA FX Composer\MEDIA\HLSL\Cartoon.fx"

Dim test As TV_4DVECTOR
test.x = 256
test.y = 0
test.z = 0
test.w = 0
myShader.SetEffectParamVector "diffuseMaterial", test

After we create the Shader, we want to apply it to something. And sometimes "SetMeshFormat 17" is required for particular shaders.
For Cartoon Shader to work, the mesh can not have any texture. so SetTexture 0
Quote
Teapot.SetMeshFormat 17
Teapot.SetTexture 0
Teapot.SetShader myShader
[/url]
« Last Edit: October 05, 2008, 07:16:41 AM by SylvainTV » Logged
JeffWeber
Community Member
*
Posts: 1023


« Reply #1 on: July 14, 2004, 11:43:57 AM »

Thanks, that'll be very helpful!!
Logged

""Space is deep, Man is small and Time is his relentless enemy" --Orson Scott Card
Trashcan
Community Member
*
Posts: 1346


« Reply #2 on: July 19, 2004, 02:41:27 PM »

nice paveli Smiley
Logged
Anti-Gremlin
Community Member
*
Posts: 862


WWW
« Reply #3 on: July 19, 2004, 09:11:44 PM »

very nice... i'll def be playing around with those..
Logged

Project: It's a secret..
Progress: <secret progress>
TV3D Chat: http://www.voidzero.com/chat/chatter.cgi?channel=tviug
TV3D Wiki Doc: http://wiki.truevision3d.com/
TV3D TVDN: http://www.truevision3d.com/tvdna/
Shaun
Community Member
*
Posts: 6


« Reply #4 on: August 17, 2004, 02:06:53 AM »

Hi Pavel

Thanks for the post - i've just tried out the glow effect and found a couple of problems with the code - has anyone else found the same thing??

First Problem: TVGraphics.InitGlowEffect TVRenderSurface.GetIndex
Should Be: TVGraphics.InitGlowEffect TVRenderSurface (i also added Set TVRenderSurface = New TVRenderSurface)

Second Problem: TVGraphics.RenderGlow
Should Be: TVGraphics.DrawGlow (Renderglow doesnt seem to exist??)

If anyone else has tried this and has different results, please let me know. otherwise hope this helps

 Cheesy
Logged
Pavel
Customers
Community Member
*****
Posts: 850


WWW
« Reply #5 on: August 17, 2004, 10:43:45 AM »

O.o

Sylv must have changed the function names.
Logged
Arli
Administrator
Community Member
*****
Posts: 993


« Reply #6 on: August 17, 2004, 10:57:05 AM »

We changed it for consistancy, I told him to change it so it matched! Smiley
Passing the RenderSurface it initially used the index, but we changed so you can pass the object instead, like the old fashioned way! Smiley
Logged

Happy Coding

Arli
Truevision3D Developer
Arli@Truevision3D.com
sashelas
Community Member
*
Posts: 227


WWW
« Reply #7 on: August 19, 2004, 12:29:19 AM »

Could you post links to the sample code files you are using with your developer tests?  

It would save time and make the beta more fun to play with Smiley

BTW a friend of mine is head of a band called In Dhaka (He is Bangladeshi).  Have you heard of them at all?
Logged
rocky
Customers
Community Member
*****
Posts: 955


« Reply #8 on: September 27, 2004, 03:38:39 PM »

hahahahaha

What's with the bunny rabbit girl.  

 Tongue


Rocky
Logged
pizzayoyo
Customers
Community Member
*****
Posts: 1320


WWW
« Reply #9 on: March 01, 2005, 06:43:15 PM »

yeah full sample code would be nice.
Logged

jviper
Community Member
*
Posts: 1366

Discipline in training


« Reply #10 on: September 15, 2005, 08:55:37 PM »

Ok, I have the following code:
Code:
Option Explicit

Private TV3D As TVEngine
Private Mesh As TVMesh
Private WaterMesh As TVMesh
Private Ground As TVMesh
Private Scene As TVScene
Private Lights As TVLightEngine
Private Materials As TVMaterialFactory
Private Textures As TVTextureFactory
Private GraphicFX As TVGraphicEffect
Private WaterPlane As TV_PLANE
Private RenderSurfaceA As TVRenderSurface
Private RenderSurfaceB As TVRenderSurface

Private i As Long
Private Mat As Long
Private Vx As TV_SVERTEX
Private Running As Boolean
Private Const pi As Double = 3.14159275180032
Private Sub Form_Load()
    Set TV3D = New TVEngine
    Set Scene = New TVScene
    Set Mesh = New TVMesh
    Set WaterMesh = New TVMesh
    Set Ground = New TVMesh
    Set Lights = New TVLightEngine
    Set Materials = New TVMaterialFactory
    Set Textures = New TVTextureFactory
    Set GraphicFX = New TVGraphicEffect
   
    Mat = Materials.CreateMaterial("Mat1")
    Materials.SetAmbient Mat, 0, 0, 0, 1
    Materials.SetDiffuse Mat, 1, 0, 0, 1
    Materials.SetEmissive Mat, 0, 0, 0, 1
    Materials.SetOpacity Mat, 1
    Materials.SetPower Mat, 1
   
    Set Mesh = Scene.CreateMeshBuilder("Mesh")
    Mesh.CreateTeapot
    Mesh.SetScale 2, 2, 2
    Mesh.SetMaterial GetMat("Mat1")
    Mesh.SetLightingMode TV_LIGHTING_NORMAL
    Mesh.SetPosition 0, 4, 0
   
    Set Ground = Scene.CreateMeshBuilder("Ground")
    Ground.AddFloor 0, -64, -64, 64, 64, -20
    Ground.SetMaterial GetMat("Mat1")
    Ground.SetLightingMode TV_LIGHTING_NORMAL
   
    Set WaterMesh = Scene.CreateMeshBuilder
    WaterMesh.AddFloor 1, -64, -64, 64, 64, -10, 1, 1, False
    WaterMesh.SetLightingMode TV_LIGHTING_MANAGED
    Set RenderSurfaceA = Scene.CreateRenderSurface(256, 256, True, -1)
    Set RenderSurfaceB = Scene.CreateRenderSurface(256, 256, True, -1)
    WaterPlane.Dist = 10
    WaterPlane.Normal = Vector3(0, 1, 0)
    GraphicFX.SetWaterReflection WaterMesh, RenderSurfaceA, RenderSurfaceB, 0, WaterPlane
   
    Lights.CreateDirectionalLight Vector(-1, -1, -1), 1, 1, 1, "MainLight", 1
    Form1.Show
End Sub
Private Sub Timer1_Timer()
    RenderSurfaceA.StartRender False
        Scene.RenderAllMeshes True
    RenderSurfaceA.EndRender
    RenderSurfaceB.StartRender False
        Scene.RenderAllMeshes True
    RenderSurfaceB.EndRender
    TV3D.Clear
    Mesh.RotateY pi / 90, True
    Scene.RenderAllMeshes True
    TV3D.RenderToScreen
End Sub

...and the water reflection doe not seem to be there.
I'm I missing somthing? Is it that the water reflections don't reflect meshes, or could it possibly be my card: NVidia GeForce4 MX 4000?
Logged

JAbstract.....Don't just imagine, make it happen!
Eric
Customers
Community Member
*****
Posts: 758


« Reply #11 on: September 16, 2005, 12:07:17 PM »

geforce 4 mx doesnt have pixel shading, so it will not work.  you need at least a ps 1.1 card but 2.0 would be preferable
Logged
jviper
Community Member
*
Posts: 1366

Discipline in training


« Reply #12 on: September 16, 2005, 12:26:39 PM »

Quote from: "Eric"
geforce 4 mx doesnt have pixel shading, so it will not work.  you need at least a ps 1.1 card but 2.0 would be preferable

*****@@#$!!$$####@#$!!!!!!    @@$$#@#^&&@!@#!@#@!@#@!!!!!!!!!!!!!! :twisted:  :twisted:  :twisted:  :evil:  :evil:  :evil:  :evil: !!!!!!!!

Oh well, I guess I gotta buy another card.  Cool
Logged

JAbstract.....Don't just imagine, make it happen!
billythekid
Community Member
*
Posts: 814


« Reply #13 on: September 16, 2005, 12:38:23 PM »

Id get a pixel shader 3.0 capable card if you are going to go buy one. I have a hunch that in the next couple of years video games will require a shader 3.0 capable card just like many of the current games require a shader 2.0 card.
Logged
jviper
Community Member
*
Posts: 1366

Discipline in training


« Reply #14 on: September 16, 2005, 12:48:41 PM »

Yea sure. Once I get the money, I may as well just buy a very good card, that can handle anything. Heck, I have to buy a whole new system anyway. My system is only an AMD Athlon 1.8 GHz. It was great back then, but how a days, 1.8 Ghz isn't enough power to run a can opener.
So what such level on the NVIDIA side should I go up to? 7200? 8400? And what about the ATI side? I know now that on the ATI side, 9800 is minimum requirement.
Also: Is there a chance that when I buy a new computer, there will be a good graphics card in it? Or should I just rip everything out of the computer when I get it, and buy new hardware for it? Or should custom made be the way to go? I'm looking to buy a new system for under...... $1,000,000,000,000.....Naw just kidding,---- uh about $4,000, if that's realisitci.
Logged

JAbstract.....Don't just imagine, make it happen!
WEst
Community Member
*
Posts: 813

Daniel Martinek


WWW
« Reply #15 on: September 16, 2005, 12:49:42 PM »

I also will buy a SM 3.0 card soon, I'm only waiting for the RX1800
Logged

Greetings

Daniel Martinek
Lead Programmer
Roaming Nova Studios
UDPFC
Customers
Community Member
*****
Posts: 17


« Reply #16 on: March 02, 2007, 06:20:05 AM »

Hi!

I'm sure this is already answered a lot of times, but, i can't get to find the cartoon.fx, even installing the composers of nvidia it didn't appear anywhere.... :cry:

So can you please tell me where can i download it?

Thanks and sorry for my poor english Wink
Logged
Red Ocktober
Customers
Community Member
*****
Posts: 19


« Reply #17 on: March 12, 2007, 01:19:31 PM »

forget that suggestion jv... a ps3 card proabably won't fit into your current slot the mx card is occupying now... your best bet would probably be a GeForce fx5200 (if you can stand the fan noise, ps 2 capable, fast enough for government work) or a Radeon 9200 (quieter in most cases, but only ps 1.4, which is good for some shader stuff) or there abouts...

they're super cheap (around $50), and while not the best, they'll give you a taste of the shader stuff without having to go out and break the bank, otherwise, i'd advise waiting, and getting a new system once all the new vista  hardware starts appearing for more reasonable prices...

*** added ********
jv... maybe some of the (ATI x300,x1300 series) might fit the bill for you... after looking through the circuit city online catalogue, there seems to be some pci cards out that will be ps 3.0 compliant... just make sure they also don't exceed the ratings for the power supply you have...
*******************

as far as the tuts above... GREAT STUFF!!! BIG THANKS!!! LETS SEE MORE!!!

this is more like it  :lol:




--Mike
Logged
jviper
Community Member
*
Posts: 1366

Discipline in training


« Reply #18 on: March 17, 2007, 10:05:46 AM »

Dont know it I mentioned this on the boards yet, but I now have a laptop equipped with a  ATI Radeon Mobility X1300 card, which is ps3 compatable. I've been though a self crash-course of the world of shaders, and how quickly this world is developing, especailly with the new Vista coming out (oh joy  :roll:  ).  Anyways, I have found out how behind ATI is from Nvidia presently, although what ATI has to offer is enough for me for now. Now that I have a bit of money under me.
Well, thanks for your insights.
Logged

JAbstract.....Don't just imagine, make it happen!
TheOneTrueGod
Community Member
*
Posts: 118


« Reply #19 on: September 28, 2007, 11:53:44 PM »

A hint for the glow:

You can achieve interesting effects if you draw the glow *before* the actual object. Creates a halo. Abstract example:

<MainRenderLoop>

RendSurf.StartRender
Scene.RenderAll
RendSurf.EndRender
GraphicEffect.UpdateGlow

Engine.Clear

GraphicEffect.DrawGlow
GraphicEffect.DrawGlow
GraphicEffect.DrawGlow
GraphicEffect.DrawGlow
Scene.RenderAll
GraphicEffect.DrawGlow

Engine.RenderToScreen

</MainRenderLoop>

This was, btw, an example for a full scene glow.
Logged
Pages: [1] 2
  Print  
 
Jump to:  

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