• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Image Based Specular Problem

4 posts in this topic

Hi guys, I'm trying to use an image (not a cubemap) for my specular component. It's working fine except that there is an outline where it's getting full light when it should be getting zero light. I don't really understand what I'm doing wrong.


(the left side is the render, the right is my specular image map)

Here is the pertinent HLSL:

View=view matrix;
Light=light position in world coords;

vertex shader:

float4 pos=position in world coords;

output.normal=the normal;
output.colour=the colour;

pixel shader:

float3 L=normalize(input.light);
float3 N=normalize(input.normal);
float3 V=normalize(input.view);

float NL=saturate(dot(N,L));
float3 R=reflect(V,N);

// diffuse is just colour
float3 diffuse=input.color.rgb;

// make uv for specular image lookup
float2 uv=R.xy/2+0.5;

// look up specular
float3 specular=tex2D(Sampler0,uv).rgb;

// put together
float3 out=diffuse*NL+specular;

Share this post

Link to post
Share on other sites
Your sampler is probably misconfigured. You should set your D3DSAMP_ADDRESSU and D3DSAMP_ADDRESSV to D3DTADDRESS_CLAMP, so that it clamps the texture coordinates of your samples to [0.0, 1.0].

May I ask, why you are using this lookup table for your specular highlights anyway? Do you want to use it as an environment map or do you want to "paint" the shape of your specular highlights? If so, I'd recommend encoding this "BRDF" as [eqn]f_r(theta_h,theta_d)[/eqn]. This way you can have physically correct specular highlights as a lookup table. As long as they are isotropic you can use a 2-dimensional texture, otherwise you need a 3-dimensional texture. You can even download captured BRDFs encoded this way from the Mitsubishi MERL BRDF database. Edited by CryZe

Share this post

Link to post
Share on other sites
Hi CryZe,

Unfortunately it's not the sampler.

Will you please give me some more info on the BRDF you described, how do I implement it ? It looks like what I want to do.

I'm doing this because the phong specular model is too limiting, it just makes a circle. I want to experiment with something a little better looking, like maybe multiple highlights, square highlights, etc.

Thanks for helping.

Share this post

Link to post
Share on other sites
Multiply your specular value with saturate(dot(N,L). This will get rid of that halo. This is also physically correct.

Share this post

Link to post
Share on other sites
First, there seems to be some confusion about coordinate spaces.
You probably want to convert R form world space into tangent space for the texture lookup.
But, as pointed out by CryZe, R is not good for this kind of thing.
Consider using a function of the half-way vector.

Here is a slightly more complicated, but much better way to do it:
Basically, you paint a microfacet distribution.
Given its simplicity, the d-BRDF works pretty well.

EDIT: Here is the pdf I wanted to link in the first place, but couldn't find:
http://www.cs.utah.edu/~michael/brdfs/facets.pdf Edited by macnihilist

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0