Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texture stages and backbuffer

Started by d000hg Jan 5, 2003 at 6:12 PM 2 replies 200+ views
Original Post
d000hg
d000hg
I''m in a situation where I want to modulate three textures so the result is T1*T2*T3. I don''t want to require 3 texture units though. Can I do T1*T2 in one pass, to the backbuffer, then blend it *T3 on a second pass? I know it''s fine for additive blending, and modulation can be done using render-textures but that takes lots of vid-mem and is a bit slow. Cheers
Read about my game, project #1 NEW (18th December)2 new screenshots, one from the engine and one from the level editor
John 3:16
S1CA
S1CA
Sure you can:

Pass #1
P = T1 * T2
ONE:ZERO blendmode

Pass #2
P = T3
ZERO:SRCCOLOR blendmode (or DESTCOLOR:ZERO)


assuming the whole operation is supported in hardware (isn''t on some really old chips)

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
d000hg
d000hg
So there''s nothing that can be done single-pass that can''t be done identically in multiple passes? Apart from DOT3 maybe?
S1CA
S1CA
On modern chips which support all the nice frame buffer blending operations, you can do most things multipass.

However things which need a "sign" bias (e.g. DOT3), or have a dependency between multiple textures (e.g. EMBM) etc aren''t so easy to work out with multipass - though if the back buffer format supports destination alpha you can use that to great effect too.

Stuff with the Z buffer and things like stencil buffers can end up a bit of a git though which is why I''d personally never aim to make a system which can emulate any multitexture setup with multipass. I''d prefer to just pre-can a few versions (a la effects & techniques), say crap chip, 2 texture unit chip, 3+ texture unit chip, shader chip.


At the end of the day it''s all a case of reorganising the maths and deciding which bit of the maths happens where. For example your maths is P = T1 * T2 * T3

All I did is reorganised that to fit the blendops available:
P = 0 * T3 + T3 * (T1*T2)

or the alternative:

P = (T1*T2) * T3 + 0 * (T1*T2)


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

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

Sign in to reply to this topic.