Featured image of post 맥스 쉐이더 기본공부 5

맥스 쉐이더 기본공부 5

일단 스페큘러(처럼 보이는 것)를 넣었습니다 !

원리는 대박 쉬운 방법… 일반 빛 구하는 것과 동일한 방법으로 중첩되서 처리하는 날림방법 ㅡ.,ㅡ
뷰 벡터를 의식하지 않은 초 허접 방법입니다.

그러므로 사실 퐁 쉐이딩이나 블린 쉐이딩 방법과는 전혀 다른 방식이라서, 시점을 변화시켜도 스페큘러가 변하지 않는다는
초 단점이 존재하는 거지요.

어쨌거나 공부하는 의미에서 저장합니다. 실제로는 못 사용할 듯.

float4x4 worldviewproj : WORLDVIEWPROJ ;
float4x4 world : WORLD ;
float4x4 View       :   VIEW;

//뷰 좌표계 추가. 나중에 쓸거라고 생각했는데 실제로는 안써버렸다.OTL
// 뷰 좌표백터를 인식해서 쓸 줄 알아야 쓰지.
//string ParamID = “0x0”;//넌 누구냐

texture basemap : DIFFUSEMAP
<
 string UIName = “디퓨즈”;
 int Texcoord = 0;
 int MapChannel = 1;

;

sampler2D basesampler = sampler_state
{
 texture = ;
 MinFilter = Linear ;
 MagFilter = Linear ;
 MipFilter = Linear ;
  
};

float3 lightdirection : DIRECTION
<
 string UIName = “라이트 디렉션”;
 string Object = “TargetLight”;
 string Space = “WORLD”;
 int RefID = 0; 

= {0.0, 0.0, 0.577};//이건 뭐냐.기본값이다.

float3 ambientcolor
<
 string UIName = “엠비언트 칼라”;
 > = float4( 0.47f, 0.47f, 0.47f, 1.0f );//이건 뭐냐고. 기본값이라니까.

float3 lightcolor : LIGHTCOLOR
<
 int LightRef =0;
 string UIWidget = “none”;

;

 
float4 specular 
<
 string UIName = “Specular”;
 > = float4( 0.5f, 0.5f, 0.5f, 1.0f );    // 왜 F를 붙이는데?

int sppower
<
 string UIName = “Specular Power”;
 string UIType = “IntSpinner”;
 float UIMin = 0.0f;//f가뭔데
 float UIMax = 50.0f; 
 >  = 15;

void VS
(
 in float4 ipos : POSITION,
 in float2 itex : TEXCOORD0,
 in float3 inormal : NORMAL,
 out float2 otex : TEXCOORD0,
 out float4 opos : POSITION,
 out float3 olight : TEXCOORD1,
 out float3 ospec : TEXCOORD2
)
{
 float3 onormal = normalize(mul(inormal,(float3x3)world));
 float3 DiffuseAmbientlight= max(0,dot(onormal,lightdirection))+ ambientcolor;
 float3 specularlight = specular * pow(max(0, dot(onormal,lightdirection)), sppower/2); 
 
 
 opos = mul(ipos, worldviewproj);
 otex = itex;
 olight = DiffuseAmbientlight ;
 ospec = specularlight;

 //olight = max(0,dot(onormal,lightdirection))+ ambientcolor;
}

void PS
(
 in float4 olight :TEXCOORD1,
 in float2 otex : TEXCOORD0,
 in float4 ospec : TEXCOORD2,
 out float4 ocolor :COLOR
)
{
 ocolor = tex2D(basesampler,otex)*olight + ospec ;
}

technique jp1
{
 pass p0
 {
  vertexshader = compile vs_2_0 VS();
  pixelshader = compile ps_2_0 PS();
 }
}

Hugo로 만듦
JimmyStack 테마 사용 중