Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1] 2
  Print  
Author Topic: CubeMapping problem (VB.NET/Tv6.5)  (Read 3257 times)
kameha
Community Member
*
Posts: 29


« on: October 19, 2007, 04:01:28 AM »

Hello,

I have a problem with cube mapping.
See the screenshot:



The centered cube may reflect the other cubes.
The project VB.NET on Tv6.5 is here:

http://perso.orange.fr/mansweb/Images/baz/testcubeMap.zip

Help! Huh
Kameha
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4946


WWW
« Reply #1 on: October 19, 2007, 04:32:03 PM »

Hello,

Unfortunately, TV doesn't support directly cubemapping. You must have a small shader applied to the middle cube to correctly use the results of the CubeRenderSurface.

If I get a lot of requests for it, a small internal cube shader will be added for special cases like that.

Check the forums to find a cubemapping shader, there are some !
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
MenDAKE
Community Member
*
Posts: 407


« Reply #2 on: October 19, 2007, 07:36:32 PM »

I just noticed this post after I had asked in another post if you were doing a cubmap. I guess that answers my question.

I personally think an internal cubmap would be extremely useful. You already have some excellent basic shaders in the engine, such as normal map, glow, lightmap, etc., so a cubmap would be very useful for prototyping, in my opinion. It's actually surprisingly difficult to come across a shader that supports bumpmapping and cubmapping simultaneously, which is a pretty standard thing for something like a shiny metal surface, and if you're new to shaders you're pretty much stuck. (There's an example shader in the nvidia site that allows bumpmapping of the reflection layer but not the model itself.)

I guess the alternative would be to include some of thees basic shaders with TV, rather than integrating it straight into the engine.
Logged
kameha
Community Member
*
Posts: 29


« Reply #3 on: October 30, 2007, 07:22:55 AM »

hello,

I searched for cubemapping shaders examples, it's not too easy as it seems...
(more than 34 topic pages talking about shaders!)

I got a GeForce4 Ti4400, so its supports vertex shader 1.1 and pixel shader 1.3, and I can't find examples talking reflections with vs1.1 and ps1.3
I know that fresnel reflection can be done on my card. I serched the effect file and articles, without success.  Angry

Can anyone help me?

(Sylvain: It should be very useful if you bring us 6.5 tutorials about shaders [reflections, glass, metal,...] in versions vs1.1, vs2.0, ...)
Logged
kameha
Community Member
*
Posts: 29


« Reply #4 on: October 31, 2007, 02:53:00 PM »

hello,

I found a shader working with my graphic card: msmetallicflakes.fx from Nvidia.  Smiley
But when I apply the shader to my cube, the RenderSurface is dark.  Angry

Here is a screenshot when I use the shader (with the dds indicated on the fx) on the cube:



Then if I use the shader with renderSurface:



I try to save a dds file from the renderSurface (tape N to save the renderSurface to render.dds).
If I don't use the shader, the dds is good (with 6 faces showing the colored cubes).
If I use the shader, all the dds faces are dark.

The link to my project:

http://perso.orange.fr/mansweb/Images/baz/testcubeMap2.zip

Where is the mistake?  Huh

Kameha

 
Logged
kameha
Community Member
*
Posts: 29


« Reply #5 on: October 31, 2007, 07:16:42 PM »

can anyone help me?   Grin
Logged
MenDAKE
Community Member
*
Posts: 407


« Reply #6 on: November 01, 2007, 01:37:01 AM »

I think what you need to do is put shadGlass.SetEffectParamTexture("EnvironmentMap", RS.GetTexture) to the main loop so it happens every frame, right after rendering the six sides of your cube render surface. I don't see any need to generate the DDS file every time, but maybe I'm misunderstanding what you're trying to do.
« Last Edit: November 01, 2007, 01:38:32 AM by MenDAKE » Logged
WEst
Customers
Community Member
*****
Posts: 945

Daniel Martinek


WWW
« Reply #7 on: November 01, 2007, 04:08:09 AM »

I think what you need to do is put shadGlass.SetEffectParamTexture("EnvironmentMap", RS.GetTexture) to the main loop so it happens every frame, right after rendering the six sides of your cube render surface. I don't see any need to generate the DDS file every time, but maybe I'm misunderstanding what you're trying to do.

You don't have to but this things in the main loop, the updated will happen automatically as the return value of a RS.GetTexture function always returns the same texture index of the rendersurface. Afaik when a RS is created it gets a texture index, and you simply use it like a normal texture. When something is drawn to the RS the texture is updated automatically.
Logged

Greetings

Daniel Martinek
Technical Director
23 Volts
MenDAKE
Community Member
*
Posts: 407


« Reply #8 on: November 01, 2007, 10:42:46 AM »

Well, that's good to know, and it makes a lot of sense. Thanks for clarifying that West -- it'll save some FPS I'm sure.

kameha, I downloaded your example and uncommented the "shadGlass.CreateFromEffectFile("files\metalf.fx")" and it looks to me like the shader is basically working. It looks black at first, but once you start moving the camera around it looks like the problem is simply that the camera projection direction is tiled slightly up so that by default you see the area just above each surrounding cube, which includes the black area of the viewport. If I start moving the camera with the arrow keys I notice the other blocks are indeed being reflected, but just not in a way that's directly in front of the cubemapped cube. Does that make sense?

I'd actually be very interested in knowing how to fix this problem. Does that projection need to be modified in the shader somehow? Does anyone know?
« Last Edit: November 01, 2007, 10:51:08 AM by MenDAKE » Logged
jviper
Community Member
*
Posts: 2130

