Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 877 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Changing material per view (without events) #95225
10/21/06 13:04
10/21/06 13:04
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline OP
Expert
Excessus  Offline OP
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
The current way of changing a material per view is not usefull in some situations.

Using an event function and ENABLE_TREE to change the material depending on the render_view has some problems when not all entities use the same material. I have seen ello's code here but it only works because there is only 1 material per view (all objects use the same material in the camera view). If you want to use multiple materials in the camera view things get difficult.

Let's look at an example:
I want to render the objects in my scene with their normal shaders in the camera view (normalmapping, terrain shader, etc). In a second view (DepthView), I want to render the depth of the scene.
I can use a ENABLE_TREE to change the material to my DepthRender material if render_view == DepthView. The problem is that I cannot use a material event for resetting it to the original material because there is no way to know what material it originally had (this is possible in ello's code because all entities use the same material in the camera view..).
To solve this, I could use a seperate DepthRender material for every other material so that each DepthRender material resets to a different original material but this is very ugly, especially when you have tons of shaders.
Additionaly, if you use this method to change the material AFTER the normal camera was rendered, the material pointer will still be set to the alternative material when the game code is executed. If I wanted to use the material pointer in my game logic I would run into problems with this.


It'd be nice if there was a more elegant way to switch the material per view. Here are some thoughts:
A) Have a material pointer in the view definition so that entities in that view are always rendered with that material.

B) Similar to solution A: have a global, predefined material pointer that overwrites the entity materials if it is not null. This pointer could then be set before a certain view is rendered.

C) Reset the material pointer after rendering the entity if it was changed in the event function. To not break old code, this could be done only if -1 was returned from the event function or something.

Re: Changing material per view (without events) [Re: Excessus] #95226
10/21/06 22:00
10/21/06 22:00
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Cool, I just had an access denied clicking that link

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Changing material per view (without events) [Re: PHeMoX] #95227
10/23/06 07:40
10/23/06 07:40
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
me too it's probably in a beta section which us public-beta-ans dont have access to.

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Changing material per view (without events) [Re: JibbSmart] #95228
10/23/06 08:33
10/23/06 08:33
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, it is a beta link. - The request makes sense and I'll implement a solution similar to B.


Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1