Skip to main content
gamedev.net
🔒 Locked

Noobish Question

Started by StockwellSteve Jan 24, 2007 at 9:43 AM 6 replies 1.2k views
Original Post
StockwellSteve
StockwellSteve
Dear Guys, I have two questions. First off, I have been using Milkshape to render some simple 3d objects - i.e. house etc and have textured them. I am exporting them to the .3ds format for use with the 3ds model loader provided by Garage Games. Question 1 is : When I open them in my program and successfully view them on the screen, the model has been rotated around the X axis and is laying flat instead of standing up. In fact, when I import any prebuilt model into Milkshape from the .3ds format, it also is laying flat against the plane on the xz axes. Why is this? Question 2 is: Why are my models showing up as being fully uniformly lit? I have been through my code and the code supplied by Garage Games which displays the model. Before any drawing that takes place I have done glDisable(GL_LIGHTING) and yet my model still shows. I want to apply a spotlight to the model and obviously only have relevant areas under the spotlight cone being displayed. Any one have any ideas why this may be happening? Thanks
Morpheus011
Morpheus011
answer 1:

Milkshape clearly uses a different orientation axis then GarageGames. Just transform the objects (or ideally if you have access to the exporter, do it there so you're not doing extra matrix multiplies every frame).

answer 2:
you probably don't have enough normals to do any decent lighting. the material settings for the object could be why it's showing. You don't have to have a light on an object for it to be visible.
StockwellSteve
StockwellSteve
Hey Morpheus - thanks for replying

Unfortunately dont have access to the exporter so I'll just have to translate in my code.

As for the materials, in order to ensure that the materials are only visible when lit by light - what should I do? I've made sure that the emissive co-efficient is 0. Should I also be altering the specular, diffuse and ambient settings?

Also as for the normals - the 3ds loader Garage Games provides also shows the normals. I've got a few houses and a lamppost in the scene. I can assure you that there are hundreds of normals on the lamppost and the few relevant ones on the house. I've literally got a cube with a pyramid on top to represent the house so there are hardly and normals here anyway, just the relevant ones for each face.

Lord_Evil
Lord_Evil
Your objects will always be displayed if you render them unless they are fully transparent (alpha = 0). You can't change the alpha by material. You could however use a vertex shader and set the alpha to 0 if the color of the vertex is not black (i.e. it's lit) - any unlit vertex should be black if no light hits it. That depends on how you define your lights (no ambient light!). Also, you should not test for color = BLACK but for color < some almost black color.

IMO the easist way to make a model "appear" to be displayed only where lit would be to have a black background. Then what is not lit would fade out until fully "invisible".


Disabling GL_LIGHTING causes OpenGL not to apply any lighting equation and output the vertex color instead. That's way your objects are uniformly lit without lighting.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
StockwellSteve
StockwellSteve
So the ONLY way to show my object unlit is to write a shader???????

Seems so peculiar!
Lord_Evil
Lord_Evil
I didn't mean to say that the ONLY way to make your model be displayed where lit only is a shader.

Sorry for expressing it misunderstandably, what I meant is that you can't just set a material with alpha = 0 and expect alpha to be affected by lighting.

Additionally what I described was an approach to have arbitrary backgrounds (not just black) plus making the model appear only where lit. This would require setting the alpha depending on whether a vertex is lit or not (or some continous function). Afaik THIS can only be done via shaders.

If you have a black background you're certainly fine with just lighting the model thus causing unlit portions to merge with the background.


As posted before, vertex lighting requires a quite high tesselation in order to look good (both approaches: alpha "fade out" to "invisible/transparent" or color "fade out" to black). You could however employ per-pixel lighting, but I agree that you aren't ready for that yet, since this requires fragment shaders.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.