What am i doing wrong?
by Robin Degen · in Torque Game Engine Advanced · 05/27/2006 (10:14 am) · 8 replies
I use the following:
The texture can be found. When i remove this it just shows the texture normally. But when i add this, the whole "cube" that has that texture on it just disappears. Completely.. And this happens with ALL the shaders i test in shaders.cs.
This works fine:
but as soon as i add a "shader=", it just stops working, becomming invisible. I got an ati radeon 9800xt, so it should work fine right?
new CustomMaterial( TestWindow1 )
{
mapTo = A_BLUETEX1A_B02;
texture[0] = "$backbuff";
texture[1] = "a_bluetex1a_b02";
shader = BlobRefractVert;
version = 2.0;
refract = true;
specular[0] = "0.85 0.85 0.85 0.85";
specularPower[0] = 16.0;
};The texture can be found. When i remove this it just shows the texture normally. But when i add this, the whole "cube" that has that texture on it just disappears. Completely.. And this happens with ALL the shaders i test in shaders.cs.
This works fine:
new Material(TestDoor2)
{
mapTo = CPUBOSSDOOR;
baseTex[0] = "cpubossdoor";
bumpTex[0] = "cpubossdoorbump";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 64.0;
};but as soon as i add a "shader=", it just stops working, becomming invisible. I got an ati radeon 9800xt, so it should work fine right?
#2
demo\data\shapes\spaceOrc\materials.cs
Everything seems to work perfectly. The face and legs of the character refract the background as expected. I'm runnning everything from my laptop with an nVidia GeForce 7800 GTX. It looks like your 9800XT should be able to support the HLSL 2.0 shaders, too.
I suggest you try the code snippet above with the orc character to see if that is working or not.
Also, what visual effect are you trying to achieve with this shader? Applying a refraction shader to a smooth surface cube just might 'appear' as invisible since you're kind of looking through it.
John K.
05/31/2006 (2:03 pm)
I tried to reproduce your problem with the TSE feature walkthrough demo. I replaced the material definition for the Orc's skin with the following (based on your material definition attempt).demo\data\shapes\spaceOrc\materials.cs
new CustomMaterial(OrcSkin)
{
mapTo = "orc_id1_skin";
texture[0] = "$backbuff";
texture[1] = "orc_ID1_skin_bump";
shader = BlobRefractVert;
version = 2.0;
refract = true;
specular[0] = "0.85 0.85 0.85 0.85";
specularPower[0] = 16.0;
};Everything seems to work perfectly. The face and legs of the character refract the background as expected. I'm runnning everything from my laptop with an nVidia GeForce 7800 GTX. It looks like your 9800XT should be able to support the HLSL 2.0 shaders, too.
I suggest you try the code snippet above with the orc character to see if that is working or not.
Also, what visual effect are you trying to achieve with this shader? Applying a refraction shader to a smooth surface cube just might 'appear' as invisible since you're kind of looking through it.
John K.
#3
Yes it's a flat surface. I'm trying out different shaders, and basicly what i want is something transparent for a window/forcefield like effect. What shader would you recommend for that then on a flat surface? And what would be the datablock for that?
06/01/2006 (2:08 am)
Ah thanks, that explains a lot.Yes it's a flat surface. I'm trying out different shaders, and basicly what i want is something transparent for a window/forcefield like effect. What shader would you recommend for that then on a flat surface? And what would be the datablock for that?
#4
06/01/2006 (3:57 am)
Interesting, I need that forcefield thing too :-)
#5
Next, create your own material definitions for the test cube. Below, I've setup the BoxEdge to glow and the individual panels to be translucent. Here's the image I used as the texture for the window (very simple) you can download it and save to your demo/data/shapes/test directory...

And here's the material definition...
The end result should look something like this (again, using the TSE demo walkthrough)...

At least, that's one of a million ways to do it. Next, you can get creative. Replace the 'window' graphic with something else, maybe something with a pattern to it. Also, after the texture is patterned, you can animate it across the surface, like streaks of energy flowing. Have the texture scale, rotate, or scroll across the cube side. Or better yet, create an animated sequence of lightning bolts to look like the cube is charged with high voltage. Just play around and have fun with it.
John K.
06/04/2006 (10:32 am)
There are many ways to pull off a forcefield effect and it really depends on the style of your game. For a windowed translucent look, here's something to try. Using the TSE demo walkthough, open the demo/data/shapes/test/materials.cs file and comment everything past:// Cube materials
Next, create your own material definitions for the test cube. Below, I've setup the BoxEdge to glow and the individual panels to be translucent. Here's the image I used as the texture for the window (very simple) you can download it and save to your demo/data/shapes/test directory...

And here's the material definition...
new Material(BoxEdge)
{
mapTo = box_edge;
baseTex[0] = "box_edge";
glow[0] = true;
};
new Material(One)
{
mapTo = one;
baseTex[0] = "window";
translucent[0] = true;
translucentBlendOp = 5;
};
new Material(Two)
{
mapTo = two;
baseTex[0] = "window";
translucent[0] = true;
translucentBlendOp = 5;
};
new Material(three)
{
mapTo = three;
baseTex[0] = "window";
translucent[0] = true;
translucentBlendOp = 5;
};
new Material(four)
{
mapTo = four;
baseTex[0] = "window";
translucent[0] = true;
translucentBlendOp = 5;
};
new Material(five)
{
mapTo = five;
baseTex[0] = "window";
translucent[0] = true;
translucentBlendOp = 5;
};
new Material(six)
{
mapTo = six;
baseTex[0] = "window";
translucent[0] = true;
translucentBlendOp = 5;
};The end result should look something like this (again, using the TSE demo walkthrough)...

At least, that's one of a million ways to do it. Next, you can get creative. Replace the 'window' graphic with something else, maybe something with a pattern to it. Also, after the texture is patterned, you can animate it across the surface, like streaks of energy flowing. Have the texture scale, rotate, or scroll across the cube side. Or better yet, create an animated sequence of lightning bolts to look like the cube is charged with high voltage. Just play around and have fun with it.
John K.
#6
ok i got it to work nicely, however see my problem:

I could make the window less thick, but that wouldn't solve the full problem. I tried making the cube just a bit smaller so that it wouldn't cut those poly's in the optimalisation, but that didn't look to good. Any proffesional suggestions or would i be better of just to make the window a tiny bit smaller then the surrounding? I also tried making it bigger, but that gives the same result in optimalisation.
06/04/2006 (3:29 pm)
Wow that looks so nice! that's accactly what i was looking for. Thanks a lot! I'm going to try it right now.ok i got it to work nicely, however see my problem:

I could make the window less thick, but that wouldn't solve the full problem. I tried making the cube just a bit smaller so that it wouldn't cut those poly's in the optimalisation, but that didn't look to good. Any proffesional suggestions or would i be better of just to make the window a tiny bit smaller then the surrounding? I also tried making it bigger, but that gives the same result in optimalisation.
#7
I'm not 100% sure I understand your problem. Are you concerned about the outside world being visible through the edge of the window? (illustrating my point...)

In this case, it looks like the problem is that the box that represents the window is slightly larger than the surrounding frame. I suggest reducing the size of the window box to be slightly smaller than the frame. That should fix it.
Also, as a side note, is the window itself supposed to be glass or more like an electric forcefield? If it's a forcefield, then try adding some speckle noise to the glass texture and then animate it across the surface really fast. I'll bet that looks pretty cool (but couldnt tell from a screen capture). Also, if you feel like you can't see through the window to well (like glass is too thick), then open the texture in your paint tool and reduce the opacity. That should make the window clearer to see through. Good Luck!
John K.
John K.
06/04/2006 (4:27 pm)
Robin,I'm not 100% sure I understand your problem. Are you concerned about the outside world being visible through the edge of the window? (illustrating my point...)

In this case, it looks like the problem is that the box that represents the window is slightly larger than the surrounding frame. I suggest reducing the size of the window box to be slightly smaller than the frame. That should fix it.
Also, as a side note, is the window itself supposed to be glass or more like an electric forcefield? If it's a forcefield, then try adding some speckle noise to the glass texture and then animate it across the surface really fast. I'll bet that looks pretty cool (but couldnt tell from a screen capture). Also, if you feel like you can't see through the window to well (like glass is too thick), then open the texture in your paint tool and reduce the opacity. That should make the window clearer to see through. Good Luck!
John K.
John K.
#8
The texture itself on the window was just a text texture i used to see how it would look. Thanks a lot for the help! I'll be using a forcefield effect on other parts. This is just a test map for shaders/lighting and alike.
I'll get my texture guy to make some forcefield animations. Maybe i'll post that to if anybody is interrested.
06/05/2006 (5:42 am)
I tried reducing the window size just a slight bit, but even on the smallest grid, it's still to big (you'll see that the window is to small for the surrounding frame). I ended up fixing it by making seperate window shape.The texture itself on the window was just a text texture i used to see how it would look. Thanks a lot for the help! I'll be using a forcefield effect on other parts. This is just a test map for shaders/lighting and alike.
I'll get my texture guy to make some forcefield animations. Maybe i'll post that to if anybody is interrested.
Torque Owner Robin Degen