Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Reflections
Topic Started: Sep 14 2007, 08:26 AM (755 Views)
Zedman3d
Member Avatar
Forum God
[ *  *  *  *  *  * ]
Could someone make me an example or something (gm6) because my code simply wont work.

Code:
 
CreateCubeTextureRenderTarget(4,256);
RenderToCubeTexture(4,character.x,character.y,character.z,255,255,255,64,Island);
SetMaterialEnvironmentMap(4,1);
SetModelMaterial(4,0,0,0,255);
Quote:
 
Eanbro: My problem with C++ is that not everything is included to start making projects with it.
Quote:
 
Dr.B: Your problem with C++ is that you want it to be like Game Maker...
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Zedman3d
Sep 14 2007, 08:26 AM
Could someone make me an example or something (gm6) because my code simply wont work.

Code:
 
CreateCubeTextureRenderTarget(4,256);
RenderToCubeTexture(4,character.x,character.y,character.z,255,255,255,64,Island);
SetMaterialEnvironmentMap(4,1);
SetModelMaterial(4,0,0,0,255);

These are some mistakes in your code:
1) "Island", the room value you pass to RenderToCubeTexture(...) is probably the ID of a Game Maker room, right? That should be the index of an U3D room that has to be rendered. Usually this is 0 (which is always rendered).
2) The values for SetMaterialEnvironmentMap(...) were passed in the wrong order (I assume that "1" is the material index of your model?)
3) You passed the index of the cube texture to SetModelMaterial(...), while it should be the index of the material that your model uses (that would be 1 if my previous assumption is correct).

So it should be like this:
Code:
 
CreateCubeTextureRenderTarget(4,256);
RenderToCubeTexture(4,character.x,character.y,character.z,255,255,255,64,0);
SetMaterialEnvironmentMap(1,4);
SetModelMaterial(1,0,0,0,255);


This code should be used only once, like in the Create Event of your model object. If you want to update the reflection of the environment regularly, you need to call RenderToCubeTexture(...) repeatedly, in the Step or Alarm Event of an arbitary object for example.

Hope this helps :).
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Zedman3d
Member Avatar
Forum God
[ *  *  *  *  *  * ]
Grrr. Its not working. I can never get any of this sort of thing to work. And before you ask, yes. I do support cube mapping.... Wtf is wrong with me.... :wacko:
Quote:
 
Eanbro: My problem with C++ is that not everything is included to start making projects with it.
Quote:
 
Dr.B: Your problem with C++ is that you want it to be like Game Maker...
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Hopefully this example can help you. Check out the Create & Step Events of the Mirror object.

There is something strange with these reflections, though; when moving sideways along the mirror, the reflection behaves as expected, but when you walk into the mirror, the reflection moves into the mirror as well. Try it out to see what I mean.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Zedman3d
Member Avatar
Forum God
[ *  *  *  *  *  * ]
Yay, thanx it works. The glitch is fine anyway, i can work around it and with it. ^_^
Thanx again.
Quote:
 
Eanbro: My problem with C++ is that not everything is included to start making projects with it.
Quote:
 
Dr.B: Your problem with C++ is that you want it to be like Game Maker...
Offline Profile Quote Post Goto Top
 
Andrew75
Member Avatar
Andrew75
[ *  *  *  *  *  * ]
MysteriXYZ
Sep 14 2007, 10:58 AM


There is something strange with these reflections, though; when moving sideways along the mirror, the reflection behaves as expected, but when you walk into the mirror, the reflection moves into the mirror as well. Try it out to see what I mean.

hey ya your right,, anyways looks like the reflection is being caused by how the polugons are layed out, i think it could be fixed by uping the poly count, but that woudnt be very nice,

wonder if theres another way to do reflections ? or maybe a code fix ?

Posted Image
Posted Image
(SONIC CD REMIX)
check out my vids
http://www.youtube.com/profile?user=tuxmask75
Check out our projects vids
http://www.youtube.com/profile?user=AXSXProject
Offline Profile Quote Post Goto Top
 
Andrew75
Member Avatar
Andrew75
[ *  *  *  *  *  * ]
Actually uping the poly count didnt help eather,,


Posted Image
Posted Image
(SONIC CD REMIX)
check out my vids
http://www.youtube.com/profile?user=tuxmask75
Check out our projects vids
http://www.youtube.com/profile?user=AXSXProject
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Does turning the edges work?
Blog|EHS
Offline Profile Quote Post Goto Top
 
Zedman3d
Member Avatar
Forum God
[ *  *  *  *  *  * ]
try making each face a quad.
Quote:
 
Eanbro: My problem with C++ is that not everything is included to start making projects with it.
Quote:
 
Dr.B: Your problem with C++ is that you want it to be like Game Maker...
Offline Profile Quote Post Goto Top
 
Matrix_Square
Member Avatar
Matrix Square Entertainment Developer
[ *  *  *  * ]
Zedman3d
Sep 17 2007, 09:52 PM
try making each face a quad.

That doesn't matter, during the rendering stage, the GPU will automatically tesselate your model into tri's.
SPRING time PROGRAMMING - GM & Ultimate3D Tutorials
Offline Profile Quote Post Goto Top
 
Andrew75
Member Avatar
Andrew75
[ *  *  *  *  *  * ]
skarik
Sep 18 2007, 04:02 AM
Does turning the edges work?

no turning the edges wont work because there will still be tryangles, i think it just be the way the reflections work.
wonder if there is a better way to do the reflections ?
Posted Image
(SONIC CD REMIX)
check out my vids
http://www.youtube.com/profile?user=tuxmask75
Check out our projects vids
http://www.youtube.com/profile?user=AXSXProject
Offline Profile Quote Post Goto Top
 
silverfire56
Forum God
[ *  *  *  *  *  * ]
tessellate eeh?
take advantage of that
or maybe change the texture cords ($10 bucks on this)

ether that or wait till "dr. best" posts, with his simple and obvious fix that we will wonder why we didn't think of that :lol:
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
I have two assumptions why this may be happening. The first one is that it's the result of the small error that results from the way this technique works in. You will never get 100% correct results, because the cube map gets computed only for one point. To get it absolutely correct one would need to compute one cube map (actually just one pixel) for every position on the surface of the object ^_^ . But since your ground model seems to be very big in comparison to the cube object, this probably isn't the cause of the problem. Assumption number two is that Direct3D is a bit imprecise when calculating the reflection vector, but I don't think that an imprecision like this could become that strong.

The only possible solution I could think of would be using a vertex shader to compute the reflection vector. This may lead to more precise results.
Offline Profile Quote Post Goto Top
 
Xeniczone
Elite Member
[ *  *  *  * ]
So how would you make a reflection using vertex shaders? and would it improve proformance over Cube mapping?
Posted ImageComcast sucks!Posted Image
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
A simple vertex shader that doesn't do much more than computing the default transformations and calculating a reflection vector would be needed here. The performance would be exactly the same as for the usual solution, because it's exactly the same technique with the only difference that the common approach uses the fixed function pipeline instead of a vertex shader.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply