Horde3D

Next-Generation Graphics Engine
It is currently 23.04.2019, 04:55

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Coloring cones
PostPosted: 07.08.2011, 22:12 
Offline

Joined: 07.08.2011, 10:01
Posts: 4
I have a scene with several identical cones that need to be colored when they enter certain areas of my map (E.g. they enter the red zone and should be colored red). The entities can not be batched into groups for this because there are a lot of colors. Because of the complexity of my scene, I can not simply use radial light sources.

Here is what I tried:

1. Create a uniform "color" that colors the cone differently. Clean and simple. Caveat: Because uniforms are per material, every entity needs its own copy of the material. This causes many rendercalls and slows the scene down when many cones are visible.
2. The cones are rotation-symmetric. Utilize the rotation around the Y-Axis to store that color information. Caveat: Objects that are attached to the cones get rotated as well. The calculation of the angle needs a dot&asin. Also it feels like hack.

Ideas that I couldn't go on with:

1. Is there maybe a way to pass along extra information to objects besides per-material uniforms? I noticed there is a uniform float nodeId; that changes with each entity of the same material during a drawcall - maybe I can do something similar?
2. I'm basically trying to apply a (colored) shadow to an object. Wouldn't something like this be used in games a lot?

Any help is appreciated. Thank you for reading.


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 09.08.2011, 15:23 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Custom per-instance uniforms that can be set for each model node would be the best solution. It could be something as simple as a generic vec4 uniform array for which arbitrary data could be stored for each model using the API. Unfortunately they are not yet implemented but they should definitely go into the next version.


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 10.08.2011, 11:12 
Offline

Joined: 07.08.2011, 10:01
Posts: 4
Thank you for your time and the positive news.

I hate to be that guy, but is there a guesstimate when that feature will come?


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 12.08.2011, 18:02 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
I'm currently still on a trip but maybe there is some time next week to quickly add this.


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 12.08.2011, 20:14 
Offline

Joined: 07.08.2011, 10:01
Posts: 4
Thank you very much for considering this.

Have a safe trip.


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 21.08.2011, 18:20 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
So here is a quick patch that adds support for custom per-model uniforms. The new API function is documented, so it should be quite obvious how it works ;)


Attachments:
model_inst_uniforms.zip [2.08 KiB]
Downloaded 273 times
Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 04.09.2011, 20:23 
Offline

Joined: 07.08.2011, 10:01
Posts: 4
Sorry for the late reply.

Just got it to work. It works perfectly and is pretty fast too! Great addition. Why did you opt to not add this to the main trunk? Are there any caveats?


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 18.09.2011, 22:23 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Sorry for the long delay, the feature is in the main trunk now!


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 10.01.2012, 01:22 
Offline

Joined: 10.01.2012, 01:17
Posts: 2
Hello, i am trying to use this new feature in a similar fashion compared to OP but
i am having some problems getting the shader uniform handle to work propperly, an example on how you colored the cones would be nice


Code:
[[FS_AMBIENT]]   

uniform vec4 customInstData;

gl_FragColor.rgb = customInstData;


works fine in rendermonkey but gRDI->getShaderConstLoc( shdObj, "customInstData" ); return -1.

I did also allot of printing of the 20 or so versions of the shader objects and do see
it in there + the unitialized effect in the renderer.


any advice apreciated


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 10.01.2012, 16:06 
Offline

Joined: 08.06.2010, 14:17
Posts: 63
customInstData is an array, try this, maybe it helps?

Code:
[[FS_AMBIENT]]

uniform vec4 customInstData[4];

gl_FragColor.rgb = customInstData[0];


Top
 Profile  
Reply with quote  
 Post subject: Re: Coloring cones
PostPosted: 10.01.2012, 19:14 
Offline

Joined: 10.01.2012, 01:17
Posts: 2
Thank you sir, that solved it!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group