Discipline in training


« Reply #9 on: November 01, 2007, 09:53:01 PM »

Hello,

Ok, I've found nothing wrong with your shader. There is also nothing wrong with your program that runs the shader, exept for a few things:

- You must call RenderSurface.SetCubeMapSettings...... function every frame, or at least every frame your object (with the shader applied) moves, or any other object in view for that matter. Also note the RenderSurface.SetCubeMapMatrix does not change anything (possible bug).
- When you are rendering the faces in your cubemap, you must disable your object (with the shader applied) temperarilly until rendering of your cubemap is complete. This is to ensure your mesh does not become an obstruction. Otherwise, you'll have to tinker with the camera for your Rendersurface to prevent any problems.
- The near plane on your RenderSirface.Camera must be set with a value that is smaller then your object's BoundingSphere radius. This is to ensure that when other objects come close your your object, their reflections don't vanish due to the clipping plain of your CubeMap's camera.

These are the changes I have made to your code to ensure that the shader functions properly. Hope this helps.
Logged

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


« Reply #10 on: November 10, 2007, 11:51:26 AM »

Hello,

Thanx jviper, the shader seems to work now  Smiley
But the reflections are strange-oriented/rotated.
As the screenshot shows:




1) the reflections are attched to the wrong faces
2) the images of reflections are not well applied on the cube or something gone wrong.
On the screenshot, we see that, for example, the réflection of the grey cube is not as we should have think of.
Perhaps it comes from the 1) problem.

Here is my project:
http://pagesperso-orange.fr/mansweb/Images/baz/testcubeMap3.zip

Anyone has an idea?  Huh

Kameha
Logged
kameha
Community Member
*
Posts: 29


« Reply #11 on: November 13, 2007, 02:44:10 PM »

can anyone help me? (again)   Grin
Logged
jviper
Community Member
*
Posts: 2130

Discipline in training


« Reply #12 on: November 14, 2007, 02:30:15 AM »

It appears actually that your reflections are not appearing with respect to your view point. I am refering to the perspective at which it is reflecting. It is not rotating with it. What I did was I took that "G" vector and multiplied it with the sematic "VIEWINVERSE", a float4x4. That solved that problem, so that not it at least rotates with your view. Then at that point, it's a matter of whether it's reflection or refraction.
Logged

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


« Reply #13 on: November 20, 2007, 02:36:35 PM »

Its means that i must modify the shader script?
How?  Huh
I don't understand the mathematical operations written in the script.

Anyone can post a version of the script which works fine in my project?
I need a shader specialist!   Grin

I tried changing some lines on the script but the results were really wrong!
Help me please.

 
Logged
jviper
Community Member
*
Posts: 2130

Discipline in training


« Reply #14 on: November 21, 2007, 02:43:39 AM »

Well yes. In most cases if you try to use a shader from somewhere, depending on where you got the shader from, you will need to modify the shader slightly for it to take advantage of the situation you put it in when using it in TV3D. In this particular example, you problebly got the shader from somewhere where the position of the object in the world was not important. Therefore all of it's reflection calculations were done against a projection matrix, and not a world projection matrix. If the shader was written in FX Composer or RenderMonkey, the position of the object was really assumed to be (0,0,0). Well when using it in TV3D, that might not always be the case. That's why you need to actually go into the shader and tweak it. You can view .fx files in notepad, wordpad, and other word document editor. Just be careful when you save it back out that it does not save any formatting of an sort (save it out as text only). I believe there is also some hlsl/.fx editors that you can tweak the .fx files in, and check syntax and all that.
Logged

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


« Reply #15 on: February 01, 2008, 05:53:02 PM »

Hello,

I found another shader for my graphic card.
And...the reflection seems working fine, see the screenshot (with a sphere):


So the main problem came from the kind of shader I used.  Angry
Thanx all for your help.

Kameha
Logged
Lyrical
Customers
Community Member
*****
Posts: 465


WWW
« Reply #16 on: February 02, 2008, 04:01:40 AM »

hi,
   I have downloaded you project which is a good example of cubemapping.
It would be nice if you could post a link to the .FX file that made this work,
or, if you could upload your project again.

It would be really helpful to others appreciate the efforts.

Thank You.
Logged
kameha
Community Member
*
Posts: 29


« Reply #17 on: February 03, 2008, 01:40:42 PM »

Hello,

Here is the project:
http://pagesperso-orange.fr/mansweb/Images/baz/test-cubeMap.zip

Camera movements with keyboard arrows keys + PageUp/PageDown
Exit with Esc key

Pay attention that the shader I use works fine with a sphere, not a cube!
For cubemapping demonstration, it is very strange.  Shocked

This problem don't come from the tv3d program, I tested the shader in FX Composer:
With a sphere:



If we zoom the object, everything is fine:



With a cube (the reflection is not as realistic than with the sphere):



If we zoom, we can see the problem:



If someone can find why it works wiht a sphere and not a cube?
Kameha
Logged
kameha
Community Member
*
Posts: 29


« Reply #18 on: February 04, 2008, 02:54:18 PM »

just a little precision: I took the shader CookTorranceMultiTexFresnel.fx and I kept the reflect effect (skipping the color, halfmap and normalmap textures).
Anyone tried my project?

Kameha
Logged
Lyrical
Customers
Community Member
*****
Posts: 465


WWW
« Reply #19 on: February 05, 2008, 11:44:24 AM »

just letting you know kameha that i have trieed you project
and all looks very well, nicley done.

I have added some rotation to the cudes just to see the reflection animate and it works
really well.

Thanks for sharing.
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