Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [solved] How to make shader uniforms initialize on bind  (Read 296 times)
0 Members and 1 Guest are viewing this topic.
Offline Spacebeans

JGO Knight


Medals: 18
Projects: 2
Exp: 4 years


Bye everyone!


« Posted 2014-07-10 02:00:05 »

Is there any way to activate shader uniforms as they're bound? Basically for having 2 different shader programs without activating the uniforms for each, every time its bound. I'm thinking of a hash map of method objects (Reflection), every time the shader is bound, it iterates through them and calls each one. ( I just thought of this on the spot, I may be wrong on how to do this)

This is a dead account. Goodbye everyone!
Offline Slyth2727
« Reply #1 - Posted 2014-07-10 02:10:57 »

Why are you trying to do this? We can help you out more this way Smiley

And I hate to be the one to do this, but it's "as they're bound". Don't take this as an insult, I'm just trying to help you out. If you make a mistake like that on a resume or something, it looks silly.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Spacebeans

JGO Knight


Medals: 18
Projects: 2
Exp: 4 years


Bye everyone!


« Reply #2 - Posted 2014-07-10 02:31:05 »

Why are you trying to do this? We can help you out more this way Smiley

I'm trying to make a lighting system. I basically just need a way to setup the uniforms during the shader initialization.

Basically, there is a list of lights, each one having a different shader. Each 'game object' (entity, or thing) is rendered with a shader parameter, then binds it, and calls its sub-classes abstract render stuff. This makes it easy for multi-render passes for different shading techniques. (Like an initial pass for ambient light/textures, then one for light boxes, then one for post-processing or something.)

And I hate to be the one to do this, but it's "as they're bound".

S***, my bad. Clueless My obnoxious cousin is playing a game next to me and he loves to over exaggerate everything. Kinda hard to focus on anything with him constantly yelling.

This is a dead account. Goodbye everyone!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Slyth2727
« Reply #3 - Posted 2014-07-10 02:43:21 »

Well shaders don't really work like that. Each time you run the shader on another object, it runs completely afresh. Are you trying to do something like a static variable?
Also, why not just pass the uniforms in each render? That's the way you're supposed to do it.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Spacebeans

JGO Knight


Medals: 18
Projects: 2
Exp: 4 years


Bye everyone!


« Reply #4 - Posted 2014-07-10 02:45:57 »

Also, why not just pass the uniforms in each render? That's the way you're supposed to do it.

I guess I could just make each light's class initialize its shaders uniforms during its 'bind' and 'unbind' functions. That shouldn't be too messy. Thanks anyway!

This is a dead account. Goodbye everyone!
Offline Slyth2727
« Reply #5 - Posted 2014-07-10 02:51:01 »

I guess I could just make each light's class initialize its shaders uniforms during its 'bind' and 'unbind' functions. That shouldn't be too messy. Thanks anyway!

No problem Smiley
I just don't really see a way to do what you're trying to do, because that's simply not how shaders work.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (24 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!