dxruby64 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +14 -0
- data/README-ja.md +125 -0
- data/README.md +120 -0
- data/lib/31/dxruby.so +0 -0
- data/lib/32/dxruby.so +0 -0
- data/lib/33/dxruby.so +0 -0
- data/lib/34/dxruby.so +0 -0
- data/lib/dxruby.rb +2 -0
- data/sample/classic_sample/8_puzzle.rb +55 -0
- data/sample/classic_sample/block_destroy.rb +161 -0
- data/sample/classic_sample/block_fall.rb +194 -0
- data/sample/classic_sample/data.png +0 -0
- data/sample/classic_sample/dot.rb +80 -0
- data/sample/classic_sample/drawtile.rb +173 -0
- data/sample/classic_sample/flight.rb +75 -0
- data/sample/classic_sample/hitrangeview.rb +66 -0
- data/sample/classic_sample/mapedit.rb +270 -0
- data/sample/classic_sample/meiro.rb +106 -0
- data/sample/classic_sample/minsample.rb +14 -0
- data/sample/classic_sample/race.rb +119 -0
- data/sample/classic_sample/readme_sample.txt +42 -0
- data/sample/classic_sample/sample.rb +110 -0
- data/sample/classic_sample/soundeffect.rb +46 -0
- data/sample/new_sample/biyo.rb +25 -0
- data/sample/new_sample/image/enemy1.png +0 -0
- data/sample/new_sample/image/enemy1bomb.png +0 -0
- data/sample/new_sample/image/enemy2.png +0 -0
- data/sample/new_sample/image/enemy2bomb.png +0 -0
- data/sample/new_sample/image/enemyshot1.png +0 -0
- data/sample/new_sample/image/enemyshot2.png +0 -0
- data/sample/new_sample/image/maptile.png +0 -0
- data/sample/new_sample/image/myship.png +0 -0
- data/sample/new_sample/image/myshot.png +0 -0
- data/sample/new_sample/iraira.rb +49 -0
- data/sample/new_sample/laser2.rb +292 -0
- data/sample/new_sample/raycast.rb +249 -0
- data/sample/new_sample/readme_sample.txt +27 -0
- data/sample/new_sample/rubima.rb +597 -0
- data/sample/new_sample/ruby.png +0 -0
- data/sample/new_sample/slg.rb +82 -0
- data/sample/new_sample/sprite_animation.rb +133 -0
- data/sample/new_sample/sprite_collision1.rb +216 -0
- data/sample/new_sample/sprite_collision2.rb +93 -0
- data/sample/new_sample/sprite_simple.rb +65 -0
- data/sample/new_sample2/ImageFont.dat +0 -0
- data/sample/new_sample2/ImageFont.dat.png +0 -0
- data/sample/new_sample2/autocall.rb +24 -0
- data/sample/new_sample2/effecttest.rb +136 -0
- data/sample/new_sample2/fibersprite.rb +89 -0
- data/sample/new_sample2/hitrange.rb +133 -0
- data/sample/new_sample2/hlstest.rb +27 -0
- data/sample/new_sample2/mapedit_perlin.rb +291 -0
- data/sample/new_sample2/noise.rb +33 -0
- data/sample/new_sample2/particle.rb +220 -0
- data/sample/new_sample2/readme_sample.txt +29 -0
- data/sample/new_sample2/scenetest.rb +200 -0
- data/sample/new_sample2/scenetest2.rb +120 -0
- data/sample/scroll_sample/map.dat +32 -0
- data/sample/scroll_sample/map.rb +77 -0
- data/sample/scroll_sample/map_sub.dat +32 -0
- data/sample/scroll_sample/mapedit.rb +102 -0
- data/sample/scroll_sample/readme_sample.txt +24 -0
- data/sample/scroll_sample/scroll1.rb +108 -0
- data/sample/scroll_sample/scroll2.rb +149 -0
- data/sample/scroll_sample/scroll3.rb +148 -0
- data/sample/scroll_sample/simple.rb +13 -0
- data/sample/shader_sample/Shader/Flash.rb +93 -0
- data/sample/shader_sample/Shader/RasterScroll.rb +71 -0
- data/sample/shader_sample/Shader/RgssSprite.rb +143 -0
- data/sample/shader_sample/Shader/Transition.rb +108 -0
- data/sample/shader_sample/bgimage/BG00a1_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG10a_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG13a_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG32a.jpg +0 -0
- data/sample/shader_sample/bgimage/BG42a.jpg +0 -0
- data/sample/shader_sample/bgimage/course.png +0 -0
- data/sample/shader_sample/bgimage/image1.png +0 -0
- data/sample/shader_sample/bgimage/world_map2.png +0 -0
- data/sample/shader_sample/fan.rb +53 -0
- data/sample/shader_sample/image/enemy1.png +0 -0
- data/sample/shader_sample/image/enemy2.png +0 -0
- data/sample/shader_sample/image/maptile.png +0 -0
- data/sample/shader_sample/readme_sample.txt +43 -0
- data/sample/shader_sample/rule//343/203/201/343/202/247/343/203/203/343/202/253/343/203/274.png +0 -0
- data/sample/shader_sample/rule//345/217/263/346/270/246/345/267/273/343/201/215.png +0 -0
- data/sample/shader_sample/rule//346/250/252/343/203/226/343/203/251/343/202/244/343/203/263/343/203/211.png +0 -0
- data/sample/shader_sample/sample_blur.rb +112 -0
- data/sample/shader_sample/sample_divide.rb +91 -0
- data/sample/shader_sample/sample_flash.rb +54 -0
- data/sample/shader_sample/sample_lens.rb +65 -0
- data/sample/shader_sample/sample_mapping.rb +50 -0
- data/sample/shader_sample/sample_rasterscroll.rb +48 -0
- data/sample/shader_sample/sample_rgsssprite.rb +41 -0
- data/sample/shader_sample/sample_spehari.rb +50 -0
- data/sample/shader_sample/sample_sphere.rb +66 -0
- data/sample/shader_sample/sample_transition.rb +62 -0
- data/sample/shader_sample/sample_vertexshader.rb +223 -0
- data/sample/shader_sample/sample_wingman.rb +47 -0
- data/sample/shader_sample/turn_transition.rb +74 -0
- metadata +141 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
class SpriteShader < Shader
|
2
|
+
hlsl = <<EOS
|
3
|
+
float4 g_blend;
|
4
|
+
float4 g_tone;
|
5
|
+
|
6
|
+
texture tex0;
|
7
|
+
sampler Samp = sampler_state
|
8
|
+
{
|
9
|
+
Texture =<tex0>;
|
10
|
+
};
|
11
|
+
|
12
|
+
struct PixelIn
|
13
|
+
{
|
14
|
+
float2 UV : TEXCOORD0;
|
15
|
+
};
|
16
|
+
struct PixelOut
|
17
|
+
{
|
18
|
+
float4 Color : COLOR0;
|
19
|
+
};
|
20
|
+
|
21
|
+
PixelOut PS(PixelIn input)
|
22
|
+
{
|
23
|
+
PixelOut output;
|
24
|
+
float3 temp;
|
25
|
+
float3 ntsc = {0.298912, 0.586611, 0.114478};
|
26
|
+
float ntscy;
|
27
|
+
output.Color = tex2D( Samp, input.UV );
|
28
|
+
|
29
|
+
ntsc = ntsc * output.Color.rgb;
|
30
|
+
ntscy = ntsc.r + ntsc.g + ntsc.b;
|
31
|
+
temp.r = output.Color.r + ((ntscy - output.Color.r) * g_tone.a);
|
32
|
+
temp.g = output.Color.g + ((ntscy - output.Color.g) * g_tone.a);
|
33
|
+
temp.b = output.Color.b + ((ntscy - output.Color.b) * g_tone.a);
|
34
|
+
|
35
|
+
output.Color.rgb = min(1.0, temp + g_tone.rgb) * (1.0 - g_blend.a) + g_blend.rgb * g_blend.a;
|
36
|
+
|
37
|
+
return output;
|
38
|
+
}
|
39
|
+
|
40
|
+
technique TShader
|
41
|
+
{
|
42
|
+
pass P0
|
43
|
+
{
|
44
|
+
PixelShader = compile ps_2_0 PS();
|
45
|
+
}
|
46
|
+
}
|
47
|
+
EOS
|
48
|
+
|
49
|
+
@@core = Shader::Core.new(hlsl,
|
50
|
+
{
|
51
|
+
:g_blend => :float,
|
52
|
+
:g_tone => :float,
|
53
|
+
}
|
54
|
+
)
|
55
|
+
|
56
|
+
def initialize
|
57
|
+
super(@@core, "TShader")
|
58
|
+
self.g_blend = [0.0,0.0,0.0,0.0]
|
59
|
+
self.g_tone = [0.0,0.0,0.0,0.0]
|
60
|
+
@tone = [0.0,0.0,0.0]
|
61
|
+
@gray = 0.0
|
62
|
+
class << self
|
63
|
+
protected :g_blend, :g_blend=, :g_tone, :g_tone=
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def tone=(ary)
|
68
|
+
self.g_tone = [ary[0] / 255.0, ary[1] / 255.0, ary[2] / 255.0, @gray / 255.0]
|
69
|
+
@tone = ary
|
70
|
+
end
|
71
|
+
|
72
|
+
def gray=(gray)
|
73
|
+
self.g_tone = [@tone[0] / 255.0, @tone[1] / 255.0, @tone[2] / 255.0, gray / 255.0]
|
74
|
+
@gray = gray
|
75
|
+
end
|
76
|
+
|
77
|
+
def color=(ary)
|
78
|
+
self.g_blend = [ary[1] / 255.0, ary[2] / 255.0, ary[3] / 255.0, ary[0] / 255.0]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class RgssSprite < Sprite
|
83
|
+
def initialize(x=0, y=0, image=nil)
|
84
|
+
super
|
85
|
+
self.shader = SpriteShader.new
|
86
|
+
@rgss_sprite_color = nil
|
87
|
+
@rgss_sprite_flash_color = nil
|
88
|
+
@rgss_sprite_flash_duration = 1
|
89
|
+
@rgss_sprite_flash_count = 0
|
90
|
+
end
|
91
|
+
|
92
|
+
def tone=(ary)
|
93
|
+
if ary == nil
|
94
|
+
self.shader.tone = [0,0,0]
|
95
|
+
else
|
96
|
+
self.shader.tone = ary
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def gray=(gray)
|
101
|
+
self.shader.gray = gray
|
102
|
+
end
|
103
|
+
|
104
|
+
def color=(ary)
|
105
|
+
@rgss_sprite_color = ary
|
106
|
+
end
|
107
|
+
|
108
|
+
def flash(color=[255,255,255,255], duration=30)
|
109
|
+
@rgss_sprite_flash_color = color
|
110
|
+
@rgss_sprite_flash_duration = duration
|
111
|
+
@rgss_sprite_flash_count = duration
|
112
|
+
end
|
113
|
+
|
114
|
+
def update
|
115
|
+
@rgss_sprite_flash_count -= 1 if @rgss_sprite_flash_count > 0
|
116
|
+
end
|
117
|
+
|
118
|
+
def draw
|
119
|
+
if @rgss_sprite_color != nil and @rgss_sprite_flash_count > 0
|
120
|
+
if @rgss_sprite_color[0] > @rgss_sprite_flash_color[0] * @rgss_sprite_flash_count / @rgss_sprite_flash_duration
|
121
|
+
self.shader.color = @rgss_sprite_color
|
122
|
+
else
|
123
|
+
self.shader.color = [@rgss_sprite_flash_color[0] * @rgss_sprite_flash_count / @rgss_sprite_flash_duration,
|
124
|
+
@rgss_sprite_flash_color[1],
|
125
|
+
@rgss_sprite_flash_color[2],
|
126
|
+
@rgss_sprite_flash_color[3]
|
127
|
+
]
|
128
|
+
end
|
129
|
+
elsif @rgss_sprite_flash_count > 0
|
130
|
+
self.shader.color = [@rgss_sprite_flash_color[0] * @rgss_sprite_flash_count / @rgss_sprite_flash_duration,
|
131
|
+
@rgss_sprite_flash_color[1],
|
132
|
+
@rgss_sprite_flash_color[2],
|
133
|
+
@rgss_sprite_flash_color[3]
|
134
|
+
]
|
135
|
+
elsif @rgss_sprite_color != nil
|
136
|
+
self.shader.color = @rgss_sprite_color
|
137
|
+
else
|
138
|
+
self.shader.color = [0,0,0,0]
|
139
|
+
end
|
140
|
+
super
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# -*- coding: Windows-31J -*-
|
2
|
+
|
3
|
+
class TransitionShader < DXRuby::Shader
|
4
|
+
hlsl = <<EOS
|
5
|
+
float g_min;
|
6
|
+
float g_max;
|
7
|
+
float2 scale;
|
8
|
+
texture tex0;
|
9
|
+
texture tex1;
|
10
|
+
sampler Samp0 = sampler_state
|
11
|
+
{
|
12
|
+
Texture =<tex0>;
|
13
|
+
};
|
14
|
+
sampler Samp1 = sampler_state
|
15
|
+
{
|
16
|
+
Texture =<tex1>;
|
17
|
+
AddressU = WRAP;
|
18
|
+
AddressV = WRAP;
|
19
|
+
};
|
20
|
+
|
21
|
+
struct PixelIn
|
22
|
+
{
|
23
|
+
float2 UV : TEXCOORD0;
|
24
|
+
};
|
25
|
+
struct PixelOut
|
26
|
+
{
|
27
|
+
float4 Color : COLOR0;
|
28
|
+
};
|
29
|
+
|
30
|
+
PixelOut PS(PixelIn input)
|
31
|
+
{
|
32
|
+
PixelOut output;
|
33
|
+
output.Color = tex2D( Samp0, input.UV );
|
34
|
+
output.Color.a *= smoothstep(g_min, g_max, tex2D( Samp1, input.UV * scale ).r );
|
35
|
+
|
36
|
+
return output;
|
37
|
+
}
|
38
|
+
|
39
|
+
technique Transition
|
40
|
+
{
|
41
|
+
pass P0
|
42
|
+
{
|
43
|
+
PixelShader = compile ps_2_0 PS();
|
44
|
+
}
|
45
|
+
}
|
46
|
+
EOS
|
47
|
+
|
48
|
+
@@core = DXRuby::Shader::Core.new(
|
49
|
+
hlsl,
|
50
|
+
{
|
51
|
+
:g_min => :float,
|
52
|
+
:g_max => :float,
|
53
|
+
:scale => :float, # HLSL����float2�̏ꍇ��:float���w�肵��[Float, Flaot]�Ƃ����`�œn��
|
54
|
+
:tex1 => :texture,
|
55
|
+
}
|
56
|
+
)
|
57
|
+
|
58
|
+
# duration�͑J�ڂɂ�����t���[�����Aimage�̓��[���摜��Image�I�u�W�F�N�g(�ȗ��ŃN���X�t�F�[�h)�Avague�͞B����
|
59
|
+
def initialize(duration, image=nil, vague=nil)
|
60
|
+
super(@@core, "Transition")
|
61
|
+
if image
|
62
|
+
@image = image
|
63
|
+
@vague = vague == nil ? 40 : vague
|
64
|
+
else
|
65
|
+
@image = DXRuby::Image.new(1, 1, [0,0,0])
|
66
|
+
@vague = 256
|
67
|
+
end
|
68
|
+
@duration = duration
|
69
|
+
@count = 0
|
70
|
+
self.g_min = -@vague.fdiv(@duration)
|
71
|
+
self.g_max = 0.0
|
72
|
+
self.tex1 = @image
|
73
|
+
self.scale = [DXRuby::Window.width.fdiv(@image.width), DXRuby::Window.height.fdiv(@image.height)]
|
74
|
+
# �V�F�[�_�p�����[�^�ݒ�̃��\�b�h�͊O������J�Ƃ���
|
75
|
+
class << self
|
76
|
+
protected :g_min, :g_min=, :g_max, :g_max=, :scale, :scale=, :tex1, :tex1=
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def start(duration = nil)
|
81
|
+
@duration = duration if duration
|
82
|
+
@count = 0
|
83
|
+
self.g_min = -@vague.fdiv(@duration)
|
84
|
+
self.g_max = 0.0
|
85
|
+
end
|
86
|
+
|
87
|
+
def next
|
88
|
+
@count += 1
|
89
|
+
self.g_min = (((@vague+@duration).fdiv(@duration)) * @count - @vague).fdiv(@duration)
|
90
|
+
self.g_max = (((@vague+@duration).fdiv(@duration)) * @count).fdiv(@duration)
|
91
|
+
end
|
92
|
+
|
93
|
+
def frame_count=(c)
|
94
|
+
@count = c
|
95
|
+
self.g_min = (((@vague+@duration).fdiv(@duration)) * @count - @vague).fdiv(@duration)
|
96
|
+
self.g_max = (((@vague+@duration).fdiv(@duration)) * @count).fdiv(@duration)
|
97
|
+
end
|
98
|
+
|
99
|
+
def frame_count
|
100
|
+
@count
|
101
|
+
end
|
102
|
+
|
103
|
+
# �`��Ώۂ��w�肷��BRenderTarget�I�u�W�F�N�g���AWindow��n���B�f�t�H���g��Window�B
|
104
|
+
def target=(t)
|
105
|
+
self.scale = [t.width.fdiv(@image.width), t.height.fdiv(@image.height)]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
hlsl = <<EOS
|
4
|
+
texture tex0;
|
5
|
+
float4 color;
|
6
|
+
float start_angle, end_angle, flag, length;
|
7
|
+
|
8
|
+
sampler Samp0 = sampler_state
|
9
|
+
{
|
10
|
+
Texture =<tex0>;
|
11
|
+
};
|
12
|
+
|
13
|
+
float4 PS(float2 input : TEXCOORD0) : COLOR0
|
14
|
+
{
|
15
|
+
float temp;
|
16
|
+
temp = degrees(atan2(0.5 - input.y ,0.5 - input.x)) + 180.0;
|
17
|
+
clip(float2((temp - start_angle) * (end_angle - temp) * flag, length - distance(float2(0.5, 0.5), input)));
|
18
|
+
|
19
|
+
return color;
|
20
|
+
}
|
21
|
+
|
22
|
+
technique
|
23
|
+
{
|
24
|
+
pass
|
25
|
+
{
|
26
|
+
PixelShader = compile ps_2_0 PS();
|
27
|
+
}
|
28
|
+
}
|
29
|
+
EOS
|
30
|
+
|
31
|
+
core = Shader::Core.new(hlsl, :color => :float, :start_angle => :float, :end_angle => :float, :flag => :float, :length => :float)
|
32
|
+
shader = Shader.new(core)
|
33
|
+
|
34
|
+
image = Image.new(300,300)
|
35
|
+
|
36
|
+
shader.color = [255, 255, 255, 255]
|
37
|
+
shader.start_angle = 0
|
38
|
+
shader.end_angle = 0
|
39
|
+
shader.flag = 1
|
40
|
+
shader.length = 0.4
|
41
|
+
|
42
|
+
x = 1
|
43
|
+
|
44
|
+
Window.loop do
|
45
|
+
x += 5
|
46
|
+
x = 0 if x > 360
|
47
|
+
shader.start_angle = x
|
48
|
+
Window.draw_ex(100, 100, image, shader:shader)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
DXRuby �V�F�[�_�T���v���v���O����
|
2
|
+
|
3
|
+
�܂��ŏ��ɁA�\�[�X�������Ă��߂�Ȃ����B
|
4
|
+
�e�L�g�[�ɍ�������̂������Q�l�ɂȂ���Ċ����ŋl�ߍ���ł���܂��B
|
5
|
+
|
6
|
+
sample_blur.rb
|
7
|
+
�E�E�E�u���[(�ڂ���)�����ł��B
|
8
|
+
|
9
|
+
sample_divide.rb
|
10
|
+
�E�E�E�}�E�X�Ő��������Ɖ摜���^����ɂȂ�܂��B
|
11
|
+
|
12
|
+
sample_flash.rb
|
13
|
+
�E�E�EZ�L�[�ʼn摜���t���b�V�����܂��B
|
14
|
+
|
15
|
+
sample_lens.rb
|
16
|
+
�E�E�E�}�E�X�J�[�\���̈ʒu�̊G�����ዾ�݂����Ɋg�傳��܂��B
|
17
|
+
|
18
|
+
sample_mapping.rb
|
19
|
+
�E�E�E���S���瓯�S�~��ɏc���X�^�X�N���[�������āA���Ɖe���v�Z���Ă��܂��B
|
20
|
+
�o���v�}�b�s���O���h�L�ł��B
|
21
|
+
|
22
|
+
sample_rasterscroll.rb
|
23
|
+
�E�E�E�V���v���ȃ��X�^�X�N���[���ł��B
|
24
|
+
|
25
|
+
sample_rgsssprite.rb
|
26
|
+
�E�E�ERGSS2��Sprite�N���X�Ƌ߂��G�t�F�N�g(flash�Atone�Acolor)����������V�F�[�_�ł��B
|
27
|
+
|
28
|
+
sample_spehari.rb
|
29
|
+
�E�E�ESEGA�̃X�y�[�X�n���A�[�̒n�ʂ̂悤�Ȃ��̂�`�悵�܂��B
|
30
|
+
|
31
|
+
sample_sphere.rb
|
32
|
+
�E�E�E���̂̕\�ʂɉ摜���}�b�s���O����悤�ȃG�t�F�N�g�ł��B
|
33
|
+
|
34
|
+
sample_transition.rb
|
35
|
+
�E�E�E���[���摜�Ɋ�Â����g�����W�V�������s���܂��BRGSS�ɋ߂��p�����[�^�ɂȂ��Ă��܂��B
|
36
|
+
|
37
|
+
sample_wingman.rb
|
38
|
+
�E�E�E�E�B���O�}���ۂ��G�t�F�N�g�ł��B�Â��Ă��݂܂���B
|
39
|
+
|
40
|
+
turn_transition.rb
|
41
|
+
�E�E�E����̓V�F�[�_�ł͂Ȃ��̂ł����A�Ȃ��������ɓ����Ă��܂��B
|
42
|
+
Window.draw_morph���g���āA���������摜��3D��]�̂悤�ɕ`�悵�܂��B
|
43
|
+
|
data/sample/shader_sample/rule//343/203/201/343/202/247/343/203/203/343/202/253/343/203/274.png
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
hlsl = <<EOS
|
4
|
+
texture tex0;
|
5
|
+
float2 g_size;
|
6
|
+
|
7
|
+
sampler Samp0 = sampler_state
|
8
|
+
{
|
9
|
+
Texture =<tex0>;
|
10
|
+
AddressU=BORDER;
|
11
|
+
AddressV=BORDER;
|
12
|
+
};
|
13
|
+
|
14
|
+
float4 PS1(float2 In : TEXCOORD0) : COLOR0
|
15
|
+
{
|
16
|
+
float2 Texel0 = In + float2( -1.0/g_size.x, 0.0f );
|
17
|
+
float2 Texel1 = In + float2( -1.0/g_size.x*2, 0.0f );
|
18
|
+
float2 Texel2 = In + float2( -1.0/g_size.x*3, 0.0f );
|
19
|
+
float2 Texel3 = In + float2( -1.0/g_size.x*4, 0.0f );
|
20
|
+
float2 Texel4 = In + float2( -1.0/g_size.x*5, 0.0f );
|
21
|
+
|
22
|
+
float2 Texel5 = In + float2( 1.0/g_size.x, 0.0f );
|
23
|
+
float2 Texel6 = In + float2( 1.0/g_size.x*2, 0.0f );
|
24
|
+
float2 Texel7 = In + float2( 1.0/g_size.x*3, 0.0f );
|
25
|
+
float2 Texel8 = In + float2( 1.0/g_size.x*4, 0.0f );
|
26
|
+
float2 Texel9 = In + float2( 1.0/g_size.x*5, 0.0f );
|
27
|
+
|
28
|
+
float4 p0 = tex2D( Samp0, In ) * 0.20f;
|
29
|
+
|
30
|
+
float4 p1 = tex2D( Samp0, Texel0 ) * 0.12f;
|
31
|
+
float4 p2 = tex2D( Samp0, Texel1 ) * 0.10f;
|
32
|
+
float4 p3 = tex2D( Samp0, Texel2 ) * 0.08f;
|
33
|
+
float4 p4 = tex2D( Samp0, Texel3 ) * 0.06f;
|
34
|
+
float4 p5 = tex2D( Samp0, Texel4 ) * 0.04f;
|
35
|
+
|
36
|
+
float4 p6 = tex2D( Samp0, Texel5 ) * 0.12f;
|
37
|
+
float4 p7 = tex2D( Samp0, Texel6 ) * 0.10f;
|
38
|
+
float4 p8 = tex2D( Samp0, Texel7 ) * 0.08f;
|
39
|
+
float4 p9 = tex2D( Samp0, Texel8 ) * 0.06f;
|
40
|
+
float4 p10 = tex2D( Samp0, Texel9 ) * 0.04f;
|
41
|
+
|
42
|
+
return p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
|
43
|
+
}
|
44
|
+
|
45
|
+
float4 PS2(float2 In : TEXCOORD0) : COLOR0
|
46
|
+
{
|
47
|
+
float2 Texel0 = In + float2( 0.0f, -1.0/g_size.y );
|
48
|
+
float2 Texel1 = In + float2( 0.0f, -1.0/g_size.y*2 );
|
49
|
+
float2 Texel2 = In + float2( 0.0f, -1.0/g_size.y*3 );
|
50
|
+
float2 Texel3 = In + float2( 0.0f, -1.0/g_size.y*4 );
|
51
|
+
float2 Texel4 = In + float2( 0.0f, -1.0/g_size.y*5 );
|
52
|
+
|
53
|
+
float2 Texel5 = In + float2( 0.0f, 1.0/g_size.y );
|
54
|
+
float2 Texel6 = In + float2( 0.0f, 1.0/g_size.y*2 );
|
55
|
+
float2 Texel7 = In + float2( 0.0f, 1.0/g_size.y*3 );
|
56
|
+
float2 Texel8 = In + float2( 0.0f, 1.0/g_size.y*4 );
|
57
|
+
float2 Texel9 = In + float2( 0.0f, 1.0/g_size.y*5 );
|
58
|
+
|
59
|
+
float4 p0 = tex2D( Samp0, In ) * 0.20f;
|
60
|
+
|
61
|
+
float4 p1 = tex2D( Samp0, Texel0 ) * 0.12f;
|
62
|
+
float4 p2 = tex2D( Samp0, Texel1 ) * 0.10f;
|
63
|
+
float4 p3 = tex2D( Samp0, Texel2 ) * 0.08f;
|
64
|
+
float4 p4 = tex2D( Samp0, Texel3 ) * 0.06f;
|
65
|
+
float4 p5 = tex2D( Samp0, Texel4 ) * 0.04f;
|
66
|
+
|
67
|
+
float4 p6 = tex2D( Samp0, Texel5 ) * 0.12f;
|
68
|
+
float4 p7 = tex2D( Samp0, Texel6 ) * 0.10f;
|
69
|
+
float4 p8 = tex2D( Samp0, Texel7 ) * 0.08f;
|
70
|
+
float4 p9 = tex2D( Samp0, Texel8 ) * 0.06f;
|
71
|
+
float4 p10 = tex2D( Samp0, Texel9 ) * 0.04f;
|
72
|
+
|
73
|
+
return p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
|
74
|
+
}
|
75
|
+
|
76
|
+
technique Blur1
|
77
|
+
{
|
78
|
+
pass P0
|
79
|
+
{
|
80
|
+
PixelShader = compile ps_2_0 PS1();
|
81
|
+
}
|
82
|
+
}
|
83
|
+
technique Blur2
|
84
|
+
{
|
85
|
+
pass P0
|
86
|
+
{
|
87
|
+
PixelShader = compile ps_2_0 PS2();
|
88
|
+
}
|
89
|
+
}
|
90
|
+
EOS
|
91
|
+
|
92
|
+
core = Shader::Core.new(hlsl,{:g_size => :float})
|
93
|
+
shader1 = Shader.new(core, "Blur1")
|
94
|
+
shader2 = Shader.new(core, "Blur2")
|
95
|
+
|
96
|
+
image = Image.load("./image/maptile.png")
|
97
|
+
|
98
|
+
shader1.g_size = [image.width,image.height]
|
99
|
+
shader2.g_size = [image.width,image.height]
|
100
|
+
|
101
|
+
rt1 = RenderTarget.new(image.width,image.height)
|
102
|
+
rt2 = RenderTarget.new(image.width,image.height)
|
103
|
+
|
104
|
+
Window.loop do
|
105
|
+
Window.draw(50, 50, image)
|
106
|
+
rt1.draw_ex(0, 0, image, :blend=>:nond, :shader=>shader1)
|
107
|
+
rt1.update
|
108
|
+
rt2.draw_ex(0, 0, rt1, :blend=>:nond, :shader=>shader2)
|
109
|
+
rt2.update
|
110
|
+
Window.draw(350, 50, rt2)
|
111
|
+
break if Input.key_push?(K_ESCAPE)
|
112
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
hlsl = <<EOS
|
4
|
+
float3 p1, p2;
|
5
|
+
texture tex0;
|
6
|
+
|
7
|
+
sampler Samp0 = sampler_state
|
8
|
+
{
|
9
|
+
Texture =<tex0>;
|
10
|
+
};
|
11
|
+
|
12
|
+
float4 PS1(float2 input : TEXCOORD0) : COLOR0
|
13
|
+
{
|
14
|
+
clip( cross( float3(p2.x - p1.x, p2.y - p1.y, 0), float3(input.x - p1.x, input.y - p1.y, 0) ).z );
|
15
|
+
return tex2D( Samp0, input );
|
16
|
+
}
|
17
|
+
|
18
|
+
float4 PS2(float2 input : TEXCOORD0) : COLOR0
|
19
|
+
{
|
20
|
+
clip( cross( float3(p1.x - p2.x, p1.y - p2.y, 0), float3(input.x - p1.x, input.y - p1.y, 0) ).z );
|
21
|
+
return tex2D( Samp0, input );
|
22
|
+
}
|
23
|
+
|
24
|
+
technique Zan1
|
25
|
+
{
|
26
|
+
pass P0
|
27
|
+
{
|
28
|
+
PixelShader = compile ps_2_0 PS1();
|
29
|
+
}
|
30
|
+
}
|
31
|
+
technique Zan2
|
32
|
+
{
|
33
|
+
pass P0
|
34
|
+
{
|
35
|
+
PixelShader = compile ps_2_0 PS2();
|
36
|
+
}
|
37
|
+
}
|
38
|
+
EOS
|
39
|
+
|
40
|
+
Window.width, Window.height = 800, 600
|
41
|
+
|
42
|
+
core = Shader::Core.new(hlsl,{:p1=>:float, :p2=>:float})
|
43
|
+
shader1 = Shader.new(core, "Zan1")
|
44
|
+
shader2 = Shader.new(core, "Zan2")
|
45
|
+
image = Image.load("bgimage/BG42a.jpg")
|
46
|
+
image1 = image2 = nil
|
47
|
+
|
48
|
+
rt = RenderTarget.new(image.width, image.height)
|
49
|
+
|
50
|
+
point = nil
|
51
|
+
transition_flg = false
|
52
|
+
|
53
|
+
x1 = y1 = x2 = y2 = 0
|
54
|
+
angle = 0
|
55
|
+
alpha = 255
|
56
|
+
|
57
|
+
Window.loop do
|
58
|
+
if !transition_flg
|
59
|
+
if Input.mouse_push?(M_LBUTTON)
|
60
|
+
point = [Input.mouse_pos_x, Input.mouse_pos_y]
|
61
|
+
end
|
62
|
+
|
63
|
+
if point
|
64
|
+
if Input.mouse_down?(M_LBUTTON)
|
65
|
+
Window.draw_line(point[0], point[1], Input.mouse_pos_x, Input.mouse_pos_y, C_WHITE, 1)
|
66
|
+
else
|
67
|
+
transition_flg = true
|
68
|
+
shader1.p1 = shader2.p1 = [point[0].quo(image.width), point[1].quo(image.height),0]
|
69
|
+
shader1.p2 = shader2.p2 = [Input.mouse_pos_x.quo(image.width), Input.mouse_pos_y.quo(image.height),0]
|
70
|
+
angle = Math.atan2( Input.mouse_pos_y - point[1], Input.mouse_pos_x - point[0] )
|
71
|
+
image1 = rt.draw_shader(0, 0, image, shader1).update.to_image
|
72
|
+
image2 = rt.draw_shader(0, 0, image, shader2).update.to_image
|
73
|
+
alpha = 255
|
74
|
+
point = nil
|
75
|
+
x1 = y1 = x2 = y2 = 0
|
76
|
+
end
|
77
|
+
end
|
78
|
+
Window.draw(0, 0, image)
|
79
|
+
else
|
80
|
+
x1 -= Math.cos(angle) * 5
|
81
|
+
y1 -= Math.sin(angle) * 5
|
82
|
+
x2 += Math.cos(angle) * 5
|
83
|
+
y2 += Math.sin(angle) * 5
|
84
|
+
alpha -= 3
|
85
|
+
Window.draw_alpha(x1, y1, image1, alpha)
|
86
|
+
Window.draw_alpha(x2, y2, image2, alpha)
|
87
|
+
transition_flg = false if alpha < 10
|
88
|
+
end
|
89
|
+
break if Input.key_push?(K_ESCAPE)
|
90
|
+
end
|
91
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
require 'dxruby'
|
3
|
+
require './shader/flash.rb'
|
4
|
+
|
5
|
+
map = [[0, 0, 0, 0, 0, 0, 0, 0, 29, 11, 11, 30, 34, 66, 67, 67],
|
6
|
+
[0, 0, 0, 24, 25, 26, 0, 0, 29, 11, 11, 39, 40, 6, 34, 34],
|
7
|
+
[0, 0, 24, 17, 31, 35, 0, 0, 12, 20, 11, 11, 11, 39, 40, 40],
|
8
|
+
[0, 24, 17, 34, 7, 44, 0, 28, 28, 29, 11, 11, 11, 11, 11, 11],
|
9
|
+
[0, 33, 31, 34, 35, 0, 28, 3, 37, 38, 11, 11, 11, 18, 19, 19],
|
10
|
+
[0, 42, 43, 43, 44, 28, 3, 38, 11, 11, 11, 18, 19, 13, 28, 28],
|
11
|
+
[0, 0, 0, 0, 3, 37, 38, 11, 11, 18, 19, 13, 28, 28, 28, 0],
|
12
|
+
[0, 0, 0, 3, 38, 11, 11, 11, 18, 13, 28, 28, 51, 52, 52, 52],
|
13
|
+
[0, 0, 3, 38, 11, 11, 18, 19, 13, 51, 52, 52, 86, 58, 61, 76],
|
14
|
+
[28, 0, 29, 11, 11, 18, 13, 28, 51, 86, 58, 58, 61, 61, 58, 62],
|
15
|
+
[0, 28, 29, 11, 18, 13, 28, 0, 60, 58, 61, 61, 61, 61, 76, 71],
|
16
|
+
[0, 28, 29, 11, 27, 28, 28, 51, 86, 61, 61, 58, 76, 70, 71, 0],
|
17
|
+
[0, 0, 29, 11, 36, 4, 28, 60, 58, 61, 58, 76, 71, 0, 1, 2],
|
18
|
+
[0, 28, 29, 11, 11, 36, 4, 69, 70, 70, 70, 71, 0, 1, 2, 0],
|
19
|
+
[0, 0, 12, 20, 11, 11, 27, 0, 1, 0, 1, 1, 1, 2, 2, 0],
|
20
|
+
[0, 0, 28, 12, 20, 11, 27, 0, 0, 0, 2, 2, 0, 2, 2, 0],
|
21
|
+
[0, 0, 0, 2, 29, 11, 27, 1, 2, 2, 2, 0, 0, 2, 2, 2],
|
22
|
+
[0, 0, 0, 2, 29, 11, 27, 1, 0, 1, 1, 2, 2, 0, 0, 2],
|
23
|
+
[0, 0, 0, 0, 29, 11, 27, 1, 0, 2, 2, 2, 1, 1, 2, 2],
|
24
|
+
[0, 45, 47, 2, 29, 11, 36, 4, 1, 2, 2, 0, 0, 2, 2, 0],
|
25
|
+
[45, 82, 56, 0, 29, 11, 11, 36, 4, 1, 2, 2, 2, 2, 0, 0],
|
26
|
+
[54, 0, 56, 0, 12, 20, 11, 11, 36, 37, 4, 0, 2, 2, 2, 2],
|
27
|
+
[54, 55, 81, 46, 47, 12, 20, 11, 11, 11, 36, 4, 1, 1, 1, 2],
|
28
|
+
[54, 55, 0, 0, 56, 0, 12, 19, 20, 11, 11, 36, 37, 4, 1, 1],
|
29
|
+
[54, 0, 55, 55, 56, 0, 0, 0, 12, 20, 11, 11, 11, 36, 37, 37],
|
30
|
+
[63, 73, 55, 55, 56, 0, 0, 2, 2, 29, 11, 11, 11, 11, 11, 11],
|
31
|
+
[0, 54, 0, 55, 81, 47, 0, 2, 3, 38, 11, 11, 11, 11, 11, 11],
|
32
|
+
[0, 54, 0, 0, 55, 56, 2, 0, 29, 11, 11, 11, 21, 22, 22, 22],
|
33
|
+
[0, 63, 64, 64, 64, 65, 0, 0, 29, 11, 11, 21, 15, 48, 49, 49],
|
34
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 29, 11, 11, 30, 34, 57, 34, 34],
|
35
|
+
]
|
36
|
+
|
37
|
+
shader = FlashShader.new(30, [255,255,255])
|
38
|
+
|
39
|
+
rt = RenderTarget.new(640, 480)
|
40
|
+
image = Image.loadToArray("image/maptile.png", 9, 10)
|
41
|
+
|
42
|
+
Window.loop do
|
43
|
+
rt.draw_tile(0, 0, map, image, 0, 0, 12, 14)
|
44
|
+
rt.draw_tile(300, 200, map, image, 0, 0, 12, 14)
|
45
|
+
rt.update
|
46
|
+
|
47
|
+
shader.start if Input.keyPush?(K_Z)
|
48
|
+
shader.next
|
49
|
+
|
50
|
+
Window.draw_ex(0, 0, rt, :shader=>shader, :angle => 20)
|
51
|
+
|
52
|
+
break if Input.keyPush?(K_ESCAPE)
|
53
|
+
end
|
54
|
+
|