New beta's "material mtl_envcube" reflection shade

Posted By: Drew

New beta's "material mtl_envcube" reflection shade - 11/05/03 12:06

New 6.12.7 beta's "material mtl_envcube" reflection shade Looks really nice! I'm also able to use flags like transparancy...
Question, how can I get about 50% of the shader to show, showing the other 50% of the models texture...
I've noticed most of the shaders are on or off, I'm looking to vary the amount of a shader...
thanks!
Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/05/03 12:47

you could try something like this:

Code:
effect=

"
texture mtlSkin1;
texture texSkin1;
matrix matMtl;
technique cubic_environment
{
pass p0
{
Texture[0]=<texSkin1>;
Texture[1]=<mtlSkin1>;
ColorArg1[0]=Texture;
ColorOp[0]=Modulate2x;
ColorArg2[0]=Diffuse;

ColorArg1[1]=Texture;
ColorOp[1]=AddSigned;
ColorArg2[1]=Current;

AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;
}
}
";

i had no time to use the new beta yet so i haven't tested this... instead of ColorOp[1]=AddSigned; you could also try ColorOp[1]=Modulate; or something like that. i think it would also be possible to control the amount of reflection with an alphachannel somehow...
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/05/03 13:14

very cool, thats exactly what i meant, thank you!
It works nicely... is there a parameter that controls the amount in this code? how could I get subtle changes?
This would work VERY well on high poly cars...
Here is my working code:

Code:
 bmap bmp_envcube2 = <enviromap.tga>;


// generate a matrix that transforms camera space back to world space
function mtl_env_view()
{
mat_set(mtl.matrix,matViewInv);
// reset the translation part of the matrix
mtl.matrix41 = 0;
mtl.matrix42 = 0;
mtl.matrix43 = 0;
}

function mtl_env_init()
{
bmap_to_cubemap(mtl.skin1);
mtl.event = mtl_env_view;
mtl.enable_view = on;
}

material mtl_envcube2 // environment cube
{
skin1 = bmp_envcube2;
event = mtl_env_init;

effect=
"
texture mtlSkin1;
texture texSkin1;
matrix matMtl;
technique cubic_environment
{
pass p0
{
Texture[0]=<texSkin1>;
Texture[1]=<mtlSkin1>;
ColorArg1[0]=Texture;
ColorOp[0]=Modulate2x;
ColorArg2[0]=Diffuse;

ColorArg1[1]=Texture;
ColorOp[1]=AddSigned;
ColorArg2[1]=Current;

AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;
}
}
";

}

action shaders_A6_envcube2
{
my.material = mtl_envcube2;
}





Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/05/03 17:55

Code:
effect=

"
texture texSkin1;
texture mtlSkin1;
matrix matMtl;
technique cubic_environment
{
pass p0
{
Texture[0]=<texSkin1>;
Texture[1]=<mtlSkin1>;

zWriteEnable=true;
AlphaBlendEnable=false;

ColorArg1[0]=Texture;
ColorOp[0]=Modulate2x;
ColorArg2[0]=Diffuse;

ColorArg1[1]=Texture;
ColorOp[1]=BlendCurrentAlpha;

AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;
}
}
";

you could use this effect. the alphachannel of the model texture specifies how reflective the texture is.
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 09:42


very Nice! Added an alpha channel to the models texture (32bit TGA) and it works nicely!
thanks!!!
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 10:12

Its nice that now I can have selective areas on my model reflect only, like the metal armor, all you need is a mask in your alpha channel. Nice too that it still uses the Bmap assigned for the reflection.
Is there a way to get a bumpmapping on skin2? as either a bump or a bumpdot3 map...
awesome work!
Posted By: Nadester

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 10:25

Havn't downloaded the update yet... takes oodles of time on my 56k But I'm just gonna try the code with the new key.zip. I just want to know, what should my enviromap.tga be? I need to make one since I dont have it.
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 10:38

the enviromap.tga...
an easy way is to take a screenshot (F6) during gameplay(1st person view, no gun),its called "Shot_0" or something in your work folder...
Make the screenshot 256x256, make it tileable.
this way it seems like its reflecting your environment.

If you want selective reflections on your model, add a alphachannel in photoshop to your model's texture.
its greyscale, so white would be completely reflective (showing enviromap) grey would be sort of reflective, and black none.
Save it as 32bit .TGA and apply it to your model as skin1.
Hope that helps
Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 10:43

you could add bumpmapping too. but the fixed-pipeline bumpmapping doesn't look good. i think for best results you would have to do the entire effect with a vertex/pixelshader but i don't know how to do correct cubic environment mapping with a shader.

you have to use the same cubic environments you would use for a sky -> look in the readbeta.txt for sky.cube!

Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 10:50

Quote:

the enviromap.tga...
an easy way is to take a screenshot (F6) during gameplay(1st person view, no gun),its called "Shot_0" or something in your work folder...
Make the screenshot 256x256, make it tileable.
this way it seems like its reflecting your environment.




i think this won't result in a "correct" reflection. you have to use a 6-frames sky cube sprite!

you would have to do it this way:
- set up a view which is 256x256 and has a view.arc of 90
- make 6 screenshots from the same position -> west, north, east, south, down, up
- copy them into a 1536x256 tga and name it cube+6.tga

the +6 is important because only then it will get recognized as cube by the engine!

(maybe i'll write a script which does this automatically!)

Posted By: Nadester

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 10:52

I see... I'll give it a wing. (btw, is that how all enviromental mapping is done, or is this just faking it? I always thought that enviromental mapping was actually reflective) Thanx!
Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 10:56

this is how all cubic environment mapping is done but cubic environment mapping is a fake! i think you can only get real reflections with raytracing which is still to slow for realtime rendering...
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 11:13

yes, very true ventilator

if possible a script or tool to make skycubes would be EXCELLENT...

Posted By: Nadester

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 12:07

Wow that is a gorgious effect! I applied it to my sword for bbr (just the blade part) and it looks amazing! Nice work
Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 12:50

ok, here is the rendercube script:

Code:
var cuberesolution=256; // set up the resolution of the cube here

var cubeposition[3]=0,0,200; // set up the position of the cube here
var west[3]=180,0,0;
var north[3]=90,0,0;
var east[3]=0,0,0;
var south[3]=-90,0,0;
var down[3]=90,-90,0;
var up[3]=90,90,0;

function rendercube()
{
video_set(cuberesolution,cuberesolution,32,0);
camera.arc=90;
vec_set(camera.x,cubeposition);
vec_set(camera.pan,west);
wait(1);
_sshot();
vec_set(camera.x,cubeposition);
vec_set(camera.pan,north);
wait(1);
_sshot();
vec_set(camera.x,cubeposition);
vec_set(camera.pan,east);
wait(1);
_sshot();
vec_set(camera.x,cubeposition);
vec_set(camera.pan,south);
wait(1);
_sshot();
vec_set(camera.x,cubeposition);
vec_set(camera.pan,down);
wait(1);
_sshot();
vec_set(camera.x,cubeposition);
vec_set(camera.pan,up);
wait(1);
_sshot();
}
on_r=rendercube;

i am not 100% sure if all directions are set up correctly. the beta watermarks are a bit annoying and unfortunately the video_set command isn't available in the non-beta version.

if you press r, 6 screenshots will be generated. nothing should move in your level while rendering the cube because there is a wait after rendering each side. copy all screenshots next to each other (in the order 0-1-2-3-4-5) into a new image in your image editing program and save it as <yourcubename+6.tga>.

(if you use this cube for a sky you shouldn't use a z offset in the sky definition because this will lead to distortions.)
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 14:13

nice, I'm about to pounce on it! thanks!
is there a similar technique for skybox textures?
Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 15:30

Quote:

is there a similar technique for skybox textures?


i am not sure what you mean? you can also use the cube rendered from the engine as sky if you want!

btw. you will achieve better quality if you render the cube sides with the size 512 and scale them down in your image editing application then...
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 16:21

Great script, worked perfectly just as you said...for both environment mapping and skycube...

Its amazing how much better they look, here's a screenshot:
(left rock is 50% reflection)


Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 16:39

looks great! what is this? an alien planet populated by zombies?
Posted By: Drew

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 16:46

lol... why yes it is. Those zombies keep popping up everywhere

Posted By: ello

Re: New beta's "material mtl_envcube" reflection shade - 11/06/03 17:10

it is so great! i used your script on a skull and i made a screenshot from the level for the enviro. all i can say: WOW - this new features add sooo much to the engine
Posted By: Beorn

Re: New beta's "material mtl_envcube" reflection shade - 11/17/03 09:23

Great code, ive been looking for this.

I got some really dumb questions though, you are free to toss some shoes on me but please gimme an answer at the same time if you have them since i just cant get this shader/material stuff into my head - its a total mental-block!

In a previous thread (idiots...) i found out that my card (geforce2 mobile)shouldn´t be able to handle shaders. Is this not a shader?

If its not, What is it then (technically speaking)?

Can i do other stuff, like taking control of the gourad shading on terrains and such with the same type of techniques?

One of the reasons im all this stuff is cause i am aiming to get a fairly low hardware req. spec for my current game, and i dont want to force people getting new cards and such
Posted By: Beorn

Re: New beta's "material mtl_envcube" reflection shade - 11/17/03 12:38

BTW, you guys havent got any problems making screenshots? I cant do them unless i use the built in "f6" version. Is there any way to call the f6 function from a script?
Posted By: jcl

Re: New beta's "material mtl_envcube" reflection shade - 11/17/03 18:05

Beorn: No, it's not a shader, it's a texture stage effect. Geforce 2 does indeed not support shaders. The [F6] key just calls the following function:

var _shot_no=0;
function _sshot() {
screenshot("shot_",_shot_no);
beep;
_shot_no+=1;
}

Posted By: Beorn

Re: New beta's "material mtl_envcube" reflection shade - 11/17/03 22:26

Thanks a lot JCL. This is extremely enlightening and helpful. Once again my universe follows certain laws from wich i can derive the future and bring to the people.

Where might one find some suitable litterature on this subject, texture stage effect?

[OT warning]
And: Isn´t "screenshot" supposed to be abandoned, and in which script is this function situated?
[Ot: Over]

And again: Very Cool Script, this! Id like to thank Ventilator and Jelly for all the "pushing" and "sharing", it is much appreciated.
Posted By: Templar

Re: New beta's "material mtl_envcube" reflection shade - 11/18/03 00:53

Yeah, where did "screenshot" function come from? I've been looking for something like this for AGES!

T.
Posted By: er_willy

Re: New beta's "material mtl_envcube" reflection shade - 12/08/03 01:58

i create a cube-omatik scrip and tutorial you can see here
Posted By: msKEN

Re: New beta's "material mtl_envcube" reflection shade - 12/08/03 03:19

While this topic has been brought up, has anyone been able to get this to work with the 6.20 release of shaders? I'm at a loss. My model's skin01 is a 32bit alpha map, but its not showing for me, and all I have is one big enviorment mapped car. lol. Any help would be great!

Code:
 
bmap bmp_envcube2 = <skycube1+6.tga>;

// generate a matrix that transforms camera space back to world space
function mtl_env_view()
{
mat_set(mtl.matrix,matViewInv);
// reset the translation part of the matrix
mtl.matrix41 = 0;
mtl.matrix42 = 0;
mtl.matrix43 = 0;
}

function mtl_env_init()
{
bmap_to_cubemap(mtl.skin1);
mtl.event = mtl_env_view;
mtl.enable_view = on;
}

material mtl_envcube2 // environment cube
{
skin1 = bmp_envcube2;
event = mtl_env_init;

effect=
"
texture texSkin1;
texture mtlSkin1;
matrix matMtl;
technique cubic_environment
{
pass p0
{
Texture[0]=<texSkin1>;
Texture[1]=<mtlSkin1>;

zWriteEnable=true;
AlphaBlendEnable=true;

ColorArg1[0]=Texture;
ColorOp[0]=Modulate2x;
ColorArg2[0]=Diffuse;

ColorArg1[1]=Texture;
ColorOp[1]=BlendCurrentAlpha;

AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;
}
}
";

}

action a
{
my.material = mtl_envcube2;
}


Posted By: ventilator

Re: New beta's "material mtl_envcube" reflection shade - 12/08/03 03:26

you have to change texskin to entskin!
Posted By: msKEN

Re: New beta's "material mtl_envcube" reflection shade - 12/08/03 03:46

Opps, yes I had that changed as you recommended before, I just reposted the wrong code.
Posted By: ceashure

Re: New beta's "material mtl_envcube" reflection shade - 01/10/04 06:38

I am trying to use the script, yet i cant seem to get it to work. Does the shader work on MDL files?
Posted By: oliver2s

"mtl_envcube" Problem - 02/16/04 05:25

In dem Effect-Level das bei A6.2 mitgeliefert wird ist bei mir ein Fehler im Environment Mapping:


Die Decke und der Boden der Cubemap ist schwarz. Dies ist bei "Material mtl_envcube" und "Material mtl_envmirror" der Fall. Ich benutze den unveränderten Code aus dem Effect-Level aus dem Work-Ordner. Hat jemand eine erklärung dafür?
Posted By: ventilator

Re: "mtl_envcube" Problem - 02/16/04 05:31

-> http://www.conitecserver.com/ubbthreads/showflat.php?Cat=&Number=341404&page=0&view=collapsed&sb=5&o=&fpart=1
Posted By: qwerty823

Re: "mtl_envcube" Problem - 02/16/04 05:31

I dont speak german, but I can understand it somewhat thanks to google. I'd bet that you have a ATI card. There is another thread that mentions that environment cubes greater then 256x256 wont work with ATI's drivers. You can scale down the environment cube texture to only use 256x256 ( i think the one in the demo is 512x512 ), and it will work correctly.

And here is the german translation from google:

Ich spreche nicht Deutsches, aber ich kann es ein wenig verstehen dank google. Ich würde wetten, daß Sie eine ATI-Karte haben. Es gibt ein anderes Gewinde, das Würfel dieses Klimas erwähnt, die, grösseres dann 256x256 nicht mit Treibern ATIs bearbeitet. Sie können hinunter die Klimawürfelbeschaffenheit einstufen, um 256x256 (mich denke, das daß im demo 512x512 ist), nur zu verwenden, und es funktioniert richtig.
Posted By: oliver2s

Re: "mtl_envcube" Problem - 02/16/04 05:37

Thanks Ventilator and qwerty823 for the replies. I've search in the shader forum for this problem, but I haven't seen this thread. Thanks
Posted By: qwerty823

Re: "mtl_envcube" Problem - 02/16/04 05:54

Here is the thread:

http://www.conitecserver.com/ubbthreads/showflat.php?Cat=&Number=341404&page=0&view=collapsed&sb=5&o=&fpart=1
Posted By: oliver2s

Re: "mtl_envcube" Problem - 02/16/04 06:07

Oh great, it works
Posted By: Adr_Archie

Re: New beta's "material mtl_envcube" reflection shade - 07/08/04 21:32

Wow, this effect would look great on the windscreen of my spaceship!

I'm still kind of new to shaders and I was wondering which version of A6 this would work on?

Are there any restrictions between the different versions?
Thx
Luke
Posted By: hourousha

Re: New beta's "material mtl_envcube" reflection shade - 07/10/04 01:36

The dx7 level Envcube effect(like above)isn't correct,because real cube reflection only depends on the view-position,dosen't depends on look-at position.In other words, it needs cube-space(or world space)reflect vector,not the camera-space reflect vector.
You can calculate the tex-coordinate(the correct reflect vector) through vertex shader.But if you want to make a per-pixel env-cube or bump env cube effect,you should use both vertex and pixel shader,calculate the reflect vector in pixel shader.I wrote such a effect,It work fine in my D3D-8.1-API App ,but it seems not friendly with GS6.22,thus it makes a totally wrong result
Posted By: MMike

Re: New beta's "material mtl_envcube" reflection shade - 07/31/04 05:30

Quote:

Wow that is a gorgious effect! I applied it to my sword for bbr (just the blade part) and it looks amazing! Nice work





Can you show me an example? of your alpha mask?? and you how u did it on skin1?
Posted By: Sichlid

Re: New beta's "material mtl_envcube" reflection shade - 08/10/04 02:57

hi I have tried using the WIKI env map code but nothing comes up near to env mapping.

I have used TGA with alpha map for the weapon skin that is a SCREEN ENTITY.

Does this code apply only to a old model or is it possible to add it to
the new weapon system of A6 Template written by doug?

Regards,
Sichlid
Posted By: FinalGod

Re: New beta's "material mtl_envcube" reflection shade - 08/11/04 07:56

I would like to see this effect with a Bumpmapping Shader.

Can someone of the Shadergurus write such a code?
Or is it possible to combine this code with Bumpmappingshader?

Would help to make very nice Graphics for models.
Posted By: Sichlid

Re: New beta's "material mtl_envcube" reflection shade - 08/11/04 20:29

hi can any of u shader guys tell me if the env. map effect wud work with
Screen entities?

Regards,
Sichlid
Posted By: Sichlid

Re: New beta's "material mtl_envcube" reflection shade - 08/12/04 22:51

I got this working now !

You have to put one model in the level and apply env. mapping to it.

pow !! and then the screen entities also get Env mapping .

Pretty surpirising but that's the way it works
© 2024 lite-C Forums