Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, rki), 395 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Refraction Shader #39312
01/16/05 22:32
01/16/05 22:32
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline OP
Expert
oliver2s  Offline OP
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Here is refraction shader I've wrote in the last few days. You can use it for example for special windows.

Here's a shot:


Here's the code (copy it first in "MS Word" and then copy it in SED or Notepad):
Code:
//Refraction Shader//////////////////////////////


VIEW refrac_view { layer = 20; } //Second View for Refraction

STARTER refrac_starter //Refrac View has always position of camera view
{
refrac_view.clip_near = 0;
camera.clip_near = 0; //that you can go very near on the refraction entity
refrac_view.visible = on;
proc_late();
while(1)
{
vec_set(refrac_view.x, camera.x);
vec_set(refrac_view.pan, camera.pan);
wait(1);
}
}

FUNCTION render_event_refraction();

MATERIAL mtl_refraction //the material
{
event = render_event_refraction();
flags = enable_view; //this is important

effect=
"
float4x4 matWorldViewProj: register(c0);

texture entSkin1;
texture entSkin2;

float mtlSkill1;
float vecSkill41;

struct VS_OUTPUT
{
float4 Pos: POSITION;
float2 textur: TEXCOORD0;
float3 eye: TEXCOORD1;
};

VS_OUTPUT VS_p0(float4 Pos: POSITION, float2 texcoord0 : TEXCOORD0)
{
VS_OUTPUT Out;

float4 pos = float4(1 * Pos.x, 1 * Pos.y, 1 * Pos.z, 1);
float4 pPos = mul(float4(pos.xyz,1), matWorldViewProj);

Out.Pos = pPos;

Out.textur = texcoord0.xy;

Out.eye.x = 0.5 * (pPos.z + pPos.x);
Out.eye.y = 0.5 * (pPos.z - pPos.y);
Out.eye.z = pPos.z * 1;

return Out;
}

sampler BumpMap = sampler_state
{
texture=(entSkin2);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

sampler RefractionMap = sampler_state
{
texture=(entSkin1);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

float4 PS_p0( float2 texCoord: TEXCOORD0, float3 eye: TEXCOORD1) : COLOR
{
float4 bump = tex2D(BumpMap, texCoord) * 2 - 1;
bump = normalize(bump);
float2 mid = eye.xy / eye.z + bump.xy * vecSkill41;
float4 refraction = tex2D(RefractionMap, mid);

clip(mtlSkill1);
return refraction;
}

technique refraction
{
pass p0
{

VertexShader = compile vs_1_1 VS_p0();
PixelShader = compile ps_2_0 PS_p0();
}
}
";

}

FUNCTION render_event_refraction() //that the refraction entity isn't visible in refrac view
{
if(render_view == camera)
{
mtl.skill1 = float(1);
}
if(render_view == refrac_view)
{
mtl.skill1 = float(-1);
}
}

ACTION ent_refraction
{
my.material = mtl_refraction;
my.skill41 = float(0.05); //bumpness
refrac_view.bmap = bmap_for_entity(my,1);
}



How to use it:
You need an entity with two skins.
  • 1# skin can be any texure (this texture will be overwritten by the refrac view).
  • 2# skin must be a normalmap

Then apply this entity the action "ent_refraction". You can change the value "my.skill41" for more or less bumpness.

Requirements for the shader:
  • Shader 2.0
  • A6.31
  • Pro Edition (for the render-to-textur feature)


Re: Refraction Shader [Re: oliver2s] #39313
01/17/05 01:10
01/17/05 01:10
Joined: May 2002
Posts: 2,541
Berlin
EX Citer Offline
Expert
EX Citer  Offline
Expert

Joined: May 2002
Posts: 2,541
Berlin
Very cool... Maybe even useful for waterfalls or ice.


:L
Re: Refraction Shader [Re: EX Citer] #39314
01/17/05 02:58
01/17/05 02:58
Joined: Jun 2004
Posts: 410
Bayern
ShooterMaker Offline
Senior Member
ShooterMaker  Offline
Senior Member

Joined: Jun 2004
Posts: 410
Bayern
wow soooooooo good THANX

EDIT: 300. post:D

Last edited by ShooterMaker; 01/17/05 03:00.

ICQ: 336-958-756 <a href="www.shootermaker.de" target="_blank"> http://www.shootermaker.de </a>
Re: Refraction Shader [Re: ShooterMaker] #39315
01/17/05 04:36
01/17/05 04:36
Joined: Jul 2002
Posts: 5,181
Austria
Blattsalat Offline
Senior Expert
Blattsalat  Offline
Senior Expert

Joined: Jul 2002
Posts: 5,181
Austria
will test this asap...looks really cool.


Models, Textures and Levels at:
http://www.blattsalat.com/
portfolio:
http://showcase.blattsalat.com/
Re: Refraction Shader [Re: oliver2s] #39316
01/17/05 07:18
01/17/05 07:18
Joined: Nov 2000
Posts: 1,534
hamburg
Samb Offline
Serious User
Samb  Offline
Serious User

Joined: Nov 2000
Posts: 1,534
hamburg
@oliver
ist momentan bekannt ob ein plugin die render_to_textur funktion ersetzen kann und somit auch die com benutzer den shader benutzen können? oder ist das völlig unmöglich?

Re: Refraction Shader [Re: Samb] #39317
01/17/05 20:10
01/17/05 20:10
Joined: Nov 2003
Posts: 1,267
ef
C
Christoph_B Offline
Serious User
Christoph_B  Offline
Serious User
C

Joined: Nov 2003
Posts: 1,267
ef
In Antwort auf:

ist momentan bekannt ob ein plugin die render_to_textur funktion ersetzen kann und somit auch die com benutzer den shader benutzen können? oder ist das völlig unmöglich?




genau, *nur com hab*


sef
Re: Refraction Shader [Re: Christoph_B] #39318
01/17/05 21:45
01/17/05 21:45
Joined: Oct 2001
Posts: 1,163
Germany
XeXeS Offline
Serious User
XeXeS  Offline
Serious User

Joined: Oct 2001
Posts: 1,163
Germany
Mein Plugin kann die RenderToTexture Funktionalität vollständig ersetzen und bieted ein eigenes shadersystem für Standard und Extra.

Re: Refraction Shader [Re: oliver2s] #39319
01/18/05 00:09
01/18/05 00:09
Joined: Dec 2002
Posts: 3,363
Vindobona (Ostarichi)
Harry Potter Offline
Expert
Harry Potter  Offline
Expert

Joined: Dec 2002
Posts: 3,363
Vindobona (Ostarichi)
@oliver2s: also ich muss sagen, dieser Refraction-Shader sieht wirklich genial aus. Ich würde sagen, das ist einer der besten und sinnvollsten Shader. Gute Arbeit.

Re: Refraction Shader [Re: Harry Potter] #39320
01/18/05 03:29
01/18/05 03:29
Joined: Jul 2002
Posts: 5,181
Austria
Blattsalat Offline
Senior Expert
Blattsalat  Offline
Senior Expert

Joined: Jul 2002
Posts: 5,181
Austria
can the second skin be transformed depending to the view in realtime?? see the bulgy glass shader from doom3 for example.


Models, Textures and Levels at:
http://www.blattsalat.com/
portfolio:
http://showcase.blattsalat.com/
Re: Refraction Shader [Re: XeXeS] #39321
01/18/05 03:51
01/18/05 03:51
Joined: Nov 2000
Posts: 1,534
hamburg
Samb Offline
Serious User
Samb  Offline
Serious User

Joined: Nov 2000
Posts: 1,534
hamburg
In Antwort auf:

Mein Plugin kann die RenderToTexture Funktionalität vollständig ersetzen und bieted ein eigenes shadersystem für Standard und Extra.




wird das mit ein paar zeilen umänderbar sein oder wird das durch die DLL wieder ne vollkommen neue funktion?

Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1