Added “new” demo
Update:
Modified the CelShading vertex shader’s code; In the new version, it only receives an input parameter (At start up) and hence runs a bit faster.
!!ARBvp1.0
ATTRIB OriginalPos = vertex.position;
ATTRIB TmpNormal = vertex.normal;
PARAM lightAngle = program.env[0];
PARAM ModelViewProj[4] = { state.matrix.mvp };
PARAM ModelViewInvertTranspose[4] = { state.matrix.modelview.invtrans};
TEMP TmpVector;
TEMP TmpShade;
TEMP temp;
DP3 TmpVector.x, TmpNormal, ModelViewInvertTranspose[0];
DP3 TmpVector.y, TmpNormal, ModelViewInvertTranspose[1];
DP3 TmpVector.z, TmpNormal, ModelViewInvertTranspose[2];
DP3 TmpVector.w, TmpVector, TmpVector;
RSQ TmpVector.w, TmpVector.w;
MUL TmpVector , TmpVector, TmpVector.w;
DP3 TmpShade.x, TmpVector , lightAngle;
MAX TmpShade.x, TmpShade.x, 0.0;
DP4 temp.x, ModelViewProj[0], OriginalPos;
DP4 temp.y, ModelViewProj[1], OriginalPos;
DP4 temp.z, ModelViewProj[2], OriginalPos;
DP4 temp.w, ModelViewProj[3], OriginalPos;
MOV result.position , temp;
MOV result.color , vertex.color;
MOV result.texcoord[0].x, TmpShade.x;
END
The perpixel lighting demo now comes in two flavors:
Vertex Shaders accelerated with per-vertex lighting computations done strictly in the GPU, and the regular version which is more CPU dependant.
The regular version as well as the GPU accelerated one include an ObjectStructure class that would take any indexedGeometry and then compute the TBN vectors needed for per-pixel lighting.
It is also over 50 times faster than the old version which used ArrayList for vertex caching…
You can also hit V and see the TBN vectors where normal are colored in Red, Binormals in Green and Tangents in Blue.
As I mentioned in some other thread, I passed the Tangents components to the Vertex Shader in the GPU accelerated version as color components since TexCoord3f is not supported yet, hence can’t pass them as texture coordinates.
Binormals are computed in the GPU by calling XPD (cross product) and using Tangents and normals.
I assume the rest is easy to figure (I for one never had assembly before :P)
!!ARBvp1.0
# Original Input...
ATTRIB OriginalPos = vertex.position;
ATTRIB tangent = vertex.color;
ATTRIB normal = vertex.normal;
PARAM ModelViewProj[4] = { state.matrix.mvp };
PARAM lightOSL = program.env[0];
PARAM halfVector = {0.5, 0.5, 0.5, 0.5};
TEMP lightVector;
TEMP colorVector;
TEMP temp;
TEMP binormal;
#Computing the binormal: normalize(cross(tangent, normal))
XPD binormal, tangent, normal;
SUB lightVector, lightOSL, OriginalPos;
DP3 lightVector.w, lightVector, lightVector;
RSQ lightVector.w, lightVector.w;
MUL lightVector , lightVector, lightVector.w;
DP3 colorVector.x, lightVector, tangent;
DP3 colorVector.y, lightVector, binormal;
DP3 colorVector.z, lightVector, normal;
MAD colorVector , colorVector, halfVector, halfVector;
DP4 temp.x, ModelViewProj[0], OriginalPos;
DP4 temp.y, ModelViewProj[1], OriginalPos;
DP4 temp.z, ModelViewProj[2], OriginalPos;
DP4 temp.w, ModelViewProj[3], OriginalPos;
MOV result.position, temp;
MOV result.color, colorVector;
MOV result.texcoord[0], vertex.texcoord[0];
MOV result.texcoord[1], vertex.texcoord[1];
END
/me back coding.
PS: One of the major flaws in the way I implemented VS in xith3d, is the fact that the VertexShaderProgram leaks to the other Shape3Ds in the scene.
A temporary fix is to set a new VertexProgram() element to all the appearances that you don’t want the VSing effects to show on.
New Demo: Phong Lighting yay
Check the front page for links
Ok so I went through all my demo and gave them a serious tweaking, so now they run better and faster than ever.
Also the code is now a lot cleaner and more efficient.
I re-wrote the PerPixel lighting shader so that the lightWorldPosition -> lightObjectPosition -> lightSpaceTangentPosition transformations are done entirely on the GPU ;D
/me off writting a new demo
PS: Sorry for those who still have a < DX8.0 card but from now on I will almost exclusively write demos using PS and VS shaders.
I would also like to have some feedback on the performance that you guys get running them demos on your machines. Something like that:
GFX ATi Radeon 9700 Pro
CPU Athlon XP 2.1 GHZ
MEM 512 DDR
MOB NForce 2
DEM Phong Lighting
FPS ~280
Thanks:)
Big release coming tomorrow
A tiny preview
http://www.users.xith.org/JavaCoolDude/Pictures/newFeaturePhong.jpg
Check first page
Anyways this new demo uses normal maps for true perpixel, phong lighting: it took me a while to put it together but I eventually got over the tough stuff ;D
This is in my opinion the best demo I’ve written so far and I’m quite proud of my achievement.
Anyways I’ve enabled TexCoord3f in the GeomertryContainer to have this demo working. In fact I had to pass the Tangent and Binormal vectors to the GPU using the second and third TextureCoordinates’ elements to transform the light as well as the view position into Tangent space.
However since I have no urgent need in using Texture3D per se, I didn’t bother implementing it
PS: You can use F1 to take a screenshot that will be saved under the name screenshotn.jpg where n is the number of screens you’ve saved so far (won’t overwrite previous screenies ;)).
nice
Hmm, won’t run. No error just dies after the splash screen. Here is my card info from another program, this is work so this card is not very good.
OpenGL Renderer = Intel Brookdale-G
OpenGL Version = 1.3.0 - Build 4.13.01.3069
OpenGL Vendor = Intel
OpenGL Extensions = GL_ARB_multitexture GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_env_crossbar GL_ARB_transpose_matrix GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_EXT_cull_vertex GL_EXT_fog_coord GL_EXT_packed_pixels GL_EXT_packed_pixels_12 GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_stencil_wrap GL_EXT_texture_compression_s3tc GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_filter_anisotropic GL_3DFX_texture_compression_FXT1 GL_IBM_texture_mirrored_repeat GL_NV_texgen_reflection GL_WIN_swap_hint
Intel’s onboard graphic chips (and even extension cards if they have any) do not support GL_VERTEX_PROGRAM_ARB and GL_FRAGMENT_PROGRAM_ARB, hence can’t run my demo.
Maybe I should write a quick checking function?
[quote]Hmm, won’t run. No error just dies after the splash screen.
[/quote]
Ditto.
Test system: Linux (Fedora), Nvidia GForce 2 MX 400, latest drivers.
A check would be nice, anything but “just dies” is good
the screen shots look great though
Will.
Nvidia GForce 2 MX 400 = Pixel & Vertex Shaders = teh noes… :-/
Updated with non-robust shadow volumes and gloss maps.
I will be working on implementing more features this week, stay tuned
Updated all demos except the latest entry and they should work on a Mac now
[quote] Hmm, won’t run. No error just dies after the splash screen.
[/quote]
Ditto. Even the flag simulation dies silently before showing the resolution dialog …
Test system: Windows 2000, Nvidia GForce 3 Ti 200, latest drivers.
I wonder why the GForce 3 series is not working either since it does support Direct X 8.1 (at least nvidia claims that) …
PS: Seems to be related to somewhere near the basic framework i.e. the dialog that allows to select the window size does never show up … Your particle demo still does work.
For some reason only the particle generator and the water simulation are working on my comp now. With the exception of the shader demos, all used to work fine before. FYI, i have a radeon 8500DV. The demos just die, without any error message, after the splash screen.
I’ll try running it from source to see if I can track down the cause, but I thought I’d make this note in case you made a recent change JCD that might have caused the break. ???
[quote]For some reason only the particle generator and the water simulation are working on my comp now. With the exception of the shader demos, all used to work fine before. FYI, i have a radeon 8500DV. The demos just die, without any error message, after the splash screen.
I’ll try running it from source to see if I can track down the cause, but I thought I’d make this note in case you made a recent change JCD that might have caused the break. ???
[/quote]
That’s strange the water demo is hardly any different structure wise from the cloth and flag sims.
Also, the shader demos should work fine on your computer since the Radeon 8500 supports PS and VS…
PS: My xith3D jar file is heavily modified in a sense where I actually added support for PS and VS, Dot3 extension, dynamic shadows sources, TexCoord3f etc…
It’s too late for me to find solutions quickly today I do believe… Are you using Java 1.5 or another compiler? That seems to be the cause (thank god that webstart does alllow logging):
Java Web Start 1.4.2_03 Konsole, gestartet Sun Feb 15 23:24:03 CET 2004
Java 2 Runtime Environment: Version 1.4.2_03 von Sun Microsystems Inc.
java.lang.UnsupportedClassVersionError: FlagSimulation (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.defineClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.access$100(Unknown Source)
at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
So maybe a javac -target 1.4 or a release below that one could help here
Indeed I’m using 1.5 SDK, I recompiled everything using target -1.4.
Should work now :-/
An error occurred while launching/running the application.
Title: Water Simulation
Vendor: Abdul Bezrati - Galactic Village
Category: Unexpected Error
RippleFactory (Unsupported major.minor version 49.0)