검색결과 리스트
Pixel Bender에 해당되는 글 6건
- 2008/11/05 PixelBender Outline View
- 2008/10/07 Scketch Shader를 위한 PV3D 튜닝
- 2008/09/25 Flex와 Pixel Bender로 iChat 흉내내기
- 2008/09/25 Human Detector! (2)
- 2008/09/18 Sketch Shader
- 2008/09/18 Sobel Operation 의 간단한 응용
글
PixelBender Outline View
'Pixel Bender' 카테고리의 다른 글
| PixelBender Outline View (0) | 2008/11/05 |
|---|---|
| Scketch Shader를 위한 PV3D 튜닝 (0) | 2008/10/07 |
| Flex와 Pixel Bender로 iChat 흉내내기 (0) | 2008/09/25 |
| Human Detector! (2) | 2008/09/25 |
| Sketch Shader (0) | 2008/09/18 |
| Sobel Operation 의 간단한 응용 (0) | 2008/09/18 |
글
Scketch Shader를 위한 PV3D 튜닝
package org.papervision3d.materials.shadematerials
{
import fl.motion.Color;
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.geom.Matrix;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.core.math.Number3D;
import org.papervision3d.core.proto.CameraObject3D;
import org.papervision3d.core.geom.renderables.Triangle3D;
import org.papervision3d.core.geom.renderables.Vertex3DInstance;
import org.papervision3d.core.material.AbstractSmoothShadeMaterial;
import org.papervision3d.core.math.Matrix3D;
import org.papervision3d.core.proto.LightObject3D;
import org.papervision3d.core.render.data.RenderSessionData;
import org.papervision3d.core.render.draw.ITriangleDrawer;
/**
* @Author Buzzler
*/
public class NormalMaterial extends AbstractSmoothShadeMaterial implements ITriangleDrawer
{
private static var x1:Number;
private static var x0:Number;
private static var x2:Number;
private static var y0:Number;
private static var y1:Number;
private static var y2:Number;
private var camera:CameraObject3D;
private var tmpN:Number3D;
private var tmpL:Number3D;
private var tmpR:uint;
private var tmpG:uint;
private var tmpB:uint;
private var tmpRGB:uint;
public function NormalMaterial(light:LightObject3D, camera:CameraObject3D)
{
super();
this.light = light;
this.camera = camera;
}
private static var useMap:BitmapData;
override public function drawTriangle(face3D:Triangle3D, graphics:Graphics, renderSessionData:RenderSessionData, altBitmap:BitmapData = null, altUV:Matrix = null):void
{
x0 = face3D.v0.vertex3DInstance.x;
y0 = face3D.v0.vertex3DInstance.y;
x1 = face3D.v1.vertex3DInstance.x;
y1 = face3D.v1.vertex3DInstance.y;
x2 = face3D.v2.vertex3DInstance.x;
y2 = face3D.v2.vertex3DInstance.y;
triMatrix.a = x1 - x0;
triMatrix.b = y1 - y0;
triMatrix.c = x2 - x0;
triMatrix.d = y2 - y0;
triMatrix.tx = x0;
triMatrix.ty = y0;
tmpN = face3D.faceNormal.clone();
tmpL = new Number3D(-light.x,-light.y,-light.z);
tmpR = uint((tmpN.x + 1.0) * 127.5);
tmpG = uint((tmpN.y + 1.0) * 127.5);
tmpB = uint((tmpN.z + 1.0) * 127.5);
tmpRGB = (tmpR << 16) | (tmpG << 8) | (tmpB);
graphics.beginFill(tmpRGB, brightness(tmpN, tmpL));
graphics.moveTo( x0, y0 );
graphics.lineTo( x1, y1 );
graphics.lineTo( x2, y2 );
graphics.lineTo( x0, y0 );
graphics.endFill();
renderSessionData.renderStatistics.shadedTriangles++;
}
private function brightness(n1:Number3D, n2:Number3D):Number
{
n1.normalize();
n2.normalize();
var result:Number = Math.acos(Number3D.dot(n1, n2)) - Math.PI / 2;
result = Math.max(result, 0) / (Math.PI / 2);
return 1 - result;
}
}
}
'Pixel Bender' 카테고리의 다른 글
| PixelBender Outline View (0) | 2008/11/05 |
|---|---|
| Scketch Shader를 위한 PV3D 튜닝 (0) | 2008/10/07 |
| Flex와 Pixel Bender로 iChat 흉내내기 (0) | 2008/09/25 |
| Human Detector! (2) | 2008/09/25 |
| Sketch Shader (0) | 2008/09/18 |
| Sobel Operation 의 간단한 응용 (0) | 2008/09/18 |
글
Flex와 Pixel Bender로 iChat 흉내내기
'Pixel Bender' 카테고리의 다른 글
| PixelBender Outline View (0) | 2008/11/05 |
|---|---|
| Scketch Shader를 위한 PV3D 튜닝 (0) | 2008/10/07 |
| Flex와 Pixel Bender로 iChat 흉내내기 (0) | 2008/09/25 |
| Human Detector! (2) | 2008/09/25 |
| Sketch Shader (0) | 2008/09/18 |
| Sobel Operation 의 간단한 응용 (0) | 2008/09/18 |
글
Human Detector!

