Need help with two steps rendering of character and background

Started by
6 comments, last by Norman Barrows 7 years ago
Hi, all! I am sorry I wasn't able to choise a better topic title.
I rendered a character 2.0 tall. She is starting from y:1 to y:-1. I did it that way to be able to get better precision to deal with petter panning/shadow acne(i think such is the best, correct me if i am wrong..) And now i want to render the room the character will walk through. My initial idea was to render first the room and then render the character on front. But now i am having trouble imagining the set-up. I imagine they render 5km wide open world scenes a similar way. I dont need 5km open world. I need my character to walk through a building.
I need you to point me in a good direction with the names of the techniques to search for them on Google or links to tutorials. Basically i am not sure how to sincronize the perspective for the room and the character. I am codding it all in js and webgl. So i need a more programming oriented tutorials. Using a library is not an option.
Advertisement

I do not understand what you are asking about. What problem behavior is your program showing?

If you render the character and the room using the same view and projection matrices then the character should appear in the room naturally.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
My character is taking the whole rendering box. If i add the room with the same scale, it will be cropped out by the rendering box of OpenGL. If my character is toching the top of the rendering box with the head, the roof of the room will fall outside the render box. Let say the roof will become at position Y:2.8 which is by 1.8 away/out of the box. I need to downscale the room in order to fit completelly inside the -1..+1 box of OpenGL. And there is where things become messy for me. I have to render a giant inside a doll-house.
Is it safe to scale down the whole building until it fits inside the rendering box? Now the distance between the eyes of my character is let say .01 but if i downscale it until the whole building fits inside -1 +1 the distance between the eyes of the character will become let say .0001 this would require less depth bias. Ok it could be acceptable because of the floating precision growing toward zero, im not sure, but what about shadow map? I still have to multiple passes render the shadow map. Is Horizon Zero Down rendering the character and the far mountains with the same perspective?

Why do you need to fit an entire building inside the rendering box? Surely parts of it could be visible at different points in time?

I think what you are looking for is the correct World View Projection transformation.

You can find a detailed example here http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/.

The general idea is that your objects are transformed into different coordinate spaces for the final rendering. Initially your meshes will be in object space with the coordinate system at the center of each object.

To this you apply the world matrix to get them into world space which has all the objects positioned relative to each other. In your example the parts of the building will have a different world matrix than the character. To move the character around you would only need to change its world matrix.

After the world matrix you apply the view transform. This is a coordinate system where the origin is the camera position and the forward vector is aligned with the cameras forward vector.

Finally you apply the projection matrix which does a perspective or orthographic projection into homogeneous coordinates where the scene from the camera is projected onto a cube with (-1,1). This is the -1 +1 range you are talking about.

Thank you, guys! I guess i will have to play with it for few days. Pulling it backward pushing it forward scalling it a little bit down and up.... Well... :(

one thing you need to do at the beginning of any project is determine the scale used. IE 1 unit in your 3D system = how many meters in the real world? then you just make everything to scale and it all works out automatically. people are the right size, houses are the right size, all meshes and models are the right size.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement