1/2 >>
jrManのShader追加
javaについて、わかったことまとめ。
(1)Shaderとなるjavaをクラスにコンパイルする。
(2)jarコマンドを使って、そのクラスをjrMan.jarに追加する。
(3)jrman で rendering
以下のようなコンスタントシェーダを作成する。
folowing : SurfaceFirst.java.
import javax.vecmath.Color3f;
import org.jrman.grid.BooleanGrid;
import org.jrman.grid.Color3fGrid;
import org.jrman.grid.FloatGrid;
import org.jrman.render.ShaderVariables;
import org.jrman.shaders.SurfaceShader;
/*
SurfaceFirst.java
*/
public class SurfaceFirst extends SurfaceShader {
public void shade(ShaderVariables sv) {
super.shade(sv);
sv.Oi.set(sv.Os);
sv.Ci.mul(sv.Cs, sv.Oi);
}
}
上記のシェーダをmyshaderフォルダに保存しておく。
以下のようにコンパイルする。
C:\RIB\jrman-0_4>javac -classpath %JRMAN_HOME%\jar\jrman.jar;%JRMAN_HOME%\jar\ve
cmath.jar;%JRMAN_HOME%\jar\commons-cli-1.0.jar myshader/SurfaceFirst.java
続いて、クラスをjrMan.jarに追加する。
C:\RIB\jrman-0_4>cd jar
C:\RIB\jrman-0_4\jar>jar uvf jrman.jar %JRMAN_HOME%\myshader\SurfaceFirst.class
C:/RIB/jrman-0_4/myshader/SurfaceFirst.class を追加中です。(入 = 642) (出 = 359)
(44% 収縮されました)
C:\RIB\jrman-0_4\jar>cd..
bin\jrman.batのclasspathにmyshaderを追加、書き換える
set CLASSPATH=%JRMAN_HOME%\jar\jrman.jar;%JRMAN_HOME%\jar\vecmath.jar;%JRMAN_HOME%\jar\commons-cli-1.0.jar;%JRMAN_HOME%\myshader
以下をfirst.ribで保存する。
Display "first.tif" "framebuffer" "rgb"
Projection "perspective" "fov" [45]
LightSource "ambientlight" 1 "intensity" [0.2]
LightSource "spotlight" 2 "from" [-1 1 0 ] "to" [0 0 3] "intensity" [3]
Translate 0 0 3
WorldBegin
Color [1 0 0]
Surface "first"
Sphere 1 -1 1 360
WorldEnd
Happy Rendering!!
C:\RIB\jrman-0_4>jrman first.rib
jrManのクラスをコンパイル
jrManのシェーダを作ってみようと、ややこしい作業をしている。
ファイル名は、正確につけておかないと怒られる。
C:\RIB\jrman-0_4>jrman tramp.rib
Exception in thread "main" java.lang.NoClassDefFoundError: SurfaceTramp (wrong n
ame: Surfacetramp)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.jrman.shaders.SurfaceShader.createShader(SurfaceShader.java:172)
at org.jrman.parser.Parser.setSurface(Parser.java:740)
at org.jrman.parser.keywords.KeywordSurface.parse(KeywordSurface.java:33
)
at org.jrman.parser.Parser.parse(Parser.java:242)
at org.jrman.main.JRMan.main(JRMan.java:80)
大文字、小文字、厳密に命名しましょう。
シェーダ名、SurfaceTrampでした。 (wrong n
ame: Surfacetramp)になっていますね。
まだまだ理解不足です。勉強ですね。
jrManのRIBでは、Surface "tramp"と書いてOKな仕様になっています。
jrManでblend shaderをつくる
RSLシェーディング言語だと、
green=color "rgb" (0,1,0);
Ct=(1-s)*Cs+s*green;
どうやるのか、コンパイルするとエラー!!
SurfaceBlend.java:84: シンボルを見つけられません。
シンボル: メソッド add(float,org.jrman.grid.Color3fGrid)
場所 : org.jrman.grid.Color3fGrid の クラス
ct1.add(1.0f,ct1);
^
エラー 1 個
なので、ct1.sub(specularcolor,ct1);としたら、コンパイルした。color型なのですね。
以下、クラスファイルのソース
/*
SurfaceBlend.java
*/
import javax.vecmath.Color3f;
import org.jrman.grid.Color3fGrid;
import org.jrman.grid.Vector3fGrid;
import org.jrman.parameters.Declaration;
import org.jrman.parameters.UniformScalarFloat;
import org.jrman.parameters.UniformScalarTuple3f;
import org.jrman.render.ShaderVariables;
import org.jrman.shaders.SurfaceShader;
public class SurfaceBlend extends SurfaceShader {
private static Vector3fGrid vg1 = new Vector3fGrid();
private static Vector3fGrid vg2 = new Vector3fGrid();
private static Color3fGrid cg1 = new Color3fGrid();
private static Color3fGrid cg2 = new Color3fGrid();
private static Color3fGrid cg3 = new Color3fGrid();
private static Color3fGrid ct1 = new Color3fGrid();
private static Color3f specularcolor = new Color3f();
private static Color3f color1 = new Color3f();
protected void initDefaults() {
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ka", "uniform float"), 1f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Kd", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ks", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("roughness", "uniform float"), .1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("specularcolor", "uniform color"),
1f,
1f,
1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("color1", "uniform color"),
0f,
1f,
0f));
}
public void shade(ShaderVariables sv) {
super.shade(sv);
UniformScalarFloat paramKa = (UniformScalarFloat) getParameter(sv, "Ka");
final float Ka = paramKa.getValue();
UniformScalarFloat paramKd = (UniformScalarFloat) getParameter(sv, "Kd");
final float Kd = paramKd.getValue();
UniformScalarFloat paramKs = (UniformScalarFloat) getParameter(sv, "Ks");
final float Ks = paramKs.getValue();
UniformScalarFloat paramRoughness = (UniformScalarFloat) getParameter(sv, "roughness");
final float roughness = paramRoughness.getValue();
UniformScalarTuple3f paramSpecularcolor =
(UniformScalarTuple3f) getParameter(sv, "specularcolor");
paramSpecularcolor.getValue(specularcolor);
UniformScalarTuple3f paramColor1 =
(UniformScalarTuple3f) getParameter(sv, "color1");
paramColor1.getValue(color1);
vg1.normalize(sv.N);
vg1.faceforward(vg1, sv.I);
vg2.normalize(sv.I);
vg2.negate(vg2);
ct1.set(sv.s);
cg3.set(color1);
cg3.mul(ct1,cg3);
ct1.sub(specularcolor,ct1);
ct1.mul(ct1,sv.Cs);
ct1.add(ct1,cg3);
sv.Oi.set(sv.Os);
ambient(sv, cg1);
cg3.set(Ka);
cg1.mul(cg1, cg3);
diffuse(sv, vg1, cg2);
cg3.set(Kd);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
specular(sv, vg1, vg2, roughness, cg2);
cg3.set(Ks);
cg2.mul(cg2, cg3);
cg3.set(specularcolor);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
cg1.mul(cg1, ct1);
sv.Ci.mul(sv.Os, cg1);
}
}
カラー変更できるようにしておいたので、良いですね。
Display "blendtest.tif" "framebuffer" "rgb"
Format 640 480 1
Projection "perspective" "fov" [45]
LightSource "ambientlight" 1 "intensity" [0.2]
LightSource "spotlight" 2 "from" [-1 1 0 ] "to" [0 0 3] "intensity" [10]
Translate 0 0 3
WorldBegin
Color [1 0 0]
Surface "blend" "color color1" [0.2 0.4 0.6]
Rotate 10 1 0 0
#Rotate 180 1 0 0
#Patch "bilinear" "P" [-1 -1 0 1 -1 0 -1 1 0 1 1 0]
Sphere 1 -1 1 360
WorldEnd
引き続き、実験君です。
jrManはレンダーマンの勉強になります。
javaについて学ぶ機会になっているかも・・・
ありがとうございます。
Thanks Gerardo.
jrManでblend shaderをつくる その2
SurfaceShader.javaを確認したら、
private final static Color3f WHITE = new Color3f(1f, 1f, 1f);
これですね。
ということで、書き直しました。
(1-s)を
ct1.sub(WHITE,ct1);
ありがとうございます。
jrMan shaderでmix()をつかう その1
javaファイルを見ながら、地道に実験してみる。Essential RenderManを参考にして、mixtest shaderを作ってみた。RenderManシェーダの基本ですね。jrManの中でmix()がどうなっているか、src folderのFloatGrid.javaに実装されていました。
/*
SurfaceMixtest.java
*/
import javax.vecmath.Color3f;
import org.jrman.grid.FloatGrid;
import org.jrman.grid.Color3fGrid;
import org.jrman.grid.Vector3fGrid;
import org.jrman.parameters.Declaration;
import org.jrman.parameters.UniformScalarFloat;
import org.jrman.parameters.UniformScalarTuple3f;
import org.jrman.render.ShaderVariables;
import org.jrman.shaders.SurfaceShader;
public class SurfaceMixtest extends SurfaceShader {
private static Vector3fGrid vg1 = new Vector3fGrid();
private static Vector3fGrid vg2 = new Vector3fGrid();
private static FloatGrid fg1 = new FloatGrid();
private static Color3fGrid cg1 = new Color3fGrid();
private static Color3fGrid cg2 = new Color3fGrid();
private static Color3fGrid cg3 = new Color3fGrid();
private static Color3fGrid ct1 = new Color3fGrid();
private static Color3f specularcolor = new Color3f();
private static Color3f color1 = new Color3f();
private static Color3f WHITE = new Color3f(1f, 1f, 1f);
protected void initDefaults() {
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ka", "uniform float"), 1f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Kd", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ks", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("roughness", "uniform float"), .1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("specularcolor", "uniform color"),
1f,
1f,
1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("color1", "uniform color"),
0f,
1f,
0f));
}
public void shade(ShaderVariables sv) {
super.shade(sv);
UniformScalarFloat paramKa = (UniformScalarFloat) getParameter(sv, "Ka");
final float Ka = paramKa.getValue();
UniformScalarFloat paramKd = (UniformScalarFloat) getParameter(sv, "Kd");
final float Kd = paramKd.getValue();
UniformScalarFloat paramKs = (UniformScalarFloat) getParameter(sv, "Ks");
final float Ks = paramKs.getValue();
UniformScalarFloat paramRoughness = (UniformScalarFloat) getParameter(sv, "roughness");
final float roughness = paramRoughness.getValue();
UniformScalarTuple3f paramSpecularcolor =
(UniformScalarTuple3f) getParameter(sv, "specularcolor");
paramSpecularcolor.getValue(specularcolor);
UniformScalarTuple3f paramColor1 =
(UniformScalarTuple3f) getParameter(sv, "color1");
paramColor1.getValue(color1);
vg1.normalize(sv.N);
vg1.faceforward(vg1, sv.I);
vg2.normalize(sv.I);
vg2.negate(vg2);
fg1.set(sv.t);
cg3.set(color1);
sv.Cs.mix(sv.Cs, cg3, fg1);
ct1.set(sv.Cs);
sv.Oi.set(sv.Os);
ambient(sv, cg1);
cg3.set(Ka);
cg1.mul(cg1, cg3);
diffuse(sv, vg1, cg2);
cg3.set(Kd);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
specular(sv, vg1, vg2, roughness, cg2);
cg3.set(Ks);
cg2.mul(cg2, cg3);
cg3.set(specularcolor);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
cg1.mul(cg1, ct1);
sv.Ci.mul(sv.Os, cg1);
}
}
RIBは以下のようになります。tを使いました。
#mixtest.rib
Display "mixtest.png" "framebuffer" "rgb"
Format 640 480 1
Projection "perspective" "fov" [45]
LightSource "ambientlight" 1 "intensity" [0.2]
LightSource "spotlight" 2 "from" [-1 1 0 ] "to" [0 0 3] "intensity" [10]
Translate 0 0 3
WorldBegin
Color [1 0 0]
Surface "mixtest"
Rotate 90 1 0 0
#Rotate 180 1 0 0
#Patch "bilinear" "P" [-1 -1 0 1 -1 0 -1 1 0 1 1 0]
Sphere 1 -1 1 360
WorldEnd
jrMan shaderでmix()をつかう その2
たったこれだけを記述するのに、えらく悩みました。
if(orientation==0)
Ct=mix(Cs,otherColor,s);
else
Ct=mix(Cs,otherColor,t);
orientationはStringにした。
作りながら、悩み、勉強になります。基本的なjava理解必要かも。
RIBは色を変更、orientationでstが入れ替わります。
Essential RenderManを参考にしました。
/*
SurfaceRamptest.java
*/
import javax.vecmath.Color3f;
import org.jrman.grid.FloatGrid;
import org.jrman.grid.Color3fGrid;
import org.jrman.grid.Vector3fGrid;
import org.jrman.parameters.Declaration;
import org.jrman.parameters.UniformScalarFloat;
import org.jrman.parameters.UniformScalarTuple3f;
import org.jrman.parameters.UniformScalarString;
import org.jrman.render.ShaderVariables;
import org.jrman.shaders.SurfaceShader;
public class SurfaceRamptest extends SurfaceShader {
private static Vector3fGrid vg1 = new Vector3fGrid();
private static Vector3fGrid vg2 = new Vector3fGrid();
private static FloatGrid fg1 = new FloatGrid();
private static FloatGrid fg2 = new FloatGrid();
private static Color3fGrid cg1 = new Color3fGrid();
private static Color3fGrid cg2 = new Color3fGrid();
private static Color3fGrid cg3 = new Color3fGrid();
private static Color3fGrid ct1 = new Color3fGrid();
private static Color3f specularcolor = new Color3f();
private static Color3f color1 = new Color3f();
private static Color3f WHITE = new Color3f(1f, 1f, 1f);
protected void initDefaults() {
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ka", "uniform float"), 1f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Kd", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ks", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarString(new Declaration("orientation", "string"), "1"));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("roughness", "uniform float"), .1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("specularcolor", "uniform color"),
1f,
1f,
1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("color1", "uniform color"),
0f,
1f,
0f));
}
public void shade(ShaderVariables sv) {
super.shade(sv);
UniformScalarFloat paramKa = (UniformScalarFloat) getParameter(sv, "Ka");
final float Ka = paramKa.getValue();
UniformScalarFloat paramKd = (UniformScalarFloat) getParameter(sv, "Kd");
final float Kd = paramKd.getValue();
UniformScalarFloat paramKs = (UniformScalarFloat) getParameter(sv, "Ks");
final float Ks = paramKs.getValue();
UniformScalarString paramOrientation =
(UniformScalarString) getParameter(sv, "orientation");
final String orientation = paramOrientation.getValue();
UniformScalarFloat paramRoughness = (UniformScalarFloat) getParameter(sv, "roughness");
final float roughness = paramRoughness.getValue();
UniformScalarTuple3f paramSpecularcolor =
(UniformScalarTuple3f) getParameter(sv, "specularcolor");
paramSpecularcolor.getValue(specularcolor);
UniformScalarTuple3f paramColor1 =
(UniformScalarTuple3f) getParameter(sv, "color1");
paramColor1.getValue(color1);
vg1.normalize(sv.N);
vg1.faceforward(vg1, sv.I);
vg2.normalize(sv.I);
vg2.negate(vg2);
fg1.set(sv.s);
fg2.set(sv.t);
cg3.set(color1);
if (orientation.equals("0")) {
sv.Cs.mix(sv.Cs, cg3, fg1);
}
if (orientation.equals("1")) {
sv.Cs.mix(sv.Cs, cg3, fg2);
}
ct1.set(sv.Cs);
sv.Oi.set(sv.Os);
ambient(sv, cg1);
cg3.set(Ka);
cg1.mul(cg1, cg3);
diffuse(sv, vg1, cg2);
cg3.set(Kd);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
specular(sv, vg1, vg2, roughness, cg2);
cg3.set(Ks);
cg2.mul(cg2, cg3);
cg3.set(specularcolor);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
cg1.mul(cg1, ct1);
sv.Ci.mul(sv.Os, cg1);
}
}
#ramptest.rib
Display "ramptest.png" "framebuffer" "rgb"
Format 640 480 1
Projection "perspective" "fov" [45]
LightSource "ambientlight" 1 "intensity" [0.2]
LightSource "spotlight" 2 "from" [-1 1 0 ] "to" [0 0 3] "intensity" [10]
Translate 0 0 3
WorldBegin
Color [0 1 0]
Surface "ramptest" "color color1" [0 0.2 1] "string orientation" "1"
Rotate 90 1 0 0
#Rotate 180 1 0 0
#Patch "bilinear" "P" [-1 -1 0 1 -1 0 -1 1 0 1 1 0]
Sphere 1 -1 1 360
WorldEnd
jrManでbandtest shader
できたと思ったら、てかりがない??
再検討するか。仕様かな??勉強ですね。
と、いろいろいじって青系の色にしてみたら、てかりしてました。笑
/*
SurfaceBandtest.java
*/
import javax.vecmath.Color3f;
import org.jrman.grid.BooleanGrid;
import org.jrman.grid.FloatGrid;
import org.jrman.grid.Color3fGrid;
import org.jrman.grid.Vector3fGrid;
import org.jrman.parameters.Declaration;
import org.jrman.parameters.UniformScalarFloat;
import org.jrman.parameters.UniformScalarTuple3f;
import org.jrman.parameters.UniformScalarString;
import org.jrman.render.ShaderVariables;
import org.jrman.shaders.SurfaceShader;
public class SurfaceBandtest extends SurfaceShader {
private static Vector3fGrid vg1 = new Vector3fGrid();
private static Vector3fGrid vg2 = new Vector3fGrid();
private static FloatGrid fg1 = new FloatGrid();
private static FloatGrid fg2 = new FloatGrid();
private static Color3fGrid cg1 = new Color3fGrid();
private static Color3fGrid cg2 = new Color3fGrid();
private static Color3fGrid cg3 = new Color3fGrid();
private static Color3fGrid cg4 = new Color3fGrid();
private static Color3fGrid ct1 = new Color3fGrid();
private static Color3f specularcolor = new Color3f();
private static Color3f color1 = new Color3f();
private static Color3f color2 = new Color3f();
private static Color3f WHITE = new Color3f(1f, 1f, 1f);
private static BooleanGrid cond = new BooleanGrid();
protected void initDefaults() {
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ka", "uniform float"), 1f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Kd", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ks", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("roughness", "uniform float"), .1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("specularcolor", "uniform color"),
1f,
1f,
1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("color1", "uniform color"),
0f,
1f,
0f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("color2", "uniform color"),
1f,
0f,
0f));
}
public void shade(ShaderVariables sv) {
super.shade(sv);
UniformScalarFloat paramKa = (UniformScalarFloat) getParameter(sv, "Ka");
final float Ka = paramKa.getValue();
UniformScalarFloat paramKd = (UniformScalarFloat) getParameter(sv, "Kd");
final float Kd = paramKd.getValue();
UniformScalarFloat paramKs = (UniformScalarFloat) getParameter(sv, "Ks");
final float Ks = paramKs.getValue();
UniformScalarFloat paramRoughness = (UniformScalarFloat) getParameter(sv, "roughness");
final float roughness = paramRoughness.getValue();
UniformScalarTuple3f paramSpecularcolor =
(UniformScalarTuple3f) getParameter(sv, "specularcolor");
paramSpecularcolor.getValue(specularcolor);
UniformScalarTuple3f paramColor1 =
(UniformScalarTuple3f) getParameter(sv, "color1");
paramColor1.getValue(color1);
UniformScalarTuple3f paramColor2 =
(UniformScalarTuple3f) getParameter(sv, "color2");
paramColor2.getValue(color2);
vg1.normalize(sv.N);
vg1.faceforward(vg1, sv.I);
vg2.normalize(sv.I);
vg2.negate(vg2);
fg1.set(sv.s);
fg2.set(sv.t);
cg3.set(color1);
cg4.set(color2);
cond.less(fg2, 0.5f);
sv.Cs.set(cg3,cond);
cond.not(cond);
sv.Cs.set(cg4,cond);
ct1.set(sv.Cs);
sv.Oi.set(sv.Os);
ambient(sv, cg1);
cg3.set(Ka);
cg1.mul(cg1, cg3);
diffuse(sv, vg1, cg2);
cg3.set(Kd);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
specular(sv, vg1, vg2, roughness, cg2);
cg3.set(Ks);
cg2.mul(cg2, cg3);
cg3.set(specularcolor);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
cg1.mul(cg1, ct1);
sv.Ci.mul(sv.Os, cg1);
}
}
jrManでsmoothstep
fg1.set(sv.s);
fg2.set(sv.t);
cg3.set(color1);
cg4.set(color2);
fg1.smoothstep(0.4f,0.6f,fg2);
sv.Cs.mix(cg3, cg4, fg1);
ct1.set(sv.Cs);
jrManでrepeating pattern
三角、三角、つくってみた。
SurfaceSankakutest.java
"Sankaku" is a triangle.
勉強ですね。
以下、ソース
/*
SurfaceSankakutest.java
*/
import javax.vecmath.Color3f;
import org.jrman.grid.BooleanGrid;
import org.jrman.grid.FloatGrid;
import org.jrman.grid.Color3fGrid;
import org.jrman.grid.Vector3fGrid;
import org.jrman.parameters.Declaration;
import org.jrman.parameters.UniformScalarFloat;
import org.jrman.parameters.UniformScalarTuple3f;
import org.jrman.parameters.UniformScalarString;
import org.jrman.render.ShaderVariables;
import org.jrman.shaders.SurfaceShader;
public class SurfaceSankakutest extends SurfaceShader {
private static Vector3fGrid vg1 = new Vector3fGrid();
private static Vector3fGrid vg2 = new Vector3fGrid();
private static FloatGrid fg1 = new FloatGrid();
private static FloatGrid fg2 = new FloatGrid();
private static Color3fGrid cg1 = new Color3fGrid();
private static Color3fGrid cg2 = new Color3fGrid();
private static Color3fGrid cg3 = new Color3fGrid();
private static Color3fGrid ct1 = new Color3fGrid();
private static Color3f specularcolor = new Color3f();
private static Color3f color1 = new Color3f();
private static Color3f WHITE = new Color3f(1f, 1f, 1f);
private static BooleanGrid cond = new BooleanGrid();
protected void initDefaults() {
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ka", "uniform float"), 1f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Kd", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("Ks", "uniform float"), .5f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("roughness", "uniform float"), .1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("specularcolor", "uniform color"),
1f,
1f,
1f));
defaultParameters.addParameter(
new UniformScalarTuple3f(
new Declaration("color1", "uniform color"),
0f,
1f,
0f));
defaultParameters.addParameter(
new UniformScalarFloat(new Declaration("repeatCount", "uniform float"), 5f));
}
public void shade(ShaderVariables sv) {
super.shade(sv);
UniformScalarFloat paramKa = (UniformScalarFloat) getParameter(sv, "Ka");
final float Ka = paramKa.getValue();
UniformScalarFloat paramKd = (UniformScalarFloat) getParameter(sv, "Kd");
final float Kd = paramKd.getValue();
UniformScalarFloat paramKs = (UniformScalarFloat) getParameter(sv, "Ks");
final float Ks = paramKs.getValue();
UniformScalarFloat paramRoughness = (UniformScalarFloat) getParameter(sv, "roughness");
final float roughness = paramRoughness.getValue();
UniformScalarTuple3f paramSpecularcolor =
(UniformScalarTuple3f) getParameter(sv, "specularcolor");
paramSpecularcolor.getValue(specularcolor);
UniformScalarTuple3f paramColor1 =
(UniformScalarTuple3f) getParameter(sv, "color1");
paramColor1.getValue(color1);
UniformScalarFloat paramRepeatCount = (UniformScalarFloat) getParameter(sv, "repeatCount");
final float repeatCount = paramRepeatCount.getValue();
vg1.normalize(sv.N);
vg1.faceforward(vg1, sv.I);
vg2.normalize(sv.I);
vg2.negate(vg2);
fg1.set(sv.s);
fg2.set(sv.t);
cg3.set(color1);
fg1.mul(fg1,repeatCount);
fg1.mod(fg1,1f);
fg2.mul(fg2,repeatCount);
fg2.mod(fg2,1f);
fg1.step(fg1,fg2);
sv.Cs.mix(sv.Cs, cg3, fg1);
ct1.set(sv.Cs);
sv.Oi.set(sv.Os);
ambient(sv, cg1);
cg3.set(Ka);
cg1.mul(cg1, cg3);
diffuse(sv, vg1, cg2);
cg3.set(Kd);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
specular(sv, vg1, vg2, roughness, cg2);
cg3.set(Ks);
cg2.mul(cg2, cg3);
cg3.set(specularcolor);
cg2.mul(cg2, cg3);
cg1.add(cg1, cg2);
cg1.mul(cg1, ct1);
sv.Ci.mul(sv.Os, cg1);
}
}
java実行時のエラー??
java.net.URLClassLoader$1.run(Unknown Source)
これは、やられました。ありがとうございます。
以下、OKwaveより引用、ありがとうございます。
javaはコンパイルすると、クラスファイルができます。
そのクラスファイルを実行するので、
クラスファイルがある場所(ディレクトリ)で(今回だとLuckyNo.class)、
java -cp . LuckyNo
として実行してください。
(.があるので見逃さないでくださいね.はカレントディレクトリを示します)
まだまだ勉強足りません。
チュートリアルをやって、確認していくのが大切ですね。
javaの資料はたくさんあってありがたい。
くりかえし、くりかえし、学習します。
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: No compression type set!
at javax.imageio.ImageWriteParam.setCompressionQuality(Unknown Source) at net.falappa.imageio.ImageViewerPanelSaveAction.writeToFile(ImageViewerPanelSaveAction.java:142)
at net.falappa.imageio.ImageViewerPanelSaveAction.actionPerformed(ImageViewerPanelSaveAction.java:127)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
いろいろやってみてから、聞いてみよう。ありがとうございます。
1/2 >>