Will pay for cone light implementation

Wait wait wait, what you re trying to do is exactly how lights are handled in a Deferred rendering process, but it’s not as easy as getting the pixel brighter if it’s in the light influence cone. you’ll need to use the normal data of the scene, to properly compute lighting, specular etc…

You would have to compute the normals and depth of the scene and recompute the position of each pixel in the fragment shader. (that’s what is done for SSAO for example)



Of course this is doable, but, doesn’t really fit in the forward rendering process of jME3.



You might want to take look at this tutorial http://www.lighthouse3d.com/tutorials/glsl-tutorial/spot-light-per-pixel/

It explain how to (simply) compute lighting for a spotlight in the pixel shader (ie lighting.frag).

This fits in a forward rendering process, and note that this shader is called each time you render a geometry.



The type of the light (Directional, Point, Spot, Ambient) is passed to the shader int the light color alpha value. The spot light type id is 2.

Also this would need to make some change in the renderMultipassLighting method of Material to properly handled the SpotLight type, and correctly pass the values.



Since we need this in the engine, I’m gonna give it a try, so hold your horses a little bit more.



And dude…I’m doing it for free, keep your money to buy coffee, cigarettes or diet Coke because that’s what a java coder really needs.

1 Like

Awsomely friendly nehon!

Really appriciate the help, its real vital to my game :smiley:

@nehon no coder ever really needed cigs :stuck_out_tongue: Can’t argue with the coffee and coke tho…

1 Like
baalgarnaal said:
@nehon no coder ever really needed cigs :P

Tell that to my lungs xD

hehehe I don’t smoke myself but, I was directly referring to Normen :stuck_out_tongue:



here is the first tease shot of spot light

http://i.imgur.com/X9JRE.jpg

3 Likes

INCREDIBLE!! I just can’t wait!! :smiley:



Nehon, You’r my new role-model! :stuck_out_tongue:

Yay! Spotlight! :smiley:



Super glad this is getting put in.



Cheers!

~FlaH

Very nice stuff, nehon :slight_smile:

Ok that’s in last revision now.

It works with lighting and terrain material, and vertex lighting is supported too.



Usage is pretty much the same as any other lights :

[java]

SpotLight spot=new SpotLight();

spot.setSpotRange(100); //the distance covered by the spot for light falloff

spot.setSpotInnerAngle(5FastMath.DEG_TO_RAD); // the inner light cone angle (in radians)

spot.setSpotOuterAngle(10
FastMath.DEG_TO_RAD); // the outer cone of light (in radians)

spot.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f)); // the position of the spot light

spot.setDirection(lightTarget.subtract(spot.getPosition())); // the direction of the spot light

spot.setColor(ColorRGBA.White.mult(2)); // the color

rootNode.addLight(spot);

[/java]



here is a shot

http://i.imgur.com/yAzHP.jpg



There are 2 test cases : TestSpotLight (screen shot above) and TestSpotLightTerrain, where the spot light come out of the camera.

4 Likes

Oyie.



This is so awesome looking. It’s probably enough to bring me out of hiding for a bit to at least try it out. Soon enough I might have more time to get to work again on my project, but I’ll definitely give this a shot in a bit.



I’ve got so many things I want to try with this spotlight :stuck_out_tongue:



Rock onnnn!

~FlaH

That is AWSOME!! :smiley:

Can’t tell you how thrilled I am to start using this! My game will look SOO cool!! :smiley:

I’ma start building some realistic buildings now :slight_smile:



But I, as always, got a little problem when trying to use this…

com.jme3.renderer.RendererException: Shader link failure, shader:Shader[language=GLSL100, numSources=2, numUniforms=16, shaderSources=[ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment]]] info:Fragment info
0(91) : error C5041: cannot locate suitable resource to bind parameter "spotVec"

It says when I try to add it. I just simply add a light just like you do in the code you gave.
I do not edit it or anything, and all my models use lighting.j3md material.
I'v updated to the 7-22-2011 version nightly builds.

To get the texture material I simply call:
[java]private static Material getLight(String name){
Material mat = new Material(MainClass.getAsset(),"Common/MatDefs/Light/Lighting.j3md");
mat.setTransparent(true);
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
Texture img = ImageLoader.Load(name);
img.setWrap(WrapMode.Repeat);
mat.setTexture("DiffuseMap", img);
mat.setBoolean("m_UseMaterialColors", true);
mat.setColor("m_Ambient", ColorRGBA.White);
mat.setColor("m_Diffuse", ColorRGBA.White);
mat.setColor("m_Specular", ColorRGBA.White);
mat.setFloat("m_Shininess", 1);

return mat;
}[/java]

Am I doing something fundamentaly wrong or is it a bug?
Once again, GREAT work nehon, very appriciated :)

mhh that’s strange, could you tell me what your hardware is?



I committed a probable fix, but I don’t have your issue so i can’t say for sure if it will fix it.



waiting for your feedback.

nehon said:
I committed a probable fix, but I don't have your issue so i can't say for sure if it will fix it.

I committed a fix to the compile on mac btw, you had some 0 instead of 0.0.

I downloaded the nightly build 7-22 again and no diffrence.

My hardwares are:

HP Windows vista 32 bit

AMD Athlon 64 X2 Dual Core Processor 5600+



I used to have a nivida geforce 6150le but It sort of broke down and now Im using the vga cable.

The card is not removed, I just cant play black ops and such graphic games anymore…

yeah, you need to update directly from svn or wait for tomorrow nightly

Lol, what were you doing exactly? Why should a svn checkout delete your other folders?

Idk, I just checked it out at the same folder I had my ZombieGame folder.

Now all files are missing.

If you still have the jar or compiled code you might want to try a java decompiler, it can probably restore something around 80% of the code depending on how it was written.

(Also you just learned the hard way to always have a backup, since such stuff can happen (my first project was killed by a defective harddisk, :confused: )





another try might be to use a restore software for partitions, I used GetDatabackntfs a while ago. It scanns for file begins in the whole drive and trys to restore them, worked quite good actually for most files. (You need a second hdd for that however and should avoid to have any write access to the one where the project was stored)

Whaayayaysia? Why in the same folder? You say you selected the project folder as the destination? Did you use svn command line or the client built into the IDE?

GOOD GOD!

It was not completly deleted, just moved to the trashbin.

-.- PHE!!



Im so making a backup cd right now :stuck_out_tongue: