Archive

Posts Tagged ‘cgfx’

Converting .fx to CgFX

June 23rd, 2007 No comments

FX Composer 2안에 이런 것이 있었다. 아주 운이 좋은 것 같다. ㅋㅋㅋㅋㅋ
HLSL로 작성된 .fx 파일을 cgfx로 변환시켜 주는 방법이다.

FX Composer 2 comes with a Perl script that automatically converts HLSL .fx files
to CgFX. It is called “convert_fx.pl” and you can find it in the Utilities sub-folder of
the FX Composer 2 installed location.
convert_fx.pl outputs a copy of the input effect with Microsoft FX/CgFX 1.2
specific state assignments converted to the new OpenGL specific state assignments
in CgFX 1.5.
Perl must be installed for the script to run. (You can download a free Perl
distribution from www.activeperl.com.) To run the script, execute the following
command:

perl convert_fx.pl input.fx output.cgfx

Limitations

Multiple state assignments on a single line are not supported. If the input file
contains any lines similar to the following:
SrcBlend = One; DestBlend = Zero;

you must move these state assignments to their own line before running this script,
as shown below:
SrcBlend = One;
DestBlend = Zero;

State that has no direct OpenGL equivalent will not be changed; instead, this script
will add a comment to the line indicating that the state will have to be manually
updated. Search for “FIXME” in the output file to locate these problem states.
See the declaration of the unsupportedState array below for a list of state that is not
supported.

  • Sampler state inside a pass block is not supported by CgFX 1.5 or this script
    and will need to be manually moved into a sampler_state block.

  • This script only updates state assignments inside a pass or sampler_state block;
    it will not modify any shaders, annotations, or semantics.

Categories: dev:game Tags: , , , ,

cgfx 쉐이더 이벡트 Template 파일

April 17th, 2007 1 comment

fx composer 1.8로 기본 쉐이더 effect를 만들면 DirectX에서 쓸 수 있는 기본 *.fx 파일이 나온다. 이와 동일하게 Cg 1.5에서 사용할 수 있는 기본 cgfx 파일의 템플릿을 만들어 보았다.

newEffect.cgfx

Categories: dev:game Tags: ,

cgfx 안에서 쓸 수 있는 state

April 11th, 2007 No comments

Available state variables


Binding                             Underlying State
———————————   —————————
state.matrix.modelview[n]           modelview matrix n
state.matrix.projection             projection matrix
state.matrix.mvp                    modelview-projection matrix
state.matrix.texture[n]             texture matrix n


state.material.ambient         (r,g,b,a)   front ambient material color
state.material.diffuse         (r,g,b,a)   front diffuse material color
state.material.specular        (r,g,b,a)   front specular material color
state.material.emission        (r,g,b,a)   front emissive material color
state.material.shininess       (s,0,0,1)   front material shininess


state.light[n].ambient         (r,g,b,a)   light n ambient color
state.light[n].diffuse         (r,g,b,a)   light n diffuse color
state.light[n].specular        (r,g,b,a)   light n specular color
state.light[n].position        (x,y,z,w)   light n position

state.matrix.modelview.inverse : 역행렬
state.matrix.modelview.invtrans : 역행렬 트랜스포즈까지

Categories: dev:game Tags: ,