10분만에 대충 짜놓은거라 꼼꼼하게 살펴보진 말고 그냥 보자.<languageVersion : 1.0;>
kernel HumanDetect
< namespace : "buzzler";
vendor : "Mobsword Systems";
version : 1;
description : "your description";
>
{
input image4 bg;
input image4 mix;
output pixel4 dst;
const pixel4 mask = pixel4(0.0, 0.0, 0.0, 0.0);
void
evaluatePixel()
{
float2 coord = outCoord();
pixel4 pixel_bg = sampleNearest(bg, coord);
pixel4 pixel_mix = sampleNearest(mix, coord);
float r = abs(pixel_bg.r - pixel_mix.r);
float g = abs(pixel_bg.g - pixel_mix.g);
float b = abs(pixel_bg.b - pixel_mix.b);
float a = abs(pixel_bg.a - pixel_mix.a);
if ((r < 0.01)&&(g < 0.01)&&(b < 0.01)&&(a < 0.01))
dst = mask;
else
dst = pixel_mix;
}
}
'Pixel Bender' 카테고리의 다른 글
| PixelBender Outline View (0) | 2008/11/05 |
|---|---|
| Scketch Shader를 위한 PV3D 튜닝 (0) | 2008/10/07 |
| Flex와 Pixel Bender로 iChat 흉내내기 (0) | 2008/09/25 |
| Human Detector! (2) | 2008/09/25 |
| Sketch Shader (0) | 2008/09/18 |
| Sobel Operation 의 간단한 응용 (0) | 2008/09/18 |
설정
트랙백
댓글
-
안녕하세요~~
플래시에서 배경합성에 대해서 알아보다가 검색을 통해
건너 건너 여기까지 왔습니다.
픽셀벤더는 사용해본적이 없어서, 이글 보고 다른 글 보면서
해보고있는데요.
위 소스를 가지고 pbj만들어서 플래시에서 임포트까지는 했는데
적용을 못하겠어요.
위 소스는 파라미터가 없어서 플래시에서 변수로 어떻게
지정해야 될지도 모르겠고요...ㅜㅜ
혹시 방법이 없나요~??쩝..
아님 위 소스중
input image4 bg;
input image4 mix;
둘중에 하나를 매개변수로 만들어서 사용할수는 없나요~???
넘 궁금하네요..ㅜㅜ-
Buzzler 2010/08/03 13:42
만든지 너무 오래돼서 기억이 안나네요 : )
배경합성은 어떤 소스로 하실지에따라 달라질 이야기긴 합니다만..
ShaderInput 도 하나의 매개변수 입니다.
ShaderParameter는 필수값이 아니구요. ShaderInput은 필수 매개변수라고 보시면 되겠네요.
합성을 하려면 반드시 두개의 이미지가 필요하니까요.
Shader 클래스를 다루는 사용법을 찾아보심이 좋겠네요 ^~^
전 다 까먹었어요. 다시 보려면 시간 좀 걸릴듯 ㅎㅎ
-
글
Sketch Shader
texture image
'Pixel Bender' 카테고리의 다른 글
| PixelBender Outline View (0) | 2008/11/05 |
|---|---|
| Scketch Shader를 위한 PV3D 튜닝 (0) | 2008/10/07 |
| Flex와 Pixel Bender로 iChat 흉내내기 (0) | 2008/09/25 |
| Human Detector! (2) | 2008/09/25 |
| Sketch Shader (0) | 2008/09/18 |
| Sobel Operation 의 간단한 응용 (0) | 2008/09/18 |
글
Sobel Operation 의 간단한 응용
<languageVersion : 1.0;>
kernel SobelFilter
< namespace : "buzzler";
vendor : "Mobsword Systems";
version : 1;
description : "Sobel Operation";
>
{
input image4 src;
output pixel4 dst;
const pixel4 black = pixel4(0.0, 0.0, 0.0, 1.0);
const float low = 1.0;
const float high = 2.0;
const float p_width = 1.0;
void evaluatePixel()
{
float g, gx, gy;
float2 coord = outCoord();
pixel4 sampled;
float tone;
sampled = sampleLinear(src, float2(coord[0]-p_width , coord[1]-p_width));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gx += low * tone;
gy += low * tone;
sampled = sampleLinear(src, float2(coord[0] , coord[1]-p_width));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gy += high * tone;
sampled = sampleLinear(src, float2(coord[0]+p_width , coord[1]-p_width));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gx -= low * tone;
gy += low * tone;
sampled = sampleLinear(src, float2(coord[0]-p_width , coord[1]));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gx += high * tone;
sampled = sampleLinear(src, float2(coord[0]+p_width , coord[1]));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gx -= high * tone;
sampled = sampleLinear(src, float2(coord[0]-p_width , coord[1]+p_width));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gx += low * tone;
gy -= low * tone;
sampled = sampleLinear(src, float2(coord[0] , coord[1]+p_width));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gy -= high * tone;
sampled = sampleLinear(src, float2(coord[0]+p_width , coord[1]+p_width));
tone = (sampled.r + sampled.g + sampled.b) / 3.0;
gx -= low * tone;
gy -= low * tone;
g = sqrt(pow(gx, 2.0) + pow(gy, 2.0));
dst = mix(sampled, black, g);
}
}
출력된 이미지 | 입력된 이미지 |
'Pixel Bender' 카테고리의 다른 글
| PixelBender Outline View (0) | 2008/11/05 |
|---|---|
| Scketch Shader를 위한 PV3D 튜닝 (0) | 2008/10/07 |
| Flex와 Pixel Bender로 iChat 흉내내기 (0) | 2008/09/25 |
| Human Detector! (2) | 2008/09/25 |
| Sketch Shader (0) | 2008/09/18 |
| Sobel Operation 의 간단한 응용 (0) | 2008/09/18 |
